amloptab.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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. amloptab.c
  9. Abstract:
  10. This module implements ACPI opcode and statement tables used for executing
  11. AML code.
  12. Author:
  13. Evan Green 13-Nov-2012
  14. Environment:
  15. Kernel
  16. --*/
  17. //
  18. // ------------------------------------------------------------------- Includes
  19. //
  20. #include <minoca/kernel/driver.h>
  21. #include "acpiobj.h"
  22. #include "amlops.h"
  23. //
  24. // ---------------------------------------------------------------- Definitions
  25. //
  26. //
  27. // Define the two-byte opcode prefix.
  28. //
  29. #define TWO_BYTE_OPCODE_PREFIX 0x5B
  30. //
  31. // ------------------------------------------------------ Data Type Definitions
  32. //
  33. //
  34. // ----------------------------------------------- Internal Function Prototypes
  35. //
  36. KSTATUS
  37. AcpipForwardToTwoByteOpcode (
  38. PAML_EXECUTION_CONTEXT Context,
  39. PAML_STATEMENT NextStatement
  40. );
  41. //
  42. // -------------------------------------------------------------------- Globals
  43. //
  44. //
  45. // Define an array that creates ACPI statements based on the first opcode byte.
  46. //
  47. PAML_CREATE_NEXT_STATEMENT_ROUTINE AcpiCreateStatement[256] = {
  48. AcpipCreateZeroStatement, // 0x00
  49. AcpipCreateOneStatement,
  50. AcpipCreateInvalidOpcodeStatement,
  51. AcpipCreateInvalidOpcodeStatement,
  52. AcpipCreateInvalidOpcodeStatement,
  53. AcpipCreateInvalidOpcodeStatement,
  54. AcpipCreateAliasStatement,
  55. AcpipCreateInvalidOpcodeStatement,
  56. AcpipCreateNameStatement,
  57. AcpipCreateDataStatement,
  58. AcpipCreateDataStatement,
  59. AcpipCreateDataStatement,
  60. AcpipCreateDataStatement,
  61. AcpipCreateDataStatement,
  62. AcpipCreateDataStatement,
  63. AcpipCreateInvalidOpcodeStatement,
  64. AcpipCreateScopeStatement, // 0x10
  65. AcpipCreateBufferStatement,
  66. AcpipCreatePackageStatement,
  67. AcpipCreateVariablePackageStatement,
  68. AcpipCreateMethodStatement,
  69. AcpipCreateInvalidOpcodeStatement,
  70. AcpipCreateInvalidOpcodeStatement,
  71. AcpipCreateInvalidOpcodeStatement,
  72. AcpipCreateInvalidOpcodeStatement,
  73. AcpipCreateInvalidOpcodeStatement,
  74. AcpipCreateInvalidOpcodeStatement,
  75. AcpipCreateInvalidOpcodeStatement,
  76. AcpipCreateInvalidOpcodeStatement,
  77. AcpipCreateInvalidOpcodeStatement,
  78. AcpipCreateInvalidOpcodeStatement,
  79. AcpipCreateInvalidOpcodeStatement,
  80. AcpipCreateInvalidOpcodeStatement, // 0x20
  81. AcpipCreateInvalidOpcodeStatement,
  82. AcpipCreateInvalidOpcodeStatement,
  83. AcpipCreateInvalidOpcodeStatement,
  84. AcpipCreateInvalidOpcodeStatement,
  85. AcpipCreateInvalidOpcodeStatement,
  86. AcpipCreateInvalidOpcodeStatement,
  87. AcpipCreateInvalidOpcodeStatement,
  88. AcpipCreateInvalidOpcodeStatement,
  89. AcpipCreateInvalidOpcodeStatement,
  90. AcpipCreateInvalidOpcodeStatement,
  91. AcpipCreateInvalidOpcodeStatement,
  92. AcpipCreateInvalidOpcodeStatement,
  93. AcpipCreateInvalidOpcodeStatement,
  94. AcpipCreateNameStringStatement,
  95. AcpipCreateNameStringStatement,
  96. AcpipCreateInvalidOpcodeStatement, // 0x30
  97. AcpipCreateInvalidOpcodeStatement,
  98. AcpipCreateInvalidOpcodeStatement,
  99. AcpipCreateInvalidOpcodeStatement,
  100. AcpipCreateInvalidOpcodeStatement,
  101. AcpipCreateInvalidOpcodeStatement,
  102. AcpipCreateInvalidOpcodeStatement,
  103. AcpipCreateInvalidOpcodeStatement,
  104. AcpipCreateInvalidOpcodeStatement,
  105. AcpipCreateInvalidOpcodeStatement,
  106. AcpipCreateInvalidOpcodeStatement,
  107. AcpipCreateInvalidOpcodeStatement,
  108. AcpipCreateInvalidOpcodeStatement,
  109. AcpipCreateInvalidOpcodeStatement,
  110. AcpipCreateInvalidOpcodeStatement,
  111. AcpipCreateInvalidOpcodeStatement,
  112. AcpipCreateInvalidOpcodeStatement, // 0x40
  113. AcpipCreateNameStringStatement,
  114. AcpipCreateNameStringStatement,
  115. AcpipCreateNameStringStatement,
  116. AcpipCreateNameStringStatement,
  117. AcpipCreateNameStringStatement,
  118. AcpipCreateNameStringStatement,
  119. AcpipCreateNameStringStatement,
  120. AcpipCreateNameStringStatement,
  121. AcpipCreateNameStringStatement,
  122. AcpipCreateNameStringStatement,
  123. AcpipCreateNameStringStatement,
  124. AcpipCreateNameStringStatement,
  125. AcpipCreateNameStringStatement,
  126. AcpipCreateNameStringStatement,
  127. AcpipCreateNameStringStatement,
  128. AcpipCreateNameStringStatement, // 0x50
  129. AcpipCreateNameStringStatement,
  130. AcpipCreateNameStringStatement,
  131. AcpipCreateNameStringStatement,
  132. AcpipCreateNameStringStatement,
  133. AcpipCreateNameStringStatement,
  134. AcpipCreateNameStringStatement,
  135. AcpipCreateNameStringStatement,
  136. AcpipCreateNameStringStatement,
  137. AcpipCreateNameStringStatement,
  138. AcpipCreateNameStringStatement,
  139. AcpipForwardToTwoByteOpcode,
  140. AcpipCreateNameStringStatement,
  141. AcpipCreateInvalidOpcodeStatement,
  142. AcpipCreateNameStringStatement,
  143. AcpipCreateNameStringStatement,
  144. AcpipCreateLocalStatement, // 0x60
  145. AcpipCreateLocalStatement,
  146. AcpipCreateLocalStatement,
  147. AcpipCreateLocalStatement,
  148. AcpipCreateLocalStatement,
  149. AcpipCreateLocalStatement,
  150. AcpipCreateLocalStatement,
  151. AcpipCreateLocalStatement,
  152. AcpipCreateArgumentStatement,
  153. AcpipCreateArgumentStatement,
  154. AcpipCreateArgumentStatement,
  155. AcpipCreateArgumentStatement,
  156. AcpipCreateArgumentStatement,
  157. AcpipCreateArgumentStatement,
  158. AcpipCreateArgumentStatement,
  159. AcpipCreateInvalidOpcodeStatement,
  160. AcpipCreateStoreStatement, // 0x70
  161. AcpipCreateReferenceOfStatement,
  162. AcpipCreateAddStatement,
  163. AcpipCreateConcatenateStatement,
  164. AcpipCreateSubtractStatement,
  165. AcpipCreateIncrementStatement,
  166. AcpipCreateDecrementStatement,
  167. AcpipCreateMultiplyStatement,
  168. AcpipCreateDivideStatement,
  169. AcpipCreateShiftLeftStatement,
  170. AcpipCreateShiftRightStatement,
  171. AcpipCreateAndStatement,
  172. AcpipCreateNandStatement,
  173. AcpipCreateOrStatement,
  174. AcpipCreateNorStatement,
  175. AcpipCreateXorStatement,
  176. AcpipCreateNotStatement, // 0x80
  177. AcpipCreateFindSetLeftBitStatement,
  178. AcpipCreateFindSetRightBitStatement,
  179. AcpipCreateDereferenceOfStatement,
  180. AcpipCreateConcatenateResourceTemplatesStatement,
  181. AcpipCreateModStatement,
  182. AcpipCreateNotifyStatement,
  183. AcpipCreateSizeOfStatement,
  184. AcpipCreateIndexStatement,
  185. AcpipCreateMatchStatement,
  186. AcpipCreateCreateDoubleWordFieldStatement,
  187. AcpipCreateCreateWordFieldStatement,
  188. AcpipCreateCreateByteFieldStatement,
  189. AcpipCreateCreateBitFieldStatement,
  190. AcpipCreateObjectTypeStatement,
  191. AcpipCreateCreateQuadWordFieldStatement,
  192. AcpipCreateLogicalAndStatement, // 0x90
  193. AcpipCreateLogicalOrStatement,
  194. AcpipCreateLogicalNotStatement,
  195. AcpipCreateLogicalEqualStatement,
  196. AcpipCreateLogicalGreaterStatement,
  197. AcpipCreateLogicalLessStatement,
  198. AcpipCreateToBufferStatement,
  199. AcpipCreateToDecimalStringStatement,
  200. AcpipCreateToHexStringStatement,
  201. AcpipCreateToIntegerStatement,
  202. AcpipCreateInvalidOpcodeStatement,
  203. AcpipCreateInvalidOpcodeStatement,
  204. AcpipCreateToStringStatement,
  205. AcpipCreateCopyObjectStatement,
  206. AcpipCreateMidStatement,
  207. AcpipCreateContinueStatement,
  208. AcpipCreateIfStatement, // 0xA0
  209. AcpipCreateElseStatement,
  210. AcpipCreateWhileStatement,
  211. AcpipCreateNoOpStatement,
  212. AcpipCreateReturnStatement,
  213. AcpipCreateBreakStatement,
  214. AcpipCreateInvalidOpcodeStatement,
  215. AcpipCreateInvalidOpcodeStatement,
  216. AcpipCreateInvalidOpcodeStatement,
  217. AcpipCreateInvalidOpcodeStatement,
  218. AcpipCreateInvalidOpcodeStatement,
  219. AcpipCreateInvalidOpcodeStatement,
  220. AcpipCreateInvalidOpcodeStatement,
  221. AcpipCreateInvalidOpcodeStatement,
  222. AcpipCreateInvalidOpcodeStatement,
  223. AcpipCreateInvalidOpcodeStatement,
  224. AcpipCreateInvalidOpcodeStatement, // 0xB0
  225. AcpipCreateInvalidOpcodeStatement,
  226. AcpipCreateInvalidOpcodeStatement,
  227. AcpipCreateInvalidOpcodeStatement,
  228. AcpipCreateInvalidOpcodeStatement,
  229. AcpipCreateInvalidOpcodeStatement,
  230. AcpipCreateInvalidOpcodeStatement,
  231. AcpipCreateInvalidOpcodeStatement,
  232. AcpipCreateInvalidOpcodeStatement,
  233. AcpipCreateInvalidOpcodeStatement,
  234. AcpipCreateInvalidOpcodeStatement,
  235. AcpipCreateInvalidOpcodeStatement,
  236. AcpipCreateInvalidOpcodeStatement,
  237. AcpipCreateInvalidOpcodeStatement,
  238. AcpipCreateInvalidOpcodeStatement,
  239. AcpipCreateInvalidOpcodeStatement,
  240. AcpipCreateInvalidOpcodeStatement, // 0xC0
  241. AcpipCreateInvalidOpcodeStatement,
  242. AcpipCreateInvalidOpcodeStatement,
  243. AcpipCreateInvalidOpcodeStatement,
  244. AcpipCreateInvalidOpcodeStatement,
  245. AcpipCreateInvalidOpcodeStatement,
  246. AcpipCreateInvalidOpcodeStatement,
  247. AcpipCreateInvalidOpcodeStatement,
  248. AcpipCreateInvalidOpcodeStatement,
  249. AcpipCreateInvalidOpcodeStatement,
  250. AcpipCreateInvalidOpcodeStatement,
  251. AcpipCreateInvalidOpcodeStatement,
  252. AcpipCreateBreakPointStatement,
  253. AcpipCreateInvalidOpcodeStatement,
  254. AcpipCreateInvalidOpcodeStatement,
  255. AcpipCreateInvalidOpcodeStatement,
  256. AcpipCreateInvalidOpcodeStatement, // 0xD0
  257. AcpipCreateInvalidOpcodeStatement,
  258. AcpipCreateInvalidOpcodeStatement,
  259. AcpipCreateInvalidOpcodeStatement,
  260. AcpipCreateInvalidOpcodeStatement,
  261. AcpipCreateInvalidOpcodeStatement,
  262. AcpipCreateInvalidOpcodeStatement,
  263. AcpipCreateInvalidOpcodeStatement,
  264. AcpipCreateInvalidOpcodeStatement,
  265. AcpipCreateInvalidOpcodeStatement,
  266. AcpipCreateInvalidOpcodeStatement,
  267. AcpipCreateInvalidOpcodeStatement,
  268. AcpipCreateInvalidOpcodeStatement,
  269. AcpipCreateInvalidOpcodeStatement,
  270. AcpipCreateInvalidOpcodeStatement,
  271. AcpipCreateInvalidOpcodeStatement,
  272. AcpipCreateInvalidOpcodeStatement, // 0xE0
  273. AcpipCreateInvalidOpcodeStatement,
  274. AcpipCreateInvalidOpcodeStatement,
  275. AcpipCreateInvalidOpcodeStatement,
  276. AcpipCreateInvalidOpcodeStatement,
  277. AcpipCreateInvalidOpcodeStatement,
  278. AcpipCreateInvalidOpcodeStatement,
  279. AcpipCreateInvalidOpcodeStatement,
  280. AcpipCreateInvalidOpcodeStatement,
  281. AcpipCreateInvalidOpcodeStatement,
  282. AcpipCreateInvalidOpcodeStatement,
  283. AcpipCreateInvalidOpcodeStatement,
  284. AcpipCreateInvalidOpcodeStatement,
  285. AcpipCreateInvalidOpcodeStatement,
  286. AcpipCreateInvalidOpcodeStatement,
  287. AcpipCreateInvalidOpcodeStatement,
  288. AcpipCreateInvalidOpcodeStatement, // 0xF0
  289. AcpipCreateInvalidOpcodeStatement,
  290. AcpipCreateInvalidOpcodeStatement,
  291. AcpipCreateInvalidOpcodeStatement,
  292. AcpipCreateInvalidOpcodeStatement,
  293. AcpipCreateInvalidOpcodeStatement,
  294. AcpipCreateInvalidOpcodeStatement,
  295. AcpipCreateInvalidOpcodeStatement,
  296. AcpipCreateInvalidOpcodeStatement,
  297. AcpipCreateInvalidOpcodeStatement,
  298. AcpipCreateInvalidOpcodeStatement,
  299. AcpipCreateInvalidOpcodeStatement,
  300. AcpipCreateInvalidOpcodeStatement,
  301. AcpipCreateInvalidOpcodeStatement,
  302. AcpipCreateInvalidOpcodeStatement,
  303. AcpipCreateOnesStatement
  304. };
  305. //
  306. // Define the two-byte opcode statements.
  307. //
  308. PAML_CREATE_NEXT_STATEMENT_ROUTINE AcpiCreateTwoByteStatement[] = {
  309. AcpipCreateMutexStatement,
  310. AcpipCreateEventStatement,
  311. AcpipCreateConditionalReferenceOfStatement,
  312. AcpipCreateCreateFieldStatement,
  313. AcpipCreateLoadTableStatement,
  314. AcpipCreateLoadStatement,
  315. AcpipCreateStallStatement,
  316. AcpipCreateSleepStatement,
  317. AcpipCreateAcquireStatement,
  318. AcpipCreateSignalStatement,
  319. AcpipCreateWaitStatement,
  320. AcpipCreateResetStatement,
  321. AcpipCreateReleaseStatement,
  322. AcpipCreateFromBcdStatement,
  323. AcpipCreateToBcdStatement,
  324. AcpipCreateUnloadStatement,
  325. AcpipCreateRevisionStatement,
  326. AcpipCreateDebugStatement,
  327. AcpipCreateFatalStatement,
  328. AcpipCreateTimerStatement,
  329. AcpipCreateOperationRegionStatement,
  330. AcpipCreateFieldStatement,
  331. AcpipCreateDeviceStatement,
  332. AcpipCreateProcessorStatement,
  333. AcpipCreatePowerResourceStatement,
  334. AcpipCreateThermalZoneStatement,
  335. AcpipCreateIndexFieldStatement,
  336. AcpipCreateBankFieldStatement,
  337. AcpipCreateDataTableRegionStatement
  338. };
  339. //
  340. // Store an array of function pointers that evaluate ACPI AML statements.
  341. //
  342. PAML_EVALUATE_STATEMENT_ROUTINE AcpiEvaluateStatement[AmlStatementCount] = {
  343. NULL, // AmlStatementInvalid,
  344. AcpipEvaluateAcquireStatement, // AmlStatementAcquire,
  345. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementAdd,
  346. AcpipEvaluateAliasStatement, // AmlStatementAlias,
  347. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementAnd,
  348. AcpipEvaluateArgumentStatement, // AmlStatementArgument,
  349. AcpipEvaluateBankFieldStatement, // AmlStatementBankField,
  350. AcpipEvaluateWhileModifierStatement, // AmlStatementBreak,
  351. AcpipEvaluateBreakPointStatement, // AmlStatementBreakPoint,
  352. AcpipEvaluateBufferStatement, // AmlStatementBuffer,
  353. AcpipEvaluateConcatenateStatement, // AmlStatementConcatenate,
  354. AcpipEvaluateConcatenateResourceTemplatesStatement,
  355. AcpipEvaluateConditionalReferenceOfStatement,
  356. AcpipEvaluateWhileModifierStatement, // AmlStatementContinue,
  357. AcpipEvaluateCopyObjectStatement, // AmlStatementCopyObject,
  358. AcpipEvaluateCreateBufferFieldStatement, // AmlStatementCreateBufferField,
  359. AcpipEvaluateCreateFixedBufferFieldStatement,
  360. AcpipEvaluateDataStatement, // AmlStatementData,
  361. NULL, // AmlStatementDataTableRegion,
  362. AcpipEvaluateDebugStatement, // AmlStatementDebug,
  363. AcpipEvaluateIncrementOrDecrementStatement, // AmlStatementDecrement,
  364. AcpipEvaluateDereferenceOfStatement, // AmlStatementDereferenceOf,
  365. AcpipEvaluateDeviceStatement, // AmlStatementDevice,
  366. AcpipEvaluateDivideStatement, // AmlStatementDivide,
  367. AcpipEvaluateElseStatement, // AmlStatementElse,
  368. AcpipEvaluateEventStatement, // AmlStatementEvent,
  369. AcpipEvaluateExecutingMethodStatement, // AmlStatementExecutingMethod,
  370. AcpipEvaluateFatalStatement, // AmlStatementFatal,
  371. AcpipEvaluateFieldStatement, // AmlStatementField,
  372. AcpipEvaluateFindSetBitStatement, // AmlStatementFindSetLeftBit,
  373. AcpipEvaluateFindSetBitStatement, // AmlStatementFindSetRightBit,
  374. AcpipEvaluateToFormatStatement, // AmlStatementFromBcd,
  375. AcpipEvaluateIfStatement, // AmlStatementIf,
  376. AcpipEvaluateIncrementOrDecrementStatement, // AmlStatementIncrement,
  377. AcpipEvaluateIndexStatement, // AmlStatementIndex,
  378. AcpipEvaluateIndexFieldStatement, // AmlStatementIndexField,
  379. AcpipEvaluateLoadStatement, // AmlStatementLoad,
  380. NULL, // AmlStatementLoadTable,
  381. AcpipEvaluateLocalStatement, // AmlStatementLocal,
  382. AcpipEvaluateLogicalExpressionStatement, // AmlStatementLogicalAnd,
  383. AcpipEvaluateLogicalExpressionStatement, // AmlStatementLogicalEqual,
  384. AcpipEvaluateLogicalExpressionStatement, // AmlStatementLogicalGreater,
  385. AcpipEvaluateLogicalExpressionStatement, // AmlStatementLogicalLess,
  386. AcpipEvaluateLogicalNotStatement, // AmlStatementLogicalNot,
  387. AcpipEvaluateLogicalExpressionStatement, // AmlStatementLogicalOr,
  388. AcpipEvaluateMatchStatement, // AmlStatementMatch,
  389. AcpipEvaluateMethodStatement, // AmlStatementMethod,
  390. AcpipEvaluateMidStatement, // AmlStatementMid,
  391. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementMod,
  392. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementMultiply,
  393. AcpipEvaluateMutexStatement, // AmlStatementMutex,
  394. AcpipEvaluateNameStatement, // AmlStatementName,
  395. AcpipEvaluateNameStringStatement, // AmlStatementNameString,
  396. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementNand,
  397. AcpipEvaluateNoOpStatement, // AmlStatementNoOp,
  398. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementNor,
  399. AcpipEvaluateNotStatement, // AmlStatementNot,
  400. AcpipEvaluateNotifyStatement, // AmlStatementNotify,
  401. AcpipEvaluateObjectTypeStatement, // AmlStatementObjectType,
  402. AcpipEvaluateIntegerStatement, // AmlStatementOne,
  403. AcpipEvaluateIntegerStatement, // AmlStatementOnes,
  404. AcpipEvaluateOperationRegionStatement, // AmlStatementOperationRegion,
  405. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementOr,
  406. AcpipEvaluatePackageStatement, // AmlStatementPackage,
  407. AcpipEvaluatePowerResourceStatement, // AmlStatementPowerResource,
  408. AcpipEvaluateProcessorStatement, // AmlStatementProcessor,
  409. AcpipEvaluateReferenceOfStatement, // AmlStatementReferenceOf,
  410. AcpipEvaluateSyncObjectStatement, // AmlStatementRelease,
  411. AcpipEvaluateSyncObjectStatement, // AmlStatementReset,
  412. AcpipEvaluateReturnStatement, // AmlStatementReturn,
  413. AcpipEvaluateIntegerStatement, // AmlStatementRevision,
  414. AcpipEvaluateScopeStatement, // AmlStatementScope,
  415. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementShiftLeft,
  416. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementShiftRight,
  417. AcpipEvaluateSyncObjectStatement, // AmlStatementSignal,
  418. AcpipEvaluateSizeOfStatement, // AmlStatementSizeOf,
  419. AcpipEvaluateDelayStatement, // AmlStatementSleep,
  420. AcpipEvaluateDelayStatement, // AmlStatementStall,
  421. AcpipEvaluateStoreStatement, // AmlStatementStore,
  422. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementSubtract,
  423. AcpipEvaluateThermalZoneStatement, // AmlStatementThermalZone,
  424. AcpipEvaluateIntegerStatement, // AmlStatementTimer,
  425. AcpipEvaluateToFormatStatement, // AmlStatementToBcd,
  426. AcpipEvaluateToFormatStatement, // AmlStatementToBuffer,
  427. AcpipEvaluateToFormatStatement, // AmlStatementToDecimalString,
  428. AcpipEvaluateToFormatStatement, // AmlStatementToHexString,
  429. AcpipEvaluateToFormatStatement, // AmlStatementToInteger,
  430. AcpipEvaluateToFormatStatement, // AmlStatementToString,
  431. AcpipEvaluateUnloadStatement, // AmlStatementUnload,
  432. AcpipEvaluatePackageStatement, // AmlStatementVariablePackage,
  433. AcpipEvaluateWaitStatement, // AmlStatementWait,
  434. AcpipEvaluateWhileStatement, // AmlStatementWhile,
  435. AcpipEvaluateIntegerArithmeticStatement, // AmlStatementXor,
  436. AcpipEvaluateIntegerStatement, // AmlStatementZero,
  437. };
  438. //
  439. // ------------------------------------------------------------------ Functions
  440. //
  441. //
  442. // --------------------------------------------------------- Internal Functions
  443. //
  444. KSTATUS
  445. AcpipForwardToTwoByteOpcode (
  446. PAML_EXECUTION_CONTEXT Context,
  447. PAML_STATEMENT NextStatement
  448. )
  449. /*++
  450. Routine Description:
  451. This routine forwards the opcode onto a two-byte opcode handler.
  452. Arguments:
  453. Context - Supplies a pointer to an initialized AML execution context. The
  454. next statement will be created based on the current execution offset.
  455. The current offset of the context will be incremented beyond the portion
  456. of this statement that was successfully parsed.
  457. NextStatement - Supplies a pointer where the next statement will be
  458. returned.
  459. Return Value:
  460. Status code.
  461. --*/
  462. {
  463. PAML_CREATE_NEXT_STATEMENT_ROUTINE CreateRoutine;
  464. PUCHAR InstructionPointer;
  465. UCHAR SecondOpcode;
  466. ULONG TableIndex;
  467. InstructionPointer = (PUCHAR)Context->AmlCode + Context->CurrentOffset;
  468. ASSERT(*InstructionPointer == TWO_BYTE_OPCODE_PREFIX);
  469. InstructionPointer += 1;
  470. Context->CurrentOffset += 1;
  471. if (Context->CurrentOffset >= Context->AmlCodeSize) {
  472. return STATUS_MALFORMED_DATA_STREAM;
  473. }
  474. SecondOpcode = *InstructionPointer;
  475. //
  476. // Determine the table index based on the second opcode. The table is
  477. // tightly packed, and the valid opcodes are 1-2, 0x12-0x13, 0x1F-0x2A,
  478. // 0x30-0x33, and 0x80-0x88.
  479. //
  480. if (SecondOpcode == 0) {
  481. return STATUS_MALFORMED_DATA_STREAM;
  482. } else if (SecondOpcode <= 0x2) {
  483. TableIndex = SecondOpcode - 1;
  484. } else if (SecondOpcode < 0x12) {
  485. return STATUS_MALFORMED_DATA_STREAM;
  486. } else if (SecondOpcode <= 0x13) {
  487. TableIndex = SecondOpcode - 0x10;
  488. } else if (SecondOpcode < 0x1F) {
  489. return STATUS_MALFORMED_DATA_STREAM;
  490. } else if (SecondOpcode <= 0x2A) {
  491. TableIndex = SecondOpcode - 0x1B;
  492. } else if (SecondOpcode < 0x30) {
  493. return STATUS_MALFORMED_DATA_STREAM;
  494. } else if (SecondOpcode <= 0x33) {
  495. TableIndex = SecondOpcode - 0x20;
  496. } else if (SecondOpcode < 0x80) {
  497. return STATUS_MALFORMED_DATA_STREAM;
  498. } else if (SecondOpcode <= 0x88) {
  499. TableIndex = SecondOpcode - 0x6C;
  500. } else {
  501. return STATUS_MALFORMED_DATA_STREAM;
  502. }
  503. CreateRoutine = AcpiCreateTwoByteStatement[TableIndex];
  504. return CreateRoutine(Context, NextStatement);
  505. }