dsopcode.c 21 KB

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