aclocal.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. /******************************************************************************
  2. *
  3. * Name: aclocal.h - Internal data types used across the ACPI subsystem
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2011, Intel Corp.
  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_SERIALIZED 0xFF
  46. typedef u32 acpi_mutex_handle;
  47. #define ACPI_GLOBAL_LOCK (acpi_semaphore) (-1)
  48. /* Total number of aml opcodes defined */
  49. #define AML_NUM_OPCODES 0x7F
  50. /* Forward declarations */
  51. struct acpi_walk_state;
  52. struct acpi_obj_mutex;
  53. union acpi_parse_object;
  54. /*****************************************************************************
  55. *
  56. * Mutex typedefs and structs
  57. *
  58. ****************************************************************************/
  59. /*
  60. * Predefined handles for the mutex objects used within the subsystem
  61. * All mutex objects are automatically created by acpi_ut_mutex_initialize.
  62. *
  63. * The acquire/release ordering protocol is implied via this list. Mutexes
  64. * with a lower value must be acquired before mutexes with a higher value.
  65. *
  66. * NOTE: any changes here must be reflected in the acpi_gbl_mutex_names
  67. * table below also!
  68. */
  69. #define ACPI_MTX_INTERPRETER 0 /* AML Interpreter, main lock */
  70. #define ACPI_MTX_NAMESPACE 1 /* ACPI Namespace */
  71. #define ACPI_MTX_TABLES 2 /* Data for ACPI tables */
  72. #define ACPI_MTX_EVENTS 3 /* Data for ACPI events */
  73. #define ACPI_MTX_CACHES 4 /* Internal caches, general purposes */
  74. #define ACPI_MTX_MEMORY 5 /* Debug memory tracking lists */
  75. #define ACPI_MTX_DEBUG_CMD_COMPLETE 6 /* AML debugger */
  76. #define ACPI_MTX_DEBUG_CMD_READY 7 /* AML debugger */
  77. #define ACPI_MAX_MUTEX 7
  78. #define ACPI_NUM_MUTEX ACPI_MAX_MUTEX+1
  79. #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
  80. #ifdef DEFINE_ACPI_GLOBALS
  81. /* Debug names for the mutexes above */
  82. static char *acpi_gbl_mutex_names[ACPI_NUM_MUTEX] = {
  83. "ACPI_MTX_Interpreter",
  84. "ACPI_MTX_Namespace",
  85. "ACPI_MTX_Tables",
  86. "ACPI_MTX_Events",
  87. "ACPI_MTX_Caches",
  88. "ACPI_MTX_Memory",
  89. "ACPI_MTX_CommandComplete",
  90. "ACPI_MTX_CommandReady"
  91. };
  92. #endif
  93. #endif
  94. /* Lock structure for reader/writer interfaces */
  95. struct acpi_rw_lock {
  96. acpi_mutex writer_mutex;
  97. acpi_mutex reader_mutex;
  98. u32 num_readers;
  99. };
  100. /*
  101. * Predefined handles for spinlocks used within the subsystem.
  102. * These spinlocks are created by acpi_ut_mutex_initialize
  103. */
  104. #define ACPI_LOCK_GPES 0
  105. #define ACPI_LOCK_HARDWARE 1
  106. #define ACPI_MAX_LOCK 1
  107. #define ACPI_NUM_LOCK ACPI_MAX_LOCK+1
  108. /* This Thread ID means that the mutex is not in use (unlocked) */
  109. #define ACPI_MUTEX_NOT_ACQUIRED (acpi_thread_id) 0
  110. /* Table for the global mutexes */
  111. struct acpi_mutex_info {
  112. acpi_mutex mutex;
  113. u32 use_count;
  114. acpi_thread_id thread_id;
  115. };
  116. /* Lock flag parameter for various interfaces */
  117. #define ACPI_MTX_DO_NOT_LOCK 0
  118. #define ACPI_MTX_LOCK 1
  119. /* Field access granularities */
  120. #define ACPI_FIELD_BYTE_GRANULARITY 1
  121. #define ACPI_FIELD_WORD_GRANULARITY 2
  122. #define ACPI_FIELD_DWORD_GRANULARITY 4
  123. #define ACPI_FIELD_QWORD_GRANULARITY 8
  124. #define ACPI_ENTRY_NOT_FOUND NULL
  125. /*****************************************************************************
  126. *
  127. * Namespace typedefs and structs
  128. *
  129. ****************************************************************************/
  130. /* Operational modes of the AML interpreter/scanner */
  131. typedef enum {
  132. ACPI_IMODE_LOAD_PASS1 = 0x01,
  133. ACPI_IMODE_LOAD_PASS2 = 0x02,
  134. ACPI_IMODE_EXECUTE = 0x03
  135. } acpi_interpreter_mode;
  136. /*
  137. * The Namespace Node describes a named object that appears in the AML.
  138. * descriptor_type is used to differentiate between internal descriptors.
  139. *
  140. * The node is optimized for both 32-bit and 64-bit platforms:
  141. * 20 bytes for the 32-bit case, 32 bytes for the 64-bit case.
  142. *
  143. * Note: The descriptor_type and Type fields must appear in the identical
  144. * position in both the struct acpi_namespace_node and union acpi_operand_object
  145. * structures.
  146. */
  147. struct acpi_namespace_node {
  148. union acpi_operand_object *object; /* Interpreter object */
  149. u8 descriptor_type; /* Differentiate object descriptor types */
  150. u8 type; /* ACPI Type associated with this name */
  151. u8 flags; /* Miscellaneous flags */
  152. acpi_owner_id owner_id; /* Node creator */
  153. union acpi_name_union name; /* ACPI Name, always 4 chars per ACPI spec */
  154. struct acpi_namespace_node *parent; /* Parent node */
  155. struct acpi_namespace_node *child; /* First child */
  156. struct acpi_namespace_node *peer; /* First peer */
  157. /*
  158. * The following fields are used by the ASL compiler and disassembler only
  159. */
  160. #ifdef ACPI_LARGE_NAMESPACE_NODE
  161. union acpi_parse_object *op;
  162. u32 value;
  163. u32 length;
  164. #endif
  165. };
  166. /* Namespace Node flags */
  167. #define ANOBJ_RESERVED 0x01 /* Available for use */
  168. #define ANOBJ_TEMPORARY 0x02 /* Node is create by a method and is temporary */
  169. #define ANOBJ_METHOD_ARG 0x04 /* Node is a method argument */
  170. #define ANOBJ_METHOD_LOCAL 0x08 /* Node is a method local */
  171. #define ANOBJ_SUBTREE_HAS_INI 0x10 /* Used to optimize device initialization */
  172. #define ANOBJ_EVALUATED 0x20 /* Set on first evaluation of node */
  173. #define ANOBJ_ALLOCATED_BUFFER 0x40 /* Method AML buffer is dynamic (install_method) */
  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. /* Internal ACPI table management - master table list */
  180. struct acpi_table_list {
  181. struct acpi_table_desc *tables; /* Table descriptor array */
  182. u32 current_table_count; /* Tables currently in the array */
  183. u32 max_table_count; /* Max tables array will hold */
  184. u8 flags;
  185. };
  186. /* Flags for above */
  187. #define ACPI_ROOT_ORIGIN_UNKNOWN (0) /* ~ORIGIN_ALLOCATED */
  188. #define ACPI_ROOT_ORIGIN_ALLOCATED (1)
  189. #define ACPI_ROOT_ALLOW_RESIZE (2)
  190. /* Predefined (fixed) table indexes */
  191. #define ACPI_TABLE_INDEX_DSDT (0)
  192. #define ACPI_TABLE_INDEX_FACS (1)
  193. struct acpi_find_context {
  194. char *search_for;
  195. acpi_handle *list;
  196. u32 *count;
  197. };
  198. struct acpi_ns_search_data {
  199. struct acpi_namespace_node *node;
  200. };
  201. /* Object types used during package copies */
  202. #define ACPI_COPY_TYPE_SIMPLE 0
  203. #define ACPI_COPY_TYPE_PACKAGE 1
  204. /* Info structure used to convert external<->internal namestrings */
  205. struct acpi_namestring_info {
  206. const char *external_name;
  207. const char *next_external_char;
  208. char *internal_name;
  209. u32 length;
  210. u32 num_segments;
  211. u32 num_carats;
  212. u8 fully_qualified;
  213. };
  214. /* Field creation info */
  215. struct acpi_create_field_info {
  216. struct acpi_namespace_node *region_node;
  217. struct acpi_namespace_node *field_node;
  218. struct acpi_namespace_node *register_node;
  219. struct acpi_namespace_node *data_register_node;
  220. u32 bank_value;
  221. u32 field_bit_position;
  222. u32 field_bit_length;
  223. u8 field_flags;
  224. u8 attribute;
  225. u8 field_type;
  226. };
  227. typedef
  228. acpi_status(*ACPI_INTERNAL_METHOD) (struct acpi_walk_state * walk_state);
  229. /*
  230. * Bitmapped ACPI types. Used internally only
  231. */
  232. #define ACPI_BTYPE_ANY 0x00000000
  233. #define ACPI_BTYPE_INTEGER 0x00000001
  234. #define ACPI_BTYPE_STRING 0x00000002
  235. #define ACPI_BTYPE_BUFFER 0x00000004
  236. #define ACPI_BTYPE_PACKAGE 0x00000008
  237. #define ACPI_BTYPE_FIELD_UNIT 0x00000010
  238. #define ACPI_BTYPE_DEVICE 0x00000020
  239. #define ACPI_BTYPE_EVENT 0x00000040
  240. #define ACPI_BTYPE_METHOD 0x00000080
  241. #define ACPI_BTYPE_MUTEX 0x00000100
  242. #define ACPI_BTYPE_REGION 0x00000200
  243. #define ACPI_BTYPE_POWER 0x00000400
  244. #define ACPI_BTYPE_PROCESSOR 0x00000800
  245. #define ACPI_BTYPE_THERMAL 0x00001000
  246. #define ACPI_BTYPE_BUFFER_FIELD 0x00002000
  247. #define ACPI_BTYPE_DDB_HANDLE 0x00004000
  248. #define ACPI_BTYPE_DEBUG_OBJECT 0x00008000
  249. #define ACPI_BTYPE_REFERENCE 0x00010000
  250. #define ACPI_BTYPE_RESOURCE 0x00020000
  251. #define ACPI_BTYPE_COMPUTE_DATA (ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER)
  252. #define ACPI_BTYPE_DATA (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_PACKAGE)
  253. #define ACPI_BTYPE_DATA_REFERENCE (ACPI_BTYPE_DATA | ACPI_BTYPE_REFERENCE | ACPI_BTYPE_DDB_HANDLE)
  254. #define ACPI_BTYPE_DEVICE_OBJECTS (ACPI_BTYPE_DEVICE | ACPI_BTYPE_THERMAL | ACPI_BTYPE_PROCESSOR)
  255. #define ACPI_BTYPE_OBJECTS_AND_REFS 0x0001FFFF /* ARG or LOCAL */
  256. #define ACPI_BTYPE_ALL_OBJECTS 0x0000FFFF
  257. /*
  258. * Information structure for ACPI predefined names.
  259. * Each entry in the table contains the following items:
  260. *
  261. * Name - The ACPI reserved name
  262. * param_count - Number of arguments to the method
  263. * expected_return_btypes - Allowed type(s) for the return value
  264. */
  265. struct acpi_name_info {
  266. char name[ACPI_NAME_SIZE];
  267. u8 param_count;
  268. u8 expected_btypes;
  269. };
  270. /*
  271. * Secondary information structures for ACPI predefined objects that return
  272. * package objects. This structure appears as the next entry in the table
  273. * after the NAME_INFO structure above.
  274. *
  275. * The reason for this is to minimize the size of the predefined name table.
  276. */
  277. /*
  278. * Used for ACPI_PTYPE1_FIXED, ACPI_PTYPE1_VAR, ACPI_PTYPE2,
  279. * ACPI_PTYPE2_MIN, ACPI_PTYPE2_PKG_COUNT, ACPI_PTYPE2_COUNT
  280. */
  281. struct acpi_package_info {
  282. u8 type;
  283. u8 object_type1;
  284. u8 count1;
  285. u8 object_type2;
  286. u8 count2;
  287. u8 reserved;
  288. };
  289. /* Used for ACPI_PTYPE2_FIXED */
  290. struct acpi_package_info2 {
  291. u8 type;
  292. u8 count;
  293. u8 object_type[4];
  294. };
  295. /* Used for ACPI_PTYPE1_OPTION */
  296. struct acpi_package_info3 {
  297. u8 type;
  298. u8 count;
  299. u8 object_type[2];
  300. u8 tail_object_type;
  301. u8 reserved;
  302. };
  303. union acpi_predefined_info {
  304. struct acpi_name_info info;
  305. struct acpi_package_info ret_info;
  306. struct acpi_package_info2 ret_info2;
  307. struct acpi_package_info3 ret_info3;
  308. };
  309. /* Data block used during object validation */
  310. struct acpi_predefined_data {
  311. char *pathname;
  312. const union acpi_predefined_info *predefined;
  313. union acpi_operand_object *parent_package;
  314. u32 flags;
  315. u8 node_flags;
  316. };
  317. /* Defines for Flags field above */
  318. #define ACPI_OBJECT_REPAIRED 1
  319. /*
  320. * Bitmapped return value types
  321. * Note: the actual data types must be contiguous, a loop in nspredef.c
  322. * depends on this.
  323. */
  324. #define ACPI_RTYPE_ANY 0x00
  325. #define ACPI_RTYPE_NONE 0x01
  326. #define ACPI_RTYPE_INTEGER 0x02
  327. #define ACPI_RTYPE_STRING 0x04
  328. #define ACPI_RTYPE_BUFFER 0x08
  329. #define ACPI_RTYPE_PACKAGE 0x10
  330. #define ACPI_RTYPE_REFERENCE 0x20
  331. #define ACPI_RTYPE_ALL 0x3F
  332. #define ACPI_NUM_RTYPES 5 /* Number of actual object types */
  333. /*****************************************************************************
  334. *
  335. * Event typedefs and structs
  336. *
  337. ****************************************************************************/
  338. /* Dispatch info for each GPE -- either a method or handler, cannot be both */
  339. struct acpi_gpe_handler_info {
  340. acpi_gpe_handler address; /* Address of handler, if any */
  341. void *context; /* Context to be passed to handler */
  342. struct acpi_namespace_node *method_node; /* Method node for this GPE level (saved) */
  343. u8 original_flags; /* Original (pre-handler) GPE info */
  344. u8 originally_enabled; /* True if GPE was originally enabled */
  345. };
  346. union acpi_gpe_dispatch_info {
  347. struct acpi_namespace_node *method_node; /* Method node for this GPE level */
  348. struct acpi_gpe_handler_info *handler; /* Installed GPE handler */
  349. struct acpi_namespace_node *device_node; /* Parent _PRW device for implicit notify */
  350. };
  351. /*
  352. * Information about a GPE, one per each GPE in an array.
  353. * NOTE: Important to keep this struct as small as possible.
  354. */
  355. struct acpi_gpe_event_info {
  356. union acpi_gpe_dispatch_info dispatch; /* Either Method or Handler */
  357. struct acpi_gpe_register_info *register_info; /* Backpointer to register info */
  358. u8 flags; /* Misc info about this GPE */
  359. u8 gpe_number; /* This GPE */
  360. u8 runtime_count; /* References to a run GPE */
  361. };
  362. /* Information about a GPE register pair, one per each status/enable pair in an array */
  363. struct acpi_gpe_register_info {
  364. struct acpi_generic_address status_address; /* Address of status reg */
  365. struct acpi_generic_address enable_address; /* Address of enable reg */
  366. u8 enable_for_wake; /* GPEs to keep enabled when sleeping */
  367. u8 enable_for_run; /* GPEs to keep enabled when running */
  368. u8 base_gpe_number; /* Base GPE number for this register */
  369. };
  370. /*
  371. * Information about a GPE register block, one per each installed block --
  372. * GPE0, GPE1, and one per each installed GPE Block Device.
  373. */
  374. struct acpi_gpe_block_info {
  375. struct acpi_namespace_node *node;
  376. struct acpi_gpe_block_info *previous;
  377. struct acpi_gpe_block_info *next;
  378. struct acpi_gpe_xrupt_info *xrupt_block; /* Backpointer to interrupt block */
  379. struct acpi_gpe_register_info *register_info; /* One per GPE register pair */
  380. struct acpi_gpe_event_info *event_info; /* One for each GPE */
  381. struct acpi_generic_address block_address; /* Base address of the block */
  382. u32 register_count; /* Number of register pairs in block */
  383. u16 gpe_count; /* Number of individual GPEs in block */
  384. u8 block_base_number; /* Base GPE number for this block */
  385. u8 initialized; /* TRUE if this block is initialized */
  386. };
  387. /* Information about GPE interrupt handlers, one per each interrupt level used for GPEs */
  388. struct acpi_gpe_xrupt_info {
  389. struct acpi_gpe_xrupt_info *previous;
  390. struct acpi_gpe_xrupt_info *next;
  391. struct acpi_gpe_block_info *gpe_block_list_head; /* List of GPE blocks for this xrupt */
  392. u32 interrupt_number; /* System interrupt number */
  393. };
  394. struct acpi_gpe_walk_info {
  395. struct acpi_namespace_node *gpe_device;
  396. struct acpi_gpe_block_info *gpe_block;
  397. u16 count;
  398. acpi_owner_id owner_id;
  399. u8 execute_by_owner_id;
  400. };
  401. struct acpi_gpe_device_info {
  402. u32 index;
  403. u32 next_block_base_index;
  404. acpi_status status;
  405. struct acpi_namespace_node *gpe_device;
  406. };
  407. typedef acpi_status(*acpi_gpe_callback) (struct acpi_gpe_xrupt_info *gpe_xrupt_info,
  408. struct acpi_gpe_block_info *gpe_block, void *context);
  409. /* Information about each particular fixed event */
  410. struct acpi_fixed_event_handler {
  411. acpi_event_handler handler; /* Address of handler. */
  412. void *context; /* Context to be passed to handler */
  413. };
  414. struct acpi_fixed_event_info {
  415. u8 status_register_id;
  416. u8 enable_register_id;
  417. u16 status_bit_mask;
  418. u16 enable_bit_mask;
  419. };
  420. /* Information used during field processing */
  421. struct acpi_field_info {
  422. u8 skip_field;
  423. u8 field_flag;
  424. u32 pkg_length;
  425. };
  426. /*****************************************************************************
  427. *
  428. * Generic "state" object for stacks
  429. *
  430. ****************************************************************************/
  431. #define ACPI_CONTROL_NORMAL 0xC0
  432. #define ACPI_CONTROL_CONDITIONAL_EXECUTING 0xC1
  433. #define ACPI_CONTROL_PREDICATE_EXECUTING 0xC2
  434. #define ACPI_CONTROL_PREDICATE_FALSE 0xC3
  435. #define ACPI_CONTROL_PREDICATE_TRUE 0xC4
  436. #define ACPI_STATE_COMMON \
  437. void *next; \
  438. u8 descriptor_type; /* To differentiate various internal objs */\
  439. u8 flags; \
  440. u16 value; \
  441. u16 state;
  442. /* There are 2 bytes available here until the next natural alignment boundary */
  443. struct acpi_common_state {
  444. ACPI_STATE_COMMON};
  445. /*
  446. * Update state - used to traverse complex objects such as packages
  447. */
  448. struct acpi_update_state {
  449. ACPI_STATE_COMMON union acpi_operand_object *object;
  450. };
  451. /*
  452. * Pkg state - used to traverse nested package structures
  453. */
  454. struct acpi_pkg_state {
  455. ACPI_STATE_COMMON u16 index;
  456. union acpi_operand_object *source_object;
  457. union acpi_operand_object *dest_object;
  458. struct acpi_walk_state *walk_state;
  459. void *this_target_obj;
  460. u32 num_packages;
  461. };
  462. /*
  463. * Control state - one per if/else and while constructs.
  464. * Allows nesting of these constructs
  465. */
  466. struct acpi_control_state {
  467. ACPI_STATE_COMMON u16 opcode;
  468. union acpi_parse_object *predicate_op;
  469. u8 *aml_predicate_start; /* Start of if/while predicate */
  470. u8 *package_end; /* End of if/while block */
  471. u32 loop_count; /* While() loop counter */
  472. };
  473. /*
  474. * Scope state - current scope during namespace lookups
  475. */
  476. struct acpi_scope_state {
  477. ACPI_STATE_COMMON struct acpi_namespace_node *node;
  478. };
  479. struct acpi_pscope_state {
  480. ACPI_STATE_COMMON u32 arg_count; /* Number of fixed arguments */
  481. union acpi_parse_object *op; /* Current op being parsed */
  482. u8 *arg_end; /* Current argument end */
  483. u8 *pkg_end; /* Current package end */
  484. u32 arg_list; /* Next argument to parse */
  485. };
  486. /*
  487. * Thread state - one per thread across multiple walk states. Multiple walk
  488. * states are created when there are nested control methods executing.
  489. */
  490. struct acpi_thread_state {
  491. ACPI_STATE_COMMON u8 current_sync_level; /* Mutex Sync (nested acquire) level */
  492. struct acpi_walk_state *walk_state_list; /* Head of list of walk_states for this thread */
  493. union acpi_operand_object *acquired_mutex_list; /* List of all currently acquired mutexes */
  494. acpi_thread_id thread_id; /* Running thread ID */
  495. };
  496. /*
  497. * Result values - used to accumulate the results of nested
  498. * AML arguments
  499. */
  500. struct acpi_result_values {
  501. ACPI_STATE_COMMON
  502. union acpi_operand_object *obj_desc[ACPI_RESULTS_FRAME_OBJ_NUM];
  503. };
  504. typedef
  505. acpi_status(*acpi_parse_downwards) (struct acpi_walk_state * walk_state,
  506. union acpi_parse_object ** out_op);
  507. typedef acpi_status(*acpi_parse_upwards) (struct acpi_walk_state * walk_state);
  508. /*
  509. * Notify info - used to pass info to the deferred notify
  510. * handler/dispatcher.
  511. */
  512. struct acpi_notify_info {
  513. ACPI_STATE_COMMON struct acpi_namespace_node *node;
  514. union acpi_operand_object *handler_obj;
  515. };
  516. /* Generic state is union of structs above */
  517. union acpi_generic_state {
  518. struct acpi_common_state common;
  519. struct acpi_control_state control;
  520. struct acpi_update_state update;
  521. struct acpi_scope_state scope;
  522. struct acpi_pscope_state parse_scope;
  523. struct acpi_pkg_state pkg;
  524. struct acpi_thread_state thread;
  525. struct acpi_result_values results;
  526. struct acpi_notify_info notify;
  527. };
  528. /*****************************************************************************
  529. *
  530. * Interpreter typedefs and structs
  531. *
  532. ****************************************************************************/
  533. typedef acpi_status(*ACPI_EXECUTE_OP) (struct acpi_walk_state * walk_state);
  534. /*****************************************************************************
  535. *
  536. * Parser typedefs and structs
  537. *
  538. ****************************************************************************/
  539. /*
  540. * AML opcode, name, and argument layout
  541. */
  542. struct acpi_opcode_info {
  543. #if defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUG_OUTPUT)
  544. char *name; /* Opcode name (disassembler/debug only) */
  545. #endif
  546. u32 parse_args; /* Grammar/Parse time arguments */
  547. u32 runtime_args; /* Interpret time arguments */
  548. u16 flags; /* Misc flags */
  549. u8 object_type; /* Corresponding internal object type */
  550. u8 class; /* Opcode class */
  551. u8 type; /* Opcode type */
  552. };
  553. union acpi_parse_value {
  554. u64 integer; /* Integer constant (Up to 64 bits) */
  555. u32 size; /* bytelist or field size */
  556. char *string; /* NULL terminated string */
  557. u8 *buffer; /* buffer or string */
  558. char *name; /* NULL terminated string */
  559. union acpi_parse_object *arg; /* arguments and contained ops */
  560. };
  561. #ifdef ACPI_DISASSEMBLER
  562. #define ACPI_DISASM_ONLY_MEMBERS(a) a;
  563. #else
  564. #define ACPI_DISASM_ONLY_MEMBERS(a)
  565. #endif
  566. #define ACPI_PARSE_COMMON \
  567. union acpi_parse_object *parent; /* Parent op */\
  568. u8 descriptor_type; /* To differentiate various internal objs */\
  569. u8 flags; /* Type of Op */\
  570. u16 aml_opcode; /* AML opcode */\
  571. u32 aml_offset; /* Offset of declaration in AML */\
  572. union acpi_parse_object *next; /* Next op */\
  573. struct acpi_namespace_node *node; /* For use by interpreter */\
  574. union acpi_parse_value value; /* Value or args associated with the opcode */\
  575. u8 arg_list_length; /* Number of elements in the arg list */\
  576. ACPI_DISASM_ONLY_MEMBERS (\
  577. u8 disasm_flags; /* Used during AML disassembly */\
  578. u8 disasm_opcode; /* Subtype used for disassembly */\
  579. char aml_op_name[16]) /* Op name (debug only) */
  580. #define ACPI_DASM_BUFFER 0x00
  581. #define ACPI_DASM_RESOURCE 0x01
  582. #define ACPI_DASM_STRING 0x02
  583. #define ACPI_DASM_UNICODE 0x03
  584. #define ACPI_DASM_EISAID 0x04
  585. #define ACPI_DASM_MATCHOP 0x05
  586. #define ACPI_DASM_LNOT_PREFIX 0x06
  587. #define ACPI_DASM_LNOT_SUFFIX 0x07
  588. #define ACPI_DASM_IGNORE 0x08
  589. /*
  590. * Generic operation (for example: If, While, Store)
  591. */
  592. struct acpi_parse_obj_common {
  593. ACPI_PARSE_COMMON};
  594. /*
  595. * Extended Op for named ops (Scope, Method, etc.), deferred ops (Methods and op_regions),
  596. * and bytelists.
  597. */
  598. struct acpi_parse_obj_named {
  599. ACPI_PARSE_COMMON u8 *path;
  600. u8 *data; /* AML body or bytelist data */
  601. u32 length; /* AML length */
  602. u32 name; /* 4-byte name or zero if no name */
  603. };
  604. /* This version is used by the i_aSL compiler only */
  605. #define ACPI_MAX_PARSEOP_NAME 20
  606. struct acpi_parse_obj_asl {
  607. ACPI_PARSE_COMMON union acpi_parse_object *child;
  608. union acpi_parse_object *parent_method;
  609. char *filename;
  610. char *external_name;
  611. char *namepath;
  612. char name_seg[4];
  613. u32 extra_value;
  614. u32 column;
  615. u32 line_number;
  616. u32 logical_line_number;
  617. u32 logical_byte_offset;
  618. u32 end_line;
  619. u32 end_logical_line;
  620. u32 acpi_btype;
  621. u32 aml_length;
  622. u32 aml_subtree_length;
  623. u32 final_aml_length;
  624. u32 final_aml_offset;
  625. u32 compile_flags;
  626. u16 parse_opcode;
  627. u8 aml_opcode_length;
  628. u8 aml_pkg_len_bytes;
  629. u8 extra;
  630. char parse_op_name[ACPI_MAX_PARSEOP_NAME];
  631. };
  632. union acpi_parse_object {
  633. struct acpi_parse_obj_common common;
  634. struct acpi_parse_obj_named named;
  635. struct acpi_parse_obj_asl asl;
  636. };
  637. /*
  638. * Parse state - one state per parser invocation and each control
  639. * method.
  640. */
  641. struct acpi_parse_state {
  642. u8 *aml_start; /* First AML byte */
  643. u8 *aml; /* Next AML byte */
  644. u8 *aml_end; /* (last + 1) AML byte */
  645. u8 *pkg_start; /* Current package begin */
  646. u8 *pkg_end; /* Current package end */
  647. union acpi_parse_object *start_op; /* Root of parse tree */
  648. struct acpi_namespace_node *start_node;
  649. union acpi_generic_state *scope; /* Current scope */
  650. union acpi_parse_object *start_scope;
  651. u32 aml_size;
  652. };
  653. /* Parse object flags */
  654. #define ACPI_PARSEOP_GENERIC 0x01
  655. #define ACPI_PARSEOP_NAMED 0x02
  656. #define ACPI_PARSEOP_DEFERRED 0x04
  657. #define ACPI_PARSEOP_BYTELIST 0x08
  658. #define ACPI_PARSEOP_IN_STACK 0x10
  659. #define ACPI_PARSEOP_TARGET 0x20
  660. #define ACPI_PARSEOP_IN_CACHE 0x80
  661. /* Parse object disasm_flags */
  662. #define ACPI_PARSEOP_IGNORE 0x01
  663. #define ACPI_PARSEOP_PARAMLIST 0x02
  664. #define ACPI_PARSEOP_EMPTY_TERMLIST 0x04
  665. #define ACPI_PARSEOP_SPECIAL 0x10
  666. /*****************************************************************************
  667. *
  668. * Hardware (ACPI registers) and PNP
  669. *
  670. ****************************************************************************/
  671. struct acpi_bit_register_info {
  672. u8 parent_register;
  673. u8 bit_position;
  674. u16 access_bit_mask;
  675. };
  676. /*
  677. * Some ACPI registers have bits that must be ignored -- meaning that they
  678. * must be preserved.
  679. */
  680. #define ACPI_PM1_STATUS_PRESERVED_BITS 0x0800 /* Bit 11 */
  681. /* Write-only bits must be zeroed by software */
  682. #define ACPI_PM1_CONTROL_WRITEONLY_BITS 0x2004 /* Bits 13, 2 */
  683. /* For control registers, both ignored and reserved bits must be preserved */
  684. /*
  685. * For PM1 control, the SCI enable bit (bit 0, SCI_EN) is defined by the
  686. * ACPI specification to be a "preserved" bit - "OSPM always preserves this
  687. * bit position", section 4.7.3.2.1. However, on some machines the OS must
  688. * write a one to this bit after resume for the machine to work properly.
  689. * To enable this, we no longer attempt to preserve this bit. No machines
  690. * are known to fail if the bit is not preserved. (May 2009)
  691. */
  692. #define ACPI_PM1_CONTROL_IGNORED_BITS 0x0200 /* Bit 9 */
  693. #define ACPI_PM1_CONTROL_RESERVED_BITS 0xC1F8 /* Bits 14-15, 3-8 */
  694. #define ACPI_PM1_CONTROL_PRESERVED_BITS \
  695. (ACPI_PM1_CONTROL_IGNORED_BITS | ACPI_PM1_CONTROL_RESERVED_BITS)
  696. #define ACPI_PM2_CONTROL_PRESERVED_BITS 0xFFFFFFFE /* All except bit 0 */
  697. /*
  698. * Register IDs
  699. * These are the full ACPI registers
  700. */
  701. #define ACPI_REGISTER_PM1_STATUS 0x01
  702. #define ACPI_REGISTER_PM1_ENABLE 0x02
  703. #define ACPI_REGISTER_PM1_CONTROL 0x03
  704. #define ACPI_REGISTER_PM2_CONTROL 0x04
  705. #define ACPI_REGISTER_PM_TIMER 0x05
  706. #define ACPI_REGISTER_PROCESSOR_BLOCK 0x06
  707. #define ACPI_REGISTER_SMI_COMMAND_BLOCK 0x07
  708. /* Masks used to access the bit_registers */
  709. #define ACPI_BITMASK_TIMER_STATUS 0x0001
  710. #define ACPI_BITMASK_BUS_MASTER_STATUS 0x0010
  711. #define ACPI_BITMASK_GLOBAL_LOCK_STATUS 0x0020
  712. #define ACPI_BITMASK_POWER_BUTTON_STATUS 0x0100
  713. #define ACPI_BITMASK_SLEEP_BUTTON_STATUS 0x0200
  714. #define ACPI_BITMASK_RT_CLOCK_STATUS 0x0400
  715. #define ACPI_BITMASK_PCIEXP_WAKE_STATUS 0x4000 /* ACPI 3.0 */
  716. #define ACPI_BITMASK_WAKE_STATUS 0x8000
  717. #define ACPI_BITMASK_ALL_FIXED_STATUS (\
  718. ACPI_BITMASK_TIMER_STATUS | \
  719. ACPI_BITMASK_BUS_MASTER_STATUS | \
  720. ACPI_BITMASK_GLOBAL_LOCK_STATUS | \
  721. ACPI_BITMASK_POWER_BUTTON_STATUS | \
  722. ACPI_BITMASK_SLEEP_BUTTON_STATUS | \
  723. ACPI_BITMASK_RT_CLOCK_STATUS | \
  724. ACPI_BITMASK_PCIEXP_WAKE_STATUS | \
  725. ACPI_BITMASK_WAKE_STATUS)
  726. #define ACPI_BITMASK_TIMER_ENABLE 0x0001
  727. #define ACPI_BITMASK_GLOBAL_LOCK_ENABLE 0x0020
  728. #define ACPI_BITMASK_POWER_BUTTON_ENABLE 0x0100
  729. #define ACPI_BITMASK_SLEEP_BUTTON_ENABLE 0x0200
  730. #define ACPI_BITMASK_RT_CLOCK_ENABLE 0x0400
  731. #define ACPI_BITMASK_PCIEXP_WAKE_DISABLE 0x4000 /* ACPI 3.0 */
  732. #define ACPI_BITMASK_SCI_ENABLE 0x0001
  733. #define ACPI_BITMASK_BUS_MASTER_RLD 0x0002
  734. #define ACPI_BITMASK_GLOBAL_LOCK_RELEASE 0x0004
  735. #define ACPI_BITMASK_SLEEP_TYPE 0x1C00
  736. #define ACPI_BITMASK_SLEEP_ENABLE 0x2000
  737. #define ACPI_BITMASK_ARB_DISABLE 0x0001
  738. /* Raw bit position of each bit_register */
  739. #define ACPI_BITPOSITION_TIMER_STATUS 0x00
  740. #define ACPI_BITPOSITION_BUS_MASTER_STATUS 0x04
  741. #define ACPI_BITPOSITION_GLOBAL_LOCK_STATUS 0x05
  742. #define ACPI_BITPOSITION_POWER_BUTTON_STATUS 0x08
  743. #define ACPI_BITPOSITION_SLEEP_BUTTON_STATUS 0x09
  744. #define ACPI_BITPOSITION_RT_CLOCK_STATUS 0x0A
  745. #define ACPI_BITPOSITION_PCIEXP_WAKE_STATUS 0x0E /* ACPI 3.0 */
  746. #define ACPI_BITPOSITION_WAKE_STATUS 0x0F
  747. #define ACPI_BITPOSITION_TIMER_ENABLE 0x00
  748. #define ACPI_BITPOSITION_GLOBAL_LOCK_ENABLE 0x05
  749. #define ACPI_BITPOSITION_POWER_BUTTON_ENABLE 0x08
  750. #define ACPI_BITPOSITION_SLEEP_BUTTON_ENABLE 0x09
  751. #define ACPI_BITPOSITION_RT_CLOCK_ENABLE 0x0A
  752. #define ACPI_BITPOSITION_PCIEXP_WAKE_DISABLE 0x0E /* ACPI 3.0 */
  753. #define ACPI_BITPOSITION_SCI_ENABLE 0x00
  754. #define ACPI_BITPOSITION_BUS_MASTER_RLD 0x01
  755. #define ACPI_BITPOSITION_GLOBAL_LOCK_RELEASE 0x02
  756. #define ACPI_BITPOSITION_SLEEP_TYPE 0x0A
  757. #define ACPI_BITPOSITION_SLEEP_ENABLE 0x0D
  758. #define ACPI_BITPOSITION_ARB_DISABLE 0x00
  759. /* Structs and definitions for _OSI support and I/O port validation */
  760. #define ACPI_OSI_WIN_2000 0x01
  761. #define ACPI_OSI_WIN_XP 0x02
  762. #define ACPI_OSI_WIN_XP_SP1 0x03
  763. #define ACPI_OSI_WINSRV_2003 0x04
  764. #define ACPI_OSI_WIN_XP_SP2 0x05
  765. #define ACPI_OSI_WINSRV_2003_SP1 0x06
  766. #define ACPI_OSI_WIN_VISTA 0x07
  767. #define ACPI_OSI_WINSRV_2008 0x08
  768. #define ACPI_OSI_WIN_VISTA_SP1 0x09
  769. #define ACPI_OSI_WIN_VISTA_SP2 0x0A
  770. #define ACPI_OSI_WIN_7 0x0B
  771. #define ACPI_ALWAYS_ILLEGAL 0x00
  772. struct acpi_interface_info {
  773. char *name;
  774. struct acpi_interface_info *next;
  775. u8 flags;
  776. u8 value;
  777. };
  778. #define ACPI_OSI_INVALID 0x01
  779. #define ACPI_OSI_DYNAMIC 0x02
  780. struct acpi_port_info {
  781. char *name;
  782. u16 start;
  783. u16 end;
  784. u8 osi_dependency;
  785. };
  786. /*****************************************************************************
  787. *
  788. * Resource descriptors
  789. *
  790. ****************************************************************************/
  791. /* resource_type values */
  792. #define ACPI_ADDRESS_TYPE_MEMORY_RANGE 0
  793. #define ACPI_ADDRESS_TYPE_IO_RANGE 1
  794. #define ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE 2
  795. /* Resource descriptor types and masks */
  796. #define ACPI_RESOURCE_NAME_LARGE 0x80
  797. #define ACPI_RESOURCE_NAME_SMALL 0x00
  798. #define ACPI_RESOURCE_NAME_SMALL_MASK 0x78 /* Bits 6:3 contain the type */
  799. #define ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK 0x07 /* Bits 2:0 contain the length */
  800. #define ACPI_RESOURCE_NAME_LARGE_MASK 0x7F /* Bits 6:0 contain the type */
  801. /*
  802. * Small resource descriptor "names" as defined by the ACPI specification.
  803. * Note: Bits 2:0 are used for the descriptor length
  804. */
  805. #define ACPI_RESOURCE_NAME_IRQ 0x20
  806. #define ACPI_RESOURCE_NAME_DMA 0x28
  807. #define ACPI_RESOURCE_NAME_START_DEPENDENT 0x30
  808. #define ACPI_RESOURCE_NAME_END_DEPENDENT 0x38
  809. #define ACPI_RESOURCE_NAME_IO 0x40
  810. #define ACPI_RESOURCE_NAME_FIXED_IO 0x48
  811. #define ACPI_RESOURCE_NAME_RESERVED_S1 0x50
  812. #define ACPI_RESOURCE_NAME_RESERVED_S2 0x58
  813. #define ACPI_RESOURCE_NAME_RESERVED_S3 0x60
  814. #define ACPI_RESOURCE_NAME_RESERVED_S4 0x68
  815. #define ACPI_RESOURCE_NAME_VENDOR_SMALL 0x70
  816. #define ACPI_RESOURCE_NAME_END_TAG 0x78
  817. /*
  818. * Large resource descriptor "names" as defined by the ACPI specification.
  819. * Note: includes the Large Descriptor bit in bit[7]
  820. */
  821. #define ACPI_RESOURCE_NAME_MEMORY24 0x81
  822. #define ACPI_RESOURCE_NAME_GENERIC_REGISTER 0x82
  823. #define ACPI_RESOURCE_NAME_RESERVED_L1 0x83
  824. #define ACPI_RESOURCE_NAME_VENDOR_LARGE 0x84
  825. #define ACPI_RESOURCE_NAME_MEMORY32 0x85
  826. #define ACPI_RESOURCE_NAME_FIXED_MEMORY32 0x86
  827. #define ACPI_RESOURCE_NAME_ADDRESS32 0x87
  828. #define ACPI_RESOURCE_NAME_ADDRESS16 0x88
  829. #define ACPI_RESOURCE_NAME_EXTENDED_IRQ 0x89
  830. #define ACPI_RESOURCE_NAME_ADDRESS64 0x8A
  831. #define ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64 0x8B
  832. #define ACPI_RESOURCE_NAME_LARGE_MAX 0x8B
  833. /*****************************************************************************
  834. *
  835. * Miscellaneous
  836. *
  837. ****************************************************************************/
  838. #define ACPI_ASCII_ZERO 0x30
  839. /*****************************************************************************
  840. *
  841. * Debugger
  842. *
  843. ****************************************************************************/
  844. struct acpi_db_method_info {
  845. acpi_handle main_thread_gate;
  846. acpi_handle thread_complete_gate;
  847. acpi_thread_id *threads;
  848. u32 num_threads;
  849. u32 num_created;
  850. u32 num_completed;
  851. char *name;
  852. u32 flags;
  853. u32 num_loops;
  854. char pathname[128];
  855. char **args;
  856. /*
  857. * Arguments to be passed to method for the command
  858. * Threads -
  859. * the Number of threads, ID of current thread and
  860. * Index of current thread inside all them created.
  861. */
  862. char init_args;
  863. char *arguments[4];
  864. char num_threads_str[11];
  865. char id_of_thread_str[11];
  866. char index_of_thread_str[11];
  867. };
  868. struct acpi_integrity_info {
  869. u32 nodes;
  870. u32 objects;
  871. };
  872. #define ACPI_DB_REDIRECTABLE_OUTPUT 0x01
  873. #define ACPI_DB_CONSOLE_OUTPUT 0x02
  874. #define ACPI_DB_DUPLICATE_OUTPUT 0x03
  875. /*****************************************************************************
  876. *
  877. * Debug
  878. *
  879. ****************************************************************************/
  880. /* Entry for a memory allocation (debug only) */
  881. #define ACPI_MEM_MALLOC 0
  882. #define ACPI_MEM_CALLOC 1
  883. #define ACPI_MAX_MODULE_NAME 16
  884. #define ACPI_COMMON_DEBUG_MEM_HEADER \
  885. struct acpi_debug_mem_block *previous; \
  886. struct acpi_debug_mem_block *next; \
  887. u32 size; \
  888. u32 component; \
  889. u32 line; \
  890. char module[ACPI_MAX_MODULE_NAME]; \
  891. u8 alloc_type;
  892. struct acpi_debug_mem_header {
  893. ACPI_COMMON_DEBUG_MEM_HEADER};
  894. struct acpi_debug_mem_block {
  895. ACPI_COMMON_DEBUG_MEM_HEADER u64 user_space;
  896. };
  897. #define ACPI_MEM_LIST_GLOBAL 0
  898. #define ACPI_MEM_LIST_NSNODE 1
  899. #define ACPI_MEM_LIST_MAX 1
  900. #define ACPI_NUM_MEM_LISTS 2
  901. #endif /* __ACLOCAL_H__ */