acpiobj.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080
  1. /*++
  2. Copyright (c) 2012 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. acpiobj.h
  9. Abstract:
  10. This header contains definitions for ACPI objects used in the ACPI namespace
  11. and AML intepreter.
  12. Author:
  13. Evan Green 13-Nov-2012
  14. --*/
  15. //
  16. // ------------------------------------------------------------------- Includes
  17. //
  18. #include "oprgnos.h"
  19. #include <minoca/kernel/acpi.h>
  20. //
  21. // --------------------------------------------------------------------- Macros
  22. //
  23. //
  24. // ---------------------------------------------------------------- Definitions
  25. //
  26. //
  27. // Define the revision of the AML interpreter. This define is visible to
  28. // executing AML code via the Revision opcode.
  29. //
  30. #define AML_REVISION 4
  31. //
  32. // Define the maximum number of arguments any ACPI statement can have.
  33. //
  34. #define MAX_AML_STATEMENT_ARGUMENT_COUNT 6
  35. #define MAX_AML_METHOD_ARGUMENT_COUNT 7
  36. #define MAX_AML_LOCAL_COUNT 8
  37. //
  38. // Define an invalid AML local index constant.
  39. //
  40. #define AML_INVALID_LOCAL_INDEX (ULONG)-1
  41. //
  42. // ------------------------------------------------------ Data Type Definitions
  43. //
  44. typedef enum _ACPI_OBJECT_TYPE {
  45. AcpiObjectUninitialized = 0,
  46. AcpiObjectInteger = 1,
  47. AcpiObjectString = 2,
  48. AcpiObjectBuffer = 3,
  49. AcpiObjectPackage = 4,
  50. AcpiObjectFieldUnit = 5,
  51. AcpiObjectDevice = 6,
  52. AcpiObjectEvent = 7,
  53. AcpiObjectMethod = 8,
  54. AcpiObjectMutex = 9,
  55. AcpiObjectOperationRegion = 10,
  56. AcpiObjectPowerResource = 11,
  57. AcpiObjectProcessor = 12,
  58. AcpiObjectThermalZone = 13,
  59. AcpiObjectBufferField = 14,
  60. AcpiObjectDdbHandle = 15,
  61. AcpiObjectDebug = 16,
  62. AcpiObjectAlias = 0x100,
  63. AcpiObjectUnresolvedName = 0x101,
  64. AcpiObjectTypeCount
  65. } ACPI_OBJECT_TYPE, *PACPI_OBJECT_TYPE;
  66. typedef enum _ACPI_FIELD_ACCESS {
  67. AcpiFieldAccessAny = 0,
  68. AcpiFieldAccessByte = 1,
  69. AcpiFieldAccessWord = 2,
  70. AcpiFieldAccessDoubleWord = 3,
  71. AcpiFieldAccessQuadWord = 4,
  72. AcpiFieldAccessBuffer = 5
  73. } ACPI_FIELD_ACCESS, *PACPI_FIELD_ACCESS;
  74. typedef enum _ACPI_FIELD_UPDATE_RULE {
  75. AcpiFieldUpdatePreserve = 0,
  76. AcpiFieldUpdateWriteAsOnes = 1,
  77. AcpiFieldUpdateWriteAsZeros = 2,
  78. AcpiFieldUpdateRuleCount
  79. } ACPI_FIELD_UPDATE_RULE, *PACPI_FIELD_UPDATE_RULE;
  80. typedef enum _AML_STATEMENT_TYPE {
  81. AmlStatementInvalid,
  82. AmlStatementAcquire,
  83. AmlStatementAdd,
  84. AmlStatementAlias,
  85. AmlStatementAnd,
  86. AmlStatementArgument,
  87. AmlStatementBankField,
  88. AmlStatementBreak,
  89. AmlStatementBreakPoint,
  90. AmlStatementBuffer,
  91. AmlStatementConcatenate,
  92. AmlStatementConcatenateResourceTemplates,
  93. AmlStatementConditionalReferenceOf,
  94. AmlStatementContinue,
  95. AmlStatementCopyObject,
  96. AmlStatementCreateBufferField,
  97. AmlStatementCreateBufferFieldFixed,
  98. AmlStatementData,
  99. AmlStatementDataTableRegion,
  100. AmlStatementDebug,
  101. AmlStatementDecrement,
  102. AmlStatementDereferenceOf,
  103. AmlStatementDevice,
  104. AmlStatementDivide,
  105. AmlStatementElse,
  106. AmlStatementEvent,
  107. AmlStatementExecutingMethod,
  108. AmlStatementFatal,
  109. AmlStatementField,
  110. AmlStatementFindSetLeftBit,
  111. AmlStatementFindSetRightBit,
  112. AmlStatementFromBcd,
  113. AmlStatementIf,
  114. AmlStatementIncrement,
  115. AmlStatementIndex,
  116. AmlStatementIndexField,
  117. AmlStatementLoad,
  118. AmlStatementLoadTable,
  119. AmlStatementLocal,
  120. AmlStatementLogicalAnd,
  121. AmlStatementLogicalEqual,
  122. AmlStatementLogicalGreater,
  123. AmlStatementLogicalLess,
  124. AmlStatementLogicalNot,
  125. AmlStatementLogicalOr,
  126. AmlStatementMatch,
  127. AmlStatementMethod,
  128. AmlStatementMid,
  129. AmlStatementMod,
  130. AmlStatementMultiply,
  131. AmlStatementMutex,
  132. AmlStatementName,
  133. AmlStatementNameString,
  134. AmlStatementNand,
  135. AmlStatementNoOp,
  136. AmlStatementNor,
  137. AmlStatementNot,
  138. AmlStatementNotify,
  139. AmlStatementObjectType,
  140. AmlStatementOne,
  141. AmlStatementOnes,
  142. AmlStatementOperationRegion,
  143. AmlStatementOr,
  144. AmlStatementPackage,
  145. AmlStatementPowerResource,
  146. AmlStatementProcessor,
  147. AmlStatementReferenceOf,
  148. AmlStatementRelease,
  149. AmlStatementReset,
  150. AmlStatementReturn,
  151. AmlStatementRevision,
  152. AmlStatementScope,
  153. AmlStatementShiftLeft,
  154. AmlStatementShiftRight,
  155. AmlStatementSignal,
  156. AmlStatementSizeOf,
  157. AmlStatementSleep,
  158. AmlStatementStall,
  159. AmlStatementStore,
  160. AmlStatementSubtract,
  161. AmlStatementThermalZone,
  162. AmlStatementTimer,
  163. AmlStatementToBcd,
  164. AmlStatementToBuffer,
  165. AmlStatementToDecimalString,
  166. AmlStatementToHexString,
  167. AmlStatementToInteger,
  168. AmlStatementToString,
  169. AmlStatementUnload,
  170. AmlStatementVariablePackage,
  171. AmlStatementWait,
  172. AmlStatementWhile,
  173. AmlStatementXor,
  174. AmlStatementZero,
  175. AmlStatementCount
  176. } AML_STATEMENT_TYPE, *PAML_STATEMENT_TYPE;
  177. /*++
  178. Structure Description:
  179. This structure stores information about an ACPI namespace integer.
  180. Members:
  181. Value - Stores the integer value.
  182. --*/
  183. typedef struct _ACPI_INTEGER_OBJECT {
  184. ULONGLONG Value;
  185. } ACPI_INTEGER_OBJECT, *PACPI_INTEGER_OBJECT;
  186. /*++
  187. Structure Description:
  188. This structure stores information about an ACPI namespace string.
  189. Members:
  190. String - Stores a pointer to the null-terminated string buffer.
  191. --*/
  192. typedef struct _ACPI_STRING_OBJECT {
  193. PSTR String;
  194. } ACPI_STRING_OBJECT, *PACPI_STRING_OBJECT;
  195. /*++
  196. Structure Description:
  197. This structure stores information about an ACPI namespace buffer.
  198. Members:
  199. Buffer - Stores a pointer to the buffer.
  200. Length - Stores the length of the buffer, in bytes.
  201. --*/
  202. typedef struct _ACPI_BUFFER_OBJECT {
  203. PVOID Buffer;
  204. ULONG Length;
  205. } ACPI_BUFFER_OBJECT, *PACPI_BUFFER_OBJECT;
  206. /*++
  207. Structure Description:
  208. This structure stores information about an ACPI namespace package.
  209. Members:
  210. Array - Stores a pointer to an array of ACPI Object pointers.
  211. ElementCount - Stores the number of elements that can be stored in the
  212. array.
  213. --*/
  214. typedef struct _ACPI_PACKAGE_OBJECT {
  215. PVOID *Array;
  216. ULONG ElementCount;
  217. } ACPI_PACKAGE_OBJECT, *PACPI_PACKAGE_OBJECT;
  218. /*++
  219. Structure Description:
  220. This structure stores information about an ACPI Field Unit object.
  221. Members:
  222. OperationRegion - Stores a pointer to the operation region this field
  223. references.
  224. Access - Stores the access width to use when reading from or writing to
  225. the Operation Region.
  226. AcquireGlobalLock - Stores a boolean indicating whether the global ACPI
  227. lock should be acquired when accessing this field.
  228. UpdateRule - Stores the rule for unreferenced bits when the field is
  229. smaller than the access width.
  230. BitOffset - Stores the offset from the beginning of the Operation Region,
  231. in bits.
  232. BitLength - Stores the length of the field, in bits.
  233. BankRegister - Stores an optional pointer to the bank register to write
  234. to before accessing this field.
  235. BankValue - Stores a pointer to the value to write into the bank register.
  236. IndexRegister - Stores an optional pointer to the Index register to write
  237. to if Index/Data style access is used.
  238. DataRegister - Stores a pointer to the Data register to use for accessing
  239. the field if Index/Data style access is used.
  240. --*/
  241. typedef struct _ACPI_FIELD_UNIT_OBJECT {
  242. PVOID OperationRegion;
  243. ACPI_FIELD_ACCESS Access;
  244. BOOL AcquireGlobalLock;
  245. ACPI_FIELD_UPDATE_RULE UpdateRule;
  246. ULONGLONG BitOffset;
  247. ULONGLONG BitLength;
  248. PVOID BankRegister;
  249. PVOID BankValue;
  250. PVOID IndexRegister;
  251. PVOID DataRegister;
  252. } ACPI_FIELD_UNIT_OBJECT, *PACPI_FIELD_UNIT_OBJECT;
  253. /*++
  254. Structure Description:
  255. This structure stores information about an ACPI namespace Device object.
  256. Members:
  257. OsDevice - Stores a pointer to the operating system event object.
  258. DeviceContext - Stores a pointer to the ACPI device context associated
  259. with this device.
  260. IsPciBus - Stores a pointer indicating if this device is a PCI bus or not.
  261. PCI busses are special in that they have an interaction with certain
  262. ACPI Operation Regions, namely PCI config and BAR target operation
  263. regions.
  264. IsDeviceStarted - Stores a boolean indicating whether or not the device is
  265. started or not.
  266. --*/
  267. typedef struct _ACPI_DEVICE_OBJECT {
  268. PVOID OsDevice;
  269. PVOID DeviceContext;
  270. BOOL IsPciBus;
  271. BOOL IsDeviceStarted;
  272. } ACPI_DEVICE_OBJECT, *PACPI_DEVICE_OBJECT;
  273. /*++
  274. Structure Description:
  275. This structure stores information about an ACPI namespace Event object.
  276. Members:
  277. OsEvent - Stores a pointer to the operating system event object.
  278. --*/
  279. typedef struct _ACPI_EVENT_OBJECT {
  280. PVOID OsEvent;
  281. } ACPI_EVENT_OBJECT, *PACPI_EVENT_OBJECT;
  282. /*++
  283. Structure Description:
  284. This structure stores information about an ACPI namespace Method object.
  285. Members:
  286. ArgumentCount - Stores the number of arguments this method takes.
  287. Serialized - Stores a boolean indicating whether concurrent execution of
  288. this routine is allowed or not.
  289. SyncLevel - Stores the sync level of this routine.
  290. OsMutex - Stores a pointer to the OS mutex guarding serial access of the
  291. routine.
  292. AmlCode - Stores a pointer to the code that implements this method.
  293. AmlCodeSize - Stores the length of the AML code, in bytes.
  294. IntegerWidthIs32 - Stores a boolean indicating whether the definition block
  295. defining this method only supports 32 bit integers (a table revision of
  296. 1).
  297. --*/
  298. typedef struct _ACPI_METHOD_OBJECT {
  299. ULONG ArgumentCount;
  300. BOOL Serialized;
  301. UCHAR SyncLevel;
  302. PVOID OsMutex;
  303. PVOID AmlCode;
  304. ULONG AmlCodeSize;
  305. BOOL IntegerWidthIs32;
  306. } ACPI_METHOD_OBJECT, *PACPI_METHOD_OBJECT;
  307. /*++
  308. Structure Description:
  309. This structure stores information about an ACPI namespace Mutex object.
  310. Members:
  311. OsMutex - Stores a pointer to the operating system mutex object.
  312. --*/
  313. typedef struct _ACPI_MUTEX_OBJECT {
  314. PVOID OsMutex;
  315. } ACPI_MUTEX_OBJECT, *PACPI_MUTEX_OBJECT;
  316. /*++
  317. Structure Description:
  318. This structure stores information about an ACPI Operation Region Object.
  319. Members:
  320. Space - Stores a pointer to the Operation Region address space type.
  321. OsContext - Stores a pointer to the operating system context pointer
  322. for the given Operation Region.
  323. Offset - Stores the byte offset into the address space where this
  324. operation region begins.
  325. Length - Stores the length of the operation region, in bytes.
  326. FunctionTable - Stores a pointer to a table of function pointers used to
  327. access and destroy the operation region.
  328. OsMutex - Stores a pointer to the mutex guarding this Operation Region.
  329. --*/
  330. typedef struct _ACPI_OPERATION_REGION_OBJECT {
  331. ACPI_OPERATION_REGION_SPACE Space;
  332. PVOID OsContext;
  333. ULONGLONG Offset;
  334. ULONGLONG Length;
  335. PACPI_OPERATION_REGION_FUNCTION_TABLE FunctionTable;
  336. PVOID OsMutex;
  337. } ACPI_OPERATION_REGION_OBJECT, *PACPI_OPERATION_REGION_OBJECT;
  338. /*++
  339. Structure Description:
  340. This structure stores information about an ACPI Power Resource object.
  341. Members:
  342. SystemLevel - Stores the lower power system sleep level the OSPM must
  343. maintain to keep this power resource on (0 is S0, 1 is S1, etc).
  344. ResourceOrder - Stores a unique value per power resource specifying the
  345. order in which power resources must be enabled or disabled (enabling
  346. goes low to high, disabling goes high to low).
  347. --*/
  348. typedef struct _ACPI_POWER_RESOURCE_OBJECT {
  349. UCHAR SystemLevel;
  350. USHORT ResourceOrder;
  351. } ACPI_POWER_RESOURCE_OBJECT, *PACPI_POWER_RESOURCE_OBJECT;
  352. /*++
  353. Structure Description:
  354. This structure stores information about an ACPI Processor object.
  355. Members:
  356. Device - Stores the device information, since processors are treated like
  357. devices.
  358. ProcessorBlockAddress - Stores the address of the processor block registers
  359. for this processor.
  360. ProcessorId - Stores the ACPI processor identifier for this processor.
  361. ProcessorBlockLength - Stores the length of the processor block register
  362. space. 0 implies that the there are no processor block registers.
  363. --*/
  364. typedef struct _ACPI_PROCESSOR_OBJECT {
  365. ACPI_DEVICE_OBJECT Device;
  366. ULONG ProcessorBlockAddress;
  367. UCHAR ProcessorId;
  368. UCHAR ProcessorBlockLength;
  369. } ACPI_PROCESSOR_OBJECT, *PACPI_PROCESSOR_OBJECT;
  370. /*++
  371. Structure Description:
  372. This structure stores information about an ACPI namespace alias.
  373. Members:
  374. DestinationObject - Stores a pointer to the ACPI object that owns the
  375. buffer.
  376. BitOffset - Stores the offset, in bits, from the beginning of the buffer
  377. to this field.
  378. BitLength - Stores the length of the field, in bits.
  379. --*/
  380. typedef struct _ACPI_BUFFER_FIELD_OBJECT {
  381. PVOID DestinationObject;
  382. ULONGLONG BitOffset;
  383. ULONGLONG BitLength;
  384. } ACPI_BUFFER_FIELD_OBJECT, *PACPI_BUFFER_FIELD_OBJECT;
  385. /*++
  386. Structure Description:
  387. This structure stores information about an ACPI namespace alias.
  388. Members:
  389. DestinationObject - Stores a pointer to the ACPI object that this alias
  390. points to.
  391. --*/
  392. typedef struct _ACPI_ALIAS_OBJECT {
  393. PVOID DestinationObject;
  394. } ACPI_ALIAS_OBJECT, *PACPI_ALIAS_OBJECT;
  395. /*++
  396. Structure Description:
  397. This structure stores information about an "unresolved name" placeholder
  398. object. These objects can live in various places where a name can be
  399. referenced before it is defined. When someone actually goes to use the
  400. object, the name is then resolved to the real object.
  401. Members:
  402. Name - Stores a pointer to a string containing the name of the object.
  403. Scope - Stores a pointer to an ACPI namespace object representing the
  404. current scope at the time the object was referenced.
  405. --*/
  406. typedef struct _ACPI_UNRESOLVED_NAME_OBJECT {
  407. PSTR Name;
  408. PVOID Scope;
  409. } ACPI_UNRESOLVED_NAME_OBJECT, *PACPI_UNRESOLVED_NAME_OBJECT;
  410. /*++
  411. Structure Description:
  412. This structure stores information about an ACPI namespace object.
  413. Members:
  414. Type - Stores the type of ACPI object this structure represents.
  415. Name - Stores the name of the ACPI object.
  416. ReferenceCount - Stores the number of parties that have references to this
  417. object. When the number reaches zero, the object is destroyed.
  418. Parent - Stores a pointer to the parent namespace object. This may be NULL
  419. if the object is not linked into the namespace.
  420. SiblingListEntry - Stores pointers to the next and previous objects in the
  421. parent's child list.
  422. ChildListHead - Stores pointers to the first and last children of this
  423. object.
  424. DestructorListEntry - Stores a list structure used to avoid recursion during
  425. namespace object destruction. Also used during object lifetime to
  426. store a list of all objects created during a given method execution.
  427. U - Stores type-specific information about the given object.
  428. --*/
  429. typedef struct _ACPI_OBJECT ACPI_OBJECT, *PACPI_OBJECT;
  430. struct _ACPI_OBJECT {
  431. ACPI_OBJECT_TYPE Type;
  432. ULONG Name;
  433. ULONG ReferenceCount;
  434. PACPI_OBJECT Parent;
  435. LIST_ENTRY SiblingListEntry;
  436. LIST_ENTRY ChildListHead;
  437. LIST_ENTRY DestructorListEntry;
  438. union {
  439. ACPI_INTEGER_OBJECT Integer;
  440. ACPI_STRING_OBJECT String;
  441. ACPI_BUFFER_OBJECT Buffer;
  442. ACPI_PACKAGE_OBJECT Package;
  443. ACPI_FIELD_UNIT_OBJECT FieldUnit;
  444. ACPI_DEVICE_OBJECT Device;
  445. ACPI_EVENT_OBJECT Event;
  446. ACPI_METHOD_OBJECT Method;
  447. ACPI_MUTEX_OBJECT Mutex;
  448. ACPI_OPERATION_REGION_OBJECT OperationRegion;
  449. ACPI_POWER_RESOURCE_OBJECT PowerResource;
  450. ACPI_PROCESSOR_OBJECT Processor;
  451. ACPI_BUFFER_FIELD_OBJECT BufferField;
  452. ACPI_ALIAS_OBJECT Alias;
  453. ACPI_UNRESOLVED_NAME_OBJECT UnresolvedName;
  454. } U;
  455. };
  456. /*++
  457. Structure Description:
  458. This structure stores information about an ACPI AML statement.
  459. Members:
  460. ListEntry - Stores pointers to the next and previous AML statements on the
  461. currently executing statement stack.
  462. Type - Stores the general flavor of this AML statement.
  463. AdditionalData - Stores statement-specific additional data related to the
  464. operation.
  465. AdditionalData2 - Stores more statement-specific information.
  466. ArgumentsNeeded - Stores the number of arguments this statement needs.
  467. ArgumentsAcquired - Stores the number of arguments that this statement
  468. has in-hand. Once all arguments are acquired, the statement can be
  469. completely evaluated.
  470. Argument - Stores an array of pointers to the various ACPI objects needed
  471. to evaluate this statement.
  472. Reduction - Stores a pointer to the ACPI object that this statement reduced
  473. to.
  474. SavedScope - Stores a pointer to the original scope before this statement
  475. started executing for statements that change the scope.
  476. --*/
  477. typedef struct _AML_STATEMENT {
  478. LIST_ENTRY ListEntry;
  479. AML_STATEMENT_TYPE Type;
  480. ULONGLONG AdditionalData;
  481. ULONGLONG AdditionalData2;
  482. ULONG ArgumentsNeeded;
  483. ULONG ArgumentsAcquired;
  484. PACPI_OBJECT Argument[MAX_AML_STATEMENT_ARGUMENT_COUNT];
  485. PACPI_OBJECT Reduction;
  486. PACPI_OBJECT SavedScope;
  487. } AML_STATEMENT, *PAML_STATEMENT;
  488. /*++
  489. Structure Description:
  490. This structure stores information about an executing ACPI method.
  491. Members:
  492. CallingMethodContext - Stores a pointer to the caller's method context
  493. (points to an object of this type).
  494. MethodMutex - Stores an optional pointer to the mutex associated with this
  495. synchronized method.
  496. IntegerWidthIs32 - Stores a boolean indicating whether the bit width of
  497. an AML integer is 32 (TRUE) or 64 (FALSE).
  498. CreatedObjectsListHead - Stores the head of the list of objects created
  499. while this method is executing. When the method returns, the list of
  500. objects will be destroyed.
  501. SavedAmlCode - Stores a pointer to the AML code pointer immediately
  502. before this method was called.
  503. SavedAmlCodeSize - Stores the old AML code size immediately before this
  504. method was called.
  505. SavedCurrentOffset - Stores the offset into the old AML code immediately
  506. after this function call. Think of it like the return instruction
  507. pointer.
  508. SavedIndentationLevel - Stores the indentation level immediately before
  509. this method was executed.
  510. LastLocalIndex - Stores an index into the local variable array of the last
  511. local statement evaluated.
  512. SavedCurrentScope - Stores the current scope immeidately before this
  513. function was called.
  514. LocalVariable - Supplies an array of objects that represent local variables
  515. to the functions.
  516. Argument - Stores an array of pointers to the method arguments, if supplied.
  517. --*/
  518. typedef struct _AML_METHOD_EXECUTION_CONTEXT {
  519. PVOID CallingMethodContext;
  520. PVOID MethodMutex;
  521. BOOL IntegerWidthIs32;
  522. LIST_ENTRY CreatedObjectsListHead;
  523. PVOID SavedAmlCode;
  524. ULONG SavedAmlCodeSize;
  525. ULONG SavedCurrentOffset;
  526. ULONG SavedIndentationLevel;
  527. ULONG LastLocalIndex;
  528. PACPI_OBJECT SavedCurrentScope;
  529. PACPI_OBJECT LocalVariable[MAX_AML_LOCAL_COUNT];
  530. PACPI_OBJECT Argument[MAX_AML_METHOD_ARGUMENT_COUNT];
  531. } AML_METHOD_EXECUTION_CONTEXT, *PAML_METHOD_EXECUTION_CONTEXT;
  532. /*++
  533. Structure Description:
  534. This structure stores information about the state of the AML interpreter
  535. during execution.
  536. Members:
  537. ExecuteStatements - Stores a boolean indicating whether or not to actually
  538. execute the statements processed. If this is set to FALSE, then the
  539. AML statements will be interpreted (and printed if that option is set),
  540. but no changes will be made to the namespace or anything else.
  541. PrintStatements - Stores a boolean determining whether statements should be
  542. printed out. If execution is also enabled, then only executed statements
  543. will be printed. If execution is not enabled, then all statements will
  544. be printed (ie both outcomes of a branch are entered).
  545. EscapingDynamicScope - Stores a boolean indicating whether objects created
  546. at this time will fall under the dynamic scope and therefore be deleted
  547. when the method completes or the block unloads (FALSE), or whether
  548. a scope operator has escaped the context from the original dynamic
  549. scope.
  550. AmlCode - Stores a pointer to the AML code buffer to be executed.
  551. AmlCodeSize - Stores the size of the AML code buffer, in bytes.
  552. CurrentOffset - Stores the current execution offset, in bytes.
  553. IndentationLevel - Stores the current indentation level, used when printing
  554. out instructions.
  555. SyncLevel - Stores the sync level of the current execution context, the
  556. highest numbered mutex it has acquired.
  557. CurrentScope - Stores a pointer to the current scope.
  558. StatementStackHead - Stores the list head of the in-flight statement stack.
  559. Values are pushed on the stack by inserting them immediately after the
  560. head, and are popped off the stack by looking at Head->Next.
  561. PreviousStatement - Stores a pointer to the previous statement that was
  562. evaluated, as the items on the statement stack are waiting for future
  563. statements to evaluate.
  564. CurrentMethod - Stores a pointer to the executing method's execution
  565. context.
  566. ReturnValue - Stores a pointer to the return value object if a method is
  567. executing.
  568. LastIfStatementResult - Stores the result of the last If statement to
  569. finish executing. This parameter is used for evaluating an Else
  570. statment.
  571. DestructorListHead - Stores a pointer to the head of a list where created
  572. namespace objects will have their destructor list entries placed. This
  573. is used for unloading definition blocks.
  574. --*/
  575. typedef struct _AML_EXECUTION_CONTEXT {
  576. BOOL ExecuteStatements;
  577. BOOL PrintStatements;
  578. BOOL EscapingDynamicScope;
  579. PVOID AmlCode;
  580. ULONG AmlCodeSize;
  581. ULONG CurrentOffset;
  582. ULONG IndentationLevel;
  583. ULONG SyncLevel;
  584. PACPI_OBJECT CurrentScope;
  585. LIST_ENTRY StatementStackHead;
  586. PAML_STATEMENT PreviousStatement;
  587. PAML_METHOD_EXECUTION_CONTEXT CurrentMethod;
  588. PACPI_OBJECT ReturnValue;
  589. BOOL LastIfStatementResult;
  590. PLIST_ENTRY DestructorListHead;
  591. } AML_EXECUTION_CONTEXT, *PAML_EXECUTION_CONTEXT;
  592. //
  593. // -------------------------------------------------------------------- Globals
  594. //
  595. //
  596. // -------------------------------------------------------- Function Prototypes
  597. //
  598. KSTATUS
  599. AcpiLoadDefinitionBlock (
  600. PDESCRIPTION_HEADER Table,
  601. PACPI_OBJECT Handle
  602. );
  603. /*++
  604. Routine Description:
  605. This routine loads an ACPI definition block, which contains a standard
  606. table description header followed by a block of AML. The AML will be loaded
  607. into the namespace.
  608. Arguments:
  609. Table - Supplies a pointer to the table containing the definition block.
  610. This table should probably only be the DSDT or an SSDT.
  611. Handle - Supplies an optional pointer to the handle associated with this
  612. definition block.
  613. Return Value:
  614. Status code.
  615. --*/
  616. VOID
  617. AcpiUnloadDefinitionBlock (
  618. PACPI_OBJECT Handle
  619. );
  620. /*++
  621. Routine Description:
  622. This routine unloads all ACPI definition blocks loaded under the given
  623. handle.
  624. Arguments:
  625. Handle - Supplies the handle to unload blocks based on. If NULL is
  626. supplied, then all blocks will be unloaded.
  627. Return Value:
  628. None.
  629. --*/
  630. KSTATUS
  631. AcpiExecuteMethod (
  632. PACPI_OBJECT MethodObject,
  633. PACPI_OBJECT *Arguments,
  634. ULONG ArgumentCount,
  635. ACPI_OBJECT_TYPE ReturnType,
  636. PACPI_OBJECT *ReturnValue
  637. );
  638. /*++
  639. Routine Description:
  640. This routine executes an ACPI method.
  641. Arguments:
  642. MethodObject - Supplies a pointer to the method object. If this object
  643. is not of type method, then the return value will be set
  644. directly to this object (and the reference count incremented).
  645. Arguments - Supplies a pointer to an array of arguments to pass to the
  646. method. This parameter is optional if the method takes no parameters.
  647. ArgumentCount - Supplies the number of arguments in the argument array.
  648. ReturnType - Supplies the desired type to convert the return type argument
  649. to. Set this to AcpiObjectUninitialized to specify that no conversion
  650. of the return type should occur (I'm feeling lucky mode).
  651. ReturnValue - Supplies an optional pointer where a pointer to the return
  652. value object will be returned. The caller must release the reference
  653. on this memory when finished with it.
  654. Return Value:
  655. Status code.
  656. --*/
  657. VOID
  658. AcpipPopExecutingStatements (
  659. PAML_EXECUTION_CONTEXT Context,
  660. BOOL PopToWhile,
  661. BOOL ContinueWhile
  662. );
  663. /*++
  664. Routine Description:
  665. This routine causes the AML execution context to pop back up, either because
  666. the method returned or because while within a while statement a break or
  667. continue was encountered. This routine only pops statements off the stack,
  668. it does not modify the current offset pointer.
  669. Arguments:
  670. Context - Supplies a pointer to the AML execution context.
  671. PopToWhile - Supplies a boolean that indicates whether the entire function
  672. should return (FALSE) or whether to pop to the nearest while statement
  673. (TRUE). For while statements, the caller is still responsible for
  674. modifying the AML offset.
  675. ContinueWhile - Supplies a boolean that indicates whether to re-execute
  676. the while statement (TRUE) or whether to pop it too (FALSE, for a break
  677. statement). If the previous argument is FALSE, this parameter is
  678. ignored.
  679. Return Value:
  680. None.
  681. --*/
  682. VOID
  683. AcpipPrintIndentedNewLine (
  684. PAML_EXECUTION_CONTEXT Context
  685. );
  686. /*++
  687. Routine Description:
  688. This routine prints a newline and then a number of space characters
  689. corresponding to the current indentation level.
  690. Arguments:
  691. Context - Supplies a pointer to the AML execution context.
  692. Return Value:
  693. None.
  694. --*/
  695. KSTATUS
  696. AcpipPushMethodOnExecutionContext (
  697. PAML_EXECUTION_CONTEXT Context,
  698. PACPI_OBJECT Scope,
  699. PVOID MethodMutex,
  700. BOOL IntegerWidthIs32,
  701. PVOID AmlCode,
  702. ULONG AmlCodeSize,
  703. ULONG ArgumentCount,
  704. PACPI_OBJECT *Arguments
  705. );
  706. /*++
  707. Routine Description:
  708. This routine pushes a control method onto the given AML execution context,
  709. causing it to be the next thing to run when the execution context is
  710. evaluated.
  711. Arguments:
  712. Context - Supplies a pointer to the AML execution context to push the
  713. method onto.
  714. Scope - Supplies a pointer to the ACPI object to put as the starting scope.
  715. If NULL is supplied, the namespace root will be used as the default
  716. scope.
  717. MethodMutex - Supplies an optional pointer to the mutex to acquire in
  718. conjunction with executing this serialized method.
  719. IntegerWidthIs32 - Supplies a boolean indicating if integers should be
  720. treated as 32-bit values or 64-bit values.
  721. AmlCode - Supplies a pointer to the first byte of the method.
  722. AmlCodeSize - Supplies the size of the method, in bytes.
  723. ArgumentCount - Supplies the number of arguments to pass to the routine.
  724. Valid values are 0 to 7.
  725. Arguments - Supplies an array of pointers to ACPI objects representing the
  726. method arguments. The number of elements in this array is defined by
  727. the argument count parameter. If that parameter is non-zero, this
  728. parameter is required.
  729. Return Value:
  730. Status code indicating whether the method was successfully pushed onto the
  731. execution context.
  732. --*/
  733. VOID
  734. AcpipPopCurrentMethodContext (
  735. PAML_EXECUTION_CONTEXT Context
  736. );
  737. /*++
  738. Routine Description:
  739. This routine pops the current method execution context off of the AML
  740. execution context, releasing all its associated objects and freeing the
  741. method context itself.
  742. Arguments:
  743. Context - Supplies a pointer to an initialized AML execution context.
  744. Return Value:
  745. None.
  746. --*/
  747. KSTATUS
  748. AcpipRunInitializationMethods (
  749. PACPI_OBJECT RootObject
  750. );
  751. /*++
  752. Routine Description:
  753. This routine runs immediately after a definition block has been loaded. As
  754. defined by the ACPI spec, it runs all applicable _INI methods on devices.
  755. Arguments:
  756. RootObject - Supplies a pointer to the object to start from. If NULL is
  757. supplied, the root system bus object \_SB will be used.
  758. Return Value:
  759. Status code. Failure means something serious went wrong, not just that some
  760. device returned a non-functioning status.
  761. --*/