psobject.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /******************************************************************************
  3. *
  4. * Module Name: psobject - Support for parse objects
  5. *
  6. * Copyright (C) 2000 - 2022, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #include <acpi/acpi.h>
  10. #include "accommon.h"
  11. #include "acparser.h"
  12. #include "amlcode.h"
  13. #include "acconvert.h"
  14. #include "acnamesp.h"
  15. #define _COMPONENT ACPI_PARSER
  16. ACPI_MODULE_NAME("psobject")
  17. /* Local prototypes */
  18. static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state);
  19. /*******************************************************************************
  20. *
  21. * FUNCTION: acpi_ps_get_aml_opcode
  22. *
  23. * PARAMETERS: walk_state - Current state
  24. *
  25. * RETURN: Status
  26. *
  27. * DESCRIPTION: Extract the next AML opcode from the input stream.
  28. *
  29. ******************************************************************************/
  30. static acpi_status acpi_ps_get_aml_opcode(struct acpi_walk_state *walk_state)
  31. {
  32. ACPI_ERROR_ONLY(u32 aml_offset);
  33. ACPI_FUNCTION_TRACE_PTR(ps_get_aml_opcode, walk_state);
  34. walk_state->aml = walk_state->parser_state.aml;
  35. walk_state->opcode = acpi_ps_peek_opcode(&(walk_state->parser_state));
  36. /*
  37. * First cut to determine what we have found:
  38. * 1) A valid AML opcode
  39. * 2) A name string
  40. * 3) An unknown/invalid opcode
  41. */
  42. walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
  43. switch (walk_state->op_info->class) {
  44. case AML_CLASS_ASCII:
  45. case AML_CLASS_PREFIX:
  46. /*
  47. * Starts with a valid prefix or ASCII char, this is a name
  48. * string. Convert the bare name string to a namepath.
  49. */
  50. walk_state->opcode = AML_INT_NAMEPATH_OP;
  51. walk_state->arg_types = ARGP_NAMESTRING;
  52. break;
  53. case AML_CLASS_UNKNOWN:
  54. /* The opcode is unrecognized. Complain and skip unknown opcodes */
  55. if (walk_state->pass_number == 2) {
  56. ACPI_ERROR_ONLY(aml_offset =
  57. (u32)ACPI_PTR_DIFF(walk_state->aml,
  58. walk_state->
  59. parser_state.
  60. aml_start));
  61. ACPI_ERROR((AE_INFO,
  62. "Unknown opcode 0x%.2X at table offset 0x%.4X, ignoring",
  63. walk_state->opcode,
  64. (u32)(aml_offset +
  65. sizeof(struct acpi_table_header))));
  66. ACPI_DUMP_BUFFER((walk_state->parser_state.aml - 16),
  67. 48);
  68. #ifdef ACPI_ASL_COMPILER
  69. /*
  70. * This is executed for the disassembler only. Output goes
  71. * to the disassembled ASL output file.
  72. */
  73. acpi_os_printf
  74. ("/*\nError: Unknown opcode 0x%.2X at table offset 0x%.4X, context:\n",
  75. walk_state->opcode,
  76. (u32)(aml_offset +
  77. sizeof(struct acpi_table_header)));
  78. ACPI_ERROR((AE_INFO,
  79. "Aborting disassembly, AML byte code is corrupt"));
  80. /* Dump the context surrounding the invalid opcode */
  81. acpi_ut_dump_buffer(((u8 *)walk_state->parser_state.
  82. aml - 16), 48, DB_BYTE_DISPLAY,
  83. (aml_offset +
  84. sizeof(struct acpi_table_header) -
  85. 16));
  86. acpi_os_printf(" */\n");
  87. /*
  88. * Just abort the disassembly, cannot continue because the
  89. * parser is essentially lost. The disassembler can then
  90. * randomly fail because an ill-constructed parse tree
  91. * can result.
  92. */
  93. return_ACPI_STATUS(AE_AML_BAD_OPCODE);
  94. #endif
  95. }
  96. /* Increment past one-byte or two-byte opcode */
  97. walk_state->parser_state.aml++;
  98. if (walk_state->opcode > 0xFF) { /* Can only happen if first byte is 0x5B */
  99. walk_state->parser_state.aml++;
  100. }
  101. return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
  102. default:
  103. /* Found opcode info, this is a normal opcode */
  104. walk_state->parser_state.aml +=
  105. acpi_ps_get_opcode_size(walk_state->opcode);
  106. walk_state->arg_types = walk_state->op_info->parse_args;
  107. break;
  108. }
  109. return_ACPI_STATUS(AE_OK);
  110. }
  111. /*******************************************************************************
  112. *
  113. * FUNCTION: acpi_ps_build_named_op
  114. *
  115. * PARAMETERS: walk_state - Current state
  116. * aml_op_start - Begin of named Op in AML
  117. * unnamed_op - Early Op (not a named Op)
  118. * op - Returned Op
  119. *
  120. * RETURN: Status
  121. *
  122. * DESCRIPTION: Parse a named Op
  123. *
  124. ******************************************************************************/
  125. acpi_status
  126. acpi_ps_build_named_op(struct acpi_walk_state *walk_state,
  127. u8 *aml_op_start,
  128. union acpi_parse_object *unnamed_op,
  129. union acpi_parse_object **op)
  130. {
  131. acpi_status status = AE_OK;
  132. union acpi_parse_object *arg = NULL;
  133. ACPI_FUNCTION_TRACE_PTR(ps_build_named_op, walk_state);
  134. unnamed_op->common.value.arg = NULL;
  135. unnamed_op->common.arg_list_length = 0;
  136. unnamed_op->common.aml_opcode = walk_state->opcode;
  137. /*
  138. * Get and append arguments until we find the node that contains
  139. * the name (the type ARGP_NAME).
  140. */
  141. while (GET_CURRENT_ARG_TYPE(walk_state->arg_types) &&
  142. (GET_CURRENT_ARG_TYPE(walk_state->arg_types) != ARGP_NAME)) {
  143. ASL_CV_CAPTURE_COMMENTS(walk_state);
  144. status =
  145. acpi_ps_get_next_arg(walk_state,
  146. &(walk_state->parser_state),
  147. GET_CURRENT_ARG_TYPE(walk_state->
  148. arg_types), &arg);
  149. if (ACPI_FAILURE(status)) {
  150. return_ACPI_STATUS(status);
  151. }
  152. acpi_ps_append_arg(unnamed_op, arg);
  153. INCREMENT_ARG_LIST(walk_state->arg_types);
  154. }
  155. /* are there any inline comments associated with the name_seg?? If so, save this. */
  156. ASL_CV_CAPTURE_COMMENTS(walk_state);
  157. #ifdef ACPI_ASL_COMPILER
  158. if (acpi_gbl_current_inline_comment != NULL) {
  159. unnamed_op->common.name_comment =
  160. acpi_gbl_current_inline_comment;
  161. acpi_gbl_current_inline_comment = NULL;
  162. }
  163. #endif
  164. /*
  165. * Make sure that we found a NAME and didn't run out of arguments
  166. */
  167. if (!GET_CURRENT_ARG_TYPE(walk_state->arg_types)) {
  168. return_ACPI_STATUS(AE_AML_NO_OPERAND);
  169. }
  170. /* We know that this arg is a name, move to next arg */
  171. INCREMENT_ARG_LIST(walk_state->arg_types);
  172. /*
  173. * Find the object. This will either insert the object into
  174. * the namespace or simply look it up
  175. */
  176. walk_state->op = NULL;
  177. status = walk_state->descending_callback(walk_state, op);
  178. if (ACPI_FAILURE(status)) {
  179. if (status != AE_CTRL_TERMINATE) {
  180. ACPI_EXCEPTION((AE_INFO, status,
  181. "During name lookup/catalog"));
  182. }
  183. return_ACPI_STATUS(status);
  184. }
  185. if (!*op) {
  186. return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
  187. }
  188. status = acpi_ps_next_parse_state(walk_state, *op, status);
  189. if (ACPI_FAILURE(status)) {
  190. if (status == AE_CTRL_PENDING) {
  191. status = AE_CTRL_PARSE_PENDING;
  192. }
  193. return_ACPI_STATUS(status);
  194. }
  195. acpi_ps_append_arg(*op, unnamed_op->common.value.arg);
  196. #ifdef ACPI_ASL_COMPILER
  197. /* save any comments that might be associated with unnamed_op. */
  198. (*op)->common.inline_comment = unnamed_op->common.inline_comment;
  199. (*op)->common.end_node_comment = unnamed_op->common.end_node_comment;
  200. (*op)->common.close_brace_comment =
  201. unnamed_op->common.close_brace_comment;
  202. (*op)->common.name_comment = unnamed_op->common.name_comment;
  203. (*op)->common.comment_list = unnamed_op->common.comment_list;
  204. (*op)->common.end_blk_comment = unnamed_op->common.end_blk_comment;
  205. (*op)->common.cv_filename = unnamed_op->common.cv_filename;
  206. (*op)->common.cv_parent_filename =
  207. unnamed_op->common.cv_parent_filename;
  208. (*op)->named.aml = unnamed_op->common.aml;
  209. unnamed_op->common.inline_comment = NULL;
  210. unnamed_op->common.end_node_comment = NULL;
  211. unnamed_op->common.close_brace_comment = NULL;
  212. unnamed_op->common.name_comment = NULL;
  213. unnamed_op->common.comment_list = NULL;
  214. unnamed_op->common.end_blk_comment = NULL;
  215. #endif
  216. if ((*op)->common.aml_opcode == AML_REGION_OP ||
  217. (*op)->common.aml_opcode == AML_DATA_REGION_OP) {
  218. /*
  219. * Defer final parsing of an operation_region body, because we don't
  220. * have enough info in the first pass to parse it correctly (i.e.,
  221. * there may be method calls within the term_arg elements of the body.)
  222. *
  223. * However, we must continue parsing because the opregion is not a
  224. * standalone package -- we don't know where the end is at this point.
  225. *
  226. * (Length is unknown until parse of the body complete)
  227. */
  228. (*op)->named.data = aml_op_start;
  229. (*op)->named.length = 0;
  230. }
  231. return_ACPI_STATUS(AE_OK);
  232. }
  233. /*******************************************************************************
  234. *
  235. * FUNCTION: acpi_ps_create_op
  236. *
  237. * PARAMETERS: walk_state - Current state
  238. * aml_op_start - Op start in AML
  239. * new_op - Returned Op
  240. *
  241. * RETURN: Status
  242. *
  243. * DESCRIPTION: Get Op from AML
  244. *
  245. ******************************************************************************/
  246. acpi_status
  247. acpi_ps_create_op(struct acpi_walk_state *walk_state,
  248. u8 *aml_op_start, union acpi_parse_object **new_op)
  249. {
  250. acpi_status status = AE_OK;
  251. union acpi_parse_object *op;
  252. union acpi_parse_object *named_op = NULL;
  253. union acpi_parse_object *parent_scope;
  254. u8 argument_count;
  255. const struct acpi_opcode_info *op_info;
  256. ACPI_FUNCTION_TRACE_PTR(ps_create_op, walk_state);
  257. status = acpi_ps_get_aml_opcode(walk_state);
  258. if (status == AE_CTRL_PARSE_CONTINUE) {
  259. return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
  260. }
  261. if (ACPI_FAILURE(status)) {
  262. return_ACPI_STATUS(status);
  263. }
  264. /* Create Op structure and append to parent's argument list */
  265. walk_state->op_info = acpi_ps_get_opcode_info(walk_state->opcode);
  266. op = acpi_ps_alloc_op(walk_state->opcode, aml_op_start);
  267. if (!op) {
  268. return_ACPI_STATUS(AE_NO_MEMORY);
  269. }
  270. if (walk_state->op_info->flags & AML_NAMED) {
  271. status =
  272. acpi_ps_build_named_op(walk_state, aml_op_start, op,
  273. &named_op);
  274. acpi_ps_free_op(op);
  275. #ifdef ACPI_ASL_COMPILER
  276. if (acpi_gbl_disasm_flag
  277. && walk_state->opcode == AML_EXTERNAL_OP
  278. && status == AE_NOT_FOUND) {
  279. /*
  280. * If parsing of AML_EXTERNAL_OP's name path fails, then skip
  281. * past this opcode and keep parsing. This is a much better
  282. * alternative than to abort the entire disassembler. At this
  283. * point, the parser_state is at the end of the namepath of the
  284. * external declaration opcode. Setting walk_state->Aml to
  285. * walk_state->parser_state.Aml + 2 moves increments the
  286. * walk_state->Aml past the object type and the paramcount of the
  287. * external opcode.
  288. */
  289. walk_state->aml = walk_state->parser_state.aml + 2;
  290. walk_state->parser_state.aml = walk_state->aml;
  291. return_ACPI_STATUS(AE_CTRL_PARSE_CONTINUE);
  292. }
  293. #endif
  294. if (ACPI_FAILURE(status)) {
  295. return_ACPI_STATUS(status);
  296. }
  297. *new_op = named_op;
  298. return_ACPI_STATUS(AE_OK);
  299. }
  300. /* Not a named opcode, just allocate Op and append to parent */
  301. if (walk_state->op_info->flags & AML_CREATE) {
  302. /*
  303. * Backup to beginning of create_XXXfield declaration
  304. * body_length is unknown until we parse the body
  305. */
  306. op->named.data = aml_op_start;
  307. op->named.length = 0;
  308. }
  309. if (walk_state->opcode == AML_BANK_FIELD_OP) {
  310. /*
  311. * Backup to beginning of bank_field declaration
  312. * body_length is unknown until we parse the body
  313. */
  314. op->named.data = aml_op_start;
  315. op->named.length = 0;
  316. }
  317. parent_scope = acpi_ps_get_parent_scope(&(walk_state->parser_state));
  318. acpi_ps_append_arg(parent_scope, op);
  319. if (parent_scope) {
  320. op_info =
  321. acpi_ps_get_opcode_info(parent_scope->common.aml_opcode);
  322. if (op_info->flags & AML_HAS_TARGET) {
  323. argument_count =
  324. acpi_ps_get_argument_count(op_info->type);
  325. if (parent_scope->common.arg_list_length >
  326. argument_count) {
  327. op->common.flags |= ACPI_PARSEOP_TARGET;
  328. }
  329. }
  330. /*
  331. * Special case for both Increment() and Decrement(), where
  332. * the lone argument is both a source and a target.
  333. */
  334. else if ((parent_scope->common.aml_opcode == AML_INCREMENT_OP)
  335. || (parent_scope->common.aml_opcode ==
  336. AML_DECREMENT_OP)) {
  337. op->common.flags |= ACPI_PARSEOP_TARGET;
  338. }
  339. }
  340. if (walk_state->descending_callback != NULL) {
  341. /*
  342. * Find the object. This will either insert the object into
  343. * the namespace or simply look it up
  344. */
  345. walk_state->op = *new_op = op;
  346. status = walk_state->descending_callback(walk_state, &op);
  347. status = acpi_ps_next_parse_state(walk_state, op, status);
  348. if (status == AE_CTRL_PENDING) {
  349. status = AE_CTRL_PARSE_PENDING;
  350. }
  351. }
  352. return_ACPI_STATUS(status);
  353. }
  354. /*******************************************************************************
  355. *
  356. * FUNCTION: acpi_ps_complete_op
  357. *
  358. * PARAMETERS: walk_state - Current state
  359. * op - Returned Op
  360. * status - Parse status before complete Op
  361. *
  362. * RETURN: Status
  363. *
  364. * DESCRIPTION: Complete Op
  365. *
  366. ******************************************************************************/
  367. acpi_status
  368. acpi_ps_complete_op(struct acpi_walk_state *walk_state,
  369. union acpi_parse_object **op, acpi_status status)
  370. {
  371. acpi_status status2;
  372. ACPI_FUNCTION_TRACE_PTR(ps_complete_op, walk_state);
  373. /*
  374. * Finished one argument of the containing scope
  375. */
  376. walk_state->parser_state.scope->parse_scope.arg_count--;
  377. /* Close this Op (will result in parse subtree deletion) */
  378. status2 = acpi_ps_complete_this_op(walk_state, *op);
  379. if (ACPI_FAILURE(status2)) {
  380. return_ACPI_STATUS(status2);
  381. }
  382. *op = NULL;
  383. switch (status) {
  384. case AE_OK:
  385. break;
  386. case AE_CTRL_TRANSFER:
  387. /* We are about to transfer to a called method */
  388. walk_state->prev_op = NULL;
  389. walk_state->prev_arg_types = walk_state->arg_types;
  390. return_ACPI_STATUS(status);
  391. case AE_CTRL_END:
  392. acpi_ps_pop_scope(&(walk_state->parser_state), op,
  393. &walk_state->arg_types,
  394. &walk_state->arg_count);
  395. if (*op) {
  396. walk_state->op = *op;
  397. walk_state->op_info =
  398. acpi_ps_get_opcode_info((*op)->common.aml_opcode);
  399. walk_state->opcode = (*op)->common.aml_opcode;
  400. status = walk_state->ascending_callback(walk_state);
  401. (void)acpi_ps_next_parse_state(walk_state, *op, status);
  402. status2 = acpi_ps_complete_this_op(walk_state, *op);
  403. if (ACPI_FAILURE(status2)) {
  404. return_ACPI_STATUS(status2);
  405. }
  406. }
  407. break;
  408. case AE_CTRL_BREAK:
  409. case AE_CTRL_CONTINUE:
  410. /* Pop off scopes until we find the While */
  411. while (!(*op) || ((*op)->common.aml_opcode != AML_WHILE_OP)) {
  412. acpi_ps_pop_scope(&(walk_state->parser_state), op,
  413. &walk_state->arg_types,
  414. &walk_state->arg_count);
  415. }
  416. /* Close this iteration of the While loop */
  417. walk_state->op = *op;
  418. walk_state->op_info =
  419. acpi_ps_get_opcode_info((*op)->common.aml_opcode);
  420. walk_state->opcode = (*op)->common.aml_opcode;
  421. status = walk_state->ascending_callback(walk_state);
  422. (void)acpi_ps_next_parse_state(walk_state, *op, status);
  423. status2 = acpi_ps_complete_this_op(walk_state, *op);
  424. if (ACPI_FAILURE(status2)) {
  425. return_ACPI_STATUS(status2);
  426. }
  427. break;
  428. case AE_CTRL_TERMINATE:
  429. /* Clean up */
  430. do {
  431. if (*op) {
  432. status2 =
  433. acpi_ps_complete_this_op(walk_state, *op);
  434. if (ACPI_FAILURE(status2)) {
  435. return_ACPI_STATUS(status2);
  436. }
  437. acpi_ut_delete_generic_state
  438. (acpi_ut_pop_generic_state
  439. (&walk_state->control_state));
  440. }
  441. acpi_ps_pop_scope(&(walk_state->parser_state), op,
  442. &walk_state->arg_types,
  443. &walk_state->arg_count);
  444. } while (*op);
  445. return_ACPI_STATUS(AE_OK);
  446. default: /* All other non-AE_OK status */
  447. do {
  448. if (*op) {
  449. /*
  450. * These Opcodes need to be removed from the namespace because they
  451. * get created even if these opcodes cannot be created due to
  452. * errors.
  453. */
  454. if (((*op)->common.aml_opcode == AML_REGION_OP)
  455. || ((*op)->common.aml_opcode ==
  456. AML_DATA_REGION_OP)) {
  457. acpi_ns_delete_children((*op)->common.
  458. node);
  459. acpi_ns_remove_node((*op)->common.node);
  460. (*op)->common.node = NULL;
  461. acpi_ps_delete_parse_tree(*op);
  462. }
  463. status2 =
  464. acpi_ps_complete_this_op(walk_state, *op);
  465. if (ACPI_FAILURE(status2)) {
  466. return_ACPI_STATUS(status2);
  467. }
  468. }
  469. acpi_ps_pop_scope(&(walk_state->parser_state), op,
  470. &walk_state->arg_types,
  471. &walk_state->arg_count);
  472. } while (*op);
  473. #if 0
  474. /*
  475. * TBD: Cleanup parse ops on error
  476. */
  477. if (*op == NULL) {
  478. acpi_ps_pop_scope(parser_state, op,
  479. &walk_state->arg_types,
  480. &walk_state->arg_count);
  481. }
  482. #endif
  483. walk_state->prev_op = NULL;
  484. walk_state->prev_arg_types = walk_state->arg_types;
  485. if (walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL) {
  486. /*
  487. * There was something that went wrong while executing code at the
  488. * module-level. We need to skip parsing whatever caused the
  489. * error and keep going. One runtime error during the table load
  490. * should not cause the entire table to not be loaded. This is
  491. * because there could be correct AML beyond the parts that caused
  492. * the runtime error.
  493. */
  494. ACPI_INFO(("Ignoring error and continuing table load"));
  495. return_ACPI_STATUS(AE_OK);
  496. }
  497. return_ACPI_STATUS(status);
  498. }
  499. /* This scope complete? */
  500. if (acpi_ps_has_completed_scope(&(walk_state->parser_state))) {
  501. acpi_ps_pop_scope(&(walk_state->parser_state), op,
  502. &walk_state->arg_types,
  503. &walk_state->arg_count);
  504. ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "Popped scope, Op=%p\n", *op));
  505. } else {
  506. *op = NULL;
  507. }
  508. return_ACPI_STATUS(AE_OK);
  509. }
  510. /*******************************************************************************
  511. *
  512. * FUNCTION: acpi_ps_complete_final_op
  513. *
  514. * PARAMETERS: walk_state - Current state
  515. * op - Current Op
  516. * status - Current parse status before complete last
  517. * Op
  518. *
  519. * RETURN: Status
  520. *
  521. * DESCRIPTION: Complete last Op.
  522. *
  523. ******************************************************************************/
  524. acpi_status
  525. acpi_ps_complete_final_op(struct acpi_walk_state *walk_state,
  526. union acpi_parse_object *op, acpi_status status)
  527. {
  528. acpi_status status2;
  529. ACPI_FUNCTION_TRACE_PTR(ps_complete_final_op, walk_state);
  530. /*
  531. * Complete the last Op (if not completed), and clear the scope stack.
  532. * It is easily possible to end an AML "package" with an unbounded number
  533. * of open scopes (such as when several ASL blocks are closed with
  534. * sequential closing braces). We want to terminate each one cleanly.
  535. */
  536. ACPI_DEBUG_PRINT((ACPI_DB_PARSE, "AML package complete at Op %p\n",
  537. op));
  538. do {
  539. if (op) {
  540. if (walk_state->ascending_callback != NULL) {
  541. walk_state->op = op;
  542. walk_state->op_info =
  543. acpi_ps_get_opcode_info(op->common.
  544. aml_opcode);
  545. walk_state->opcode = op->common.aml_opcode;
  546. status =
  547. walk_state->ascending_callback(walk_state);
  548. status =
  549. acpi_ps_next_parse_state(walk_state, op,
  550. status);
  551. if (status == AE_CTRL_PENDING) {
  552. status =
  553. acpi_ps_complete_op(walk_state, &op,
  554. AE_OK);
  555. if (ACPI_FAILURE(status)) {
  556. return_ACPI_STATUS(status);
  557. }
  558. }
  559. if (status == AE_CTRL_TERMINATE) {
  560. status = AE_OK;
  561. /* Clean up */
  562. do {
  563. if (op) {
  564. status2 =
  565. acpi_ps_complete_this_op
  566. (walk_state, op);
  567. if (ACPI_FAILURE
  568. (status2)) {
  569. return_ACPI_STATUS
  570. (status2);
  571. }
  572. }
  573. acpi_ps_pop_scope(&
  574. (walk_state->
  575. parser_state),
  576. &op,
  577. &walk_state->
  578. arg_types,
  579. &walk_state->
  580. arg_count);
  581. } while (op);
  582. return_ACPI_STATUS(status);
  583. }
  584. else if (ACPI_FAILURE(status)) {
  585. /* First error is most important */
  586. (void)
  587. acpi_ps_complete_this_op(walk_state,
  588. op);
  589. return_ACPI_STATUS(status);
  590. }
  591. }
  592. status2 = acpi_ps_complete_this_op(walk_state, op);
  593. if (ACPI_FAILURE(status2)) {
  594. return_ACPI_STATUS(status2);
  595. }
  596. }
  597. acpi_ps_pop_scope(&(walk_state->parser_state), &op,
  598. &walk_state->arg_types,
  599. &walk_state->arg_count);
  600. } while (op);
  601. return_ACPI_STATUS(status);
  602. }