exstore.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  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. #define _COMPONENT ACPI_EXECUTER
  48. ACPI_MODULE_NAME("exstore")
  49. /* Local prototypes */
  50. static void
  51. acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
  52. u32 level, u32 index);
  53. static acpi_status
  54. acpi_ex_store_object_to_index(union acpi_operand_object *val_desc,
  55. union acpi_operand_object *dest_desc,
  56. struct acpi_walk_state *walk_state);
  57. /*******************************************************************************
  58. *
  59. * FUNCTION: acpi_ex_do_debug_object
  60. *
  61. * PARAMETERS: source_desc - Value to be stored
  62. * Level - Indentation level (used for packages)
  63. * Index - Current package element, zero if not pkg
  64. *
  65. * RETURN: None
  66. *
  67. * DESCRIPTION: Handles stores to the Debug Object.
  68. *
  69. ******************************************************************************/
  70. static void
  71. acpi_ex_do_debug_object(union acpi_operand_object *source_desc,
  72. u32 level, u32 index)
  73. {
  74. u32 i;
  75. ACPI_FUNCTION_TRACE_PTR(ex_do_debug_object, source_desc);
  76. /* Print line header as long as we are not in the middle of an object display */
  77. if (!((level > 0) && index == 0)) {
  78. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[ACPI Debug] %*s",
  79. level, " "));
  80. }
  81. /* Display index for package output only */
  82. if (index > 0) {
  83. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  84. "(%.2u) ", index - 1));
  85. }
  86. if (!source_desc) {
  87. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[Null Object]\n"));
  88. return_VOID;
  89. }
  90. if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) == ACPI_DESC_TYPE_OPERAND) {
  91. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s ",
  92. acpi_ut_get_object_type_name
  93. (source_desc)));
  94. if (!acpi_ut_valid_internal_object(source_desc)) {
  95. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  96. "%p, Invalid Internal Object!\n",
  97. source_desc));
  98. return_VOID;
  99. }
  100. } else if (ACPI_GET_DESCRIPTOR_TYPE(source_desc) ==
  101. ACPI_DESC_TYPE_NAMED) {
  102. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%s: %p\n",
  103. acpi_ut_get_type_name(((struct
  104. acpi_namespace_node
  105. *)source_desc)->
  106. type),
  107. source_desc));
  108. return_VOID;
  109. } else {
  110. return_VOID;
  111. }
  112. /* source_desc is of type ACPI_DESC_TYPE_OPERAND */
  113. switch (ACPI_GET_OBJECT_TYPE(source_desc)) {
  114. case ACPI_TYPE_INTEGER:
  115. /* Output correct integer width */
  116. if (acpi_gbl_integer_byte_width == 4) {
  117. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "0x%8.8X\n",
  118. (u32) source_desc->integer.
  119. value));
  120. } else {
  121. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  122. "0x%8.8X%8.8X\n",
  123. ACPI_FORMAT_UINT64(source_desc->
  124. integer.
  125. value)));
  126. }
  127. break;
  128. case ACPI_TYPE_BUFFER:
  129. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X]\n",
  130. (u32) source_desc->buffer.length));
  131. ACPI_DUMP_BUFFER(source_desc->buffer.pointer,
  132. (source_desc->buffer.length <
  133. 256) ? source_desc->buffer.length : 256);
  134. break;
  135. case ACPI_TYPE_STRING:
  136. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[0x%.2X] \"%s\"\n",
  137. source_desc->string.length,
  138. source_desc->string.pointer));
  139. break;
  140. case ACPI_TYPE_PACKAGE:
  141. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  142. "[Contains 0x%.2X Elements]\n",
  143. source_desc->package.count));
  144. /* Output the entire contents of the package */
  145. for (i = 0; i < source_desc->package.count; i++) {
  146. acpi_ex_do_debug_object(source_desc->package.
  147. elements[i], level + 4, i + 1);
  148. }
  149. break;
  150. case ACPI_TYPE_LOCAL_REFERENCE:
  151. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "[%s] ",
  152. acpi_ut_get_reference_name(source_desc)));
  153. /* Decode the reference */
  154. switch (source_desc->reference.class) {
  155. case ACPI_REFCLASS_INDEX:
  156. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "0x%X\n",
  157. source_desc->reference.value));
  158. break;
  159. case ACPI_REFCLASS_TABLE:
  160. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  161. "Table Index 0x%X\n",
  162. source_desc->reference.value));
  163. break;
  164. default:
  165. break;
  166. }
  167. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, " "));
  168. /* Check for valid node first, then valid object */
  169. if (source_desc->reference.node) {
  170. if (ACPI_GET_DESCRIPTOR_TYPE
  171. (source_desc->reference.node) !=
  172. ACPI_DESC_TYPE_NAMED) {
  173. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  174. " %p - Not a valid namespace node\n",
  175. source_desc->reference.
  176. node));
  177. } else {
  178. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT,
  179. "Node %p [%4.4s] ",
  180. source_desc->reference.
  181. node,
  182. (source_desc->reference.
  183. node)->name.ascii));
  184. switch ((source_desc->reference.node)->type) {
  185. /* These types have no attached object */
  186. case ACPI_TYPE_DEVICE:
  187. acpi_os_printf("Device\n");
  188. break;
  189. case ACPI_TYPE_THERMAL:
  190. acpi_os_printf("Thermal Zone\n");
  191. break;
  192. default:
  193. acpi_ex_do_debug_object((source_desc->
  194. reference.
  195. node)->object,
  196. level + 4, 0);
  197. break;
  198. }
  199. }
  200. } else if (source_desc->reference.object) {
  201. if (ACPI_GET_DESCRIPTOR_TYPE
  202. (source_desc->reference.object) ==
  203. ACPI_DESC_TYPE_NAMED) {
  204. acpi_ex_do_debug_object(((struct
  205. acpi_namespace_node *)
  206. source_desc->reference.
  207. object)->object,
  208. level + 4, 0);
  209. } else {
  210. acpi_ex_do_debug_object(source_desc->reference.
  211. object, level + 4, 0);
  212. }
  213. }
  214. break;
  215. default:
  216. ACPI_DEBUG_PRINT_RAW((ACPI_DB_DEBUG_OBJECT, "%p\n",
  217. source_desc));
  218. break;
  219. }
  220. ACPI_DEBUG_PRINT_RAW((ACPI_DB_EXEC, "\n"));
  221. return_VOID;
  222. }
  223. /*******************************************************************************
  224. *
  225. * FUNCTION: acpi_ex_store
  226. *
  227. * PARAMETERS: *source_desc - Value to be stored
  228. * *dest_desc - Where to store it. Must be an NS node
  229. * or an union acpi_operand_object of type
  230. * Reference;
  231. * walk_state - Current walk state
  232. *
  233. * RETURN: Status
  234. *
  235. * DESCRIPTION: Store the value described by source_desc into the location
  236. * described by dest_desc. Called by various interpreter
  237. * functions to store the result of an operation into
  238. * the destination operand -- not just simply the actual "Store"
  239. * ASL operator.
  240. *
  241. ******************************************************************************/
  242. acpi_status
  243. acpi_ex_store(union acpi_operand_object *source_desc,
  244. union acpi_operand_object *dest_desc,
  245. struct acpi_walk_state *walk_state)
  246. {
  247. acpi_status status = AE_OK;
  248. union acpi_operand_object *ref_desc = dest_desc;
  249. ACPI_FUNCTION_TRACE_PTR(ex_store, dest_desc);
  250. /* Validate parameters */
  251. if (!source_desc || !dest_desc) {
  252. ACPI_ERROR((AE_INFO, "Null parameter"));
  253. return_ACPI_STATUS(AE_AML_NO_OPERAND);
  254. }
  255. /* dest_desc can be either a namespace node or an ACPI object */
  256. if (ACPI_GET_DESCRIPTOR_TYPE(dest_desc) == ACPI_DESC_TYPE_NAMED) {
  257. /*
  258. * Dest is a namespace node,
  259. * Storing an object into a Named node.
  260. */
  261. status = acpi_ex_store_object_to_node(source_desc,
  262. (struct
  263. acpi_namespace_node *)
  264. dest_desc, walk_state,
  265. ACPI_IMPLICIT_CONVERSION);
  266. return_ACPI_STATUS(status);
  267. }
  268. /* Destination object must be a Reference or a Constant object */
  269. switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
  270. case ACPI_TYPE_LOCAL_REFERENCE:
  271. break;
  272. case ACPI_TYPE_INTEGER:
  273. /* Allow stores to Constants -- a Noop as per ACPI spec */
  274. if (dest_desc->common.flags & AOPOBJ_AML_CONSTANT) {
  275. return_ACPI_STATUS(AE_OK);
  276. }
  277. /*lint -fallthrough */
  278. default:
  279. /* Destination is not a Reference object */
  280. ACPI_ERROR((AE_INFO,
  281. "Target is not a Reference or Constant object - %s [%p]",
  282. acpi_ut_get_object_type_name(dest_desc),
  283. dest_desc));
  284. return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
  285. }
  286. /*
  287. * Examine the Reference class. These cases are handled:
  288. *
  289. * 1) Store to Name (Change the object associated with a name)
  290. * 2) Store to an indexed area of a Buffer or Package
  291. * 3) Store to a Method Local or Arg
  292. * 4) Store to the debug object
  293. */
  294. switch (ref_desc->reference.class) {
  295. case ACPI_REFCLASS_REFOF:
  296. /* Storing an object into a Name "container" */
  297. status = acpi_ex_store_object_to_node(source_desc,
  298. ref_desc->reference.
  299. object, walk_state,
  300. ACPI_IMPLICIT_CONVERSION);
  301. break;
  302. case ACPI_REFCLASS_INDEX:
  303. /* Storing to an Index (pointer into a packager or buffer) */
  304. status =
  305. acpi_ex_store_object_to_index(source_desc, ref_desc,
  306. walk_state);
  307. break;
  308. case ACPI_REFCLASS_LOCAL:
  309. case ACPI_REFCLASS_ARG:
  310. /* Store to a method local/arg */
  311. status =
  312. acpi_ds_store_object_to_local(ref_desc->reference.class,
  313. ref_desc->reference.value,
  314. source_desc, walk_state);
  315. break;
  316. case ACPI_REFCLASS_DEBUG:
  317. /*
  318. * Storing to the Debug object causes the value stored to be
  319. * displayed and otherwise has no effect -- see ACPI Specification
  320. */
  321. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  322. "**** Write to Debug Object: Object %p %s ****:\n\n",
  323. source_desc,
  324. acpi_ut_get_object_type_name(source_desc)));
  325. acpi_ex_do_debug_object(source_desc, 0, 0);
  326. break;
  327. default:
  328. ACPI_ERROR((AE_INFO, "Unknown Reference Class %2.2X",
  329. ref_desc->reference.class));
  330. ACPI_DUMP_ENTRY(ref_desc, ACPI_LV_INFO);
  331. status = AE_AML_INTERNAL;
  332. break;
  333. }
  334. return_ACPI_STATUS(status);
  335. }
  336. /*******************************************************************************
  337. *
  338. * FUNCTION: acpi_ex_store_object_to_index
  339. *
  340. * PARAMETERS: *source_desc - Value to be stored
  341. * *dest_desc - Named object to receive the value
  342. * walk_state - Current walk state
  343. *
  344. * RETURN: Status
  345. *
  346. * DESCRIPTION: Store the object to indexed Buffer or Package element
  347. *
  348. ******************************************************************************/
  349. static acpi_status
  350. acpi_ex_store_object_to_index(union acpi_operand_object *source_desc,
  351. union acpi_operand_object *index_desc,
  352. struct acpi_walk_state *walk_state)
  353. {
  354. acpi_status status = AE_OK;
  355. union acpi_operand_object *obj_desc;
  356. union acpi_operand_object *new_desc;
  357. u8 value = 0;
  358. u32 i;
  359. ACPI_FUNCTION_TRACE(ex_store_object_to_index);
  360. /*
  361. * Destination must be a reference pointer, and
  362. * must point to either a buffer or a package
  363. */
  364. switch (index_desc->reference.target_type) {
  365. case ACPI_TYPE_PACKAGE:
  366. /*
  367. * Storing to a package element. Copy the object and replace
  368. * any existing object with the new object. No implicit
  369. * conversion is performed.
  370. *
  371. * The object at *(index_desc->Reference.Where) is the
  372. * element within the package that is to be modified.
  373. * The parent package object is at index_desc->Reference.Object
  374. */
  375. obj_desc = *(index_desc->reference.where);
  376. if (ACPI_GET_OBJECT_TYPE(source_desc) ==
  377. 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 ((ACPI_GET_OBJECT_TYPE(obj_desc) != ACPI_TYPE_BUFFER) &&
  424. (ACPI_GET_OBJECT_TYPE(obj_desc) != 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 (ACPI_GET_OBJECT_TYPE(source_desc)) {
  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. ACPI_GET_OBJECT_TYPE
  577. (source_desc));
  578. break;
  579. }
  580. return_ACPI_STATUS(status);
  581. }