dsopcode.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  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 - 2022, 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_BIOS_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. status = AE_AML_BUFFER_LIMIT;
  157. ACPI_BIOS_EXCEPTION((AE_INFO, status,
  158. "Field [%4.4s] at bit offset/length %u/%u "
  159. "exceeds size of target Buffer (%u bits)",
  160. acpi_ut_get_node_name(result_desc),
  161. bit_offset, bit_count,
  162. 8 * (u32)buffer_desc->buffer.length));
  163. goto cleanup;
  164. }
  165. /*
  166. * Initialize areas of the field object that are common to all fields
  167. * For field_flags, use LOCK_RULE = 0 (NO_LOCK),
  168. * UPDATE_RULE = 0 (UPDATE_PRESERVE)
  169. */
  170. status =
  171. acpi_ex_prep_common_field_object(obj_desc, field_flags, 0,
  172. bit_offset, bit_count);
  173. if (ACPI_FAILURE(status)) {
  174. goto cleanup;
  175. }
  176. obj_desc->buffer_field.buffer_obj = buffer_desc;
  177. obj_desc->buffer_field.is_create_field =
  178. aml_opcode == AML_CREATE_FIELD_OP;
  179. /* Reference count for buffer_desc inherits obj_desc count */
  180. buffer_desc->common.reference_count = (u16)
  181. (buffer_desc->common.reference_count +
  182. obj_desc->common.reference_count);
  183. cleanup:
  184. /* Always delete the operands */
  185. acpi_ut_remove_reference(offset_desc);
  186. acpi_ut_remove_reference(buffer_desc);
  187. if (aml_opcode == AML_CREATE_FIELD_OP) {
  188. acpi_ut_remove_reference(length_desc);
  189. }
  190. /* On failure, delete the result descriptor */
  191. if (ACPI_FAILURE(status)) {
  192. acpi_ut_remove_reference(result_desc); /* Result descriptor */
  193. } else {
  194. /* Now the address and length are valid for this buffer_field */
  195. obj_desc->buffer_field.flags |= AOPOBJ_DATA_VALID;
  196. }
  197. return_ACPI_STATUS(status);
  198. }
  199. /*******************************************************************************
  200. *
  201. * FUNCTION: acpi_ds_eval_buffer_field_operands
  202. *
  203. * PARAMETERS: walk_state - Current walk
  204. * op - A valid buffer_field Op object
  205. *
  206. * RETURN: Status
  207. *
  208. * DESCRIPTION: Get buffer_field Buffer and Index
  209. * Called from acpi_ds_exec_end_op during buffer_field parse tree walk
  210. *
  211. ******************************************************************************/
  212. acpi_status
  213. acpi_ds_eval_buffer_field_operands(struct acpi_walk_state *walk_state,
  214. union acpi_parse_object *op)
  215. {
  216. acpi_status status;
  217. union acpi_operand_object *obj_desc;
  218. struct acpi_namespace_node *node;
  219. union acpi_parse_object *next_op;
  220. ACPI_FUNCTION_TRACE_PTR(ds_eval_buffer_field_operands, op);
  221. /*
  222. * This is where we evaluate the address and length fields of the
  223. * create_xxx_field declaration
  224. */
  225. node = op->common.node;
  226. /* next_op points to the op that holds the Buffer */
  227. next_op = op->common.value.arg;
  228. /* Evaluate/create the address and length operands */
  229. status = acpi_ds_create_operands(walk_state, next_op);
  230. if (ACPI_FAILURE(status)) {
  231. return_ACPI_STATUS(status);
  232. }
  233. obj_desc = acpi_ns_get_attached_object(node);
  234. if (!obj_desc) {
  235. return_ACPI_STATUS(AE_NOT_EXIST);
  236. }
  237. /* Resolve the operands */
  238. status =
  239. acpi_ex_resolve_operands(op->common.aml_opcode, ACPI_WALK_OPERANDS,
  240. walk_state);
  241. if (ACPI_FAILURE(status)) {
  242. ACPI_ERROR((AE_INFO, "(%s) bad operand(s), status 0x%X",
  243. acpi_ps_get_opcode_name(op->common.aml_opcode),
  244. status));
  245. return_ACPI_STATUS(status);
  246. }
  247. /* Initialize the Buffer Field */
  248. if (op->common.aml_opcode == AML_CREATE_FIELD_OP) {
  249. /* NOTE: Slightly different operands for this opcode */
  250. status =
  251. acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
  252. walk_state->operands[0],
  253. walk_state->operands[1],
  254. walk_state->operands[2],
  255. walk_state->operands[3]);
  256. } else {
  257. /* All other, create_xxx_field opcodes */
  258. status =
  259. acpi_ds_init_buffer_field(op->common.aml_opcode, obj_desc,
  260. walk_state->operands[0],
  261. walk_state->operands[1], NULL,
  262. walk_state->operands[2]);
  263. }
  264. return_ACPI_STATUS(status);
  265. }
  266. /*******************************************************************************
  267. *
  268. * FUNCTION: acpi_ds_eval_region_operands
  269. *
  270. * PARAMETERS: walk_state - Current walk
  271. * op - A valid region Op object
  272. *
  273. * RETURN: Status
  274. *
  275. * DESCRIPTION: Get region address and length
  276. * Called from acpi_ds_exec_end_op during op_region parse tree walk
  277. *
  278. ******************************************************************************/
  279. acpi_status
  280. acpi_ds_eval_region_operands(struct acpi_walk_state *walk_state,
  281. union acpi_parse_object *op)
  282. {
  283. acpi_status status;
  284. union acpi_operand_object *obj_desc;
  285. union acpi_operand_object *operand_desc;
  286. struct acpi_namespace_node *node;
  287. union acpi_parse_object *next_op;
  288. acpi_adr_space_type space_id;
  289. ACPI_FUNCTION_TRACE_PTR(ds_eval_region_operands, op);
  290. /*
  291. * This is where we evaluate the address and length fields of the
  292. * op_region declaration
  293. */
  294. node = op->common.node;
  295. /* next_op points to the op that holds the space_ID */
  296. next_op = op->common.value.arg;
  297. space_id = (acpi_adr_space_type)next_op->common.value.integer;
  298. /* next_op points to address op */
  299. next_op = next_op->common.next;
  300. /* Evaluate/create the address and length operands */
  301. status = acpi_ds_create_operands(walk_state, next_op);
  302. if (ACPI_FAILURE(status)) {
  303. return_ACPI_STATUS(status);
  304. }
  305. /* Resolve the length and address operands to numbers */
  306. status =
  307. acpi_ex_resolve_operands(op->common.aml_opcode, ACPI_WALK_OPERANDS,
  308. walk_state);
  309. if (ACPI_FAILURE(status)) {
  310. return_ACPI_STATUS(status);
  311. }
  312. obj_desc = acpi_ns_get_attached_object(node);
  313. if (!obj_desc) {
  314. return_ACPI_STATUS(AE_NOT_EXIST);
  315. }
  316. /*
  317. * Get the length operand and save it
  318. * (at Top of stack)
  319. */
  320. operand_desc = walk_state->operands[walk_state->num_operands - 1];
  321. obj_desc->region.length = (u32) operand_desc->integer.value;
  322. acpi_ut_remove_reference(operand_desc);
  323. /* A zero-length operation region is unusable. Just warn */
  324. if (!obj_desc->region.length
  325. && (space_id < ACPI_NUM_PREDEFINED_REGIONS)) {
  326. ACPI_WARNING((AE_INFO,
  327. "Operation Region [%4.4s] has zero length (SpaceId %X)",
  328. node->name.ascii, space_id));
  329. }
  330. /*
  331. * Get the address and save it
  332. * (at top of stack - 1)
  333. */
  334. operand_desc = walk_state->operands[walk_state->num_operands - 2];
  335. obj_desc->region.address = (acpi_physical_address)
  336. operand_desc->integer.value;
  337. acpi_ut_remove_reference(operand_desc);
  338. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
  339. obj_desc,
  340. ACPI_FORMAT_UINT64(obj_desc->region.address),
  341. obj_desc->region.length));
  342. status = acpi_ut_add_address_range(obj_desc->region.space_id,
  343. obj_desc->region.address,
  344. obj_desc->region.length, node);
  345. /* Now the address and length are valid for this opregion */
  346. obj_desc->region.flags |= AOPOBJ_DATA_VALID;
  347. return_ACPI_STATUS(status);
  348. }
  349. /*******************************************************************************
  350. *
  351. * FUNCTION: acpi_ds_eval_table_region_operands
  352. *
  353. * PARAMETERS: walk_state - Current walk
  354. * op - A valid region Op object
  355. *
  356. * RETURN: Status
  357. *
  358. * DESCRIPTION: Get region address and length.
  359. * Called from acpi_ds_exec_end_op during data_table_region parse
  360. * tree walk.
  361. *
  362. ******************************************************************************/
  363. acpi_status
  364. acpi_ds_eval_table_region_operands(struct acpi_walk_state *walk_state,
  365. union acpi_parse_object *op)
  366. {
  367. acpi_status status;
  368. union acpi_operand_object *obj_desc;
  369. union acpi_operand_object **operand;
  370. struct acpi_namespace_node *node;
  371. union acpi_parse_object *next_op;
  372. struct acpi_table_header *table;
  373. u32 table_index;
  374. ACPI_FUNCTION_TRACE_PTR(ds_eval_table_region_operands, op);
  375. /*
  376. * This is where we evaluate the Signature string, oem_id string,
  377. * and oem_table_id string of the Data Table Region declaration
  378. */
  379. node = op->common.node;
  380. /* next_op points to Signature string op */
  381. next_op = op->common.value.arg;
  382. /*
  383. * Evaluate/create the Signature string, oem_id string,
  384. * and oem_table_id string operands
  385. */
  386. status = acpi_ds_create_operands(walk_state, next_op);
  387. if (ACPI_FAILURE(status)) {
  388. return_ACPI_STATUS(status);
  389. }
  390. operand = &walk_state->operands[0];
  391. /*
  392. * Resolve the Signature string, oem_id string,
  393. * and oem_table_id string operands
  394. */
  395. status =
  396. acpi_ex_resolve_operands(op->common.aml_opcode, ACPI_WALK_OPERANDS,
  397. walk_state);
  398. if (ACPI_FAILURE(status)) {
  399. goto cleanup;
  400. }
  401. /* Find the ACPI table */
  402. status = acpi_tb_find_table(operand[0]->string.pointer,
  403. operand[1]->string.pointer,
  404. operand[2]->string.pointer, &table_index);
  405. if (ACPI_FAILURE(status)) {
  406. if (status == AE_NOT_FOUND) {
  407. ACPI_ERROR((AE_INFO,
  408. "ACPI Table [%4.4s] OEM:(%s, %s) not found in RSDT/XSDT",
  409. operand[0]->string.pointer,
  410. operand[1]->string.pointer,
  411. operand[2]->string.pointer));
  412. }
  413. goto cleanup;
  414. }
  415. status = acpi_get_table_by_index(table_index, &table);
  416. if (ACPI_FAILURE(status)) {
  417. goto cleanup;
  418. }
  419. obj_desc = acpi_ns_get_attached_object(node);
  420. if (!obj_desc) {
  421. status = AE_NOT_EXIST;
  422. goto cleanup;
  423. }
  424. obj_desc->region.address = ACPI_PTR_TO_PHYSADDR(table);
  425. obj_desc->region.length = table->length;
  426. obj_desc->region.pointer = table;
  427. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "RgnObj %p Addr %8.8X%8.8X Len %X\n",
  428. obj_desc,
  429. ACPI_FORMAT_UINT64(obj_desc->region.address),
  430. obj_desc->region.length));
  431. /* Now the address and length are valid for this opregion */
  432. obj_desc->region.flags |= AOPOBJ_DATA_VALID;
  433. cleanup:
  434. acpi_ut_remove_reference(operand[0]);
  435. acpi_ut_remove_reference(operand[1]);
  436. acpi_ut_remove_reference(operand[2]);
  437. return_ACPI_STATUS(status);
  438. }
  439. /*******************************************************************************
  440. *
  441. * FUNCTION: acpi_ds_eval_data_object_operands
  442. *
  443. * PARAMETERS: walk_state - Current walk
  444. * op - A valid data_object Op object
  445. * obj_desc - data_object
  446. *
  447. * RETURN: Status
  448. *
  449. * DESCRIPTION: Get the operands and complete the following data object types:
  450. * Buffer, Package.
  451. *
  452. ******************************************************************************/
  453. acpi_status
  454. acpi_ds_eval_data_object_operands(struct acpi_walk_state *walk_state,
  455. union acpi_parse_object *op,
  456. union acpi_operand_object *obj_desc)
  457. {
  458. acpi_status status;
  459. union acpi_operand_object *arg_desc;
  460. u32 length;
  461. ACPI_FUNCTION_TRACE(ds_eval_data_object_operands);
  462. /* The first operand (for all of these data objects) is the length */
  463. /*
  464. * Set proper index into operand stack for acpi_ds_obj_stack_push
  465. * invoked inside acpi_ds_create_operand.
  466. */
  467. walk_state->operand_index = walk_state->num_operands;
  468. /* Ignore if child is not valid */
  469. if (!op->common.value.arg) {
  470. ACPI_ERROR((AE_INFO,
  471. "Missing child while evaluating opcode %4.4X, Op %p",
  472. op->common.aml_opcode, op));
  473. return_ACPI_STATUS(AE_OK);
  474. }
  475. status = acpi_ds_create_operand(walk_state, op->common.value.arg, 1);
  476. if (ACPI_FAILURE(status)) {
  477. return_ACPI_STATUS(status);
  478. }
  479. status = acpi_ex_resolve_operands(walk_state->opcode,
  480. &(walk_state->
  481. operands[walk_state->num_operands -
  482. 1]), walk_state);
  483. if (ACPI_FAILURE(status)) {
  484. return_ACPI_STATUS(status);
  485. }
  486. /* Extract length operand */
  487. arg_desc = walk_state->operands[walk_state->num_operands - 1];
  488. length = (u32) arg_desc->integer.value;
  489. /* Cleanup for length operand */
  490. status = acpi_ds_obj_stack_pop(1, walk_state);
  491. if (ACPI_FAILURE(status)) {
  492. return_ACPI_STATUS(status);
  493. }
  494. acpi_ut_remove_reference(arg_desc);
  495. /*
  496. * Create the actual data object
  497. */
  498. switch (op->common.aml_opcode) {
  499. case AML_BUFFER_OP:
  500. status =
  501. acpi_ds_build_internal_buffer_obj(walk_state, op, length,
  502. &obj_desc);
  503. break;
  504. case AML_PACKAGE_OP:
  505. case AML_VARIABLE_PACKAGE_OP:
  506. status =
  507. acpi_ds_build_internal_package_obj(walk_state, op, length,
  508. &obj_desc);
  509. break;
  510. default:
  511. return_ACPI_STATUS(AE_AML_BAD_OPCODE);
  512. }
  513. if (ACPI_SUCCESS(status)) {
  514. /*
  515. * Return the object in the walk_state, unless the parent is a package -
  516. * in this case, the return object will be stored in the parse tree
  517. * for the package.
  518. */
  519. if ((!op->common.parent) ||
  520. ((op->common.parent->common.aml_opcode != AML_PACKAGE_OP) &&
  521. (op->common.parent->common.aml_opcode !=
  522. AML_VARIABLE_PACKAGE_OP)
  523. && (op->common.parent->common.aml_opcode !=
  524. AML_NAME_OP))) {
  525. walk_state->result_obj = obj_desc;
  526. }
  527. }
  528. return_ACPI_STATUS(status);
  529. }
  530. /*******************************************************************************
  531. *
  532. * FUNCTION: acpi_ds_eval_bank_field_operands
  533. *
  534. * PARAMETERS: walk_state - Current walk
  535. * op - A valid bank_field Op object
  536. *
  537. * RETURN: Status
  538. *
  539. * DESCRIPTION: Get bank_field bank_value
  540. * Called from acpi_ds_exec_end_op during bank_field parse tree walk
  541. *
  542. ******************************************************************************/
  543. acpi_status
  544. acpi_ds_eval_bank_field_operands(struct acpi_walk_state *walk_state,
  545. union acpi_parse_object *op)
  546. {
  547. acpi_status status;
  548. union acpi_operand_object *obj_desc;
  549. union acpi_operand_object *operand_desc;
  550. struct acpi_namespace_node *node;
  551. union acpi_parse_object *next_op;
  552. union acpi_parse_object *arg;
  553. ACPI_FUNCTION_TRACE_PTR(ds_eval_bank_field_operands, op);
  554. /*
  555. * This is where we evaluate the bank_value field of the
  556. * bank_field declaration
  557. */
  558. /* next_op points to the op that holds the Region */
  559. next_op = op->common.value.arg;
  560. /* next_op points to the op that holds the Bank Register */
  561. next_op = next_op->common.next;
  562. /* next_op points to the op that holds the Bank Value */
  563. next_op = next_op->common.next;
  564. /*
  565. * Set proper index into operand stack for acpi_ds_obj_stack_push
  566. * invoked inside acpi_ds_create_operand.
  567. *
  568. * We use walk_state->Operands[0] to store the evaluated bank_value
  569. */
  570. walk_state->operand_index = 0;
  571. status = acpi_ds_create_operand(walk_state, next_op, 0);
  572. if (ACPI_FAILURE(status)) {
  573. return_ACPI_STATUS(status);
  574. }
  575. status = acpi_ex_resolve_to_value(&walk_state->operands[0], walk_state);
  576. if (ACPI_FAILURE(status)) {
  577. return_ACPI_STATUS(status);
  578. }
  579. ACPI_DUMP_OPERANDS(ACPI_WALK_OPERANDS,
  580. acpi_ps_get_opcode_name(op->common.aml_opcode), 1);
  581. /*
  582. * Get the bank_value operand and save it
  583. * (at Top of stack)
  584. */
  585. operand_desc = walk_state->operands[0];
  586. /* Arg points to the start Bank Field */
  587. arg = acpi_ps_get_arg(op, 4);
  588. while (arg) {
  589. /* Ignore OFFSET and ACCESSAS terms here */
  590. if (arg->common.aml_opcode == AML_INT_NAMEDFIELD_OP) {
  591. node = arg->common.node;
  592. obj_desc = acpi_ns_get_attached_object(node);
  593. if (!obj_desc) {
  594. return_ACPI_STATUS(AE_NOT_EXIST);
  595. }
  596. obj_desc->bank_field.value =
  597. (u32) operand_desc->integer.value;
  598. }
  599. /* Move to next field in the list */
  600. arg = arg->common.next;
  601. }
  602. acpi_ut_remove_reference(operand_desc);
  603. return_ACPI_STATUS(status);
  604. }