dsopcode.c 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
  2. /******************************************************************************
  3. *
  4. * Module Name: dsopcode - Dispatcher support for regions and fields
  5. *
  6. * Copyright (C) 2000 - 2018, Intel Corp.
  7. *
  8. *****************************************************************************/
  9. #include <acpi/acpi.h>
  10. #include "accommon.h"
  11. #include "acparser.h"
  12. #include "amlcode.h"
  13. #include "acdispat.h"
  14. #include "acinterp.h"
  15. #include "acnamesp.h"
  16. #include "acevents.h"
  17. #include "actables.h"
  18. #define _COMPONENT ACPI_DISPATCHER
  19. ACPI_MODULE_NAME("dsopcode")
  20. /* Local prototypes */
  21. static acpi_status
  22. acpi_ds_init_buffer_field(u16 aml_opcode,
  23. union acpi_operand_object *obj_desc,
  24. union acpi_operand_object *buffer_desc,
  25. union acpi_operand_object *offset_desc,
  26. union acpi_operand_object *length_desc,
  27. union acpi_operand_object *result_desc);
  28. /*******************************************************************************
  29. *
  30. * FUNCTION: acpi_ds_initialize_region
  31. *
  32. * PARAMETERS: obj_handle - Region namespace node
  33. *
  34. * RETURN: Status
  35. *
  36. * DESCRIPTION: Front end to ev_initialize_region
  37. *
  38. ******************************************************************************/
  39. acpi_status acpi_ds_initialize_region(acpi_handle obj_handle)
  40. {
  41. union acpi_operand_object *obj_desc;
  42. acpi_status status;
  43. obj_desc = acpi_ns_get_attached_object(obj_handle);
  44. /* Namespace is NOT locked */
  45. status = acpi_ev_initialize_region(obj_desc);
  46. return (status);
  47. }
  48. /*******************************************************************************
  49. *
  50. * FUNCTION: acpi_ds_init_buffer_field
  51. *
  52. * PARAMETERS: aml_opcode - create_xxx_field
  53. * obj_desc - buffer_field object
  54. * buffer_desc - Host Buffer
  55. * offset_desc - Offset into buffer
  56. * length_desc - Length of field (CREATE_FIELD_OP only)
  57. * result_desc - Where to store the result
  58. *
  59. * RETURN: Status
  60. *
  61. * DESCRIPTION: Perform actual initialization of a buffer field
  62. *
  63. ******************************************************************************/
  64. static acpi_status
  65. acpi_ds_init_buffer_field(u16 aml_opcode,
  66. union acpi_operand_object *obj_desc,
  67. union acpi_operand_object *buffer_desc,
  68. union acpi_operand_object *offset_desc,
  69. union acpi_operand_object *length_desc,
  70. union acpi_operand_object *result_desc)
  71. {
  72. u32 offset;
  73. u32 bit_offset;
  74. u32 bit_count;
  75. u8 field_flags;
  76. acpi_status status;
  77. ACPI_FUNCTION_TRACE_PTR(ds_init_buffer_field, obj_desc);
  78. /* Host object must be a Buffer */
  79. if (buffer_desc->common.type != ACPI_TYPE_BUFFER) {
  80. ACPI_ERROR((AE_INFO,
  81. "Target of Create Field is not a Buffer object - %s",
  82. acpi_ut_get_object_type_name(buffer_desc)));
  83. status = AE_AML_OPERAND_TYPE;
  84. goto cleanup;
  85. }
  86. /*
  87. * The last parameter to all of these opcodes (result_desc) started
  88. * out as a name_string, and should therefore now be a NS node
  89. * after resolution in acpi_ex_resolve_operands().
  90. */
  91. if (ACPI_GET_DESCRIPTOR_TYPE(result_desc) != ACPI_DESC_TYPE_NAMED) {
  92. ACPI_ERROR((AE_INFO,
  93. "(%s) destination not a NS Node [%s]",
  94. acpi_ps_get_opcode_name(aml_opcode),
  95. acpi_ut_get_descriptor_name(result_desc)));
  96. status = AE_AML_OPERAND_TYPE;
  97. goto cleanup;
  98. }
  99. offset = (u32) offset_desc->integer.value;
  100. /*
  101. * Setup the Bit offsets and counts, according to the opcode
  102. */
  103. switch (aml_opcode) {
  104. case AML_CREATE_FIELD_OP:
  105. /* Offset is in bits, count is in bits */
  106. field_flags = AML_FIELD_ACCESS_BYTE;
  107. bit_offset = offset;
  108. bit_count = (u32) length_desc->integer.value;
  109. /* Must have a valid (>0) bit count */
  110. if (bit_count == 0) {
  111. ACPI_ERROR((AE_INFO,
  112. "Attempt to CreateField of length zero"));
  113. status = AE_AML_OPERAND_VALUE;
  114. goto cleanup;
  115. }
  116. break;
  117. case AML_CREATE_BIT_FIELD_OP:
  118. /* Offset is in bits, Field is one bit */
  119. bit_offset = offset;
  120. bit_count = 1;
  121. field_flags = AML_FIELD_ACCESS_BYTE;
  122. break;
  123. case AML_CREATE_BYTE_FIELD_OP:
  124. /* Offset is in bytes, field is one byte */
  125. bit_offset = 8 * offset;
  126. bit_count = 8;
  127. field_flags = AML_FIELD_ACCESS_BYTE;
  128. break;
  129. case AML_CREATE_WORD_FIELD_OP:
  130. /* Offset is in bytes, field is one word */
  131. bit_offset = 8 * offset;
  132. bit_count = 16;
  133. field_flags = AML_FIELD_ACCESS_WORD;
  134. break;
  135. case AML_CREATE_DWORD_FIELD_OP:
  136. /* Offset is in bytes, field is one dword */
  137. bit_offset = 8 * offset;
  138. bit_count = 32;
  139. field_flags = AML_FIELD_ACCESS_DWORD;
  140. break;
  141. case AML_CREATE_QWORD_FIELD_OP:
  142. /* Offset is in bytes, field is one qword */
  143. bit_offset = 8 * offset;
  144. bit_count = 64;
  145. field_flags = AML_FIELD_ACCESS_QWORD;
  146. break;
  147. default:
  148. ACPI_ERROR((AE_INFO,
  149. "Unknown field creation opcode 0x%02X",
  150. aml_opcode));
  151. status = AE_AML_BAD_OPCODE;
  152. goto cleanup;
  153. }
  154. /* Entire field must fit within the current length of the buffer */
  155. if ((bit_offset + bit_count) > (8 * (u32)buffer_desc->buffer.length)) {
  156. ACPI_ERROR((AE_INFO,
  157. "Field [%4.4s] at bit offset/length %u/%u "
  158. "exceeds size of target Buffer (%u bits)",
  159. acpi_ut_get_node_name(result_desc), bit_offset,
  160. bit_count, 8 * (u32)buffer_desc->buffer.length));
  161. status = AE_AML_BUFFER_LIMIT;
  162. goto cleanup;
  163. }
  164. /*
  165. * Initialize areas of the field object that are common to all fields
  166. * For field_flags, use LOCK_RULE = 0 (NO_LOCK),
  167. * UPDATE_RULE = 0 (UPDATE_PRESERVE)
  168. */
  169. status =
  170. acpi_ex_prep_common_field_object(obj_desc, field_flags, 0,
  171. bit_offset, bit_count);
  172. if (ACPI_FAILURE(status)) {
  173. goto cleanup;
  174. }
  175. obj_desc->buffer_field.buffer_obj = buffer_desc;
  176. /* Reference count for buffer_desc inherits obj_desc count */
  177. buffer_desc->common.reference_count = (u16)
  178. (buffer_desc->common.reference_count +
  179. obj_desc->common.reference_count);
  180. cleanup:
  181. /* Always delete the operands */
  182. acpi_ut_remove_reference(offset_desc);
  183. acpi_ut_remove_reference(buffer_desc);
  184. if (aml_opcode == AML_CREATE_FIELD_OP) {
  185. acpi_ut_remove_reference(length_desc);
  186. }
  187. /* On failure, delete the result descriptor */
  188. if (ACPI_FAILURE(status)) {
  189. acpi_ut_remove_reference(result_desc); /* Result descriptor */
  190. } else {
  191. /* Now the address and length are valid for this buffer_field */
  192. obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
  193. }
  194. return_ACPI_STATUS(status);
  195. }
  196. /*******************************************************************************
  197. *
  198. * FUNCTION: acpi_ds_eval_buffer_field_operands
  199. *
  200. * PARAMETERS: walk_state - Current walk
  201. * op - A valid buffer_field Op object
  202. *
  203. * RETURN: Status
  204. *
  205. * DESCRIPTION: Get buffer_field Buffer and Index
  206. * Called from acpi_ds_exec_end_op during buffer_field parse tree walk
  207. *
  208. ******************************************************************************/
  209. acpi_status
  210. acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
  211. union acpi_parse_object *op)
  212. {
  213. acpi_status status;
  214. union acpi_operand_object *obj_desc;
  215. struct acpi_namespace_node *node;
  216. union acpi_parse_object *next_op;
  217. ACPI_FUNCTION_TRACE_PTR(ds_eval_buffer_field_operands, op);
  218. /*
  219. * This is where we evaluate the address and length fields of the
  220. * create_xxx_field declaration
  221. */
  222. node = op->common.node;
  223. /* next_op points to the op that holds the Buffer */
  224. next_op = op->common.value.arg;
  225. /* Evaluate/create the address and length operands */
  226. status = acpi_ds_create_operands(walk_state, next_op);
  227. if (ACPI_FAILURE(status)) {
  228. return_ACPI_STATUS(status);
  229. }
  230. obj_desc = acpi_ns_get_attached_object(node);
  231. if (!obj_desc) {
  232. return_ACPI_STATUS(AE_NOT_EXIST);
  233. }
  234. /* Resolve the operands */
  235. status =
  236. acpi_ex_resolve_operands(op->common.aml_opcode, ACPI_WALK_OPERANDS,
  237. walk_state);
  238. if (ACPI_FAILURE(status)) {
  239. ACPI_ERROR((AE_INFO, "(%s) bad operand(s), status 0x%X",
  240. acpi_ps_get_opcode_name(op->common.aml_opcode),
  241. status));
  242. return_ACPI_STATUS(status);
  243. }
  244. /* Initialize the Buffer Field */
  245. if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
  246. /* NOTE: Slightly different operands for this opcode */
  247. status =
  248. acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
  249. walk_state->operands[0],
  250. walk_state->operands[1],
  251. walk_state->operands[2],
  252. walk_state->operands[3]);
  253. } else {
  254. /* All other, create_xxx_field opcodes */
  255. status =
  256. acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
  257. walk_state->operands[0],
  258. walk_state->operands[1], NULL,
  259. walk_state->operands[2]);
  260. }
  261. return_ACPI_STATUS(status);
  262. }
  263. /*******************************************************************************
  264. *
  265. * FUNCTION: acpi_ds_eval_region_operands
  266. *
  267. * PARAMETERS: walk_state - Current walk
  268. * op - A valid region Op object
  269. *
  270. * RETURN: Status
  271. *
  272. * DESCRIPTION: Get region address and length
  273. * Called from acpi_ds_exec_end_op during op_region parse tree walk
  274. *
  275. ******************************************************************************/
  276. acpi_status
  277. acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
  278. union acpi_parse_object *op)
  279. {
  280. acpi_status status;
  281. union acpi_operand_object *obj_desc;
  282. union acpi_operand_object *operand_desc;
  283. struct acpi_namespace_node *node;
  284. union acpi_parse_object *next_op;
  285. ACPI_FUNCTION_TRACE_PTR(ds_eval_region_operands, op);
  286. /*
  287. * This is where we evaluate the address and length fields of the
  288. * op_region declaration
  289. */
  290. node = op->common.node;
  291. /* next_op points to the op that holds the space_ID */
  292. next_op = op->common.value.arg;
  293. /* next_op points to address op */
  294. next_op = next_op->common.next;
  295. /* Evaluate/create the address and length operands */
  296. status = acpi_ds_create_operands(walk_state, next_op);
  297. if (ACPI_FAILURE(status)) {
  298. return_ACPI_STATUS(status);
  299. }
  300. /* Resolve the length and address operands to numbers */
  301. status =
  302. acpi_ex_resolve_operands(op->common.aml_opcode, ACPI_WALK_OPERANDS,
  303. walk_state);
  304. if (ACPI_FAILURE(status)) {
  305. return_ACPI_STATUS(status);
  306. }
  307. obj_desc = acpi_ns_get_attached_object(node);
  308. if (!obj_desc) {
  309. return_ACPI_STATUS(AE_NOT_EXIST);
  310. }
  311. /*
  312. * Get the length operand and save it
  313. * (at Top of stack)
  314. */
  315. operand_desc = walk_state->operands[walk_state->num_operands - 1];
  316. obj_desc->region.length = (u32) operand_desc->integer.value;
  317. acpi_ut_remove_reference(operand_desc);
  318. /*
  319. * Get the address and save it
  320. * (at top of stack - 1)
  321. */
  322. operand_desc = walk_state->operands[walk_state->num_operands - 2];
  323. obj_desc->region.address = (acpi_physical_address)
  324. operand_desc->integer.value;
  325. acpi_ut_remove_reference(operand_desc);
  326. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
  327. obj_desc,
  328. ACPI_FORMAT_UINT64(obj_desc->region.address),
  329. obj_desc->region.length));
  330. status = acpi_ut_add_address_range(obj_desc->region.space_id,
  331. obj_desc->region.address,
  332. obj_desc->region.length, node);
  333. /* Now the address and length are valid for this opregion */
  334. obj_desc->region.flags |= AOPOBJ_DATA_VALID;
  335. return_ACPI_STATUS(status);
  336. }
  337. /*******************************************************************************
  338. *
  339. * FUNCTION: acpi_ds_eval_table_region_operands
  340. *
  341. * PARAMETERS: walk_state - Current walk
  342. * op - A valid region Op object
  343. *
  344. * RETURN: Status
  345. *
  346. * DESCRIPTION: Get region address and length.
  347. * Called from acpi_ds_exec_end_op during data_table_region parse
  348. * tree walk.
  349. *
  350. ******************************************************************************/
  351. acpi_status
  352. acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
  353. union acpi_parse_object *op)
  354. {
  355. acpi_status status;
  356. union acpi_operand_object *obj_desc;
  357. union acpi_operand_object **operand;
  358. struct acpi_namespace_node *node;
  359. union acpi_parse_object *next_op;
  360. struct acpi_table_header *table;
  361. u32 table_index;
  362. ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op);
  363. /*
  364. * This is where we evaluate the Signature string, oem_id string,
  365. * and oem_table_id string of the Data Table Region declaration
  366. */
  367. node = op->common.node;
  368. /* next_op points to Signature string op */
  369. next_op = op->common.value.arg;
  370. /*
  371. * Evaluate/create the Signature string, oem_id string,
  372. * and oem_table_id string operands
  373. */
  374. status = acpi_ds_create_operands(walk_state, next_op);
  375. if (ACPI_FAILURE(status)) {
  376. return_ACPI_STATUS(status);
  377. }
  378. operand = &walk_state->operands[0];
  379. /*
  380. * Resolve the Signature string, oem_id string,
  381. * and oem_table_id string operands
  382. */
  383. status =
  384. acpi_ex_resolve_operands(op->common.aml_opcode, ACPI_WALK_OPERANDS,
  385. walk_state);
  386. if (ACPI_FAILURE(status)) {
  387. goto cleanup;
  388. }
  389. /* Find the ACPI table */
  390. status = acpi_tb_find_table(operand[0]->string.pointer,
  391. operand[1]->string.pointer,
  392. operand[2]->string.pointer, &table_index);
  393. if (ACPI_FAILURE(status)) {
  394. if (status == AE_NOT_FOUND) {
  395. ACPI_ERROR((AE_INFO,
  396. "ACPI Table [%4.4s] OEM:(%s, %s) not found in RSDT/XSDT",
  397. operand[0]->string.pointer,
  398. operand[1]->string.pointer,
  399. operand[2]->string.pointer));
  400. }
  401. goto cleanup;
  402. }
  403. status = acpi_get_table_by_index(table_index, &table);
  404. if (ACPI_FAILURE(status)) {
  405. goto cleanup;
  406. }
  407. obj_desc = acpi_ns_get_attached_object(node);
  408. if (!obj_desc) {
  409. status = AE_NOT_EXIST;
  410. goto cleanup;
  411. }
  412. obj_desc->region.address = ACPI_PTR_TO_PHYSADDR(table);
  413. obj_desc->region.length = table->length;
  414. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
  415. obj_desc,
  416. ACPI_FORMAT_UINT64(obj_desc->region.address),
  417. obj_desc->region.length));
  418. /* Now the address and length are valid for this opregion */
  419. obj_desc->region.flags |= AOPOBJ_DATA_VALID;
  420. cleanup:
  421. acpi_ut_remove_reference(operand[0]);
  422. acpi_ut_remove_reference(operand[1]);
  423. acpi_ut_remove_reference(operand[2]);
  424. return_ACPI_STATUS(status);
  425. }
  426. /*******************************************************************************
  427. *
  428. * FUNCTION: acpi_ds_eval_data_object_operands
  429. *
  430. * PARAMETERS: walk_state - Current walk
  431. * op - A valid data_object Op object
  432. * obj_desc - data_object
  433. *
  434. * RETURN: Status
  435. *
  436. * DESCRIPTION: Get the operands and complete the following data object types:
  437. * Buffer, Package.
  438. *
  439. ******************************************************************************/
  440. acpi_status
  441. acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
  442. union acpi_parse_object *op,
  443. union acpi_operand_object *obj_desc)
  444. {
  445. acpi_status status;
  446. union acpi_operand_object *arg_desc;
  447. u32 length;
  448. ACPI_FUNCTION_TRACE(ds_eval_data_object_operands);
  449. /* The first operand (for all of these data objects) is the length */
  450. /*
  451. * Set proper index into operand stack for acpi_ds_obj_stack_push
  452. * invoked inside acpi_ds_create_operand.
  453. */
  454. walk_state->operand_index = walk_state->num_operands;
  455. /* Ignore if child is not valid */
  456. if (!op->common.value.arg) {
  457. ACPI_ERROR((AE_INFO,
  458. "Missing child while evaluating opcode %4.4X, Op %p",
  459. op->common.aml_opcode, op));
  460. return_ACPI_STATUS(AE_OK);
  461. }
  462. status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1);
  463. if (ACPI_FAILURE(status)) {
  464. return_ACPI_STATUS(status);
  465. }
  466. status = acpi_ex_resolve_operands(walk_state->opcode,
  467. &(walk_state->
  468. operands[walk_state->num_operands -
  469. 1]), walk_state);
  470. if (ACPI_FAILURE(status)) {
  471. return_ACPI_STATUS(status);
  472. }
  473. /* Extract length operand */
  474. arg_desc = walk_state->operands[walk_state->num_operands - 1];
  475. length = (u32) arg_desc->integer.value;
  476. /* Cleanup for length operand */
  477. status = acpi_ds_obj_stack_pop(1, walk_state);
  478. if (ACPI_FAILURE(status)) {
  479. return_ACPI_STATUS(status);
  480. }
  481. acpi_ut_remove_reference(arg_desc);
  482. /*
  483. * Create the actual data object
  484. */
  485. switch (op->common.aml_opcode) {
  486. case AML_BUFFER_OP:
  487. status =
  488. acpi_ds_build_internal_buffer_obj(walk_state, op, length,
  489. &obj_desc);
  490. break;
  491. case AML_PACKAGE_OP:
  492. case AML_VARIABLE_PACKAGE_OP:
  493. status =
  494. acpi_ds_build_internal_package_obj(walk_state, op, length,
  495. &obj_desc);
  496. break;
  497. default:
  498. return_ACPI_STATUS(AE_AML_BAD_OPCODE);
  499. }
  500. if (ACPI_SUCCESS(status)) {
  501. /*
  502. * Return the object in the walk_state, unless the parent is a package -
  503. * in this case, the return object will be stored in the parse tree
  504. * for the package.
  505. */
  506. if ((!op->common.parent) ||
  507. ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
  508. (op->common.parent->common.aml_opcode !=
  509. AML_VARIABLE_PACKAGE_OP)
  510. && (op->common.parent->common.aml_opcode !=
  511. AML_NAME_OP))) {
  512. walk_state->result_obj = obj_desc;
  513. }
  514. }
  515. return_ACPI_STATUS(status);
  516. }
  517. /*******************************************************************************
  518. *
  519. * FUNCTION: acpi_ds_eval_bank_field_operands
  520. *
  521. * PARAMETERS: walk_state - Current walk
  522. * op - A valid bank_field Op object
  523. *
  524. * RETURN: Status
  525. *
  526. * DESCRIPTION: Get bank_field bank_value
  527. * Called from acpi_ds_exec_end_op during bank_field parse tree walk
  528. *
  529. ******************************************************************************/
  530. acpi_status
  531. acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
  532. union acpi_parse_object *op)
  533. {
  534. acpi_status status;
  535. union acpi_operand_object *obj_desc;
  536. union acpi_operand_object *operand_desc;
  537. struct acpi_namespace_node *node;
  538. union acpi_parse_object *next_op;
  539. union acpi_parse_object *arg;
  540. ACPI_FUNCTION_TRACE_PTR(ds_eval_bank_field_operands, op);
  541. /*
  542. * This is where we evaluate the bank_value field of the
  543. * bank_field declaration
  544. */
  545. /* next_op points to the op that holds the Region */
  546. next_op = op->common.value.arg;
  547. /* next_op points to the op that holds the Bank Register */
  548. next_op = next_op->common.next;
  549. /* next_op points to the op that holds the Bank Value */
  550. next_op = next_op->common.next;
  551. /*
  552. * Set proper index into operand stack for acpi_ds_obj_stack_push
  553. * invoked inside acpi_ds_create_operand.
  554. *
  555. * We use walk_state->Operands[0] to store the evaluated bank_value
  556. */
  557. walk_state->operand_index = 0;
  558. status = acpi_ds_create_operand(walk_state, next_op, 0);
  559. if (ACPI_FAILURE(status)) {
  560. return_ACPI_STATUS(status);
  561. }
  562. status = acpi_ex_resolve_to_value(&walk_state->operands[0], walk_state);
  563. if (ACPI_FAILURE(status)) {
  564. return_ACPI_STATUS(status);
  565. }
  566. ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS,
  567. acpi_ps_get_opcode_name(op->common.aml_opcode), 1);
  568. /*
  569. * Get the bank_value operand and save it
  570. * (at Top of stack)
  571. */
  572. operand_desc = walk_state->operands[0];
  573. /* Arg points to the start Bank Field */
  574. arg = acpi_ps_get_arg(op, 4);
  575. while (arg) {
  576. /* Ignore OFFSET and ACCESSAS terms here */
  577. if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
  578. node = arg->common.node;
  579. obj_desc = acpi_ns_get_attached_object(node);
  580. if (!obj_desc) {
  581. return_ACPI_STATUS(AE_NOT_EXIST);
  582. }
  583. obj_desc->bank_field.value =
  584. (u32) operand_desc->integer.value;
  585. }
  586. /* Move to next field in the list */
  587. arg = arg->common.next;
  588. }
  589. acpi_ut_remove_reference(operand_desc);
  590. return_ACPI_STATUS(status);
  591. }