aclocal.h 33 KB

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