exstore.c 20 KB

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