psobject.c 19 KB

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