dsopcode.c 21 KB

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