dsopcode.c 21 KB

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