aclocal.h 35 KB

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