exstore.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  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. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  287. }
  288. /*
  289. * Examine the Reference opcode. These cases are handled:
  290. *
  291. * 1) Store to Name (Change the object associated with a name)
  292. * 2) Store to an indexed area of a Buffer or Package
  293. * 3) Store to a Method Local or Arg
  294. * 4) Store to the debug object
  295. */
  296. switch (ref_desc->reference.opcode) {
  297. case AML_REF_OF_OP:
  298. /* Storing an object into a Name "container" */
  299. status = acpi_ex_store_object_to_node(source_desc,
  300. ref_desc->reference.
  301. object, walk_state,
  302. ACPI_IMPLICIT_CONVERSION);
  303. break;
  304. case AML_INDEX_OP:
  305. /* Storing to an Index (pointer into a packager or buffer) */
  306. status =
  307. acpi_ex_store_object_to_index(source_desc, ref_desc,
  308. walk_state);
  309. break;
  310. case AML_LOCAL_OP:
  311. case AML_ARG_OP:
  312. /* Store to a method local/arg */
  313. status =
  314. acpi_ds_store_object_to_local(ref_desc->reference.opcode,
  315. ref_desc->reference.offset,
  316. source_desc, walk_state);
  317. break;
  318. case AML_DEBUG_OP:
  319. /*
  320. * Storing to the Debug object causes the value stored to be
  321. * displayed and otherwise has no effect -- see ACPI Specification
  322. */
  323. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  324. "**** Write to Debug Object: Object %p %s ****:\n\n",
  325. source_desc,
  326. acpi_ut_get_object_type_name(source_desc)));
  327. acpi_ex_do_debug_object(source_desc, 0, 0);
  328. break;
  329. default:
  330. ACPI_ERROR((AE_INFO, "Unknown Reference opcode %X",
  331. ref_desc->reference.opcode));
  332. ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_ERROR);
  333. status = AE_AML_INTERNAL;
  334. break;
  335. }
  336. return_ACPI_STATUS(status);
  337. }
  338. /*******************************************************************************
  339. *
  340. * FUNCTION: acpi_ex_store_object_to_index
  341. *
  342. * PARAMETERS: *source_desc - Value to be stored
  343. * *dest_desc - Named object to receive the value
  344. * walk_state - Current walk state
  345. *
  346. * RETURN: Status
  347. *
  348. * DESCRIPTION: Store the object to indexed Buffer or Package element
  349. *
  350. ******************************************************************************/
  351. static acpi_status
  352. acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
  353. union acpi_operand_object *index_desc,
  354. struct acpi_walk_state *walk_state)
  355. {
  356. acpi_status status = AE_OK;
  357. union acpi_operand_object *obj_desc;
  358. union acpi_operand_object *new_desc;
  359. u8 value = 0;
  360. u32 i;
  361. ACPI_FUNCTION_TRACE(ex_store_object_to_index);
  362. /*
  363. * Destination must be a reference pointer, and
  364. * must point to either a buffer or a package
  365. */
  366. switch (index_desc->reference.target_type) {
  367. case ACPI_TYPE_PACKAGE:
  368. /*
  369. * Storing to a package element. Copy the object and replace
  370. * any existing object with the new object. No implicit
  371. * conversion is performed.
  372. *
  373. * The object at *(index_desc->Reference.Where) is the
  374. * element within the package that is to be modified.
  375. * The parent package object is at index_desc->Reference.Object
  376. */
  377. obj_desc = *(index_desc->reference.where);
  378. if (ACPI_GET_OBJECT_TYPE(source_desc) ==
  379. ACPI_TYPE_LOCAL_REFERENCE
  380. && source_desc->reference.opcode == AML_LOAD_OP) {
  381. /* This is a DDBHandle, just add a reference to it */
  382. acpi_ut_add_reference(source_desc);
  383. new_desc = source_desc;
  384. } else {
  385. /* Normal object, copy it */
  386. status =
  387. acpi_ut_copy_iobject_to_iobject(source_desc,
  388. &new_desc,
  389. walk_state);
  390. if (ACPI_FAILURE(status)) {
  391. return_ACPI_STATUS(status);
  392. }
  393. }
  394. if (obj_desc) {
  395. /* Decrement reference count by the ref count of the parent package */
  396. for (i = 0; i < ((union acpi_operand_object *)
  397. index_desc->reference.object)->common.
  398. reference_count; i++) {
  399. acpi_ut_remove_reference(obj_desc);
  400. }
  401. }
  402. *(index_desc->reference.where) = new_desc;
  403. /* Increment ref count by the ref count of the parent package-1 */
  404. for (i = 1; i < ((union acpi_operand_object *)
  405. index_desc->reference.object)->common.
  406. reference_count; i++) {
  407. acpi_ut_add_reference(new_desc);
  408. }
  409. break;
  410. case ACPI_TYPE_BUFFER_FIELD:
  411. /*
  412. * Store into a Buffer or String (not actually a real buffer_field)
  413. * at a location defined by an Index.
  414. *
  415. * The first 8-bit element of the source object is written to the
  416. * 8-bit Buffer location defined by the Index destination object,
  417. * according to the ACPI 2.0 specification.
  418. */
  419. /*
  420. * Make sure the target is a Buffer or String. An error should
  421. * not happen here, since the reference_object was constructed
  422. * by the INDEX_OP code.
  423. */
  424. obj_desc = index_desc->reference.object;
  425. if ((ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_BUFFER) &&
  426. (ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_STRING)) {
  427. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  428. }
  429. /*
  430. * The assignment of the individual elements will be slightly
  431. * different for each source type.
  432. */
  433. switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
  434. case ACPI_TYPE_INTEGER:
  435. /* Use the least-significant byte of the integer */
  436. value = (u8) (source_desc->integer.value);
  437. break;
  438. case ACPI_TYPE_BUFFER:
  439. case ACPI_TYPE_STRING:
  440. /* Note: Takes advantage of common string/buffer fields */
  441. value = source_desc->buffer.pointer[0];
  442. break;
  443. default:
  444. /* All other types are invalid */
  445. ACPI_ERROR((AE_INFO,
  446. "Source must be Integer/Buffer/String type, not %s",
  447. acpi_ut_get_object_type_name(source_desc)));
  448. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  449. }
  450. /* Store the source value into the target buffer byte */
  451. obj_desc->buffer.pointer[index_desc->reference.offset] = value;
  452. break;
  453. default:
  454. ACPI_ERROR((AE_INFO, "Target is not a Package or BufferField"));
  455. status = AE_AML_OPERAND_TYPE;
  456. break;
  457. }
  458. return_ACPI_STATUS(status);
  459. }
  460. /*******************************************************************************
  461. *
  462. * FUNCTION: acpi_ex_store_object_to_node
  463. *
  464. * PARAMETERS: source_desc - Value to be stored
  465. * Node - Named object to receive the value
  466. * walk_state - Current walk state
  467. * implicit_conversion - Perform implicit conversion (yes/no)
  468. *
  469. * RETURN: Status
  470. *
  471. * DESCRIPTION: Store the object to the named object.
  472. *
  473. * The Assignment of an object to a named object is handled here
  474. * The value passed in will replace the current value (if any)
  475. * with the input value.
  476. *
  477. * When storing into an object the data is converted to the
  478. * target object type then stored in the object. This means
  479. * that the target object type (for an initialized target) will
  480. * not be changed by a store operation.
  481. *
  482. * Assumes parameters are already validated.
  483. *
  484. ******************************************************************************/
  485. acpi_status
  486. acpi_ex_store_object_to_node(union acpi_operand_object *source_desc,
  487. struct acpi_namespace_node *node,
  488. struct acpi_walk_state *walk_state,
  489. u8 implicit_conversion)
  490. {
  491. acpi_status status = AE_OK;
  492. union acpi_operand_object *target_desc;
  493. union acpi_operand_object *new_desc;
  494. acpi_object_type target_type;
  495. ACPI_FUNCTION_TRACE_PTR(ex_store_object_to_node, source_desc);
  496. /* Get current type of the node, and object attached to Node */
  497. target_type = acpi_ns_get_type(node);
  498. target_desc = acpi_ns_get_attached_object(node);
  499. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Storing %p(%s) into node %p(%s)\n",
  500. source_desc,
  501. acpi_ut_get_object_type_name(source_desc), node,
  502. acpi_ut_get_type_name(target_type)));
  503. /*
  504. * Resolve the source object to an actual value
  505. * (If it is a reference object)
  506. */
  507. status = acpi_ex_resolve_object(&source_desc, target_type, walk_state);
  508. if (ACPI_FAILURE(status)) {
  509. return_ACPI_STATUS(status);
  510. }
  511. /* If no implicit conversion, drop into the default case below */
  512. if ((!implicit_conversion) ||
  513. ((walk_state->opcode == AML_COPY_OP) &&
  514. (target_type != ACPI_TYPE_LOCAL_REGION_FIELD) &&
  515. (target_type != ACPI_TYPE_LOCAL_BANK_FIELD) &&
  516. (target_type != ACPI_TYPE_LOCAL_INDEX_FIELD))) {
  517. /*
  518. * Force execution of default (no implicit conversion). Note:
  519. * copy_object does not perform an implicit conversion, as per the ACPI
  520. * spec -- except in case of region/bank/index fields -- because these
  521. * objects must retain their original type permanently.
  522. */
  523. target_type = ACPI_TYPE_ANY;
  524. }
  525. /* Do the actual store operation */
  526. switch (target_type) {
  527. case ACPI_TYPE_BUFFER_FIELD:
  528. case ACPI_TYPE_LOCAL_REGION_FIELD:
  529. case ACPI_TYPE_LOCAL_BANK_FIELD:
  530. case ACPI_TYPE_LOCAL_INDEX_FIELD:
  531. /* For fields, copy the source data to the target field. */
  532. status = acpi_ex_write_data_to_field(source_desc, target_desc,
  533. &walk_state->result_obj);
  534. break;
  535. case ACPI_TYPE_INTEGER:
  536. case ACPI_TYPE_STRING:
  537. case ACPI_TYPE_BUFFER:
  538. /*
  539. * These target types are all of type Integer/String/Buffer, and
  540. * therefore support implicit conversion before the store.
  541. *
  542. * Copy and/or convert the source object to a new target object
  543. */
  544. status =
  545. acpi_ex_store_object_to_object(source_desc, target_desc,
  546. &new_desc, walk_state);
  547. if (ACPI_FAILURE(status)) {
  548. return_ACPI_STATUS(status);
  549. }
  550. if (new_desc != target_desc) {
  551. /*
  552. * Store the new new_desc as the new value of the Name, and set
  553. * the Name's type to that of the value being stored in it.
  554. * source_desc reference count is incremented by attach_object.
  555. *
  556. * Note: This may change the type of the node if an explicit store
  557. * has been performed such that the node/object type has been
  558. * changed.
  559. */
  560. status =
  561. acpi_ns_attach_object(node, new_desc,
  562. new_desc->common.type);
  563. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  564. "Store %s into %s via Convert/Attach\n",
  565. acpi_ut_get_object_type_name
  566. (source_desc),
  567. acpi_ut_get_object_type_name
  568. (new_desc)));
  569. }
  570. break;
  571. default:
  572. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  573. "Storing %s (%p) directly into node (%p) with no implicit conversion\n",
  574. acpi_ut_get_object_type_name(source_desc),
  575. source_desc, node));
  576. /* No conversions for all other types. Just attach the source object */
  577. status = acpi_ns_attach_object(node, source_desc,
  578. ACPI_GET_OBJECT_TYPE
  579. (source_desc));
  580. break;
  581. }
  582. return_ACPI_STATUS(status);
  583. }