exstore.c 19 KB

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