exstore.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /******************************************************************************
  2. *
  3. * Module Name: exstore - AML Interpreter object store support
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2008, 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 <acpi/acdispat.h>
  44. #include <acpi/acinterp.h>
  45. #include <acpi/amlcode.h>
  46. #include <acpi/acnamesp.h>
  47. #include <acpi/acparser.h>
  48. #define _COMPONENT ACPI_EXECUTER
  49. ACPI_MODULE_NAME("exstore")
  50. /* Local prototypes */
  51. static void
  52. acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
  53. u32 level, u32 index);
  54. static acpi_status
  55. acpi_ex_store_object_to_index(union acpi_operand_object *val_desc,
  56. union acpi_operand_object *dest_desc,
  57. struct acpi_walk_state *walk_state);
  58. /*******************************************************************************
  59. *
  60. * FUNCTION: acpi_ex_do_debug_object
  61. *
  62. * PARAMETERS: source_desc - Value to be stored
  63. * Level - Indentation level (used for packages)
  64. * Index - Current package element, zero if not pkg
  65. *
  66. * RETURN: None
  67. *
  68. * DESCRIPTION: Handles stores to the Debug Object.
  69. *
  70. ******************************************************************************/
  71. static void
  72. acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
  73. u32 level, u32 index)
  74. {
  75. u32 i;
  76. ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
  77. /* Print line header as long as we are not in the middle of an object display */
  78. if (!((level > 0) && index == 0)) {
  79. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s",
  80. level, " "));
  81. }
  82. /* Display index for package output only */
  83. if (index > 0) {
  84. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  85. "(%.2u) ", index - 1));
  86. }
  87. if (!source_desc) {
  88. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[Null Object]\n"));
  89. return_VOID;
  90. }
  91. if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
  92. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s ",
  93. acpi_ut_get_object_type_name
  94. (source_desc)));
  95. if (!acpi_ut_valid_internal_object(source_desc)) {
  96. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  97. "%p, Invalid Internal Object!\n",
  98. source_desc));
  99. return_VOID;
  100. }
  101. } else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
  102. ACPI_DESC_TYPE_NAMED) {
  103. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s: %p\n",
  104. acpi_ut_get_type_name(((struct
  105. acpi_namespace_node
  106. *)source_desc)->
  107. type),
  108. source_desc));
  109. return_VOID;
  110. } else {
  111. return_VOID;
  112. }
  113. /* source_desc is of type ACPI_DESC_TYPE_OPERAND */
  114. switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
  115. case ACPI_TYPE_INTEGER:
  116. /* Output correct integer width */
  117. if (acpi_gbl_integer_byte_width == 4) {
  118. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
  119. (u32) source_desc->integer.
  120. value));
  121. } else {
  122. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  123. "0x%8.8X%8.8X\n",
  124. ACPI_FORMAT_UINT64(source_desc->
  125. integer.
  126. value)));
  127. }
  128. break;
  129. case ACPI_TYPE_BUFFER:
  130. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n",
  131. (u32) source_desc->buffer.length));
  132. ACPI_DUMP_BUFFER(source_desc->buffer.pointer,
  133. (source_desc->buffer.length <
  134. 256) ? source_desc->buffer.length : 256);
  135. break;
  136. case ACPI_TYPE_STRING:
  137. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
  138. source_desc->string.length,
  139. source_desc->string.pointer));
  140. break;
  141. case ACPI_TYPE_PACKAGE:
  142. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  143. "[Contains 0x%.2X Elements]\n",
  144. source_desc->package.count));
  145. /* Output the entire contents of the package */
  146. for (i = 0; i < source_desc->package.count; i++) {
  147. acpi_ex_do_debug_object(source_desc->package.
  148. elements[i], level + 4, i + 1);
  149. }
  150. break;
  151. case ACPI_TYPE_LOCAL_REFERENCE:
  152. if (source_desc->reference.opcode == AML_INDEX_OP) {
  153. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  154. "[%s, 0x%X]\n",
  155. acpi_ps_get_opcode_name
  156. (source_desc->reference.opcode),
  157. source_desc->reference.offset));
  158. } else {
  159. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[%s]",
  160. acpi_ps_get_opcode_name
  161. (source_desc->reference.opcode)));
  162. }
  163. if (source_desc->reference.opcode == AML_LOAD_OP) { /* Load and load_table */
  164. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  165. " Table OwnerId %p\n",
  166. source_desc->reference.object));
  167. break;
  168. }
  169. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, " "));
  170. /* Check for valid node first, then valid object */
  171. if (source_desc->reference.node) {
  172. if (ACPI_GET_DESCRIPTOR_TYPE
  173. (source_desc->reference.node) !=
  174. ACPI_DESC_TYPE_NAMED) {
  175. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  176. " %p - Not a valid namespace node\n",
  177. source_desc->reference.
  178. node));
  179. } else {
  180. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  181. "Node %p [%4.4s] ",
  182. source_desc->reference.
  183. node,
  184. (source_desc->reference.
  185. node)->name.ascii));
  186. switch ((source_desc->reference.node)->type) {
  187. /* These types have no attached object */
  188. case ACPI_TYPE_DEVICE:
  189. acpi_os_printf("Device\n");
  190. break;
  191. case ACPI_TYPE_THERMAL:
  192. acpi_os_printf("Thermal Zone\n");
  193. break;
  194. default:
  195. acpi_ex_do_debug_object((source_desc->
  196. reference.
  197. node)->object,
  198. level + 4, 0);
  199. break;
  200. }
  201. }
  202. } else if (source_desc->reference.object) {
  203. if (ACPI_GET_DESCRIPTOR_TYPE
  204. (source_desc->reference.object) ==
  205. ACPI_DESC_TYPE_NAMED) {
  206. acpi_ex_do_debug_object(((struct
  207. acpi_namespace_node *)
  208. source_desc->reference.
  209. object)->object,
  210. level + 4, 0);
  211. } else {
  212. acpi_ex_do_debug_object(source_desc->reference.
  213. object, level + 4, 0);
  214. }
  215. }
  216. break;
  217. default:
  218. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%p\n",
  219. source_desc));
  220. break;
  221. }
  222. ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
  223. return_VOID;
  224. }
  225. /*******************************************************************************
  226. *
  227. * FUNCTION: acpi_ex_store
  228. *
  229. * PARAMETERS: *source_desc - Value to be stored
  230. * *dest_desc - Where to store it. Must be an NS node
  231. * or an union acpi_operand_object of type
  232. * Reference;
  233. * walk_state - Current walk state
  234. *
  235. * RETURN: Status
  236. *
  237. * DESCRIPTION: Store the value described by source_desc into the location
  238. * described by dest_desc. Called by various interpreter
  239. * functions to store the result of an operation into
  240. * the destination operand -- not just simply the actual "Store"
  241. * ASL operator.
  242. *
  243. ******************************************************************************/
  244. acpi_status
  245. acpi_ex_store(union acpi_operand_object *source_desc,
  246. union acpi_operand_object *dest_desc,
  247. struct acpi_walk_state *walk_state)
  248. {
  249. acpi_status status = AE_OK;
  250. union acpi_operand_object *ref_desc = dest_desc;
  251. ACPI_FUNCTION_TRACE_PTR(ex_store, dest_desc);
  252. /* Validate parameters */
  253. if (!source_desc || !dest_desc) {
  254. ACPI_ERROR((AE_INFO, "Null parameter"));
  255. return_ACPI_STATUS(AE_AML_NO_OPERAND);
  256. }
  257. /* dest_desc can be either a namespace node or an ACPI object */
  258. if (ACPI_GET_DESCRIPTOR_TYPE(dest_desc) == ACPI_DESC_TYPE_NAMED) {
  259. /*
  260. * Dest is a namespace node,
  261. * Storing an object into a Named node.
  262. */
  263. status = acpi_ex_store_object_to_node(source_desc,
  264. (struct
  265. acpi_namespace_node *)
  266. dest_desc, walk_state,
  267. ACPI_IMPLICIT_CONVERSION);
  268. return_ACPI_STATUS(status);
  269. }
  270. /* Destination object must be a Reference or a Constant object */
  271. switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
  272. case ACPI_TYPE_LOCAL_REFERENCE:
  273. break;
  274. case ACPI_TYPE_INTEGER:
  275. /* Allow stores to Constants -- a Noop as per ACPI spec */
  276. if (dest_desc->common.flags & AOPOBJ_AML_CONSTANT) {
  277. return_ACPI_STATUS(AE_OK);
  278. }
  279. /*lint -fallthrough */
  280. default:
  281. /* Destination is not a Reference object */
  282. ACPI_ERROR((AE_INFO,
  283. "Target is not a Reference or Constant object - %s [%p]",
  284. acpi_ut_get_object_type_name(dest_desc),
  285. dest_desc));
  286. ACPI_DUMP_STACK_ENTRY(source_desc);
  287. ACPI_DUMP_STACK_ENTRY(dest_desc);
  288. ACPI_DUMP_OPERANDS(&dest_desc, ACPI_IMODE_EXECUTE, "ExStore",
  289. 2,
  290. "Target is not a Reference or Constant object");
  291. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  292. }
  293. /*
  294. * Examine the Reference opcode. These cases are handled:
  295. *
  296. * 1) Store to Name (Change the object associated with a name)
  297. * 2) Store to an indexed area of a Buffer or Package
  298. * 3) Store to a Method Local or Arg
  299. * 4) Store to the debug object
  300. */
  301. switch (ref_desc->reference.opcode) {
  302. case AML_REF_OF_OP:
  303. /* Storing an object into a Name "container" */
  304. status = acpi_ex_store_object_to_node(source_desc,
  305. ref_desc->reference.
  306. object, walk_state,
  307. ACPI_IMPLICIT_CONVERSION);
  308. break;
  309. case AML_INDEX_OP:
  310. /* Storing to an Index (pointer into a packager or buffer) */
  311. status =
  312. acpi_ex_store_object_to_index(source_desc, ref_desc,
  313. walk_state);
  314. break;
  315. case AML_LOCAL_OP:
  316. case AML_ARG_OP:
  317. /* Store to a method local/arg */
  318. status =
  319. acpi_ds_store_object_to_local(ref_desc->reference.opcode,
  320. ref_desc->reference.offset,
  321. source_desc, walk_state);
  322. break;
  323. case AML_DEBUG_OP:
  324. /*
  325. * Storing to the Debug object causes the value stored to be
  326. * displayed and otherwise has no effect -- see ACPI Specification
  327. */
  328. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  329. "**** Write to Debug Object: Object %p %s ****:\n\n",
  330. source_desc,
  331. acpi_ut_get_object_type_name(source_desc)));
  332. acpi_ex_do_debug_object(source_desc, 0, 0);
  333. break;
  334. default:
  335. ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X",
  336. ref_desc->reference.opcode));
  337. ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR);
  338. status = AE_AML_INTERNAL;
  339. break;
  340. }
  341. return_ACPI_STATUS(status);
  342. }
  343. /*******************************************************************************
  344. *
  345. * FUNCTION: acpi_ex_store_object_to_index
  346. *
  347. * PARAMETERS: *source_desc - Value to be stored
  348. * *dest_desc - Named object to receive the value
  349. * walk_state - Current walk state
  350. *
  351. * RETURN: Status
  352. *
  353. * DESCRIPTION: Store the object to indexed Buffer or Package element
  354. *
  355. ******************************************************************************/
  356. static acpi_status
  357. acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
  358. union acpi_operand_object *index_desc,
  359. struct acpi_walk_state *walk_state)
  360. {
  361. acpi_status status = AE_OK;
  362. union acpi_operand_object *obj_desc;
  363. union acpi_operand_object *new_desc;
  364. u8 value = 0;
  365. u32 i;
  366. ACPI_FUNCTION_TRACE(ex_store_object_to_index);
  367. /*
  368. * Destination must be a reference pointer, and
  369. * must point to either a buffer or a package
  370. */
  371. switch (index_desc->reference.target_type) {
  372. case ACPI_TYPE_PACKAGE:
  373. /*
  374. * Storing to a package element. Copy the object and replace
  375. * any existing object with the new object. No implicit
  376. * conversion is performed.
  377. *
  378. * The object at *(index_desc->Reference.Where) is the
  379. * element within the package that is to be modified.
  380. * The parent package object is at index_desc->Reference.Object
  381. */
  382. obj_desc = *(index_desc->reference.where);
  383. if (ACPI_GET_OBJECT_TYPE(source_desc) ==
  384. ACPI_TYPE_LOCAL_REFERENCE
  385. && source_desc->reference.opcode == AML_LOAD_OP) {
  386. /* This is a DDBHandle, just add a reference to it */
  387. acpi_ut_add_reference(source_desc);
  388. new_desc = source_desc;
  389. } else {
  390. /* Normal object, copy it */
  391. status =
  392. acpi_ut_copy_iobject_to_iobject(source_desc,
  393. &new_desc,
  394. walk_state);
  395. if (ACPI_FAILURE(status)) {
  396. return_ACPI_STATUS(status);
  397. }
  398. }
  399. if (obj_desc) {
  400. /* Decrement reference count by the ref count of the parent package */
  401. for (i = 0; i < ((union acpi_operand_object *)
  402. index_desc->reference.object)->common.
  403. reference_count; i++) {
  404. acpi_ut_remove_reference(obj_desc);
  405. }
  406. }
  407. *(index_desc->reference.where) = new_desc;
  408. /* Increment ref count by the ref count of the parent package-1 */
  409. for (i = 1; i < ((union acpi_operand_object *)
  410. index_desc->reference.object)->common.
  411. reference_count; i++) {
  412. acpi_ut_add_reference(new_desc);
  413. }
  414. break;
  415. case ACPI_TYPE_BUFFER_FIELD:
  416. /*
  417. * Store into a Buffer or String (not actually a real buffer_field)
  418. * at a location defined by an Index.
  419. *
  420. * The first 8-bit element of the source object is written to the
  421. * 8-bit Buffer location defined by the Index destination object,
  422. * according to the ACPI 2.0 specification.
  423. */
  424. /*
  425. * Make sure the target is a Buffer or String. An error should
  426. * not happen here, since the reference_object was constructed
  427. * by the INDEX_OP code.
  428. */
  429. obj_desc = index_desc->reference.object;
  430. if ((ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_BUFFER) &&
  431. (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_STRING)) {
  432. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  433. }
  434. /*
  435. * The assignment of the individual elements will be slightly
  436. * different for each source type.
  437. */
  438. switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
  439. case ACPI_TYPE_INTEGER:
  440. /* Use the least-significant byte of the integer */
  441. value = (u8) (source_desc->integer.value);
  442. break;
  443. case ACPI_TYPE_BUFFER:
  444. case ACPI_TYPE_STRING:
  445. /* Note: Takes advantage of common string/buffer fields */
  446. value = source_desc->buffer.pointer[0];
  447. break;
  448. default:
  449. /* All other types are invalid */
  450. ACPI_ERROR((AE_INFO,
  451. "Source must be Integer/Buffer/String type, not %s",
  452. acpi_ut_get_object_type_name(source_desc)));
  453. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  454. }
  455. /* Store the source value into the target buffer byte */
  456. obj_desc->buffer.pointer[index_desc->reference.offset] = value;
  457. break;
  458. default:
  459. ACPI_ERROR((AE_INFO, "Target is not a Package or BufferField"));
  460. status = AE_AML_OPERAND_TYPE;
  461. break;
  462. }
  463. return_ACPI_STATUS(status);
  464. }
  465. /*******************************************************************************
  466. *
  467. * FUNCTION: acpi_ex_store_object_to_node
  468. *
  469. * PARAMETERS: source_desc - Value to be stored
  470. * Node - Named object to receive the value
  471. * walk_state - Current walk state
  472. * implicit_conversion - Perform implicit conversion (yes/no)
  473. *
  474. * RETURN: Status
  475. *
  476. * DESCRIPTION: Store the object to the named object.
  477. *
  478. * The Assignment of an object to a named object is handled here
  479. * The value passed in will replace the current value (if any)
  480. * with the input value.
  481. *
  482. * When storing into an object the data is converted to the
  483. * target object type then stored in the object. This means
  484. * that the target object type (for an initialized target) will
  485. * not be changed by a store operation.
  486. *
  487. * Assumes parameters are already validated.
  488. *
  489. ******************************************************************************/
  490. acpi_status
  491. acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
  492. struct acpi_namespace_node *node,
  493. struct acpi_walk_state *walk_state,
  494. u8 implicit_conversion)
  495. {
  496. acpi_status status = AE_OK;
  497. union acpi_operand_object *target_desc;
  498. union acpi_operand_object *new_desc;
  499. acpi_object_type target_type;
  500. ACPI_FUNCTION_TRACE_PTR(ex_store_object_to_node, source_desc);
  501. /* Get current type of the node, and object attached to Node */
  502. target_type = acpi_ns_get_type(node);
  503. target_desc = acpi_ns_get_attached_object(node);
  504. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
  505. source_desc,
  506. acpi_ut_get_object_type_name(source_desc), node,
  507. acpi_ut_get_type_name(target_type)));
  508. /*
  509. * Resolve the source object to an actual value
  510. * (If it is a reference object)
  511. */
  512. status = acpi_ex_resolve_object(&source_desc, target_type, walk_state);
  513. if (ACPI_FAILURE(status)) {
  514. return_ACPI_STATUS(status);
  515. }
  516. /* If no implicit conversion, drop into the default case below */
  517. if ((!implicit_conversion) ||
  518. ((walk_state->opcode == AML_COPY_OP) &&
  519. (target_type != ACPI_TYPE_LOCAL_REGION_FIELD) &&
  520. (target_type != ACPI_TYPE_LOCAL_BANK_FIELD) &&
  521. (target_type != ACPI_TYPE_LOCAL_INDEX_FIELD))) {
  522. /*
  523. * Force execution of default (no implicit conversion). Note:
  524. * copy_object does not perform an implicit conversion, as per the ACPI
  525. * spec -- except in case of region/bank/index fields -- because these
  526. * objects must retain their original type permanently.
  527. */
  528. target_type = ACPI_TYPE_ANY;
  529. }
  530. /* Do the actual store operation */
  531. switch (target_type) {
  532. case ACPI_TYPE_BUFFER_FIELD:
  533. case ACPI_TYPE_LOCAL_REGION_FIELD:
  534. case ACPI_TYPE_LOCAL_BANK_FIELD:
  535. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  536. /* For fields, copy the source data to the target field. */
  537. status = acpi_ex_write_data_to_field(source_desc, target_desc,
  538. &walk_state->result_obj);
  539. break;
  540. case ACPI_TYPE_INTEGER:
  541. case ACPI_TYPE_STRING:
  542. case ACPI_TYPE_BUFFER:
  543. /*
  544. * These target types are all of type Integer/String/Buffer, and
  545. * therefore support implicit conversion before the store.
  546. *
  547. * Copy and/or convert the source object to a new target object
  548. */
  549. status =
  550. acpi_ex_store_object_to_object(source_desc, target_desc,
  551. &new_desc, walk_state);
  552. if (ACPI_FAILURE(status)) {
  553. return_ACPI_STATUS(status);
  554. }
  555. if (new_desc != target_desc) {
  556. /*
  557. * Store the new new_desc as the new value of the Name, and set
  558. * the Name's type to that of the value being stored in it.
  559. * source_desc reference count is incremented by attach_object.
  560. *
  561. * Note: This may change the type of the node if an explicit store
  562. * has been performed such that the node/object type has been
  563. * changed.
  564. */
  565. status =
  566. acpi_ns_attach_object(node, new_desc,
  567. new_desc->common.type);
  568. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  569. "Store %s into %s via Convert/Attach\n",
  570. acpi_ut_get_object_type_name
  571. (source_desc),
  572. acpi_ut_get_object_type_name
  573. (new_desc)));
  574. }
  575. break;
  576. default:
  577. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  578. "Storing %s (%p) directly into node (%p) with no implicit conversion\n",
  579. acpi_ut_get_object_type_name(source_desc),
  580. source_desc, node));
  581. /* No conversions for all other types. Just attach the source object */
  582. status = acpi_ns_attach_object(node, source_desc,
  583. ACPI_GET_OBJECT_TYPE
  584. (source_desc));
  585. break;
  586. }
  587. return_ACPI_STATUS(status);
  588. }