dsmthdat.c 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. /*******************************************************************************
  2. *
  3. * Module Name: dsmthdat - control method arguments and local variables
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, 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/amlcode.h>
  45. #include <acpi/acnamesp.h>
  46. #include <acpi/acinterp.h>
  47. #define _COMPONENT ACPI_DISPATCHER
  48. ACPI_MODULE_NAME ("dsmthdat")
  49. /* Local prototypes */
  50. static void
  51. acpi_ds_method_data_delete_value (
  52. u16 opcode,
  53. u32 index,
  54. struct acpi_walk_state *walk_state);
  55. static acpi_status
  56. acpi_ds_method_data_set_value (
  57. u16 opcode,
  58. u32 index,
  59. union acpi_operand_object *object,
  60. struct acpi_walk_state *walk_state);
  61. #ifdef ACPI_OBSOLETE_FUNCTIONS
  62. acpi_object_type
  63. acpi_ds_method_data_get_type (
  64. u16 opcode,
  65. u32 index,
  66. struct acpi_walk_state *walk_state);
  67. #endif
  68. /*******************************************************************************
  69. *
  70. * FUNCTION: acpi_ds_method_data_init
  71. *
  72. * PARAMETERS: walk_state - Current walk state object
  73. *
  74. * RETURN: Status
  75. *
  76. * DESCRIPTION: Initialize the data structures that hold the method's arguments
  77. * and locals. The data struct is an array of namespace nodes for
  78. * each - this allows ref_of and de_ref_of to work properly for these
  79. * special data types.
  80. *
  81. * NOTES: walk_state fields are initialized to zero by the
  82. * ACPI_MEM_CALLOCATE().
  83. *
  84. * A pseudo-Namespace Node is assigned to each argument and local
  85. * so that ref_of() can return a pointer to the Node.
  86. *
  87. ******************************************************************************/
  88. void
  89. acpi_ds_method_data_init (
  90. struct acpi_walk_state *walk_state)
  91. {
  92. u32 i;
  93. ACPI_FUNCTION_TRACE ("ds_method_data_init");
  94. /* Init the method arguments */
  95. for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) {
  96. ACPI_MOVE_32_TO_32 (&walk_state->arguments[i].name,
  97. NAMEOF_ARG_NTE);
  98. walk_state->arguments[i].name.integer |= (i << 24);
  99. walk_state->arguments[i].descriptor = ACPI_DESC_TYPE_NAMED;
  100. walk_state->arguments[i].type = ACPI_TYPE_ANY;
  101. walk_state->arguments[i].flags = ANOBJ_END_OF_PEER_LIST |
  102. ANOBJ_METHOD_ARG;
  103. }
  104. /* Init the method locals */
  105. for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) {
  106. ACPI_MOVE_32_TO_32 (&walk_state->local_variables[i].name,
  107. NAMEOF_LOCAL_NTE);
  108. walk_state->local_variables[i].name.integer |= (i << 24);
  109. walk_state->local_variables[i].descriptor = ACPI_DESC_TYPE_NAMED;
  110. walk_state->local_variables[i].type = ACPI_TYPE_ANY;
  111. walk_state->local_variables[i].flags = ANOBJ_END_OF_PEER_LIST |
  112. ANOBJ_METHOD_LOCAL;
  113. }
  114. return_VOID;
  115. }
  116. /*******************************************************************************
  117. *
  118. * FUNCTION: acpi_ds_method_data_delete_all
  119. *
  120. * PARAMETERS: walk_state - Current walk state object
  121. *
  122. * RETURN: None
  123. *
  124. * DESCRIPTION: Delete method locals and arguments. Arguments are only
  125. * deleted if this method was called from another method.
  126. *
  127. ******************************************************************************/
  128. void
  129. acpi_ds_method_data_delete_all (
  130. struct acpi_walk_state *walk_state)
  131. {
  132. u32 index;
  133. ACPI_FUNCTION_TRACE ("ds_method_data_delete_all");
  134. /* Detach the locals */
  135. for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) {
  136. if (walk_state->local_variables[index].object) {
  137. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
  138. index, walk_state->local_variables[index].object));
  139. /* Detach object (if present) and remove a reference */
  140. acpi_ns_detach_object (&walk_state->local_variables[index]);
  141. }
  142. }
  143. /* Detach the arguments */
  144. for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) {
  145. if (walk_state->arguments[index].object) {
  146. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
  147. index, walk_state->arguments[index].object));
  148. /* Detach object (if present) and remove a reference */
  149. acpi_ns_detach_object (&walk_state->arguments[index]);
  150. }
  151. }
  152. return_VOID;
  153. }
  154. /*******************************************************************************
  155. *
  156. * FUNCTION: acpi_ds_method_data_init_args
  157. *
  158. * PARAMETERS: *Params - Pointer to a parameter list for the method
  159. * max_param_count - The arg count for this method
  160. * walk_state - Current walk state object
  161. *
  162. * RETURN: Status
  163. *
  164. * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
  165. * of ACPI operand objects, either null terminated or whose length
  166. * is defined by max_param_count.
  167. *
  168. ******************************************************************************/
  169. acpi_status
  170. acpi_ds_method_data_init_args (
  171. union acpi_operand_object **params,
  172. u32 max_param_count,
  173. struct acpi_walk_state *walk_state)
  174. {
  175. acpi_status status;
  176. u32 index = 0;
  177. ACPI_FUNCTION_TRACE_PTR ("ds_method_data_init_args", params);
  178. if (!params) {
  179. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n"));
  180. return_ACPI_STATUS (AE_OK);
  181. }
  182. /* Copy passed parameters into the new method stack frame */
  183. while ((index < ACPI_METHOD_NUM_ARGS) &&
  184. (index < max_param_count) &&
  185. params[index]) {
  186. /*
  187. * A valid parameter.
  188. * Store the argument in the method/walk descriptor.
  189. * Do not copy the arg in order to implement call by reference
  190. */
  191. status = acpi_ds_method_data_set_value (AML_ARG_OP, index,
  192. params[index], walk_state);
  193. if (ACPI_FAILURE (status)) {
  194. return_ACPI_STATUS (status);
  195. }
  196. index++;
  197. }
  198. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", index));
  199. return_ACPI_STATUS (AE_OK);
  200. }
  201. /*******************************************************************************
  202. *
  203. * FUNCTION: acpi_ds_method_data_get_node
  204. *
  205. * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
  206. * Index - Which Local or Arg whose type to get
  207. * walk_state - Current walk state object
  208. * Node - Where the node is returned.
  209. *
  210. * RETURN: Status and node
  211. *
  212. * DESCRIPTION: Get the Node associated with a local or arg.
  213. *
  214. ******************************************************************************/
  215. acpi_status
  216. acpi_ds_method_data_get_node (
  217. u16 opcode,
  218. u32 index,
  219. struct acpi_walk_state *walk_state,
  220. struct acpi_namespace_node **node)
  221. {
  222. ACPI_FUNCTION_TRACE ("ds_method_data_get_node");
  223. /*
  224. * Method Locals and Arguments are supported
  225. */
  226. switch (opcode) {
  227. case AML_LOCAL_OP:
  228. if (index > ACPI_METHOD_MAX_LOCAL) {
  229. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
  230. "Local index %d is invalid (max %d)\n",
  231. index, ACPI_METHOD_MAX_LOCAL));
  232. return_ACPI_STATUS (AE_AML_INVALID_INDEX);
  233. }
  234. /* Return a pointer to the pseudo-node */
  235. *node = &walk_state->local_variables[index];
  236. break;
  237. case AML_ARG_OP:
  238. if (index > ACPI_METHOD_MAX_ARG) {
  239. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
  240. "Arg index %d is invalid (max %d)\n",
  241. index, ACPI_METHOD_MAX_ARG));
  242. return_ACPI_STATUS (AE_AML_INVALID_INDEX);
  243. }
  244. /* Return a pointer to the pseudo-node */
  245. *node = &walk_state->arguments[index];
  246. break;
  247. default:
  248. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Opcode %d is invalid\n", opcode));
  249. return_ACPI_STATUS (AE_AML_BAD_OPCODE);
  250. }
  251. return_ACPI_STATUS (AE_OK);
  252. }
  253. /*******************************************************************************
  254. *
  255. * FUNCTION: acpi_ds_method_data_set_value
  256. *
  257. * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
  258. * Index - Which Local or Arg to get
  259. * Object - Object to be inserted into the stack entry
  260. * walk_state - Current walk state object
  261. *
  262. * RETURN: Status
  263. *
  264. * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
  265. * Note: There is no "implicit conversion" for locals.
  266. *
  267. ******************************************************************************/
  268. static acpi_status
  269. acpi_ds_method_data_set_value (
  270. u16 opcode,
  271. u32 index,
  272. union acpi_operand_object *object,
  273. struct acpi_walk_state *walk_state)
  274. {
  275. acpi_status status;
  276. struct acpi_namespace_node *node;
  277. ACPI_FUNCTION_TRACE ("ds_method_data_set_value");
  278. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
  279. "new_obj %p Opcode %X, Refs=%d [%s]\n", object,
  280. opcode, object->common.reference_count,
  281. acpi_ut_get_type_name (object->common.type)));
  282. /* Get the namespace node for the arg/local */
  283. status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
  284. if (ACPI_FAILURE (status)) {
  285. return_ACPI_STATUS (status);
  286. }
  287. /*
  288. * Increment ref count so object can't be deleted while installed.
  289. * NOTE: We do not copy the object in order to preserve the call by
  290. * reference semantics of ACPI Control Method invocation.
  291. * (See ACPI specification 2.0_c)
  292. */
  293. acpi_ut_add_reference (object);
  294. /* Install the object */
  295. node->object = object;
  296. return_ACPI_STATUS (status);
  297. }
  298. /*******************************************************************************
  299. *
  300. * FUNCTION: acpi_ds_method_data_get_value
  301. *
  302. * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
  303. * Index - which local_var or argument to get
  304. * walk_state - Current walk state object
  305. * dest_desc - Where Arg or Local value is returned
  306. *
  307. * RETURN: Status
  308. *
  309. * DESCRIPTION: Retrieve value of selected Arg or Local for this method
  310. * Used only in acpi_ex_resolve_to_value().
  311. *
  312. ******************************************************************************/
  313. acpi_status
  314. acpi_ds_method_data_get_value (
  315. u16 opcode,
  316. u32 index,
  317. struct acpi_walk_state *walk_state,
  318. union acpi_operand_object **dest_desc)
  319. {
  320. acpi_status status;
  321. struct acpi_namespace_node *node;
  322. union acpi_operand_object *object;
  323. ACPI_FUNCTION_TRACE ("ds_method_data_get_value");
  324. /* Validate the object descriptor */
  325. if (!dest_desc) {
  326. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null object descriptor pointer\n"));
  327. return_ACPI_STATUS (AE_BAD_PARAMETER);
  328. }
  329. /* Get the namespace node for the arg/local */
  330. status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
  331. if (ACPI_FAILURE (status)) {
  332. return_ACPI_STATUS (status);
  333. }
  334. /* Get the object from the node */
  335. object = node->object;
  336. /* Examine the returned object, it must be valid. */
  337. if (!object) {
  338. /*
  339. * Index points to uninitialized object.
  340. * This means that either 1) The expected argument was
  341. * not passed to the method, or 2) A local variable
  342. * was referenced by the method (via the ASL)
  343. * before it was initialized. Either case is an error.
  344. */
  345. /* If slack enabled, init the local_x/arg_x to an Integer of value zero */
  346. if (acpi_gbl_enable_interpreter_slack) {
  347. object = acpi_ut_create_internal_object (ACPI_TYPE_INTEGER);
  348. if (!object) {
  349. return_ACPI_STATUS (AE_NO_MEMORY);
  350. }
  351. object->integer.value = 0;
  352. node->object = object;
  353. }
  354. /* Otherwise, return the error */
  355. else switch (opcode) {
  356. case AML_ARG_OP:
  357. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
  358. "Uninitialized Arg[%d] at node %p\n",
  359. index, node));
  360. return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
  361. case AML_LOCAL_OP:
  362. ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
  363. "Uninitialized Local[%d] at node %p\n",
  364. index, node));
  365. return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
  366. default:
  367. ACPI_REPORT_ERROR (("Not Arg/Local opcode: %X\n", opcode));
  368. return_ACPI_STATUS (AE_AML_INTERNAL);
  369. }
  370. }
  371. /*
  372. * The Index points to an initialized and valid object.
  373. * Return an additional reference to the object
  374. */
  375. *dest_desc = object;
  376. acpi_ut_add_reference (object);
  377. return_ACPI_STATUS (AE_OK);
  378. }
  379. /*******************************************************************************
  380. *
  381. * FUNCTION: acpi_ds_method_data_delete_value
  382. *
  383. * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
  384. * Index - which local_var or argument to delete
  385. * walk_state - Current walk state object
  386. *
  387. * RETURN: None
  388. *
  389. * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
  390. * a null into the stack slot after the object is deleted.
  391. *
  392. ******************************************************************************/
  393. static void
  394. acpi_ds_method_data_delete_value (
  395. u16 opcode,
  396. u32 index,
  397. struct acpi_walk_state *walk_state)
  398. {
  399. acpi_status status;
  400. struct acpi_namespace_node *node;
  401. union acpi_operand_object *object;
  402. ACPI_FUNCTION_TRACE ("ds_method_data_delete_value");
  403. /* Get the namespace node for the arg/local */
  404. status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
  405. if (ACPI_FAILURE (status)) {
  406. return_VOID;
  407. }
  408. /* Get the associated object */
  409. object = acpi_ns_get_attached_object (node);
  410. /*
  411. * Undefine the Arg or Local by setting its descriptor
  412. * pointer to NULL. Locals/Args can contain both
  413. * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
  414. */
  415. node->object = NULL;
  416. if ((object) &&
  417. (ACPI_GET_DESCRIPTOR_TYPE (object) == ACPI_DESC_TYPE_OPERAND)) {
  418. /*
  419. * There is a valid object.
  420. * Decrement the reference count by one to balance the
  421. * increment when the object was stored.
  422. */
  423. acpi_ut_remove_reference (object);
  424. }
  425. return_VOID;
  426. }
  427. /*******************************************************************************
  428. *
  429. * FUNCTION: acpi_ds_store_object_to_local
  430. *
  431. * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
  432. * Index - Which Local or Arg to set
  433. * obj_desc - Value to be stored
  434. * walk_state - Current walk state
  435. *
  436. * RETURN: Status
  437. *
  438. * DESCRIPTION: Store a value in an Arg or Local. The obj_desc is installed
  439. * as the new value for the Arg or Local and the reference count
  440. * for obj_desc is incremented.
  441. *
  442. ******************************************************************************/
  443. acpi_status
  444. acpi_ds_store_object_to_local (
  445. u16 opcode,
  446. u32 index,
  447. union acpi_operand_object *obj_desc,
  448. struct acpi_walk_state *walk_state)
  449. {
  450. acpi_status status;
  451. struct acpi_namespace_node *node;
  452. union acpi_operand_object *current_obj_desc;
  453. union acpi_operand_object *new_obj_desc;
  454. ACPI_FUNCTION_TRACE ("ds_store_object_to_local");
  455. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Opcode=%X Index=%d Obj=%p\n",
  456. opcode, index, obj_desc));
  457. /* Parameter validation */
  458. if (!obj_desc) {
  459. return_ACPI_STATUS (AE_BAD_PARAMETER);
  460. }
  461. /* Get the namespace node for the arg/local */
  462. status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
  463. if (ACPI_FAILURE (status)) {
  464. return_ACPI_STATUS (status);
  465. }
  466. current_obj_desc = acpi_ns_get_attached_object (node);
  467. if (current_obj_desc == obj_desc) {
  468. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
  469. obj_desc));
  470. return_ACPI_STATUS (status);
  471. }
  472. /*
  473. * If the reference count on the object is more than one, we must
  474. * take a copy of the object before we store. A reference count
  475. * of exactly 1 means that the object was just created during the
  476. * evaluation of an expression, and we can safely use it since it
  477. * is not used anywhere else.
  478. */
  479. new_obj_desc = obj_desc;
  480. if (obj_desc->common.reference_count > 1) {
  481. status = acpi_ut_copy_iobject_to_iobject (obj_desc, &new_obj_desc, walk_state);
  482. if (ACPI_FAILURE (status)) {
  483. return_ACPI_STATUS (status);
  484. }
  485. }
  486. /*
  487. * If there is an object already in this slot, we either
  488. * have to delete it, or if this is an argument and there
  489. * is an object reference stored there, we have to do
  490. * an indirect store!
  491. */
  492. if (current_obj_desc) {
  493. /*
  494. * Check for an indirect store if an argument
  495. * contains an object reference (stored as an Node).
  496. * We don't allow this automatic dereferencing for
  497. * locals, since a store to a local should overwrite
  498. * anything there, including an object reference.
  499. *
  500. * If both Arg0 and Local0 contain ref_of (Local4):
  501. *
  502. * Store (1, Arg0) - Causes indirect store to local4
  503. * Store (1, Local0) - Stores 1 in local0, overwriting
  504. * the reference to local4
  505. * Store (1, de_refof (Local0)) - Causes indirect store to local4
  506. *
  507. * Weird, but true.
  508. */
  509. if (opcode == AML_ARG_OP) {
  510. /*
  511. * Make sure that the object is the correct type. This may be
  512. * overkill, butit is here because references were NS nodes in
  513. * the past. Now they are operand objects of type Reference.
  514. */
  515. if (ACPI_GET_DESCRIPTOR_TYPE (current_obj_desc) != ACPI_DESC_TYPE_OPERAND) {
  516. ACPI_REPORT_ERROR ((
  517. "Invalid descriptor type while storing to method arg: [%s]\n",
  518. acpi_ut_get_descriptor_name (current_obj_desc)));
  519. return_ACPI_STATUS (AE_AML_INTERNAL);
  520. }
  521. /*
  522. * If we have a valid reference object that came from ref_of(),
  523. * do the indirect store
  524. */
  525. if ((current_obj_desc->common.type == ACPI_TYPE_LOCAL_REFERENCE) &&
  526. (current_obj_desc->reference.opcode == AML_REF_OF_OP)) {
  527. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
  528. "Arg (%p) is an obj_ref(Node), storing in node %p\n",
  529. new_obj_desc, current_obj_desc));
  530. /*
  531. * Store this object to the Node (perform the indirect store)
  532. * NOTE: No implicit conversion is performed, as per the ACPI
  533. * specification rules on storing to Locals/Args.
  534. */
  535. status = acpi_ex_store_object_to_node (new_obj_desc,
  536. current_obj_desc->reference.object, walk_state,
  537. ACPI_NO_IMPLICIT_CONVERSION);
  538. /* Remove local reference if we copied the object above */
  539. if (new_obj_desc != obj_desc) {
  540. acpi_ut_remove_reference (new_obj_desc);
  541. }
  542. return_ACPI_STATUS (status);
  543. }
  544. }
  545. /*
  546. * Delete the existing object
  547. * before storing the new one
  548. */
  549. acpi_ds_method_data_delete_value (opcode, index, walk_state);
  550. }
  551. /*
  552. * Install the Obj descriptor (*new_obj_desc) into
  553. * the descriptor for the Arg or Local.
  554. * (increments the object reference count by one)
  555. */
  556. status = acpi_ds_method_data_set_value (opcode, index, new_obj_desc, walk_state);
  557. /* Remove local reference if we copied the object above */
  558. if (new_obj_desc != obj_desc) {
  559. acpi_ut_remove_reference (new_obj_desc);
  560. }
  561. return_ACPI_STATUS (status);
  562. }
  563. #ifdef ACPI_OBSOLETE_FUNCTIONS
  564. /*******************************************************************************
  565. *
  566. * FUNCTION: acpi_ds_method_data_get_type
  567. *
  568. * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
  569. * Index - Which Local or Arg whose type to get
  570. * walk_state - Current walk state object
  571. *
  572. * RETURN: Data type of current value of the selected Arg or Local
  573. *
  574. * DESCRIPTION: Get the type of the object stored in the Local or Arg
  575. *
  576. ******************************************************************************/
  577. acpi_object_type
  578. acpi_ds_method_data_get_type (
  579. u16 opcode,
  580. u32 index,
  581. struct acpi_walk_state *walk_state)
  582. {
  583. acpi_status status;
  584. struct acpi_namespace_node *node;
  585. union acpi_operand_object *object;
  586. ACPI_FUNCTION_TRACE ("ds_method_data_get_type");
  587. /* Get the namespace node for the arg/local */
  588. status = acpi_ds_method_data_get_node (opcode, index, walk_state, &node);
  589. if (ACPI_FAILURE (status)) {
  590. return_VALUE ((ACPI_TYPE_NOT_FOUND));
  591. }
  592. /* Get the object */
  593. object = acpi_ns_get_attached_object (node);
  594. if (!object) {
  595. /* Uninitialized local/arg, return TYPE_ANY */
  596. return_VALUE (ACPI_TYPE_ANY);
  597. }
  598. /* Get the object type */
  599. return_VALUE (ACPI_GET_OBJECT_TYPE (object));
  600. }
  601. #endif