aclocal.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. /******************************************************************************
  2. *
  3. * Name: aclocal.h - Internal data types used across the ACPI subsystem
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, 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. #define ACPI_WAIT_FOREVER 0xFFFF /* u16, as per ACPI spec */
  45. typedef void *acpi_mutex;
  46. typedef u32 acpi_mutex_handle;
  47. /* Total number of aml opcodes defined */
  48. #define AML_NUM_OPCODES 0x7F
  49. /* Forward declarations */
  50. struct acpi_walk_state;
  51. struct acpi_obj_mutex;
  52. union acpi_parse_object;
  53. /*****************************************************************************
  54. *
  55. * Mutex typedefs and structs
  56. *
  57. ****************************************************************************/
  58. /*
  59. * Predefined handles for the mutex objects used within the subsystem
  60. * All mutex objects are automatically created by acpi_ut_mutex_initialize.
  61. *
  62. * The acquire/release ordering protocol is implied via this list. Mutexes
  63. * with a lower value must be acquired before mutexes with a higher value.
  64. *
  65. * NOTE: any changes here must be reflected in the acpi_gbl_mutex_names table also!
  66. */
  67. #define ACPI_MTX_EXECUTE 0
  68. #define ACPI_MTX_INTERPRETER 1
  69. #define ACPI_MTX_PARSER 2
  70. #define ACPI_MTX_DISPATCHER 3
  71. #define ACPI_MTX_TABLES 4
  72. #define ACPI_MTX_OP_REGIONS 5
  73. #define ACPI_MTX_NAMESPACE 6
  74. #define ACPI_MTX_EVENTS 7
  75. #define ACPI_MTX_HARDWARE 8
  76. #define ACPI_MTX_CACHES 9
  77. #define ACPI_MTX_MEMORY 10
  78. #define ACPI_MTX_DEBUG_CMD_COMPLETE 11
  79. #define ACPI_MTX_DEBUG_CMD_READY 12
  80. #define MAX_MUTEX 12
  81. #define NUM_MUTEX MAX_MUTEX+1
  82. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  83. #ifdef DEFINE_ACPI_GLOBALS
  84. /* Names for the mutexes used in the subsystem */
  85. static char *acpi_gbl_mutex_names[] = {
  86. "ACPI_MTX_Execute",
  87. "ACPI_MTX_Interpreter",
  88. "ACPI_MTX_Parser",
  89. "ACPI_MTX_Dispatcher",
  90. "ACPI_MTX_Tables",
  91. "ACPI_MTX_op_regions",
  92. "ACPI_MTX_Namespace",
  93. "ACPI_MTX_Events",
  94. "ACPI_MTX_Hardware",
  95. "ACPI_MTX_Caches",
  96. "ACPI_MTX_Memory",
  97. "ACPI_MTX_debug_cmd_complete",
  98. "ACPI_MTX_debug_cmd_ready",
  99. };
  100. #endif
  101. #endif
  102. /* Owner IDs are used to track namespace nodes for selective deletion */
  103. typedef u8 acpi_owner_id;
  104. #define ACPI_OWNER_ID_MAX 0xFF
  105. /* This Thread ID means that the mutex is not in use (unlocked) */
  106. #define ACPI_MUTEX_NOT_ACQUIRED (u32) -1
  107. /* Table for the global mutexes */
  108. struct acpi_mutex_info {
  109. acpi_mutex mutex;
  110. u32 use_count;
  111. u32 thread_id;
  112. };
  113. /* Lock flag parameter for various interfaces */
  114. #define ACPI_MTX_DO_NOT_LOCK 0
  115. #define ACPI_MTX_LOCK 1
  116. /* Field access granularities */
  117. #define ACPI_FIELD_BYTE_GRANULARITY 1
  118. #define ACPI_FIELD_WORD_GRANULARITY 2
  119. #define ACPI_FIELD_DWORD_GRANULARITY 4
  120. #define ACPI_FIELD_QWORD_GRANULARITY 8
  121. /*****************************************************************************
  122. *
  123. * Namespace typedefs and structs
  124. *
  125. ****************************************************************************/
  126. /* Operational modes of the AML interpreter/scanner */
  127. typedef enum {
  128. ACPI_IMODE_LOAD_PASS1 = 0x01,
  129. ACPI_IMODE_LOAD_PASS2 = 0x02,
  130. ACPI_IMODE_EXECUTE = 0x0E
  131. } acpi_interpreter_mode;
  132. /*
  133. * The Node describes a named object that appears in the AML
  134. * An acpi_node is used to store Nodes.
  135. *
  136. * data_type is used to differentiate between internal descriptors, and MUST
  137. * be the first byte in this structure.
  138. */
  139. union acpi_name_union {
  140. u32 integer;
  141. char ascii[4];
  142. };
  143. struct acpi_namespace_node {
  144. u8 descriptor; /* Used to differentiate object descriptor types */
  145. u8 type; /* Type associated with this name */
  146. u16 reference_count; /* Current count of references and children */
  147. union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */
  148. union acpi_operand_object *object; /* Pointer to attached ACPI object (optional) */
  149. struct acpi_namespace_node *child; /* First child */
  150. struct acpi_namespace_node *peer; /* Next peer */
  151. u8 owner_id; /* Who created this node */
  152. u8 flags;
  153. /* Fields used by the ASL compiler only */
  154. #ifdef ACPI_ASL_COMPILER
  155. u32 value;
  156. union acpi_parse_object *op;
  157. #endif
  158. };
  159. #define ACPI_ENTRY_NOT_FOUND NULL
  160. /* Node flags */
  161. #define ANOBJ_RESERVED 0x01
  162. #define ANOBJ_END_OF_PEER_LIST 0x02
  163. #define ANOBJ_DATA_WIDTH_32 0x04 /* Parent table is 64-bits */
  164. #define ANOBJ_METHOD_ARG 0x08
  165. #define ANOBJ_METHOD_LOCAL 0x10
  166. #define ANOBJ_METHOD_NO_RETVAL 0x20
  167. #define ANOBJ_METHOD_SOME_NO_RETVAL 0x40
  168. #define ANOBJ_IS_BIT_OFFSET 0x80
  169. /*
  170. * ACPI Table Descriptor. One per ACPI table
  171. */
  172. struct acpi_table_desc {
  173. struct acpi_table_desc *prev;
  174. struct acpi_table_desc *next;
  175. struct acpi_table_desc *installed_desc;
  176. struct acpi_table_header *pointer;
  177. u8 *aml_start;
  178. u64 physical_address;
  179. u32 aml_length;
  180. acpi_size length;
  181. acpi_owner_id owner_id;
  182. u8 type;
  183. u8 allocation;
  184. u8 loaded_into_namespace;
  185. };
  186. struct acpi_table_list {
  187. struct acpi_table_desc *next;
  188. u32 count;
  189. };
  190. struct acpi_find_context {
  191. char *search_for;
  192. acpi_handle *list;
  193. u32 *count;
  194. };
  195. struct acpi_ns_search_data {
  196. struct acpi_namespace_node *node;
  197. };
  198. /*
  199. * Predefined Namespace items
  200. */
  201. struct acpi_predefined_names {
  202. char *name;
  203. u8 type;
  204. char *val;
  205. };
  206. /* Object types used during package copies */
  207. #define ACPI_COPY_TYPE_SIMPLE 0
  208. #define ACPI_COPY_TYPE_PACKAGE 1
  209. /* Info structure used to convert external<->internal namestrings */
  210. struct acpi_namestring_info {
  211. char *external_name;
  212. char *next_external_char;
  213. char *internal_name;
  214. u32 length;
  215. u32 num_segments;
  216. u32 num_carats;
  217. u8 fully_qualified;
  218. };
  219. /* Field creation info */
  220. struct acpi_create_field_info {
  221. struct acpi_namespace_node *region_node;
  222. struct acpi_namespace_node *field_node;
  223. struct acpi_namespace_node *register_node;
  224. struct acpi_namespace_node *data_register_node;
  225. u32 bank_value;
  226. u32 field_bit_position;
  227. u32 field_bit_length;
  228. u8 field_flags;
  229. u8 attribute;
  230. u8 field_type;
  231. };
  232. /*****************************************************************************
  233. *
  234. * Event typedefs and structs
  235. *
  236. ****************************************************************************/
  237. /* Dispatch info for each GPE -- either a method or handler, cannot be both */
  238. struct acpi_handler_info {
  239. acpi_event_handler address; /* Address of handler, if any */
  240. void *context; /* Context to be passed to handler */
  241. struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */
  242. };
  243. union acpi_gpe_dispatch_info {
  244. struct acpi_namespace_node *method_node; /* Method node for this GPE level */
  245. struct acpi_handler_info *handler;
  246. };
  247. /*
  248. * Information about a GPE, one per each GPE in an array.
  249. * NOTE: Important to keep this struct as small as possible.
  250. */
  251. struct acpi_gpe_event_info {
  252. union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */
  253. struct acpi_gpe_register_info *register_info; /* Backpointer to register info */
  254. u8 flags; /* Misc info about this GPE */
  255. u8 register_bit; /* This GPE bit within the register */
  256. };
  257. /* Information about a GPE register pair, one per each status/enable pair in an array */
  258. struct acpi_gpe_register_info {
  259. struct acpi_generic_address status_address; /* Address of status reg */
  260. struct acpi_generic_address enable_address; /* Address of enable reg */
  261. u8 enable_for_wake; /* GPEs to keep enabled when sleeping */
  262. u8 enable_for_run; /* GPEs to keep enabled when running */
  263. u8 base_gpe_number; /* Base GPE number for this register */
  264. };
  265. /*
  266. * Information about a GPE register block, one per each installed block --
  267. * GPE0, GPE1, and one per each installed GPE Block Device.
  268. */
  269. struct acpi_gpe_block_info {
  270. struct acpi_namespace_node *node;
  271. struct acpi_gpe_block_info *previous;
  272. struct acpi_gpe_block_info *next;
  273. struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */
  274. struct acpi_gpe_register_info *register_info; /* One per GPE register pair */
  275. struct acpi_gpe_event_info *event_info; /* One for each GPE */
  276. struct acpi_generic_address block_address; /* Base address of the block */
  277. u32 register_count; /* Number of register pairs in block */
  278. u8 block_base_number; /* Base GPE number for this block */
  279. };
  280. /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
  281. struct acpi_gpe_xrupt_info {
  282. struct acpi_gpe_xrupt_info *previous;
  283. struct acpi_gpe_xrupt_info *next;
  284. struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */
  285. u32 interrupt_number; /* System interrupt number */
  286. };
  287. struct acpi_gpe_walk_info {
  288. struct acpi_namespace_node *gpe_device;
  289. struct acpi_gpe_block_info *gpe_block;
  290. };
  291. typedef acpi_status(*ACPI_GPE_CALLBACK) (struct acpi_gpe_xrupt_info *
  292. gpe_xrupt_info,
  293. struct acpi_gpe_block_info *
  294. gpe_block);
  295. /* Information about each particular fixed event */
  296. struct acpi_fixed_event_handler {
  297. acpi_event_handler handler; /* Address of handler. */
  298. void *context; /* Context to be passed to handler */
  299. };
  300. struct acpi_fixed_event_info {
  301. u8 status_register_id;
  302. u8 enable_register_id;
  303. u16 status_bit_mask;
  304. u16 enable_bit_mask;
  305. };
  306. /* Information used during field processing */
  307. struct acpi_field_info {
  308. u8 skip_field;
  309. u8 field_flag;
  310. u32 pkg_length;
  311. };
  312. /*****************************************************************************
  313. *
  314. * Generic "state" object for stacks
  315. *
  316. ****************************************************************************/
  317. #define ACPI_CONTROL_NORMAL 0xC0
  318. #define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1
  319. #define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2
  320. #define ACPI_CONTROL_PREDICATE_FALSE 0xC3
  321. #define ACPI_CONTROL_PREDICATE_TRUE 0xC4
  322. #define ACPI_STATE_COMMON /* Two 32-bit fields and a pointer */\
  323. u8 data_type; /* To differentiate various internal objs */\
  324. u8 flags; \
  325. u16 value; \
  326. u16 state; \
  327. u16 reserved; \
  328. void *next; \
  329. struct acpi_common_state {
  330. ACPI_STATE_COMMON};
  331. /*
  332. * Update state - used to traverse complex objects such as packages
  333. */
  334. struct acpi_update_state {
  335. ACPI_STATE_COMMON union acpi_operand_object *object;
  336. };
  337. /*
  338. * Pkg state - used to traverse nested package structures
  339. */
  340. struct acpi_pkg_state {
  341. ACPI_STATE_COMMON union acpi_operand_object *source_object;
  342. union acpi_operand_object *dest_object;
  343. struct acpi_walk_state *walk_state;
  344. void *this_target_obj;
  345. u32 num_packages;
  346. u16 index;
  347. };
  348. /*
  349. * Control state - one per if/else and while constructs.
  350. * Allows nesting of these constructs
  351. */
  352. struct acpi_control_state {
  353. ACPI_STATE_COMMON union acpi_parse_object *predicate_op;
  354. u8 *aml_predicate_start; /* Start of if/while predicate */
  355. u8 *package_end; /* End of if/while block */
  356. u16 opcode;
  357. };
  358. /*
  359. * Scope state - current scope during namespace lookups
  360. */
  361. struct acpi_scope_state {
  362. ACPI_STATE_COMMON struct acpi_namespace_node *node;
  363. };
  364. struct acpi_pscope_state {
  365. ACPI_STATE_COMMON union acpi_parse_object *op; /* Current op being parsed */
  366. u8 *arg_end; /* Current argument end */
  367. u8 *pkg_end; /* Current package end */
  368. u32 arg_list; /* Next argument to parse */
  369. u32 arg_count; /* Number of fixed arguments */
  370. };
  371. /*
  372. * Thread state - one per thread across multiple walk states. Multiple walk
  373. * states are created when there are nested control methods executing.
  374. */
  375. struct acpi_thread_state {
  376. ACPI_STATE_COMMON struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */
  377. union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */
  378. u32 thread_id; /* Running thread ID */
  379. u8 current_sync_level; /* Mutex Sync (nested acquire) level */
  380. };
  381. /*
  382. * Result values - used to accumulate the results of nested
  383. * AML arguments
  384. */
  385. struct acpi_result_values {
  386. ACPI_STATE_COMMON
  387. union acpi_operand_object *obj_desc[ACPI_OBJ_NUM_OPERANDS];
  388. u8 num_results;
  389. u8 last_insert;
  390. };
  391. typedef
  392. acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state,
  393. union acpi_parse_object ** out_op);
  394. typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state);
  395. /*
  396. * Notify info - used to pass info to the deferred notify
  397. * handler/dispatcher.
  398. */
  399. struct acpi_notify_info {
  400. ACPI_STATE_COMMON struct acpi_namespace_node *node;
  401. union acpi_operand_object *handler_obj;
  402. };
  403. /* Generic state is union of structs above */
  404. union acpi_generic_state {
  405. struct acpi_common_state common;
  406. struct acpi_control_state control;
  407. struct acpi_update_state update;
  408. struct acpi_scope_state scope;
  409. struct acpi_pscope_state parse_scope;
  410. struct acpi_pkg_state pkg;
  411. struct acpi_thread_state thread;
  412. struct acpi_result_values results;
  413. struct acpi_notify_info notify;
  414. };
  415. /*****************************************************************************
  416. *
  417. * Interpreter typedefs and structs
  418. *
  419. ****************************************************************************/
  420. typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state);
  421. /*****************************************************************************
  422. *
  423. * Parser typedefs and structs
  424. *
  425. ****************************************************************************/
  426. /*
  427. * AML opcode, name, and argument layout
  428. */
  429. struct acpi_opcode_info {
  430. #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
  431. char *name; /* Opcode name (disassembler/debug only) */
  432. #endif
  433. u32 parse_args; /* Grammar/Parse time arguments */
  434. u32 runtime_args; /* Interpret time arguments */
  435. u32 flags; /* Misc flags */
  436. u8 object_type; /* Corresponding internal object type */
  437. u8 class; /* Opcode class */
  438. u8 type; /* Opcode type */
  439. };
  440. union acpi_parse_value {
  441. acpi_integer integer; /* Integer constant (Up to 64 bits) */
  442. struct uint64_struct integer64; /* Structure overlay for 2 32-bit Dwords */
  443. u32 size; /* bytelist or field size */
  444. char *string; /* NULL terminated string */
  445. u8 *buffer; /* buffer or string */
  446. char *name; /* NULL terminated string */
  447. union acpi_parse_object *arg; /* arguments and contained ops */
  448. };
  449. #define ACPI_PARSE_COMMON \
  450. u8 data_type; /* To differentiate various internal objs */\
  451. u8 flags; /* Type of Op */\
  452. u16 aml_opcode; /* AML opcode */\
  453. u32 aml_offset; /* Offset of declaration in AML */\
  454. union acpi_parse_object *parent; /* Parent op */\
  455. union acpi_parse_object *next; /* Next op */\
  456. ACPI_DISASM_ONLY_MEMBERS (\
  457. u8 disasm_flags; /* Used during AML disassembly */\
  458. u8 disasm_opcode; /* Subtype used for disassembly */\
  459. char aml_op_name[16]) /* Op name (debug only) */\
  460. /* NON-DEBUG members below: */\
  461. struct acpi_namespace_node *node; /* For use by interpreter */\
  462. union acpi_parse_value value; /* Value or args associated with the opcode */\
  463. #define ACPI_DASM_BUFFER 0x00
  464. #define ACPI_DASM_RESOURCE 0x01
  465. #define ACPI_DASM_STRING 0x02
  466. #define ACPI_DASM_UNICODE 0x03
  467. #define ACPI_DASM_EISAID 0x04
  468. #define ACPI_DASM_MATCHOP 0x05
  469. /*
  470. * generic operation (for example: If, While, Store)
  471. */
  472. struct acpi_parse_obj_common {
  473. ACPI_PARSE_COMMON};
  474. /*
  475. * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions),
  476. * and bytelists.
  477. */
  478. struct acpi_parse_obj_named {
  479. ACPI_PARSE_COMMON u8 * path;
  480. u8 *data; /* AML body or bytelist data */
  481. u32 length; /* AML length */
  482. u32 name; /* 4-byte name or zero if no name */
  483. };
  484. /* The parse node is the fundamental element of the parse tree */
  485. struct acpi_parse_obj_asl {
  486. ACPI_PARSE_COMMON union acpi_parse_object *child;
  487. union acpi_parse_object *parent_method;
  488. char *filename;
  489. char *external_name;
  490. char *namepath;
  491. char name_seg[4];
  492. u32 extra_value;
  493. u32 column;
  494. u32 line_number;
  495. u32 logical_line_number;
  496. u32 logical_byte_offset;
  497. u32 end_line;
  498. u32 end_logical_line;
  499. u32 acpi_btype;
  500. u32 aml_length;
  501. u32 aml_subtree_length;
  502. u32 final_aml_length;
  503. u32 final_aml_offset;
  504. u32 compile_flags;
  505. u16 parse_opcode;
  506. u8 aml_opcode_length;
  507. u8 aml_pkg_len_bytes;
  508. u8 extra;
  509. char parse_op_name[12];
  510. };
  511. union acpi_parse_object {
  512. struct acpi_parse_obj_common common;
  513. struct acpi_parse_obj_named named;
  514. struct acpi_parse_obj_asl asl;
  515. };
  516. /*
  517. * Parse state - one state per parser invocation and each control
  518. * method.
  519. */
  520. struct acpi_parse_state {
  521. u32 aml_size;
  522. u8 *aml_start; /* First AML byte */
  523. u8 *aml; /* Next AML byte */
  524. u8 *aml_end; /* (last + 1) AML byte */
  525. u8 *pkg_start; /* Current package begin */
  526. u8 *pkg_end; /* Current package end */
  527. union acpi_parse_object *start_op; /* Root of parse tree */
  528. struct acpi_namespace_node *start_node;
  529. union acpi_generic_state *scope; /* Current scope */
  530. union acpi_parse_object *start_scope;
  531. };
  532. /* Parse object flags */
  533. #define ACPI_PARSEOP_GENERIC 0x01
  534. #define ACPI_PARSEOP_NAMED 0x02
  535. #define ACPI_PARSEOP_DEFERRED 0x04
  536. #define ACPI_PARSEOP_BYTELIST 0x08
  537. #define ACPI_PARSEOP_IN_CACHE 0x80
  538. /* Parse object disasm_flags */
  539. #define ACPI_PARSEOP_IGNORE 0x01
  540. #define ACPI_PARSEOP_PARAMLIST 0x02
  541. #define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
  542. #define ACPI_PARSEOP_SPECIAL 0x10
  543. /*****************************************************************************
  544. *
  545. * Hardware (ACPI registers) and PNP
  546. *
  547. ****************************************************************************/
  548. #define PCI_ROOT_HID_STRING "PNP0A03"
  549. #define PCI_EXPRESS_ROOT_HID_STRING "PNP0A08"
  550. struct acpi_bit_register_info {
  551. u8 parent_register;
  552. u8 bit_position;
  553. u16 access_bit_mask;
  554. };
  555. /*
  556. * Register IDs
  557. * These are the full ACPI registers
  558. */
  559. #define ACPI_REGISTER_PM1_STATUS 0x01
  560. #define ACPI_REGISTER_PM1_ENABLE 0x02
  561. #define ACPI_REGISTER_PM1_CONTROL 0x03
  562. #define ACPI_REGISTER_PM1A_CONTROL 0x04
  563. #define ACPI_REGISTER_PM1B_CONTROL 0x05
  564. #define ACPI_REGISTER_PM2_CONTROL 0x06
  565. #define ACPI_REGISTER_PM_TIMER 0x07
  566. #define ACPI_REGISTER_PROCESSOR_BLOCK 0x08
  567. #define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x09
  568. /* Masks used to access the bit_registers */
  569. #define ACPI_BITMASK_TIMER_STATUS 0x0001
  570. #define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010
  571. #define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020
  572. #define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100
  573. #define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200
  574. #define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400
  575. #define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */
  576. #define ACPI_BITMASK_WAKE_STATUS 0x8000
  577. #define ACPI_BITMASK_ALL_FIXED_STATUS (ACPI_BITMASK_TIMER_STATUS | \
  578. ACPI_BITMASK_BUS_MASTER_STATUS | \
  579. ACPI_BITMASK_GLOBAL_LOCK_STATUS | \
  580. ACPI_BITMASK_POWER_BUTTON_STATUS | \
  581. ACPI_BITMASK_SLEEP_BUTTON_STATUS | \
  582. ACPI_BITMASK_RT_CLOCK_STATUS | \
  583. ACPI_BITMASK_WAKE_STATUS)
  584. #define ACPI_BITMASK_TIMER_ENABLE 0x0001
  585. #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020
  586. #define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100
  587. #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200
  588. #define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400
  589. #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */
  590. #define ACPI_BITMASK_SCI_ENABLE 0x0001
  591. #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002
  592. #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004
  593. #define ACPI_BITMASK_SLEEP_TYPE_X 0x1C00
  594. #define ACPI_BITMASK_SLEEP_ENABLE 0x2000
  595. #define ACPI_BITMASK_ARB_DISABLE 0x0001
  596. /* Raw bit position of each bit_register */
  597. #define ACPI_BITPOSITION_TIMER_STATUS 0x00
  598. #define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04
  599. #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05
  600. #define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08
  601. #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09
  602. #define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A
  603. #define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */
  604. #define ACPI_BITPOSITION_WAKE_STATUS 0x0F
  605. #define ACPI_BITPOSITION_TIMER_ENABLE 0x00
  606. #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05
  607. #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08
  608. #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09
  609. #define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A
  610. #define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */
  611. #define ACPI_BITPOSITION_SCI_ENABLE 0x00
  612. #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01
  613. #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02
  614. #define ACPI_BITPOSITION_SLEEP_TYPE_X 0x0A
  615. #define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D
  616. #define ACPI_BITPOSITION_ARB_DISABLE 0x00
  617. /*****************************************************************************
  618. *
  619. * Resource descriptors
  620. *
  621. ****************************************************************************/
  622. /* resource_type values */
  623. #define ACPI_RESOURCE_TYPE_MEMORY_RANGE 0
  624. #define ACPI_RESOURCE_TYPE_IO_RANGE 1
  625. #define ACPI_RESOURCE_TYPE_BUS_NUMBER_RANGE 2
  626. /* Resource descriptor types and masks */
  627. #define ACPI_RDESC_TYPE_LARGE 0x80
  628. #define ACPI_RDESC_TYPE_SMALL 0x00
  629. #define ACPI_RDESC_TYPE_MASK 0x80
  630. #define ACPI_RDESC_SMALL_MASK 0x78 /* Only bits 6:3 contain the type */
  631. /*
  632. * Small resource descriptor types
  633. * Note: The 3 length bits (2:0) must be zero
  634. */
  635. #define ACPI_RDESC_TYPE_IRQ_FORMAT 0x20
  636. #define ACPI_RDESC_TYPE_DMA_FORMAT 0x28
  637. #define ACPI_RDESC_TYPE_START_DEPENDENT 0x30
  638. #define ACPI_RDESC_TYPE_END_DEPENDENT 0x38
  639. #define ACPI_RDESC_TYPE_IO_PORT 0x40
  640. #define ACPI_RDESC_TYPE_FIXED_IO_PORT 0x48
  641. #define ACPI_RDESC_TYPE_SMALL_VENDOR 0x70
  642. #define ACPI_RDESC_TYPE_END_TAG 0x78
  643. /*
  644. * Large resource descriptor types
  645. */
  646. #define ACPI_RDESC_TYPE_MEMORY_24 0x81
  647. #define ACPI_RDESC_TYPE_GENERAL_REGISTER 0x82
  648. #define ACPI_RDESC_TYPE_LARGE_VENDOR 0x84
  649. #define ACPI_RDESC_TYPE_MEMORY_32 0x85
  650. #define ACPI_RDESC_TYPE_FIXED_MEMORY_32 0x86
  651. #define ACPI_RDESC_TYPE_DWORD_ADDRESS_SPACE 0x87
  652. #define ACPI_RDESC_TYPE_WORD_ADDRESS_SPACE 0x88
  653. #define ACPI_RDESC_TYPE_EXTENDED_XRUPT 0x89
  654. #define ACPI_RDESC_TYPE_QWORD_ADDRESS_SPACE 0x8A
  655. #define ACPI_RDESC_TYPE_EXTENDED_ADDRESS_SPACE 0x8B
  656. /*****************************************************************************
  657. *
  658. * Miscellaneous
  659. *
  660. ****************************************************************************/
  661. #define ACPI_ASCII_ZERO 0x30
  662. /*****************************************************************************
  663. *
  664. * Debugger
  665. *
  666. ****************************************************************************/
  667. struct acpi_db_method_info {
  668. acpi_handle thread_gate;
  669. char *name;
  670. char **args;
  671. u32 flags;
  672. u32 num_loops;
  673. char pathname[128];
  674. };
  675. struct acpi_integrity_info {
  676. u32 nodes;
  677. u32 objects;
  678. };
  679. #define ACPI_DB_REDIRECTABLE_OUTPUT 0x01
  680. #define ACPI_DB_CONSOLE_OUTPUT 0x02
  681. #define ACPI_DB_DUPLICATE_OUTPUT 0x03
  682. /*****************************************************************************
  683. *
  684. * Debug
  685. *
  686. ****************************************************************************/
  687. /* Entry for a memory allocation (debug only) */
  688. #define ACPI_MEM_MALLOC 0
  689. #define ACPI_MEM_CALLOC 1
  690. #define ACPI_MAX_MODULE_NAME 16
  691. #define ACPI_COMMON_DEBUG_MEM_HEADER \
  692. struct acpi_debug_mem_block *previous; \
  693. struct acpi_debug_mem_block *next; \
  694. u32 size; \
  695. u32 component; \
  696. u32 line; \
  697. char module[ACPI_MAX_MODULE_NAME]; \
  698. u8 alloc_type;
  699. struct acpi_debug_mem_header {
  700. ACPI_COMMON_DEBUG_MEM_HEADER};
  701. struct acpi_debug_mem_block {
  702. ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space;
  703. };
  704. #define ACPI_MEM_LIST_GLOBAL 0
  705. #define ACPI_MEM_LIST_NSNODE 1
  706. #define ACPI_MEM_LIST_MAX 1
  707. #define ACPI_NUM_MEM_LISTS 2
  708. struct acpi_memory_list {
  709. char *list_name;
  710. void *list_head;
  711. u16 object_size;
  712. u16 max_depth;
  713. u16 current_depth;
  714. u16 link_offset;
  715. #ifdef ACPI_DBG_TRACK_ALLOCATIONS
  716. /* Statistics for debug memory tracking only */
  717. u32 total_allocated;
  718. u32 total_freed;
  719. u32 current_total_size;
  720. u32 requests;
  721. u32 hits;
  722. #endif
  723. };
  724. #endif /* __ACLOCAL_H__ */