dswexec.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. /******************************************************************************
  2. *
  3. * Module Name: dswexec - Dispatcher method execution callbacks;
  4. * dispatch to interpreter.
  5. *
  6. *****************************************************************************/
  7. /*
  8. * Copyright (C) 2000 - 2008, Intel Corp.
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without
  12. * modification, are permitted provided that the following conditions
  13. * are met:
  14. * 1. Redistributions of source code must retain the above copyright
  15. * notice, this list of conditions, and the following disclaimer,
  16. * without modification.
  17. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18. * substantially similar to the "NO WARRANTY" disclaimer below
  19. * ("Disclaimer") and any redistribution must be conditioned upon
  20. * including a substantially similar Disclaimer requirement for further
  21. * binary redistribution.
  22. * 3. Neither the names of the above-listed copyright holders nor the names
  23. * of any contributors may be used to endorse or promote products derived
  24. * from this software without specific prior written permission.
  25. *
  26. * Alternatively, this software may be distributed under the terms of the
  27. * GNU General Public License ("GPL") version 2 as published by the Free
  28. * Software Foundation.
  29. *
  30. * NO WARRANTY
  31. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  34. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  35. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  37. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41. * POSSIBILITY OF SUCH DAMAGES.
  42. */
  43. #include <acpi/acpi.h>
  44. #include <acpi/acparser.h>
  45. #include <acpi/amlcode.h>
  46. #include <acpi/acdispat.h>
  47. #include <acpi/acinterp.h>
  48. #include <acpi/acnamesp.h>
  49. #include <acpi/acdebug.h>
  50. #define _COMPONENT ACPI_DISPATCHER
  51. ACPI_MODULE_NAME("dswexec")
  52. /*
  53. * Dispatch table for opcode classes
  54. */
  55. static ACPI_EXECUTE_OP acpi_gbl_op_type_dispatch[] = {
  56. acpi_ex_opcode_0A_0T_1R,
  57. acpi_ex_opcode_1A_0T_0R,
  58. acpi_ex_opcode_1A_0T_1R,
  59. acpi_ex_opcode_1A_1T_0R,
  60. acpi_ex_opcode_1A_1T_1R,
  61. acpi_ex_opcode_2A_0T_0R,
  62. acpi_ex_opcode_2A_0T_1R,
  63. acpi_ex_opcode_2A_1T_1R,
  64. acpi_ex_opcode_2A_2T_1R,
  65. acpi_ex_opcode_3A_0T_0R,
  66. acpi_ex_opcode_3A_1T_1R,
  67. acpi_ex_opcode_6A_0T_1R
  68. };
  69. /*****************************************************************************
  70. *
  71. * FUNCTION: acpi_ds_get_predicate_value
  72. *
  73. * PARAMETERS: walk_state - Current state of the parse tree walk
  74. * result_obj - if non-zero, pop result from result stack
  75. *
  76. * RETURN: Status
  77. *
  78. * DESCRIPTION: Get the result of a predicate evaluation
  79. *
  80. ****************************************************************************/
  81. acpi_status
  82. acpi_ds_get_predicate_value(struct acpi_walk_state *walk_state,
  83. union acpi_operand_object *result_obj)
  84. {
  85. acpi_status status = AE_OK;
  86. union acpi_operand_object *obj_desc;
  87. union acpi_operand_object *local_obj_desc = NULL;
  88. ACPI_FUNCTION_TRACE_PTR(ds_get_predicate_value, walk_state);
  89. walk_state->control_state->common.state = 0;
  90. if (result_obj) {
  91. status = acpi_ds_result_pop(&obj_desc, walk_state);
  92. if (ACPI_FAILURE(status)) {
  93. ACPI_EXCEPTION((AE_INFO, status,
  94. "Could not get result from predicate evaluation"));
  95. return_ACPI_STATUS(status);
  96. }
  97. } else {
  98. status = acpi_ds_create_operand(walk_state, walk_state->op, 0);
  99. if (ACPI_FAILURE(status)) {
  100. return_ACPI_STATUS(status);
  101. }
  102. status =
  103. acpi_ex_resolve_to_value(&walk_state->operands[0],
  104. walk_state);
  105. if (ACPI_FAILURE(status)) {
  106. return_ACPI_STATUS(status);
  107. }
  108. obj_desc = walk_state->operands[0];
  109. }
  110. if (!obj_desc) {
  111. ACPI_ERROR((AE_INFO,
  112. "No predicate ObjDesc=%p State=%p",
  113. obj_desc, walk_state));
  114. return_ACPI_STATUS(AE_AML_NO_OPERAND);
  115. }
  116. /*
  117. * Result of predicate evaluation must be an Integer
  118. * object. Implicitly convert the argument if necessary.
  119. */
  120. status = acpi_ex_convert_to_integer(obj_desc, &local_obj_desc, 16);
  121. if (ACPI_FAILURE(status)) {
  122. goto cleanup;
  123. }
  124. if (ACPI_GET_OBJECT_TYPE(local_obj_desc) != ACPI_TYPE_INTEGER) {
  125. ACPI_ERROR((AE_INFO,
  126. "Bad predicate (not an integer) ObjDesc=%p State=%p Type=%X",
  127. obj_desc, walk_state,
  128. ACPI_GET_OBJECT_TYPE(obj_desc)));
  129. status = AE_AML_OPERAND_TYPE;
  130. goto cleanup;
  131. }
  132. /* Truncate the predicate to 32-bits if necessary */
  133. acpi_ex_truncate_for32bit_table(local_obj_desc);
  134. /*
  135. * Save the result of the predicate evaluation on
  136. * the control stack
  137. */
  138. if (local_obj_desc->integer.value) {
  139. walk_state->control_state->common.value = TRUE;
  140. } else {
  141. /*
  142. * Predicate is FALSE, we will just toss the
  143. * rest of the package
  144. */
  145. walk_state->control_state->common.value = FALSE;
  146. status = AE_CTRL_FALSE;
  147. }
  148. cleanup:
  149. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Completed a predicate eval=%X Op=%p\n",
  150. walk_state->control_state->common.value,
  151. walk_state->op));
  152. /* Break to debugger to display result */
  153. ACPI_DEBUGGER_EXEC(acpi_db_display_result_object
  154. (local_obj_desc, walk_state));
  155. /*
  156. * Delete the predicate result object (we know that
  157. * we don't need it anymore)
  158. */
  159. if (local_obj_desc != obj_desc) {
  160. acpi_ut_remove_reference(local_obj_desc);
  161. }
  162. acpi_ut_remove_reference(obj_desc);
  163. walk_state->control_state->common.state = ACPI_CONTROL_NORMAL;
  164. return_ACPI_STATUS(status);
  165. }
  166. /*****************************************************************************
  167. *
  168. * FUNCTION: acpi_ds_exec_begin_op
  169. *
  170. * PARAMETERS: walk_state - Current state of the parse tree walk
  171. * out_op - Where to return op if a new one is created
  172. *
  173. * RETURN: Status
  174. *
  175. * DESCRIPTION: Descending callback used during the execution of control
  176. * methods. This is where most operators and operands are
  177. * dispatched to the interpreter.
  178. *
  179. ****************************************************************************/
  180. acpi_status
  181. acpi_ds_exec_begin_op(struct acpi_walk_state *walk_state,
  182. union acpi_parse_object **out_op)
  183. {
  184. union acpi_parse_object *op;
  185. acpi_status status = AE_OK;
  186. u32 opcode_class;
  187. ACPI_FUNCTION_TRACE_PTR(ds_exec_begin_op, walk_state);
  188. op = walk_state->op;
  189. if (!op) {
  190. status = acpi_ds_load2_begin_op(walk_state, out_op);
  191. if (ACPI_FAILURE(status)) {
  192. goto error_exit;
  193. }
  194. op = *out_op;
  195. walk_state->op = op;
  196. walk_state->opcode = op->common.aml_opcode;
  197. walk_state->op_info =
  198. acpi_ps_get_opcode_info(op->common.aml_opcode);
  199. if (acpi_ns_opens_scope(walk_state->op_info->object_type)) {
  200. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  201. "(%s) Popping scope for Op %p\n",
  202. acpi_ut_get_type_name(walk_state->
  203. op_info->
  204. object_type),
  205. op));
  206. status = acpi_ds_scope_stack_pop(walk_state);
  207. if (ACPI_FAILURE(status)) {
  208. goto error_exit;
  209. }
  210. }
  211. }
  212. if (op == walk_state->origin) {
  213. if (out_op) {
  214. *out_op = op;
  215. }
  216. return_ACPI_STATUS(AE_OK);
  217. }
  218. /*
  219. * If the previous opcode was a conditional, this opcode
  220. * must be the beginning of the associated predicate.
  221. * Save this knowledge in the current scope descriptor
  222. */
  223. if ((walk_state->control_state) &&
  224. (walk_state->control_state->common.state ==
  225. ACPI_CONTROL_CONDITIONAL_EXECUTING)) {
  226. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  227. "Exec predicate Op=%p State=%p\n", op,
  228. walk_state));
  229. walk_state->control_state->common.state =
  230. ACPI_CONTROL_PREDICATE_EXECUTING;
  231. /* Save start of predicate */
  232. walk_state->control_state->control.predicate_op = op;
  233. }
  234. opcode_class = walk_state->op_info->class;
  235. /* We want to send namepaths to the load code */
  236. if (op->common.aml_opcode == AML_INT_NAMEPATH_OP) {
  237. opcode_class = AML_CLASS_NAMED_OBJECT;
  238. }
  239. /*
  240. * Handle the opcode based upon the opcode type
  241. */
  242. switch (opcode_class) {
  243. case AML_CLASS_CONTROL:
  244. status = acpi_ds_exec_begin_control_op(walk_state, op);
  245. break;
  246. case AML_CLASS_NAMED_OBJECT:
  247. if (walk_state->walk_type & ACPI_WALK_METHOD) {
  248. /*
  249. * Found a named object declaration during method execution;
  250. * we must enter this object into the namespace. The created
  251. * object is temporary and will be deleted upon completion of
  252. * the execution of this method.
  253. */
  254. status = acpi_ds_load2_begin_op(walk_state, NULL);
  255. }
  256. break;
  257. case AML_CLASS_EXECUTE:
  258. case AML_CLASS_CREATE:
  259. break;
  260. default:
  261. break;
  262. }
  263. /* Nothing to do here during method execution */
  264. return_ACPI_STATUS(status);
  265. error_exit:
  266. status = acpi_ds_method_error(status, walk_state);
  267. return_ACPI_STATUS(status);
  268. }
  269. /*****************************************************************************
  270. *
  271. * FUNCTION: acpi_ds_exec_end_op
  272. *
  273. * PARAMETERS: walk_state - Current state of the parse tree walk
  274. *
  275. * RETURN: Status
  276. *
  277. * DESCRIPTION: Ascending callback used during the execution of control
  278. * methods. The only thing we really need to do here is to
  279. * notice the beginning of IF, ELSE, and WHILE blocks.
  280. *
  281. ****************************************************************************/
  282. acpi_status acpi_ds_exec_end_op(struct acpi_walk_state *walk_state)
  283. {
  284. union acpi_parse_object *op;
  285. acpi_status status = AE_OK;
  286. u32 op_type;
  287. u32 op_class;
  288. union acpi_parse_object *next_op;
  289. union acpi_parse_object *first_arg;
  290. ACPI_FUNCTION_TRACE_PTR(ds_exec_end_op, walk_state);
  291. op = walk_state->op;
  292. op_type = walk_state->op_info->type;
  293. op_class = walk_state->op_info->class;
  294. if (op_class == AML_CLASS_UNKNOWN) {
  295. ACPI_ERROR((AE_INFO, "Unknown opcode %X",
  296. op->common.aml_opcode));
  297. return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
  298. }
  299. first_arg = op->common.value.arg;
  300. /* Init the walk state */
  301. walk_state->num_operands = 0;
  302. walk_state->operand_index = 0;
  303. walk_state->return_desc = NULL;
  304. walk_state->result_obj = NULL;
  305. /* Call debugger for single step support (DEBUG build only) */
  306. ACPI_DEBUGGER_EXEC(status =
  307. acpi_db_single_step(walk_state, op, op_class));
  308. ACPI_DEBUGGER_EXEC(if (ACPI_FAILURE(status)) {
  309. return_ACPI_STATUS(status);}
  310. ) ;
  311. /* Decode the Opcode Class */
  312. switch (op_class) {
  313. case AML_CLASS_ARGUMENT: /* Constants, literals, etc. */
  314. if (walk_state->opcode == AML_INT_NAMEPATH_OP) {
  315. status = acpi_ds_evaluate_name_path(walk_state);
  316. if (ACPI_FAILURE(status)) {
  317. goto cleanup;
  318. }
  319. }
  320. break;
  321. case AML_CLASS_EXECUTE: /* Most operators with arguments */
  322. /* Build resolved operand stack */
  323. status = acpi_ds_create_operands(walk_state, first_arg);
  324. if (ACPI_FAILURE(status)) {
  325. goto cleanup;
  326. }
  327. /*
  328. * All opcodes require operand resolution, with the only exceptions
  329. * being the object_type and size_of operators.
  330. */
  331. if (!(walk_state->op_info->flags & AML_NO_OPERAND_RESOLVE)) {
  332. /* Resolve all operands */
  333. status = acpi_ex_resolve_operands(walk_state->opcode,
  334. &(walk_state->
  335. operands
  336. [walk_state->
  337. num_operands - 1]),
  338. walk_state);
  339. if (ACPI_SUCCESS(status)) {
  340. ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS,
  341. ACPI_IMODE_EXECUTE,
  342. acpi_ps_get_opcode_name
  343. (walk_state->opcode),
  344. walk_state->num_operands,
  345. "after ExResolveOperands");
  346. }
  347. }
  348. if (ACPI_SUCCESS(status)) {
  349. /*
  350. * Dispatch the request to the appropriate interpreter handler
  351. * routine. There is one routine per opcode "type" based upon the
  352. * number of opcode arguments and return type.
  353. */
  354. status =
  355. acpi_gbl_op_type_dispatch[op_type] (walk_state);
  356. } else {
  357. /*
  358. * Treat constructs of the form "Store(LocalX,LocalX)" as noops when the
  359. * Local is uninitialized.
  360. */
  361. if ((status == AE_AML_UNINITIALIZED_LOCAL) &&
  362. (walk_state->opcode == AML_STORE_OP) &&
  363. (walk_state->operands[0]->common.type ==
  364. ACPI_TYPE_LOCAL_REFERENCE)
  365. && (walk_state->operands[1]->common.type ==
  366. ACPI_TYPE_LOCAL_REFERENCE)
  367. && (walk_state->operands[0]->reference.opcode ==
  368. walk_state->operands[1]->reference.opcode)
  369. && (walk_state->operands[0]->reference.offset ==
  370. walk_state->operands[1]->reference.offset)) {
  371. status = AE_OK;
  372. } else {
  373. ACPI_EXCEPTION((AE_INFO, status,
  374. "While resolving operands for [%s]",
  375. acpi_ps_get_opcode_name
  376. (walk_state->opcode)));
  377. }
  378. }
  379. /* Always delete the argument objects and clear the operand stack */
  380. acpi_ds_clear_operands(walk_state);
  381. /*
  382. * If a result object was returned from above, push it on the
  383. * current result stack
  384. */
  385. if (ACPI_SUCCESS(status) && walk_state->result_obj) {
  386. status =
  387. acpi_ds_result_push(walk_state->result_obj,
  388. walk_state);
  389. }
  390. break;
  391. default:
  392. switch (op_type) {
  393. case AML_TYPE_CONTROL: /* Type 1 opcode, IF/ELSE/WHILE/NOOP */
  394. /* 1 Operand, 0 external_result, 0 internal_result */
  395. status = acpi_ds_exec_end_control_op(walk_state, op);
  396. break;
  397. case AML_TYPE_METHOD_CALL:
  398. /*
  399. * If the method is referenced from within a package
  400. * declaration, it is not a invocation of the method, just
  401. * a reference to it.
  402. */
  403. if ((op->asl.parent) &&
  404. ((op->asl.parent->asl.aml_opcode == AML_PACKAGE_OP)
  405. || (op->asl.parent->asl.aml_opcode ==
  406. AML_VAR_PACKAGE_OP))) {
  407. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  408. "Method Reference in a Package, Op=%p\n",
  409. op));
  410. op->common.node =
  411. (struct acpi_namespace_node *)op->asl.value.
  412. arg->asl.node;
  413. acpi_ut_add_reference(op->asl.value.arg->asl.
  414. node->object);
  415. return_ACPI_STATUS(AE_OK);
  416. }
  417. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  418. "Method invocation, Op=%p\n", op));
  419. /*
  420. * (AML_METHODCALL) Op->Asl.Value.Arg->Asl.Node contains
  421. * the method Node pointer
  422. */
  423. /* next_op points to the op that holds the method name */
  424. next_op = first_arg;
  425. /* next_op points to first argument op */
  426. next_op = next_op->common.next;
  427. /*
  428. * Get the method's arguments and put them on the operand stack
  429. */
  430. status = acpi_ds_create_operands(walk_state, next_op);
  431. if (ACPI_FAILURE(status)) {
  432. break;
  433. }
  434. /*
  435. * Since the operands will be passed to another control method,
  436. * we must resolve all local references here (Local variables,
  437. * arguments to *this* method, etc.)
  438. */
  439. status = acpi_ds_resolve_operands(walk_state);
  440. if (ACPI_FAILURE(status)) {
  441. /* On error, clear all resolved operands */
  442. acpi_ds_clear_operands(walk_state);
  443. break;
  444. }
  445. /*
  446. * Tell the walk loop to preempt this running method and
  447. * execute the new method
  448. */
  449. status = AE_CTRL_TRANSFER;
  450. /*
  451. * Return now; we don't want to disturb anything,
  452. * especially the operand count!
  453. */
  454. return_ACPI_STATUS(status);
  455. case AML_TYPE_CREATE_FIELD:
  456. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  457. "Executing CreateField Buffer/Index Op=%p\n",
  458. op));
  459. status = acpi_ds_load2_end_op(walk_state);
  460. if (ACPI_FAILURE(status)) {
  461. break;
  462. }
  463. status =
  464. acpi_ds_eval_buffer_field_operands(walk_state, op);
  465. break;
  466. case AML_TYPE_CREATE_OBJECT:
  467. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  468. "Executing CreateObject (Buffer/Package) Op=%p\n",
  469. op));
  470. switch (op->common.parent->common.aml_opcode) {
  471. case AML_NAME_OP:
  472. /*
  473. * Put the Node on the object stack (Contains the ACPI Name
  474. * of this object)
  475. */
  476. walk_state->operands[0] =
  477. (void *)op->common.parent->common.node;
  478. walk_state->num_operands = 1;
  479. status = acpi_ds_create_node(walk_state,
  480. op->common.parent->
  481. common.node,
  482. op->common.parent);
  483. if (ACPI_FAILURE(status)) {
  484. break;
  485. }
  486. /* Fall through */
  487. /*lint -fallthrough */
  488. case AML_INT_EVAL_SUBTREE_OP:
  489. status =
  490. acpi_ds_eval_data_object_operands
  491. (walk_state, op,
  492. acpi_ns_get_attached_object(op->common.
  493. parent->common.
  494. node));
  495. break;
  496. default:
  497. status =
  498. acpi_ds_eval_data_object_operands
  499. (walk_state, op, NULL);
  500. break;
  501. }
  502. /*
  503. * If a result object was returned from above, push it on the
  504. * current result stack
  505. */
  506. if (walk_state->result_obj) {
  507. status =
  508. acpi_ds_result_push(walk_state->result_obj,
  509. walk_state);
  510. }
  511. break;
  512. case AML_TYPE_NAMED_FIELD:
  513. case AML_TYPE_NAMED_COMPLEX:
  514. case AML_TYPE_NAMED_SIMPLE:
  515. case AML_TYPE_NAMED_NO_OBJ:
  516. status = acpi_ds_load2_end_op(walk_state);
  517. if (ACPI_FAILURE(status)) {
  518. break;
  519. }
  520. if (op->common.aml_opcode == AML_REGION_OP) {
  521. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  522. "Executing OpRegion Address/Length Op=%p\n",
  523. op));
  524. status =
  525. acpi_ds_eval_region_operands(walk_state,
  526. op);
  527. if (ACPI_FAILURE(status)) {
  528. break;
  529. }
  530. } else if (op->common.aml_opcode == AML_DATA_REGION_OP) {
  531. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  532. "Executing DataTableRegion Strings Op=%p\n",
  533. op));
  534. status =
  535. acpi_ds_eval_table_region_operands
  536. (walk_state, op);
  537. if (ACPI_FAILURE(status)) {
  538. break;
  539. }
  540. } else if (op->common.aml_opcode == AML_BANK_FIELD_OP) {
  541. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  542. "Executing BankField Op=%p\n",
  543. op));
  544. status =
  545. acpi_ds_eval_bank_field_operands(walk_state,
  546. op);
  547. if (ACPI_FAILURE(status)) {
  548. break;
  549. }
  550. }
  551. break;
  552. case AML_TYPE_UNDEFINED:
  553. ACPI_ERROR((AE_INFO,
  554. "Undefined opcode type Op=%p", op));
  555. return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
  556. case AML_TYPE_BOGUS:
  557. ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
  558. "Internal opcode=%X type Op=%p\n",
  559. walk_state->opcode, op));
  560. break;
  561. default:
  562. ACPI_ERROR((AE_INFO,
  563. "Unimplemented opcode, class=%X type=%X Opcode=%X Op=%p",
  564. op_class, op_type, op->common.aml_opcode,
  565. op));
  566. status = AE_NOT_IMPLEMENTED;
  567. break;
  568. }
  569. }
  570. /*
  571. * ACPI 2.0 support for 64-bit integers: Truncate numeric
  572. * result value if we are executing from a 32-bit ACPI table
  573. */
  574. acpi_ex_truncate_for32bit_table(walk_state->result_obj);
  575. /*
  576. * Check if we just completed the evaluation of a
  577. * conditional predicate
  578. */
  579. if ((ACPI_SUCCESS(status)) &&
  580. (walk_state->control_state) &&
  581. (walk_state->control_state->common.state ==
  582. ACPI_CONTROL_PREDICATE_EXECUTING) &&
  583. (walk_state->control_state->control.predicate_op == op)) {
  584. status =
  585. acpi_ds_get_predicate_value(walk_state,
  586. walk_state->result_obj);
  587. walk_state->result_obj = NULL;
  588. }
  589. cleanup:
  590. if (walk_state->result_obj) {
  591. /* Break to debugger to display result */
  592. ACPI_DEBUGGER_EXEC(acpi_db_display_result_object
  593. (walk_state->result_obj, walk_state));
  594. /*
  595. * Delete the result op if and only if:
  596. * Parent will not use the result -- such as any
  597. * non-nested type2 op in a method (parent will be method)
  598. */
  599. acpi_ds_delete_result_if_not_used(op, walk_state->result_obj,
  600. walk_state);
  601. }
  602. #ifdef _UNDER_DEVELOPMENT
  603. if (walk_state->parser_state.aml == walk_state->parser_state.aml_end) {
  604. acpi_db_method_end(walk_state);
  605. }
  606. #endif
  607. /* Invoke exception handler on error */
  608. if (ACPI_FAILURE(status)) {
  609. status = acpi_ds_method_error(status, walk_state);
  610. }
  611. /* Always clear the object stack */
  612. walk_state->num_operands = 0;
  613. return_ACPI_STATUS(status);
  614. }