dsutils.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744
  1. /*******************************************************************************
  2. *
  3. * Module Name: dsutils - Dispatcher utilities
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, R. Byron Moore
  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 <acpi/acparser.h>
  44. #include <acpi/amlcode.h>
  45. #include <acpi/acdispat.h>
  46. #include <acpi/acinterp.h>
  47. #include <acpi/acnamesp.h>
  48. #include <acpi/acdebug.h>
  49. #define _COMPONENT ACPI_DISPATCHER
  50. ACPI_MODULE_NAME ("dsutils")
  51. /*******************************************************************************
  52. *
  53. * FUNCTION: acpi_ds_clear_implicit_return
  54. *
  55. * PARAMETERS: walk_state - Current State
  56. *
  57. * RETURN: None.
  58. *
  59. * DESCRIPTION: Clear and remove a reference on an implicit return value. Used
  60. * to delete "stale" return values (if enabled, the return value
  61. * from every operator is saved at least momentarily, in case the
  62. * parent method exits.)
  63. *
  64. ******************************************************************************/
  65. void
  66. acpi_ds_clear_implicit_return (
  67. struct acpi_walk_state *walk_state)
  68. {
  69. ACPI_FUNCTION_NAME ("ds_clear_implicit_return");
  70. /*
  71. * Slack must be enabled for this feature
  72. */
  73. if (!acpi_gbl_enable_interpreter_slack) {
  74. return;
  75. }
  76. if (walk_state->implicit_return_obj) {
  77. /*
  78. * Delete any "stale" implicit return. However, in
  79. * complex statements, the implicit return value can be
  80. * bubbled up several levels.
  81. */
  82. ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
  83. "Removing reference on stale implicit return obj %p\n",
  84. walk_state->implicit_return_obj));
  85. acpi_ut_remove_reference (walk_state->implicit_return_obj);
  86. walk_state->implicit_return_obj = NULL;
  87. }
  88. }
  89. #ifndef ACPI_NO_METHOD_EXECUTION
  90. /*******************************************************************************
  91. *
  92. * FUNCTION: acpi_ds_do_implicit_return
  93. *
  94. * PARAMETERS: return_desc - The return value
  95. * walk_state - Current State
  96. * add_reference - True if a reference should be added to the
  97. * return object
  98. *
  99. * RETURN: TRUE if implicit return enabled, FALSE otherwise
  100. *
  101. * DESCRIPTION: Implements the optional "implicit return". We save the result
  102. * of every ASL operator and control method invocation in case the
  103. * parent method exit. Before storing a new return value, we
  104. * delete the previous return value.
  105. *
  106. ******************************************************************************/
  107. u8
  108. acpi_ds_do_implicit_return (
  109. union acpi_operand_object *return_desc,
  110. struct acpi_walk_state *walk_state,
  111. u8 add_reference)
  112. {
  113. ACPI_FUNCTION_NAME ("ds_do_implicit_return");
  114. /*
  115. * Slack must be enabled for this feature, and we must
  116. * have a valid return object
  117. */
  118. if ((!acpi_gbl_enable_interpreter_slack) ||
  119. (!return_desc)) {
  120. return (FALSE);
  121. }
  122. ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
  123. "Result %p will be implicitly returned; Prev=%p\n",
  124. return_desc,
  125. walk_state->implicit_return_obj));
  126. /*
  127. * Delete any "stale" implicit return value first. However, in
  128. * complex statements, the implicit return value can be
  129. * bubbled up several levels, so we don't clear the value if it
  130. * is the same as the return_desc.
  131. */
  132. if (walk_state->implicit_return_obj) {
  133. if (walk_state->implicit_return_obj == return_desc) {
  134. return (TRUE);
  135. }
  136. acpi_ds_clear_implicit_return (walk_state);
  137. }
  138. /* Save the implicit return value, add a reference if requested */
  139. walk_state->implicit_return_obj = return_desc;
  140. if (add_reference) {
  141. acpi_ut_add_reference (return_desc);
  142. }
  143. return (TRUE);
  144. }
  145. /*******************************************************************************
  146. *
  147. * FUNCTION: acpi_ds_is_result_used
  148. *
  149. * PARAMETERS: Op - Current Op
  150. * walk_state - Current State
  151. *
  152. * RETURN: TRUE if result is used, FALSE otherwise
  153. *
  154. * DESCRIPTION: Check if a result object will be used by the parent
  155. *
  156. ******************************************************************************/
  157. u8
  158. acpi_ds_is_result_used (
  159. union acpi_parse_object *op,
  160. struct acpi_walk_state *walk_state)
  161. {
  162. const struct acpi_opcode_info *parent_info;
  163. ACPI_FUNCTION_TRACE_PTR ("ds_is_result_used", op);
  164. /* Must have both an Op and a Result Object */
  165. if (!op) {
  166. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n"));
  167. return_VALUE (TRUE);
  168. }
  169. /*
  170. * We know that this operator is not a
  171. * Return() operator (would not come here.) The following code is the
  172. * optional support for a so-called "implicit return". Some AML code
  173. * assumes that the last value of the method is "implicitly" returned
  174. * to the caller. Just save the last result as the return value.
  175. * NOTE: this is optional because the ASL language does not actually
  176. * support this behavior.
  177. */
  178. acpi_ds_do_implicit_return (walk_state->result_obj, walk_state, TRUE);
  179. /*
  180. * Now determine if the parent will use the result
  181. *
  182. * If there is no parent, or the parent is a scope_op, we are executing
  183. * at the method level. An executing method typically has no parent,
  184. * since each method is parsed separately. A method invoked externally
  185. * via execute_control_method has a scope_op as the parent.
  186. */
  187. if ((!op->common.parent) ||
  188. (op->common.parent->common.aml_opcode == AML_SCOPE_OP)) {
  189. /* No parent, the return value cannot possibly be used */
  190. ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "At Method level, result of [%s] not used\n",
  191. acpi_ps_get_opcode_name (op->common.aml_opcode)));
  192. return_VALUE (FALSE);
  193. }
  194. /* Get info on the parent. The root_op is AML_SCOPE */
  195. parent_info = acpi_ps_get_opcode_info (op->common.parent->common.aml_opcode);
  196. if (parent_info->class == AML_CLASS_UNKNOWN) {
  197. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown parent opcode. Op=%p\n", op));
  198. return_VALUE (FALSE);
  199. }
  200. /*
  201. * Decide what to do with the result based on the parent. If
  202. * the parent opcode will not use the result, delete the object.
  203. * Otherwise leave it as is, it will be deleted when it is used
  204. * as an operand later.
  205. */
  206. switch (parent_info->class) {
  207. case AML_CLASS_CONTROL:
  208. switch (op->common.parent->common.aml_opcode) {
  209. case AML_RETURN_OP:
  210. /* Never delete the return value associated with a return opcode */
  211. goto result_used;
  212. case AML_IF_OP:
  213. case AML_WHILE_OP:
  214. /*
  215. * If we are executing the predicate AND this is the predicate op,
  216. * we will use the return value
  217. */
  218. if ((walk_state->control_state->common.state == ACPI_CONTROL_PREDICATE_EXECUTING) &&
  219. (walk_state->control_state->control.predicate_op == op)) {
  220. goto result_used;
  221. }
  222. break;
  223. default:
  224. /* Ignore other control opcodes */
  225. break;
  226. }
  227. /* The general control opcode returns no result */
  228. goto result_not_used;
  229. case AML_CLASS_CREATE:
  230. /*
  231. * These opcodes allow term_arg(s) as operands and therefore
  232. * the operands can be method calls. The result is used.
  233. */
  234. goto result_used;
  235. case AML_CLASS_NAMED_OBJECT:
  236. if ((op->common.parent->common.aml_opcode == AML_REGION_OP) ||
  237. (op->common.parent->common.aml_opcode == AML_DATA_REGION_OP) ||
  238. (op->common.parent->common.aml_opcode == AML_PACKAGE_OP) ||
  239. (op->common.parent->common.aml_opcode == AML_VAR_PACKAGE_OP) ||
  240. (op->common.parent->common.aml_opcode == AML_BUFFER_OP) ||
  241. (op->common.parent->common.aml_opcode == AML_INT_EVAL_SUBTREE_OP)) {
  242. /*
  243. * These opcodes allow term_arg(s) as operands and therefore
  244. * the operands can be method calls. The result is used.
  245. */
  246. goto result_used;
  247. }
  248. goto result_not_used;
  249. default:
  250. /*
  251. * In all other cases. the parent will actually use the return
  252. * object, so keep it.
  253. */
  254. goto result_used;
  255. }
  256. result_used:
  257. ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] used by Parent [%s] Op=%p\n",
  258. acpi_ps_get_opcode_name (op->common.aml_opcode),
  259. acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
  260. return_VALUE (TRUE);
  261. result_not_used:
  262. ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Result of [%s] not used by Parent [%s] Op=%p\n",
  263. acpi_ps_get_opcode_name (op->common.aml_opcode),
  264. acpi_ps_get_opcode_name (op->common.parent->common.aml_opcode), op));
  265. return_VALUE (FALSE);
  266. }
  267. /*******************************************************************************
  268. *
  269. * FUNCTION: acpi_ds_delete_result_if_not_used
  270. *
  271. * PARAMETERS: Op - Current parse Op
  272. * result_obj - Result of the operation
  273. * walk_state - Current state
  274. *
  275. * RETURN: Status
  276. *
  277. * DESCRIPTION: Used after interpretation of an opcode. If there is an internal
  278. * result descriptor, check if the parent opcode will actually use
  279. * this result. If not, delete the result now so that it will
  280. * not become orphaned.
  281. *
  282. ******************************************************************************/
  283. void
  284. acpi_ds_delete_result_if_not_used (
  285. union acpi_parse_object *op,
  286. union acpi_operand_object *result_obj,
  287. struct acpi_walk_state *walk_state)
  288. {
  289. union acpi_operand_object *obj_desc;
  290. acpi_status status;
  291. ACPI_FUNCTION_TRACE_PTR ("ds_delete_result_if_not_used", result_obj);
  292. if (!op) {
  293. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null Op\n"));
  294. return_VOID;
  295. }
  296. if (!result_obj) {
  297. return_VOID;
  298. }
  299. if (!acpi_ds_is_result_used (op, walk_state)) {
  300. /* Must pop the result stack (obj_desc should be equal to result_obj) */
  301. status = acpi_ds_result_pop (&obj_desc, walk_state);
  302. if (ACPI_SUCCESS (status)) {
  303. acpi_ut_remove_reference (result_obj);
  304. }
  305. }
  306. return_VOID;
  307. }
  308. /*******************************************************************************
  309. *
  310. * FUNCTION: acpi_ds_resolve_operands
  311. *
  312. * PARAMETERS: walk_state - Current walk state with operands on stack
  313. *
  314. * RETURN: Status
  315. *
  316. * DESCRIPTION: Resolve all operands to their values. Used to prepare
  317. * arguments to a control method invocation (a call from one
  318. * method to another.)
  319. *
  320. ******************************************************************************/
  321. acpi_status
  322. acpi_ds_resolve_operands (
  323. struct acpi_walk_state *walk_state)
  324. {
  325. u32 i;
  326. acpi_status status = AE_OK;
  327. ACPI_FUNCTION_TRACE_PTR ("ds_resolve_operands", walk_state);
  328. /*
  329. * Attempt to resolve each of the valid operands
  330. * Method arguments are passed by reference, not by value. This means
  331. * that the actual objects are passed, not copies of the objects.
  332. */
  333. for (i = 0; i < walk_state->num_operands; i++) {
  334. status = acpi_ex_resolve_to_value (&walk_state->operands[i], walk_state);
  335. if (ACPI_FAILURE (status)) {
  336. break;
  337. }
  338. }
  339. return_ACPI_STATUS (status);
  340. }
  341. /*******************************************************************************
  342. *
  343. * FUNCTION: acpi_ds_clear_operands
  344. *
  345. * PARAMETERS: walk_state - Current walk state with operands on stack
  346. *
  347. * RETURN: None
  348. *
  349. * DESCRIPTION: Clear all operands on the current walk state operand stack.
  350. *
  351. ******************************************************************************/
  352. void
  353. acpi_ds_clear_operands (
  354. struct acpi_walk_state *walk_state)
  355. {
  356. u32 i;
  357. ACPI_FUNCTION_TRACE_PTR ("ds_clear_operands", walk_state);
  358. /* Remove a reference on each operand on the stack */
  359. for (i = 0; i < walk_state->num_operands; i++) {
  360. /*
  361. * Remove a reference to all operands, including both
  362. * "Arguments" and "Targets".
  363. */
  364. acpi_ut_remove_reference (walk_state->operands[i]);
  365. walk_state->operands[i] = NULL;
  366. }
  367. walk_state->num_operands = 0;
  368. return_VOID;
  369. }
  370. #endif
  371. /*******************************************************************************
  372. *
  373. * FUNCTION: acpi_ds_create_operand
  374. *
  375. * PARAMETERS: walk_state - Current walk state
  376. * Arg - Parse object for the argument
  377. * arg_index - Which argument (zero based)
  378. *
  379. * RETURN: Status
  380. *
  381. * DESCRIPTION: Translate a parse tree object that is an argument to an AML
  382. * opcode to the equivalent interpreter object. This may include
  383. * looking up a name or entering a new name into the internal
  384. * namespace.
  385. *
  386. ******************************************************************************/
  387. acpi_status
  388. acpi_ds_create_operand (
  389. struct acpi_walk_state *walk_state,
  390. union acpi_parse_object *arg,
  391. u32 arg_index)
  392. {
  393. acpi_status status = AE_OK;
  394. char *name_string;
  395. u32 name_length;
  396. union acpi_operand_object *obj_desc;
  397. union acpi_parse_object *parent_op;
  398. u16 opcode;
  399. acpi_interpreter_mode interpreter_mode;
  400. const struct acpi_opcode_info *op_info;
  401. ACPI_FUNCTION_TRACE_PTR ("ds_create_operand", arg);
  402. /* A valid name must be looked up in the namespace */
  403. if ((arg->common.aml_opcode == AML_INT_NAMEPATH_OP) &&
  404. (arg->common.value.string)) {
  405. ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Getting a name: Arg=%p\n", arg));
  406. /* Get the entire name string from the AML stream */
  407. status = acpi_ex_get_name_string (ACPI_TYPE_ANY, arg->common.value.buffer,
  408. &name_string, &name_length);
  409. if (ACPI_FAILURE (status)) {
  410. return_ACPI_STATUS (status);
  411. }
  412. /* All prefixes have been handled, and the name is in name_string */
  413. /*
  414. * Special handling for buffer_field declarations. This is a deferred
  415. * opcode that unfortunately defines the field name as the last
  416. * parameter instead of the first. We get here when we are performing
  417. * the deferred execution, so the actual name of the field is already
  418. * in the namespace. We don't want to attempt to look it up again
  419. * because we may be executing in a different scope than where the
  420. * actual opcode exists.
  421. */
  422. if ((walk_state->deferred_node) &&
  423. (walk_state->deferred_node->type == ACPI_TYPE_BUFFER_FIELD) &&
  424. (arg_index != 0)) {
  425. obj_desc = ACPI_CAST_PTR (union acpi_operand_object, walk_state->deferred_node);
  426. status = AE_OK;
  427. }
  428. else /* All other opcodes */ {
  429. /*
  430. * Differentiate between a namespace "create" operation
  431. * versus a "lookup" operation (IMODE_LOAD_PASS2 vs.
  432. * IMODE_EXECUTE) in order to support the creation of
  433. * namespace objects during the execution of control methods.
  434. */
  435. parent_op = arg->common.parent;
  436. op_info = acpi_ps_get_opcode_info (parent_op->common.aml_opcode);
  437. if ((op_info->flags & AML_NSNODE) &&
  438. (parent_op->common.aml_opcode != AML_INT_METHODCALL_OP) &&
  439. (parent_op->common.aml_opcode != AML_REGION_OP) &&
  440. (parent_op->common.aml_opcode != AML_INT_NAMEPATH_OP)) {
  441. /* Enter name into namespace if not found */
  442. interpreter_mode = ACPI_IMODE_LOAD_PASS2;
  443. }
  444. else {
  445. /* Return a failure if name not found */
  446. interpreter_mode = ACPI_IMODE_EXECUTE;
  447. }
  448. status = acpi_ns_lookup (walk_state->scope_info, name_string,
  449. ACPI_TYPE_ANY, interpreter_mode,
  450. ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
  451. walk_state,
  452. ACPI_CAST_INDIRECT_PTR (struct acpi_namespace_node, &obj_desc));
  453. /*
  454. * The only case where we pass through (ignore) a NOT_FOUND
  455. * error is for the cond_ref_of opcode.
  456. */
  457. if (status == AE_NOT_FOUND) {
  458. if (parent_op->common.aml_opcode == AML_COND_REF_OF_OP) {
  459. /*
  460. * For the Conditional Reference op, it's OK if
  461. * the name is not found; We just need a way to
  462. * indicate this to the interpreter, set the
  463. * object to the root
  464. */
  465. obj_desc = ACPI_CAST_PTR (union acpi_operand_object, acpi_gbl_root_node);
  466. status = AE_OK;
  467. }
  468. else {
  469. /*
  470. * We just plain didn't find it -- which is a
  471. * very serious error at this point
  472. */
  473. status = AE_AML_NAME_NOT_FOUND;
  474. }
  475. }
  476. if (ACPI_FAILURE (status)) {
  477. ACPI_REPORT_NSERROR (name_string, status);
  478. }
  479. }
  480. /* Free the namestring created above */
  481. ACPI_MEM_FREE (name_string);
  482. /* Check status from the lookup */
  483. if (ACPI_FAILURE (status)) {
  484. return_ACPI_STATUS (status);
  485. }
  486. /* Put the resulting object onto the current object stack */
  487. status = acpi_ds_obj_stack_push (obj_desc, walk_state);
  488. if (ACPI_FAILURE (status)) {
  489. return_ACPI_STATUS (status);
  490. }
  491. ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
  492. }
  493. else {
  494. /* Check for null name case */
  495. if (arg->common.aml_opcode == AML_INT_NAMEPATH_OP) {
  496. /*
  497. * If the name is null, this means that this is an
  498. * optional result parameter that was not specified
  499. * in the original ASL. Create a Zero Constant for a
  500. * placeholder. (Store to a constant is a Noop.)
  501. */
  502. opcode = AML_ZERO_OP; /* Has no arguments! */
  503. ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Null namepath: Arg=%p\n", arg));
  504. }
  505. else {
  506. opcode = arg->common.aml_opcode;
  507. }
  508. /* Get the object type of the argument */
  509. op_info = acpi_ps_get_opcode_info (opcode);
  510. if (op_info->object_type == ACPI_TYPE_INVALID) {
  511. return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
  512. }
  513. if (op_info->flags & AML_HAS_RETVAL) {
  514. ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
  515. "Argument previously created, already stacked \n"));
  516. ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (
  517. walk_state->operands [walk_state->num_operands - 1], walk_state));
  518. /*
  519. * Use value that was already previously returned
  520. * by the evaluation of this argument
  521. */
  522. status = acpi_ds_result_pop_from_bottom (&obj_desc, walk_state);
  523. if (ACPI_FAILURE (status)) {
  524. /*
  525. * Only error is underflow, and this indicates
  526. * a missing or null operand!
  527. */
  528. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Missing or null operand, %s\n",
  529. acpi_format_exception (status)));
  530. return_ACPI_STATUS (status);
  531. }
  532. }
  533. else {
  534. /* Create an ACPI_INTERNAL_OBJECT for the argument */
  535. obj_desc = acpi_ut_create_internal_object (op_info->object_type);
  536. if (!obj_desc) {
  537. return_ACPI_STATUS (AE_NO_MEMORY);
  538. }
  539. /* Initialize the new object */
  540. status = acpi_ds_init_object_from_op (walk_state, arg,
  541. opcode, &obj_desc);
  542. if (ACPI_FAILURE (status)) {
  543. acpi_ut_delete_object_desc (obj_desc);
  544. return_ACPI_STATUS (status);
  545. }
  546. }
  547. /* Put the operand object on the object stack */
  548. status = acpi_ds_obj_stack_push (obj_desc, walk_state);
  549. if (ACPI_FAILURE (status)) {
  550. return_ACPI_STATUS (status);
  551. }
  552. ACPI_DEBUGGER_EXEC (acpi_db_display_argument_object (obj_desc, walk_state));
  553. }
  554. return_ACPI_STATUS (AE_OK);
  555. }
  556. /*******************************************************************************
  557. *
  558. * FUNCTION: acpi_ds_create_operands
  559. *
  560. * PARAMETERS: walk_state - Current state
  561. * first_arg - First argument of a parser argument tree
  562. *
  563. * RETURN: Status
  564. *
  565. * DESCRIPTION: Convert an operator's arguments from a parse tree format to
  566. * namespace objects and place those argument object on the object
  567. * stack in preparation for evaluation by the interpreter.
  568. *
  569. ******************************************************************************/
  570. acpi_status
  571. acpi_ds_create_operands (
  572. struct acpi_walk_state *walk_state,
  573. union acpi_parse_object *first_arg)
  574. {
  575. acpi_status status = AE_OK;
  576. union acpi_parse_object *arg;
  577. u32 arg_count = 0;
  578. ACPI_FUNCTION_TRACE_PTR ("ds_create_operands", first_arg);
  579. /* For all arguments in the list... */
  580. arg = first_arg;
  581. while (arg) {
  582. status = acpi_ds_create_operand (walk_state, arg, arg_count);
  583. if (ACPI_FAILURE (status)) {
  584. goto cleanup;
  585. }
  586. ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%d (%p) done, Arg1=%p\n",
  587. arg_count, arg, first_arg));
  588. /* Move on to next argument, if any */
  589. arg = arg->common.next;
  590. arg_count++;
  591. }
  592. return_ACPI_STATUS (status);
  593. cleanup:
  594. /*
  595. * We must undo everything done above; meaning that we must
  596. * pop everything off of the operand stack and delete those
  597. * objects
  598. */
  599. (void) acpi_ds_obj_stack_pop_and_delete (arg_count, walk_state);
  600. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While creating Arg %d - %s\n",
  601. (arg_count + 1), acpi_format_exception (status)));
  602. return_ACPI_STATUS (status);
  603. }