aclocal.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. /******************************************************************************
  2. *
  3. * Name: aclocal.h - Internal data types used across the ACPI subsystem
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2007, R. Byron Moore
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #ifndef __ACLOCAL_H__
  43. #define __ACLOCAL_H__
  44. /* acpisrc:struct_defs -- for acpisrc conversion */
  45. #define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */
  46. #define ACPI_DO_NOT_WAIT 0
  47. #define ACPI_SERIALIZED 0xFF
  48. typedef u32 acpi_mutex_handle;
  49. #define ACPI_GLOBAL_LOCK (acpi_semaphore) (-1)
  50. /* Total number of aml opcodes defined */
  51. #define AML_NUM_OPCODES 0x7F
  52. /* Forward declarations */
  53. struct acpi_walk_state;
  54. struct acpi_obj_mutex;
  55. union acpi_parse_object;
  56. /*****************************************************************************
  57. *
  58. * Mutex typedefs and structs
  59. *
  60. ****************************************************************************/
  61. /*
  62. * Predefined handles for the mutex objects used within the subsystem
  63. * All mutex objects are automatically created by acpi_ut_mutex_initialize.
  64. *
  65. * The acquire/release ordering protocol is implied via this list. Mutexes
  66. * with a lower value must be acquired before mutexes with a higher value.
  67. *
  68. * NOTE: any changes here must be reflected in the acpi_gbl_mutex_names
  69. * table below also!
  70. */
  71. #define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */
  72. #define ACPI_MTX_NAMESPACE 1 /* ACPI Namespace */
  73. #define ACPI_MTX_TABLES 2 /* Data for ACPI tables */
  74. #define ACPI_MTX_EVENTS 3 /* Data for ACPI events */
  75. #define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */
  76. #define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */
  77. #define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */
  78. #define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */
  79. #define ACPI_MAX_MUTEX 7
  80. #define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1
  81. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  82. #ifdef DEFINE_ACPI_GLOBALS
  83. /* Debug names for the mutexes above */
  84. static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
  85. "ACPI_MTX_Interpreter",
  86. "ACPI_MTX_Tables",
  87. "ACPI_MTX_Namespace",
  88. "ACPI_MTX_Events",
  89. "ACPI_MTX_Caches",
  90. "ACPI_MTX_Memory",
  91. "ACPI_MTX_CommandComplete",
  92. "ACPI_MTX_CommandReady"
  93. };
  94. #endif
  95. #endif
  96. /*
  97. * Predefined handles for spinlocks used within the subsystem.
  98. * These spinlocks are created by acpi_ut_mutex_initialize
  99. */
  100. #define ACPI_LOCK_GPES 0
  101. #define ACPI_LOCK_HARDWARE 1
  102. #define ACPI_MAX_LOCK 1
  103. #define ACPI_NUM_LOCK ACPI_MAX_LOCK+1
  104. /* Owner IDs are used to track namespace nodes for selective deletion */
  105. typedef u8 acpi_owner_id;
  106. #define ACPI_OWNER_ID_MAX 0xFF
  107. /* This Thread ID means that the mutex is not in use (unlocked) */
  108. #define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0
  109. /* Table for the global mutexes */
  110. struct acpi_mutex_info {
  111. acpi_mutex mutex;
  112. u32 use_count;
  113. acpi_thread_id thread_id;
  114. };
  115. /* Lock flag parameter for various interfaces */
  116. #define ACPI_MTX_DO_NOT_LOCK 0
  117. #define ACPI_MTX_LOCK 1
  118. /* Field access granularities */
  119. #define ACPI_FIELD_BYTE_GRANULARITY 1
  120. #define ACPI_FIELD_WORD_GRANULARITY 2
  121. #define ACPI_FIELD_DWORD_GRANULARITY 4
  122. #define ACPI_FIELD_QWORD_GRANULARITY 8
  123. #define ACPI_ENTRY_NOT_FOUND NULL
  124. /*****************************************************************************
  125. *
  126. * Namespace typedefs and structs
  127. *
  128. ****************************************************************************/
  129. /* Operational modes of the AML interpreter/scanner */
  130. typedef enum {
  131. ACPI_IMODE_LOAD_PASS1 = 0x01,
  132. ACPI_IMODE_LOAD_PASS2 = 0x02,
  133. ACPI_IMODE_EXECUTE = 0x03
  134. } acpi_interpreter_mode;
  135. union acpi_name_union {
  136. u32 integer;
  137. char ascii[4];
  138. };
  139. /*
  140. * The Namespace Node describes a named object that appears in the AML.
  141. * descriptor_type is used to differentiate between internal descriptors.
  142. *
  143. * The node is optimized for both 32-bit and 64-bit platforms:
  144. * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case.
  145. *
  146. * Note: The descriptor_type and Type fields must appear in the identical
  147. * position in both the struct acpi_namespace_node and union acpi_operand_object
  148. * structures.
  149. */
  150. struct acpi_namespace_node {
  151. union acpi_operand_object *object; /* Interpreter object */
  152. u8 descriptor_type; /* Differentiate object descriptor types */
  153. u8 type; /* ACPI Type associated with this name */
  154. u8 flags; /* Miscellaneous flags */
  155. acpi_owner_id owner_id; /* Node creator */
  156. union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */
  157. struct acpi_namespace_node *child; /* First child */
  158. struct acpi_namespace_node *peer; /* Peer. Parent if ANOBJ_END_OF_PEER_LIST set */
  159. /*
  160. * The following fields are used by the ASL compiler and disassembler only
  161. */
  162. #ifdef ACPI_LARGE_NAMESPACE_NODE
  163. union acpi_parse_object *op;
  164. u32 value;
  165. u32 length;
  166. #endif
  167. };
  168. /* Namespace Node flags */
  169. #define ANOBJ_END_OF_PEER_LIST 0x01 /* End-of-list, Peer field points to parent */
  170. #define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */
  171. #define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */
  172. #define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */
  173. #define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */
  174. #define ANOBJ_IS_EXTERNAL 0x08 /* i_aSL only: This object created via External() */
  175. #define ANOBJ_METHOD_NO_RETVAL 0x10 /* i_aSL only: Method has no return value */
  176. #define ANOBJ_METHOD_SOME_NO_RETVAL 0x20 /* i_aSL only: Method has at least one return value */
  177. #define ANOBJ_IS_BIT_OFFSET 0x40 /* i_aSL only: Reference is a bit offset */
  178. #define ANOBJ_IS_REFERENCED 0x80 /* i_aSL only: Object was referenced */
  179. /*
  180. * ACPI Table Descriptor. One per ACPI table
  181. */
  182. struct acpi_table_desc {
  183. acpi_physical_address address;
  184. struct acpi_table_header *pointer;
  185. u32 length; /* Length fixed at 32 bits */
  186. union acpi_name_union signature;
  187. acpi_owner_id owner_id;
  188. u8 flags;
  189. };
  190. /* Flags for above */
  191. #define ACPI_TABLE_ORIGIN_UNKNOWN (0)
  192. #define ACPI_TABLE_ORIGIN_MAPPED (1)
  193. #define ACPI_TABLE_ORIGIN_ALLOCATED (2)
  194. #define ACPI_TABLE_ORIGIN_MASK (3)
  195. #define ACPI_TABLE_IS_LOADED (4)
  196. /* One internal RSDT for table management */
  197. struct acpi_internal_rsdt {
  198. struct acpi_table_desc *tables;
  199. u32 count;
  200. u32 size;
  201. u8 flags;
  202. };
  203. /* Flags for above */
  204. #define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */
  205. #define ACPI_ROOT_ORIGIN_ALLOCATED (1)
  206. #define ACPI_ROOT_ALLOW_RESIZE (2)
  207. /* Predefined (fixed) table indexes */
  208. #define ACPI_TABLE_INDEX_DSDT (0)
  209. #define ACPI_TABLE_INDEX_FACS (1)
  210. struct acpi_find_context {
  211. char *search_for;
  212. acpi_handle *list;
  213. u32 *count;
  214. };
  215. struct acpi_ns_search_data {
  216. struct acpi_namespace_node *node;
  217. };
  218. /*
  219. * Predefined Namespace items
  220. */
  221. struct acpi_predefined_names {
  222. char *name;
  223. u8 type;
  224. char *val;
  225. };
  226. /* Object types used during package copies */
  227. #define ACPI_COPY_TYPE_SIMPLE 0
  228. #define ACPI_COPY_TYPE_PACKAGE 1
  229. /* Info structure used to convert external<->internal namestrings */
  230. struct acpi_namestring_info {
  231. char *external_name;
  232. char *next_external_char;
  233. char *internal_name;
  234. u32 length;
  235. u32 num_segments;
  236. u32 num_carats;
  237. u8 fully_qualified;
  238. };
  239. /* Field creation info */
  240. struct acpi_create_field_info {
  241. struct acpi_namespace_node *region_node;
  242. struct acpi_namespace_node *field_node;
  243. struct acpi_namespace_node *register_node;
  244. struct acpi_namespace_node *data_register_node;
  245. u32 bank_value;
  246. u32 field_bit_position;
  247. u32 field_bit_length;
  248. u8 field_flags;
  249. u8 attribute;
  250. u8 field_type;
  251. };
  252. typedef
  253. acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state);
  254. /*
  255. * Bitmapped ACPI types. Used internally only
  256. */
  257. #define ACPI_BTYPE_ANY 0x00000000
  258. #define ACPI_BTYPE_INTEGER 0x00000001
  259. #define ACPI_BTYPE_STRING 0x00000002
  260. #define ACPI_BTYPE_BUFFER 0x00000004
  261. #define ACPI_BTYPE_PACKAGE 0x00000008
  262. #define ACPI_BTYPE_FIELD_UNIT 0x00000010
  263. #define ACPI_BTYPE_DEVICE 0x00000020
  264. #define ACPI_BTYPE_EVENT 0x00000040
  265. #define ACPI_BTYPE_METHOD 0x00000080
  266. #define ACPI_BTYPE_MUTEX 0x00000100
  267. #define ACPI_BTYPE_REGION 0x00000200
  268. #define ACPI_BTYPE_POWER 0x00000400
  269. #define ACPI_BTYPE_PROCESSOR 0x00000800
  270. #define ACPI_BTYPE_THERMAL 0x00001000
  271. #define ACPI_BTYPE_BUFFER_FIELD 0x00002000
  272. #define ACPI_BTYPE_DDB_HANDLE 0x00004000
  273. #define ACPI_BTYPE_DEBUG_OBJECT 0x00008000
  274. #define ACPI_BTYPE_REFERENCE 0x00010000
  275. #define ACPI_BTYPE_RESOURCE 0x00020000
  276. #define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
  277. #define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE)
  278. #define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
  279. #define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
  280. #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */
  281. #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF
  282. /*****************************************************************************
  283. *
  284. * Event typedefs and structs
  285. *
  286. ****************************************************************************/
  287. /* Dispatch info for each GPE -- either a method or handler, cannot be both */
  288. struct acpi_handler_info {
  289. acpi_event_handler address; /* Address of handler, if any */
  290. void *context; /* Context to be passed to handler */
  291. struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */
  292. };
  293. union acpi_gpe_dispatch_info {
  294. struct acpi_namespace_node *method_node; /* Method node for this GPE level */
  295. struct acpi_handler_info *handler;
  296. };
  297. /*
  298. * Information about a GPE, one per each GPE in an array.
  299. * NOTE: Important to keep this struct as small as possible.
  300. */
  301. struct acpi_gpe_event_info {
  302. union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */
  303. struct acpi_gpe_register_info *register_info; /* Backpointer to register info */
  304. u8 flags; /* Misc info about this GPE */
  305. u8 gpe_number; /* This GPE */
  306. };
  307. /* Information about a GPE register pair, one per each status/enable pair in an array */
  308. struct acpi_gpe_register_info {
  309. struct acpi_generic_address status_address; /* Address of status reg */
  310. struct acpi_generic_address enable_address; /* Address of enable reg */
  311. u8 enable_for_wake; /* GPEs to keep enabled when sleeping */
  312. u8 enable_for_run; /* GPEs to keep enabled when running */
  313. u8 base_gpe_number; /* Base GPE number for this register */
  314. };
  315. /*
  316. * Information about a GPE register block, one per each installed block --
  317. * GPE0, GPE1, and one per each installed GPE Block Device.
  318. */
  319. struct acpi_gpe_block_info {
  320. struct acpi_namespace_node *node;
  321. struct acpi_gpe_block_info *previous;
  322. struct acpi_gpe_block_info *next;
  323. struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */
  324. struct acpi_gpe_register_info *register_info; /* One per GPE register pair */
  325. struct acpi_gpe_event_info *event_info; /* One for each GPE */
  326. struct acpi_generic_address block_address; /* Base address of the block */
  327. u32 register_count; /* Number of register pairs in block */
  328. u8 block_base_number; /* Base GPE number for this block */
  329. };
  330. /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
  331. struct acpi_gpe_xrupt_info {
  332. struct acpi_gpe_xrupt_info *previous;
  333. struct acpi_gpe_xrupt_info *next;
  334. struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */
  335. u32 interrupt_number; /* System interrupt number */
  336. };
  337. struct acpi_gpe_walk_info {
  338. struct acpi_namespace_node *gpe_device;
  339. struct acpi_gpe_block_info *gpe_block;
  340. };
  341. typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info *
  342. gpe_xrupt_info,
  343. struct acpi_gpe_block_info *
  344. gpe_block);
  345. /* Information about each particular fixed event */
  346. struct acpi_fixed_event_handler {
  347. acpi_event_handler handler; /* Address of handler. */
  348. void *context; /* Context to be passed to handler */
  349. };
  350. struct acpi_fixed_event_info {
  351. u8 status_register_id;
  352. u8 enable_register_id;
  353. u16 status_bit_mask;
  354. u16 enable_bit_mask;
  355. };
  356. /* Information used during field processing */
  357. struct acpi_field_info {
  358. u8 skip_field;
  359. u8 field_flag;
  360. u32 pkg_length;
  361. };
  362. /*****************************************************************************
  363. *
  364. * Generic "state" object for stacks
  365. *
  366. ****************************************************************************/
  367. #define ACPI_CONTROL_NORMAL 0xC0
  368. #define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1
  369. #define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2
  370. #define ACPI_CONTROL_PREDICATE_FALSE 0xC3
  371. #define ACPI_CONTROL_PREDICATE_TRUE 0xC4
  372. #define ACPI_STATE_COMMON \
  373. void *next; \
  374. u8 descriptor_type; /* To differentiate various internal objs */\
  375. u8 flags; \
  376. u16 value; \
  377. u16 state;
  378. /* There are 2 bytes available here until the next natural alignment boundary */
  379. struct acpi_common_state {
  380. ACPI_STATE_COMMON};
  381. /*
  382. * Update state - used to traverse complex objects such as packages
  383. */
  384. struct acpi_update_state {
  385. ACPI_STATE_COMMON union acpi_operand_object *object;
  386. };
  387. /*
  388. * Pkg state - used to traverse nested package structures
  389. */
  390. struct acpi_pkg_state {
  391. ACPI_STATE_COMMON u16 index;
  392. union acpi_operand_object *source_object;
  393. union acpi_operand_object *dest_object;
  394. struct acpi_walk_state *walk_state;
  395. void *this_target_obj;
  396. u32 num_packages;
  397. };
  398. /*
  399. * Control state - one per if/else and while constructs.
  400. * Allows nesting of these constructs
  401. */
  402. struct acpi_control_state {
  403. ACPI_STATE_COMMON u16 opcode;
  404. union acpi_parse_object *predicate_op;
  405. u8 *aml_predicate_start; /* Start of if/while predicate */
  406. u8 *package_end; /* End of if/while block */
  407. };
  408. /*
  409. * Scope state - current scope during namespace lookups
  410. */
  411. struct acpi_scope_state {
  412. ACPI_STATE_COMMON struct acpi_namespace_node *node;
  413. };
  414. struct acpi_pscope_state {
  415. ACPI_STATE_COMMON u32 arg_count; /* Number of fixed arguments */
  416. union acpi_parse_object *op; /* Current op being parsed */
  417. u8 *arg_end; /* Current argument end */
  418. u8 *pkg_end; /* Current package end */
  419. u32 arg_list; /* Next argument to parse */
  420. };
  421. /*
  422. * Thread state - one per thread across multiple walk states. Multiple walk
  423. * states are created when there are nested control methods executing.
  424. */
  425. struct acpi_thread_state {
  426. ACPI_STATE_COMMON u8 current_sync_level; /* Mutex Sync (nested acquire) level */
  427. struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */
  428. union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */
  429. acpi_thread_id thread_id; /* Running thread ID */
  430. };
  431. /*
  432. * Result values - used to accumulate the results of nested
  433. * AML arguments
  434. */
  435. struct acpi_result_values {
  436. ACPI_STATE_COMMON u8 num_results;
  437. u8 last_insert;
  438. union acpi_operand_object *obj_desc[ACPI_OBJ_NUM_OPERANDS];
  439. };
  440. typedef
  441. acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state,
  442. union acpi_parse_object ** out_op);
  443. typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state);
  444. /*
  445. * Notify info - used to pass info to the deferred notify
  446. * handler/dispatcher.
  447. */
  448. struct acpi_notify_info {
  449. ACPI_STATE_COMMON struct acpi_namespace_node *node;
  450. union acpi_operand_object *handler_obj;
  451. };
  452. /* Generic state is union of structs above */
  453. union acpi_generic_state {
  454. struct acpi_common_state common;
  455. struct acpi_control_state control;
  456. struct acpi_update_state update;
  457. struct acpi_scope_state scope;
  458. struct acpi_pscope_state parse_scope;
  459. struct acpi_pkg_state pkg;
  460. struct acpi_thread_state thread;
  461. struct acpi_result_values results;
  462. struct acpi_notify_info notify;
  463. };
  464. /*****************************************************************************
  465. *
  466. * Interpreter typedefs and structs
  467. *
  468. ****************************************************************************/
  469. typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state);
  470. /*****************************************************************************
  471. *
  472. * Parser typedefs and structs
  473. *
  474. ****************************************************************************/
  475. /*
  476. * AML opcode, name, and argument layout
  477. */
  478. struct acpi_opcode_info {
  479. #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
  480. char *name; /* Opcode name (disassembler/debug only) */
  481. #endif
  482. u32 parse_args; /* Grammar/Parse time arguments */
  483. u32 runtime_args; /* Interpret time arguments */
  484. u16 flags; /* Misc flags */
  485. u8 object_type; /* Corresponding internal object type */
  486. u8 class; /* Opcode class */
  487. u8 type; /* Opcode type */
  488. };
  489. union acpi_parse_value {
  490. acpi_integer integer; /* Integer constant (Up to 64 bits) */
  491. struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */
  492. u32 size; /* bytelist or field size */
  493. char *string; /* NULL terminated string */
  494. u8 *buffer; /* buffer or string */
  495. char *name; /* NULL terminated string */
  496. union acpi_parse_object *arg; /* arguments and contained ops */
  497. };
  498. #define ACPI_PARSE_COMMON \
  499. union acpi_parse_object *parent; /* Parent op */\
  500. u8 descriptor_type; /* To differentiate various internal objs */\
  501. u8 flags; /* Type of Op */\
  502. u16 aml_opcode; /* AML opcode */\
  503. u32 aml_offset; /* Offset of declaration in AML */\
  504. union acpi_parse_object *next; /* Next op */\
  505. struct acpi_namespace_node *node; /* For use by interpreter */\
  506. union acpi_parse_value value; /* Value or args associated with the opcode */\
  507. ACPI_DISASM_ONLY_MEMBERS (\
  508. u8 disasm_flags; /* Used during AML disassembly */\
  509. u8 disasm_opcode; /* Subtype used for disassembly */\
  510. char aml_op_name[16]) /* Op name (debug only) */
  511. #define ACPI_DASM_BUFFER 0x00
  512. #define ACPI_DASM_RESOURCE 0x01
  513. #define ACPI_DASM_STRING 0x02
  514. #define ACPI_DASM_UNICODE 0x03
  515. #define ACPI_DASM_EISAID 0x04
  516. #define ACPI_DASM_MATCHOP 0x05
  517. #define ACPI_DASM_LNOT_PREFIX 0x06
  518. #define ACPI_DASM_LNOT_SUFFIX 0x07
  519. #define ACPI_DASM_IGNORE 0x08
  520. /*
  521. * Generic operation (for example: If, While, Store)
  522. */
  523. struct acpi_parse_obj_common {
  524. ACPI_PARSE_COMMON};
  525. /*
  526. * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions),
  527. * and bytelists.
  528. */
  529. struct acpi_parse_obj_named {
  530. ACPI_PARSE_COMMON u8 * path;
  531. u8 *data; /* AML body or bytelist data */
  532. u32 length; /* AML length */
  533. u32 name; /* 4-byte name or zero if no name */
  534. };
  535. /* This version is used by the i_aSL compiler only */
  536. #define ACPI_MAX_PARSEOP_NAME 20
  537. struct acpi_parse_obj_asl {
  538. ACPI_PARSE_COMMON union acpi_parse_object *child;
  539. union acpi_parse_object *parent_method;
  540. char *filename;
  541. char *external_name;
  542. char *namepath;
  543. char name_seg[4];
  544. u32 extra_value;
  545. u32 column;
  546. u32 line_number;
  547. u32 logical_line_number;
  548. u32 logical_byte_offset;
  549. u32 end_line;
  550. u32 end_logical_line;
  551. u32 acpi_btype;
  552. u32 aml_length;
  553. u32 aml_subtree_length;
  554. u32 final_aml_length;
  555. u32 final_aml_offset;
  556. u32 compile_flags;
  557. u16 parse_opcode;
  558. u8 aml_opcode_length;
  559. u8 aml_pkg_len_bytes;
  560. u8 extra;
  561. char parse_op_name[ACPI_MAX_PARSEOP_NAME];
  562. };
  563. union acpi_parse_object {
  564. struct acpi_parse_obj_common common;
  565. struct acpi_parse_obj_named named;
  566. struct acpi_parse_obj_asl asl;
  567. };
  568. /*
  569. * Parse state - one state per parser invocation and each control
  570. * method.
  571. */
  572. struct acpi_parse_state {
  573. u8 *aml_start; /* First AML byte */
  574. u8 *aml; /* Next AML byte */
  575. u8 *aml_end; /* (last + 1) AML byte */
  576. u8 *pkg_start; /* Current package begin */
  577. u8 *pkg_end; /* Current package end */
  578. union acpi_parse_object *start_op; /* Root of parse tree */
  579. struct acpi_namespace_node *start_node;
  580. union acpi_generic_state *scope; /* Current scope */
  581. union acpi_parse_object *start_scope;
  582. u32 aml_size;
  583. };
  584. /* Parse object flags */
  585. #define ACPI_PARSEOP_GENERIC 0x01
  586. #define ACPI_PARSEOP_NAMED 0x02
  587. #define ACPI_PARSEOP_DEFERRED 0x04
  588. #define ACPI_PARSEOP_BYTELIST 0x08
  589. #define ACPI_PARSEOP_IN_CACHE 0x80
  590. /* Parse object disasm_flags */
  591. #define ACPI_PARSEOP_IGNORE 0x01
  592. #define ACPI_PARSEOP_PARAMLIST 0x02
  593. #define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
  594. #define ACPI_PARSEOP_SPECIAL 0x10
  595. /*****************************************************************************
  596. *
  597. * Hardware (ACPI registers) and PNP
  598. *
  599. ****************************************************************************/
  600. #define PCI_ROOT_HID_STRING "PNP0A03"
  601. #define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08"
  602. struct acpi_bit_register_info {
  603. u8 parent_register;
  604. u8 bit_position;
  605. u16 access_bit_mask;
  606. };
  607. /*
  608. * Some ACPI registers have bits that must be ignored -- meaning that they
  609. * must be preserved.
  610. */
  611. #define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */
  612. #define ACPI_PM1_CONTROL_PRESERVED_BITS 0x0200 /* Bit 9 (whatever) */
  613. /*
  614. * Register IDs
  615. * These are the full ACPI registers
  616. */
  617. #define ACPI_REGISTER_PM1_STATUS 0x01
  618. #define ACPI_REGISTER_PM1_ENABLE 0x02
  619. #define ACPI_REGISTER_PM1_CONTROL 0x03
  620. #define ACPI_REGISTER_PM1A_CONTROL 0x04
  621. #define ACPI_REGISTER_PM1B_CONTROL 0x05
  622. #define ACPI_REGISTER_PM2_CONTROL 0x06
  623. #define ACPI_REGISTER_PM_TIMER 0x07
  624. #define ACPI_REGISTER_PROCESSOR_BLOCK 0x08
  625. #define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09
  626. /* Masks used to access the bit_registers */
  627. #define ACPI_BITMASK_TIMER_STATUS 0x0001
  628. #define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010
  629. #define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020
  630. #define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100
  631. #define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200
  632. #define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400
  633. #define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */
  634. #define ACPI_BITMASK_WAKE_STATUS 0x8000
  635. #define ACPI_BITMASK_ALL_FIXED_STATUS (\
  636. ACPI_BITMASK_TIMER_STATUS | \
  637. ACPI_BITMASK_BUS_MASTER_STATUS | \
  638. ACPI_BITMASK_GLOBAL_LOCK_STATUS | \
  639. ACPI_BITMASK_POWER_BUTTON_STATUS | \
  640. ACPI_BITMASK_SLEEP_BUTTON_STATUS | \
  641. ACPI_BITMASK_RT_CLOCK_STATUS | \
  642. ACPI_BITMASK_WAKE_STATUS)
  643. #define ACPI_BITMASK_TIMER_ENABLE 0x0001
  644. #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020
  645. #define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100
  646. #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200
  647. #define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400
  648. #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */
  649. #define ACPI_BITMASK_SCI_ENABLE 0x0001
  650. #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002
  651. #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004
  652. #define ACPI_BITMASK_SLEEP_TYPE_X 0x1C00
  653. #define ACPI_BITMASK_SLEEP_ENABLE 0x2000
  654. #define ACPI_BITMASK_ARB_DISABLE 0x0001
  655. /* Raw bit position of each bit_register */
  656. #define ACPI_BITPOSITION_TIMER_STATUS 0x00
  657. #define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04
  658. #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05
  659. #define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08
  660. #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09
  661. #define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A
  662. #define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */
  663. #define ACPI_BITPOSITION_WAKE_STATUS 0x0F
  664. #define ACPI_BITPOSITION_TIMER_ENABLE 0x00
  665. #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05
  666. #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08
  667. #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09
  668. #define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A
  669. #define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */
  670. #define ACPI_BITPOSITION_SCI_ENABLE 0x00
  671. #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01
  672. #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02
  673. #define ACPI_BITPOSITION_SLEEP_TYPE_X 0x0A
  674. #define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D
  675. #define ACPI_BITPOSITION_ARB_DISABLE 0x00
  676. /*****************************************************************************
  677. *
  678. * Resource descriptors
  679. *
  680. ****************************************************************************/
  681. /* resource_type values */
  682. #define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0
  683. #define ACPI_ADDRESS_TYPE_IO_RANGE 1
  684. #define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2
  685. /* Resource descriptor types and masks */
  686. #define ACPI_RESOURCE_NAME_LARGE 0x80
  687. #define ACPI_RESOURCE_NAME_SMALL 0x00
  688. #define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */
  689. #define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */
  690. #define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */
  691. /*
  692. * Small resource descriptor "names" as defined by the ACPI specification.
  693. * Note: Bits 2:0 are used for the descriptor length
  694. */
  695. #define ACPI_RESOURCE_NAME_IRQ 0x20
  696. #define ACPI_RESOURCE_NAME_DMA 0x28
  697. #define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30
  698. #define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38
  699. #define ACPI_RESOURCE_NAME_IO 0x40
  700. #define ACPI_RESOURCE_NAME_FIXED_IO 0x48
  701. #define ACPI_RESOURCE_NAME_RESERVED_S1 0x50
  702. #define ACPI_RESOURCE_NAME_RESERVED_S2 0x58
  703. #define ACPI_RESOURCE_NAME_RESERVED_S3 0x60
  704. #define ACPI_RESOURCE_NAME_RESERVED_S4 0x68
  705. #define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70
  706. #define ACPI_RESOURCE_NAME_END_TAG 0x78
  707. /*
  708. * Large resource descriptor "names" as defined by the ACPI specification.
  709. * Note: includes the Large Descriptor bit in bit[7]
  710. */
  711. #define ACPI_RESOURCE_NAME_MEMORY24 0x81
  712. #define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82
  713. #define ACPI_RESOURCE_NAME_RESERVED_L1 0x83
  714. #define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84
  715. #define ACPI_RESOURCE_NAME_MEMORY32 0x85
  716. #define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86
  717. #define ACPI_RESOURCE_NAME_ADDRESS32 0x87
  718. #define ACPI_RESOURCE_NAME_ADDRESS16 0x88
  719. #define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89
  720. #define ACPI_RESOURCE_NAME_ADDRESS64 0x8A
  721. #define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B
  722. #define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B
  723. /*****************************************************************************
  724. *
  725. * Miscellaneous
  726. *
  727. ****************************************************************************/
  728. #define ACPI_ASCII_ZERO 0x30
  729. /*****************************************************************************
  730. *
  731. * Debugger
  732. *
  733. ****************************************************************************/
  734. struct acpi_db_method_info {
  735. acpi_handle main_thread_gate;
  736. acpi_handle thread_complete_gate;
  737. u32 *threads;
  738. u32 num_threads;
  739. u32 num_created;
  740. u32 num_completed;
  741. char *name;
  742. u32 flags;
  743. u32 num_loops;
  744. char pathname[128];
  745. char **args;
  746. /*
  747. * Arguments to be passed to method for the command
  748. * Threads -
  749. * the Number of threads, ID of current thread and
  750. * Index of current thread inside all them created.
  751. */
  752. char init_args;
  753. char *arguments[4];
  754. char num_threads_str[11];
  755. char id_of_thread_str[11];
  756. char index_of_thread_str[11];
  757. };
  758. struct acpi_integrity_info {
  759. u32 nodes;
  760. u32 objects;
  761. };
  762. #define ACPI_DB_REDIRECTABLE_OUTPUT 0x01
  763. #define ACPI_DB_CONSOLE_OUTPUT 0x02
  764. #define ACPI_DB_DUPLICATE_OUTPUT 0x03
  765. /*****************************************************************************
  766. *
  767. * Debug
  768. *
  769. ****************************************************************************/
  770. /* Entry for a memory allocation (debug only) */
  771. #define ACPI_MEM_MALLOC 0
  772. #define ACPI_MEM_CALLOC 1
  773. #define ACPI_MAX_MODULE_NAME 16
  774. #define ACPI_COMMON_DEBUG_MEM_HEADER \
  775. struct acpi_debug_mem_block *previous; \
  776. struct acpi_debug_mem_block *next; \
  777. u32 size; \
  778. u32 component; \
  779. u32 line; \
  780. char module[ACPI_MAX_MODULE_NAME]; \
  781. u8 alloc_type;
  782. struct acpi_debug_mem_header {
  783. ACPI_COMMON_DEBUG_MEM_HEADER};
  784. struct acpi_debug_mem_block {
  785. ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space;
  786. };
  787. #define ACPI_MEM_LIST_GLOBAL 0
  788. #define ACPI_MEM_LIST_NSNODE 1
  789. #define ACPI_MEM_LIST_MAX 1
  790. #define ACPI_NUM_MEM_LISTS 2
  791. struct acpi_memory_list {
  792. char *list_name;
  793. void *list_head;
  794. u16 object_size;
  795. u16 max_depth;
  796. u16 current_depth;
  797. u16 link_offset;
  798. #ifdef ACPI_DBG_TRACK_ALLOCATIONS
  799. /* Statistics for debug memory tracking only */
  800. u32 total_allocated;
  801. u32 total_freed;
  802. u32 max_occupied;
  803. u32 total_size;
  804. u32 current_total_size;
  805. u32 requests;
  806. u32 hits;
  807. #endif
  808. };
  809. #endif /* __ACLOCAL_H__ */