psloop.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /******************************************************************************
  3. *
  4. * Module Name: psloop - Main AML parse loop
  5. *
  6. * Copyright (C) 2000 - 2018, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. /*
  10. * Parse the AML and build an operation tree as most interpreters, (such as
  11. * Perl) do. Parsing is done by hand rather than with a YACC generated parser
  12. * to tightly constrain stack and dynamic memory usage. Parsing is kept
  13. * flexible and the code fairly compact by parsing based on a list of AML
  14. * opcode templates in aml_op_info[].
  15. */
  16. #include <acpi/acpi.h>
  17. #include "accommon.h"
  18. #include "acinterp.h"
  19. #include "acparser.h"
  20. #include "acdispat.h"
  21. #include "amlcode.h"
  22. #include "acconvert.h"
  23. #include "acnamesp.h"
  24. #define _COMPONENT ACPI_PARSER
  25. ACPI_MODULE_NAME("psloop")
  26. /* Local prototypes */
  27. static acpi_status
  28. acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
  29. u8 * aml_op_start, union acpi_parse_object *op);
  30. static void
  31. acpi_ps_link_module_code(union acpi_parse_object *parent_op,
  32. u8 *aml_start, u32 aml_length, acpi_owner_id owner_id);
  33. /*******************************************************************************
  34. *
  35. * FUNCTION: acpi_ps_get_arguments
  36. *
  37. * PARAMETERS: walk_state - Current state
  38. * aml_op_start - Op start in AML
  39. * op - Current Op
  40. *
  41. * RETURN: Status
  42. *
  43. * DESCRIPTION: Get arguments for passed Op.
  44. *
  45. ******************************************************************************/
  46. static acpi_status
  47. acpi_ps_get_arguments(struct acpi_walk_state *walk_state,
  48. u8 * aml_op_start, union acpi_parse_object *op)
  49. {
  50. acpi_status status = AE_OK;
  51. union acpi_parse_object *arg = NULL;
  52. const struct acpi_opcode_info *op_info;
  53. ACPI_FUNCTION_TRACE_PTR(ps_get_arguments, walk_state);
  54. ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
  55. "Get arguments for opcode [%s]\n",
  56. op->common.aml_op_name));
  57. switch (op->common.aml_opcode) {
  58. case AML_BYTE_OP: /* AML_BYTEDATA_ARG */
  59. case AML_WORD_OP: /* AML_WORDDATA_ARG */
  60. case AML_DWORD_OP: /* AML_DWORDATA_ARG */
  61. case AML_QWORD_OP: /* AML_QWORDATA_ARG */
  62. case AML_STRING_OP: /* AML_ASCIICHARLIST_ARG */
  63. /* Fill in constant or string argument directly */
  64. acpi_ps_get_next_simple_arg(&(walk_state->parser_state),
  65. GET_CURRENT_ARG_TYPE(walk_state->
  66. arg_types),
  67. op);
  68. break;
  69. case AML_INT_NAMEPATH_OP: /* AML_NAMESTRING_ARG */
  70. status = acpi_ps_get_next_namepath(walk_state,
  71. &(walk_state->parser_state),
  72. op,
  73. ACPI_POSSIBLE_METHOD_CALL);
  74. if (ACPI_FAILURE(status)) {
  75. return_ACPI_STATUS(status);
  76. }
  77. walk_state->arg_types = 0;
  78. break;
  79. default:
  80. /*
  81. * Op is not a constant or string, append each argument to the Op
  82. */
  83. while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) &&
  84. !walk_state->arg_count) {
  85. walk_state->aml = walk_state->parser_state.aml;
  86. switch (op->common.aml_opcode) {
  87. case AML_METHOD_OP:
  88. case AML_BUFFER_OP:
  89. case AML_PACKAGE_OP:
  90. case AML_VARIABLE_PACKAGE_OP:
  91. case AML_WHILE_OP:
  92. break;
  93. default:
  94. ASL_CV_CAPTURE_COMMENTS(walk_state);
  95. break;
  96. }
  97. status =
  98. acpi_ps_get_next_arg(walk_state,
  99. &(walk_state->parser_state),
  100. GET_CURRENT_ARG_TYPE
  101. (walk_state->arg_types), &arg);
  102. if (ACPI_FAILURE(status)) {
  103. return_ACPI_STATUS(status);
  104. }
  105. if (arg) {
  106. acpi_ps_append_arg(op, arg);
  107. }
  108. INCREMENT_ARG_LIST(walk_state->arg_types);
  109. }
  110. ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
  111. "Final argument count: %8.8X pass %u\n",
  112. walk_state->arg_count,
  113. walk_state->pass_number));
  114. /*
  115. * This case handles the legacy option that groups all module-level
  116. * code blocks together and defers execution until all of the tables
  117. * are loaded. Execute all of these blocks at this time.
  118. * Execute any module-level code that was detected during the table
  119. * load phase.
  120. *
  121. * Note: this option is deprecated and will be eliminated in the
  122. * future. Use of this option can cause problems with AML code that
  123. * depends upon in-order immediate execution of module-level code.
  124. */
  125. if (!acpi_gbl_execute_tables_as_methods &&
  126. (walk_state->pass_number <= ACPI_IMODE_LOAD_PASS2) &&
  127. ((walk_state->parse_flags & ACPI_PARSE_DISASSEMBLE) == 0)) {
  128. /*
  129. * We want to skip If/Else/While constructs during Pass1 because we
  130. * want to actually conditionally execute the code during Pass2.
  131. *
  132. * Except for disassembly, where we always want to walk the
  133. * If/Else/While packages
  134. */
  135. switch (op->common.aml_opcode) {
  136. case AML_IF_OP:
  137. case AML_ELSE_OP:
  138. case AML_WHILE_OP:
  139. /*
  140. * Currently supported module-level opcodes are:
  141. * IF/ELSE/WHILE. These appear to be the most common,
  142. * and easiest to support since they open an AML
  143. * package.
  144. */
  145. if (walk_state->pass_number ==
  146. ACPI_IMODE_LOAD_PASS1) {
  147. acpi_ps_link_module_code(op->common.
  148. parent,
  149. aml_op_start,
  150. (u32)
  151. (walk_state->
  152. parser_state.
  153. pkg_end -
  154. aml_op_start),
  155. walk_state->
  156. owner_id);
  157. }
  158. ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
  159. "Pass1: Skipping an If/Else/While body\n"));
  160. /* Skip body of if/else/while in pass 1 */
  161. walk_state->parser_state.aml =
  162. walk_state->parser_state.pkg_end;
  163. walk_state->arg_count = 0;
  164. break;
  165. default:
  166. /*
  167. * Check for an unsupported executable opcode at module
  168. * level. We must be in PASS1, the parent must be a SCOPE,
  169. * The opcode class must be EXECUTE, and the opcode must
  170. * not be an argument to another opcode.
  171. */
  172. if ((walk_state->pass_number ==
  173. ACPI_IMODE_LOAD_PASS1)
  174. && (op->common.parent->common.aml_opcode ==
  175. AML_SCOPE_OP)) {
  176. op_info =
  177. acpi_ps_get_opcode_info(op->common.
  178. aml_opcode);
  179. if ((op_info->class ==
  180. AML_CLASS_EXECUTE) && (!arg)) {
  181. ACPI_WARNING((AE_INFO,
  182. "Unsupported module-level executable opcode "
  183. "0x%.2X at table offset 0x%.4X",
  184. op->common.
  185. aml_opcode,
  186. (u32)
  187. (ACPI_PTR_DIFF
  188. (aml_op_start,
  189. walk_state->
  190. parser_state.
  191. aml_start) +
  192. sizeof(struct
  193. acpi_table_header))));
  194. }
  195. }
  196. break;
  197. }
  198. }
  199. /* Special processing for certain opcodes */
  200. switch (op->common.aml_opcode) {
  201. case AML_METHOD_OP:
  202. /*
  203. * Skip parsing of control method because we don't have enough
  204. * info in the first pass to parse it correctly.
  205. *
  206. * Save the length and address of the body
  207. */
  208. op->named.data = walk_state->parser_state.aml;
  209. op->named.length = (u32)
  210. (walk_state->parser_state.pkg_end -
  211. walk_state->parser_state.aml);
  212. /* Skip body of method */
  213. walk_state->parser_state.aml =
  214. walk_state->parser_state.pkg_end;
  215. walk_state->arg_count = 0;
  216. break;
  217. case AML_BUFFER_OP:
  218. case AML_PACKAGE_OP:
  219. case AML_VARIABLE_PACKAGE_OP:
  220. if ((op->common.parent) &&
  221. (op->common.parent->common.aml_opcode ==
  222. AML_NAME_OP)
  223. && (walk_state->pass_number <=
  224. ACPI_IMODE_LOAD_PASS2)) {
  225. ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
  226. "Setup Package/Buffer: Pass %u, AML Ptr: %p\n",
  227. walk_state->pass_number,
  228. aml_op_start));
  229. /*
  230. * Skip parsing of Buffers and Packages because we don't have
  231. * enough info in the first pass to parse them correctly.
  232. */
  233. op->named.data = aml_op_start;
  234. op->named.length = (u32)
  235. (walk_state->parser_state.pkg_end -
  236. aml_op_start);
  237. /* Skip body */
  238. walk_state->parser_state.aml =
  239. walk_state->parser_state.pkg_end;
  240. walk_state->arg_count = 0;
  241. }
  242. break;
  243. case AML_WHILE_OP:
  244. if (walk_state->control_state) {
  245. walk_state->control_state->control.package_end =
  246. walk_state->parser_state.pkg_end;
  247. }
  248. break;
  249. default:
  250. /* No action for all other opcodes */
  251. break;
  252. }
  253. break;
  254. }
  255. return_ACPI_STATUS(AE_OK);
  256. }
  257. /*******************************************************************************
  258. *
  259. * FUNCTION: acpi_ps_link_module_code
  260. *
  261. * PARAMETERS: parent_op - Parent parser op
  262. * aml_start - Pointer to the AML
  263. * aml_length - Length of executable AML
  264. * owner_id - owner_id of module level code
  265. *
  266. * RETURN: None.
  267. *
  268. * DESCRIPTION: Wrap the module-level code with a method object and link the
  269. * object to the global list. Note, the mutex field of the method
  270. * object is used to link multiple module-level code objects.
  271. *
  272. * NOTE: In this legacy option, each block of detected executable AML
  273. * code that is outside of any control method is wrapped with a temporary
  274. * control method object and placed on a global list below.
  275. *
  276. * This function executes the module-level code for all tables only after
  277. * all of the tables have been loaded. It is a legacy option and is
  278. * not compatible with other ACPI implementations. See acpi_ns_load_table.
  279. *
  280. * This function will be removed when the legacy option is removed.
  281. *
  282. ******************************************************************************/
  283. static void
  284. acpi_ps_link_module_code(union acpi_parse_object *parent_op,
  285. u8 *aml_start, u32 aml_length, acpi_owner_id owner_id)
  286. {
  287. union acpi_operand_object *prev;
  288. union acpi_operand_object *next;
  289. union acpi_operand_object *method_obj;
  290. struct acpi_namespace_node *parent_node;
  291. ACPI_FUNCTION_TRACE(ps_link_module_code);
  292. /* Get the tail of the list */
  293. prev = next = acpi_gbl_module_code_list;
  294. while (next) {
  295. prev = next;
  296. next = next->method.mutex;
  297. }
  298. /*
  299. * Insert the module level code into the list. Merge it if it is
  300. * adjacent to the previous element.
  301. */
  302. if (!prev ||
  303. ((prev->method.aml_start + prev->method.aml_length) != aml_start)) {
  304. /* Create, initialize, and link a new temporary method object */
  305. method_obj = acpi_ut_create_internal_object(ACPI_TYPE_METHOD);
  306. if (!method_obj) {
  307. return_VOID;
  308. }
  309. ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
  310. "Create/Link new code block: %p\n",
  311. method_obj));
  312. if (parent_op->common.node) {
  313. parent_node = parent_op->common.node;
  314. } else {
  315. parent_node = acpi_gbl_root_node;
  316. }
  317. method_obj->method.aml_start = aml_start;
  318. method_obj->method.aml_length = aml_length;
  319. method_obj->method.owner_id = owner_id;
  320. method_obj->method.info_flags |= ACPI_METHOD_MODULE_LEVEL;
  321. /*
  322. * Save the parent node in next_object. This is cheating, but we
  323. * don't want to expand the method object.
  324. */
  325. method_obj->method.next_object =
  326. ACPI_CAST_PTR(union acpi_operand_object, parent_node);
  327. if (!prev) {
  328. acpi_gbl_module_code_list = method_obj;
  329. } else {
  330. prev->method.mutex = method_obj;
  331. }
  332. } else {
  333. ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
  334. "Appending to existing code block: %p\n",
  335. prev));
  336. prev->method.aml_length += aml_length;
  337. }
  338. return_VOID;
  339. }
  340. /*******************************************************************************
  341. *
  342. * FUNCTION: acpi_ps_parse_loop
  343. *
  344. * PARAMETERS: walk_state - Current state
  345. *
  346. * RETURN: Status
  347. *
  348. * DESCRIPTION: Parse AML (pointed to by the current parser state) and return
  349. * a tree of ops.
  350. *
  351. ******************************************************************************/
  352. acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
  353. {
  354. acpi_status status = AE_OK;
  355. union acpi_parse_object *op = NULL; /* current op */
  356. struct acpi_parse_state *parser_state;
  357. u8 *aml_op_start = NULL;
  358. u8 opcode_length;
  359. ACPI_FUNCTION_TRACE_PTR(ps_parse_loop, walk_state);
  360. if (walk_state->descending_callback == NULL) {
  361. return_ACPI_STATUS(AE_BAD_PARAMETER);
  362. }
  363. parser_state = &walk_state->parser_state;
  364. walk_state->arg_types = 0;
  365. #if (!defined (ACPI_NO_METHOD_EXECUTION) && !defined (ACPI_CONSTANT_EVAL_ONLY))
  366. if (walk_state->walk_type & ACPI_WALK_METHOD_RESTART) {
  367. /* We are restarting a preempted control method */
  368. if (acpi_ps_has_completed_scope(parser_state)) {
  369. /*
  370. * We must check if a predicate to an IF or WHILE statement
  371. * was just completed
  372. */
  373. if ((parser_state->scope->parse_scope.op) &&
  374. ((parser_state->scope->parse_scope.op->common.
  375. aml_opcode == AML_IF_OP)
  376. || (parser_state->scope->parse_scope.op->common.
  377. aml_opcode == AML_WHILE_OP))
  378. && (walk_state->control_state)
  379. && (walk_state->control_state->common.state ==
  380. ACPI_CONTROL_PREDICATE_EXECUTING)) {
  381. /*
  382. * A predicate was just completed, get the value of the
  383. * predicate and branch based on that value
  384. */
  385. walk_state->op = NULL;
  386. status =
  387. acpi_ds_get_predicate_value(walk_state,
  388. ACPI_TO_POINTER
  389. (TRUE));
  390. if (ACPI_FAILURE(status)
  391. && ((status & AE_CODE_MASK) !=
  392. AE_CODE_CONTROL)) {
  393. if (status == AE_AML_NO_RETURN_VALUE) {
  394. ACPI_EXCEPTION((AE_INFO, status,
  395. "Invoked method did not return a value"));
  396. }
  397. ACPI_EXCEPTION((AE_INFO, status,
  398. "GetPredicate Failed"));
  399. return_ACPI_STATUS(status);
  400. }
  401. status =
  402. acpi_ps_next_parse_state(walk_state, op,
  403. status);
  404. }
  405. acpi_ps_pop_scope(parser_state, &op,
  406. &walk_state->arg_types,
  407. &walk_state->arg_count);
  408. ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
  409. "Popped scope, Op=%p\n", op));
  410. } else if (walk_state->prev_op) {
  411. /* We were in the middle of an op */
  412. op = walk_state->prev_op;
  413. walk_state->arg_types = walk_state->prev_arg_types;
  414. }
  415. }
  416. #endif
  417. /* Iterative parsing loop, while there is more AML to process: */
  418. while ((parser_state->aml < parser_state->aml_end) || (op)) {
  419. ASL_CV_CAPTURE_COMMENTS(walk_state);
  420. aml_op_start = parser_state->aml;
  421. if (!op) {
  422. status =
  423. acpi_ps_create_op(walk_state, aml_op_start, &op);
  424. if (ACPI_FAILURE(status)) {
  425. /*
  426. * ACPI_PARSE_MODULE_LEVEL means that we are loading a table by
  427. * executing it as a control method. However, if we encounter
  428. * an error while loading the table, we need to keep trying to
  429. * load the table rather than aborting the table load. Set the
  430. * status to AE_OK to proceed with the table load.
  431. */
  432. if ((walk_state->
  433. parse_flags & ACPI_PARSE_MODULE_LEVEL)
  434. && status == AE_ALREADY_EXISTS) {
  435. status = AE_OK;
  436. }
  437. if (status == AE_CTRL_PARSE_CONTINUE) {
  438. continue;
  439. }
  440. if (status == AE_CTRL_PARSE_PENDING) {
  441. status = AE_OK;
  442. }
  443. if (status == AE_CTRL_TERMINATE) {
  444. return_ACPI_STATUS(status);
  445. }
  446. status =
  447. acpi_ps_complete_op(walk_state, &op,
  448. status);
  449. if (ACPI_FAILURE(status)) {
  450. return_ACPI_STATUS(status);
  451. }
  452. if (acpi_ns_opens_scope
  453. (acpi_ps_get_opcode_info
  454. (walk_state->opcode)->object_type)) {
  455. /*
  456. * If the scope/device op fails to parse, skip the body of
  457. * the scope op because the parse failure indicates that
  458. * the device may not exist.
  459. */
  460. ACPI_ERROR((AE_INFO,
  461. "Skip parsing opcode %s",
  462. acpi_ps_get_opcode_name
  463. (walk_state->opcode)));
  464. /*
  465. * Determine the opcode length before skipping the opcode.
  466. * An opcode can be 1 byte or 2 bytes in length.
  467. */
  468. opcode_length = 1;
  469. if ((walk_state->opcode & 0xFF00) ==
  470. AML_EXTENDED_OPCODE) {
  471. opcode_length = 2;
  472. }
  473. walk_state->parser_state.aml =
  474. walk_state->aml + opcode_length;
  475. walk_state->parser_state.aml =
  476. acpi_ps_get_next_package_end
  477. (&walk_state->parser_state);
  478. walk_state->aml =
  479. walk_state->parser_state.aml;
  480. }
  481. continue;
  482. }
  483. acpi_ex_start_trace_opcode(op, walk_state);
  484. }
  485. /*
  486. * Start arg_count at zero because we don't know if there are
  487. * any args yet
  488. */
  489. walk_state->arg_count = 0;
  490. switch (op->common.aml_opcode) {
  491. case AML_BYTE_OP:
  492. case AML_WORD_OP:
  493. case AML_DWORD_OP:
  494. case AML_QWORD_OP:
  495. break;
  496. default:
  497. ASL_CV_CAPTURE_COMMENTS(walk_state);
  498. break;
  499. }
  500. /* Are there any arguments that must be processed? */
  501. if (walk_state->arg_types) {
  502. /* Get arguments */
  503. status =
  504. acpi_ps_get_arguments(walk_state, aml_op_start, op);
  505. if (ACPI_FAILURE(status)) {
  506. status =
  507. acpi_ps_complete_op(walk_state, &op,
  508. status);
  509. if (ACPI_FAILURE(status)) {
  510. return_ACPI_STATUS(status);
  511. }
  512. if ((walk_state->control_state) &&
  513. ((walk_state->control_state->control.
  514. opcode == AML_IF_OP)
  515. || (walk_state->control_state->control.
  516. opcode == AML_WHILE_OP))) {
  517. /*
  518. * If the if/while op fails to parse, we will skip parsing
  519. * the body of the op.
  520. */
  521. parser_state->aml =
  522. walk_state->control_state->control.
  523. aml_predicate_start + 1;
  524. parser_state->aml =
  525. acpi_ps_get_next_package_end
  526. (parser_state);
  527. walk_state->aml = parser_state->aml;
  528. ACPI_ERROR((AE_INFO,
  529. "Skipping While/If block"));
  530. if (*walk_state->aml == AML_ELSE_OP) {
  531. ACPI_ERROR((AE_INFO,
  532. "Skipping Else block"));
  533. walk_state->parser_state.aml =
  534. walk_state->aml + 1;
  535. walk_state->parser_state.aml =
  536. acpi_ps_get_next_package_end
  537. (parser_state);
  538. walk_state->aml =
  539. parser_state->aml;
  540. }
  541. ACPI_FREE(acpi_ut_pop_generic_state
  542. (&walk_state->control_state));
  543. }
  544. op = NULL;
  545. continue;
  546. }
  547. }
  548. /* Check for arguments that need to be processed */
  549. ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
  550. "Parseloop: argument count: %8.8X\n",
  551. walk_state->arg_count));
  552. if (walk_state->arg_count) {
  553. /*
  554. * There are arguments (complex ones), push Op and
  555. * prepare for argument
  556. */
  557. status = acpi_ps_push_scope(parser_state, op,
  558. walk_state->arg_types,
  559. walk_state->arg_count);
  560. if (ACPI_FAILURE(status)) {
  561. status =
  562. acpi_ps_complete_op(walk_state, &op,
  563. status);
  564. if (ACPI_FAILURE(status)) {
  565. return_ACPI_STATUS(status);
  566. }
  567. continue;
  568. }
  569. op = NULL;
  570. continue;
  571. }
  572. /*
  573. * All arguments have been processed -- Op is complete,
  574. * prepare for next
  575. */
  576. walk_state->op_info =
  577. acpi_ps_get_opcode_info(op->common.aml_opcode);
  578. if (walk_state->op_info->flags & AML_NAMED) {
  579. if (op->common.aml_opcode == AML_REGION_OP ||
  580. op->common.aml_opcode == AML_DATA_REGION_OP) {
  581. /*
  582. * Skip parsing of control method or opregion body,
  583. * because we don't have enough info in the first pass
  584. * to parse them correctly.
  585. *
  586. * Completed parsing an op_region declaration, we now
  587. * know the length.
  588. */
  589. op->named.length =
  590. (u32) (parser_state->aml - op->named.data);
  591. }
  592. }
  593. if (walk_state->op_info->flags & AML_CREATE) {
  594. /*
  595. * Backup to beginning of create_XXXfield declaration (1 for
  596. * Opcode)
  597. *
  598. * body_length is unknown until we parse the body
  599. */
  600. op->named.length =
  601. (u32) (parser_state->aml - op->named.data);
  602. }
  603. if (op->common.aml_opcode == AML_BANK_FIELD_OP) {
  604. /*
  605. * Backup to beginning of bank_field declaration
  606. *
  607. * body_length is unknown until we parse the body
  608. */
  609. op->named.length =
  610. (u32) (parser_state->aml - op->named.data);
  611. }
  612. /* This op complete, notify the dispatcher */
  613. if (walk_state->ascending_callback != NULL) {
  614. walk_state->op = op;
  615. walk_state->opcode = op->common.aml_opcode;
  616. status = walk_state->ascending_callback(walk_state);
  617. status =
  618. acpi_ps_next_parse_state(walk_state, op, status);
  619. if (status == AE_CTRL_PENDING) {
  620. status = AE_OK;
  621. } else
  622. if ((walk_state->
  623. parse_flags & ACPI_PARSE_MODULE_LEVEL)
  624. && (ACPI_AML_EXCEPTION(status)
  625. || status == AE_ALREADY_EXISTS
  626. || status == AE_NOT_FOUND)) {
  627. /*
  628. * ACPI_PARSE_MODULE_LEVEL flag means that we
  629. * are currently loading a table by executing
  630. * it as a control method. However, if we
  631. * encounter an error while loading the table,
  632. * we need to keep trying to load the table
  633. * rather than aborting the table load (setting
  634. * the status to AE_OK continues the table
  635. * load). If we get a failure at this point, it
  636. * means that the dispatcher got an error while
  637. * trying to execute the Op.
  638. */
  639. status = AE_OK;
  640. }
  641. }
  642. status = acpi_ps_complete_op(walk_state, &op, status);
  643. if (ACPI_FAILURE(status)) {
  644. return_ACPI_STATUS(status);
  645. }
  646. } /* while parser_state->Aml */
  647. status = acpi_ps_complete_final_op(walk_state, op, status);
  648. return_ACPI_STATUS(status);
  649. }