dsmthdat.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  1. /*******************************************************************************
  2. *
  3. * Module Name: dsmthdat - control method arguments and local variables
  4. *
  5. ******************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2008, Intel Corp.
  8. * All rights reserved.
  9. *
  10. * Redistribution and use in source and binary forms, with or without
  11. * modification, are permitted provided that the following conditions
  12. * are met:
  13. * 1. Redistributions of source code must retain the above copyright
  14. * notice, this list of conditions, and the following disclaimer,
  15. * without modification.
  16. * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  17. * substantially similar to the "NO WARRANTY" disclaimer below
  18. * ("Disclaimer") and any redistribution must be conditioned upon
  19. * including a substantially similar Disclaimer requirement for further
  20. * binary redistribution.
  21. * 3. Neither the names of the above-listed copyright holders nor the names
  22. * of any contributors may be used to endorse or promote products derived
  23. * from this software without specific prior written permission.
  24. *
  25. * Alternatively, this software may be distributed under the terms of the
  26. * GNU General Public License ("GPL") version 2 as published by the Free
  27. * Software Foundation.
  28. *
  29. * NO WARRANTY
  30. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  31. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  32. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  33. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  34. * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  35. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  36. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  37. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  38. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  39. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  40. * POSSIBILITY OF SUCH DAMAGES.
  41. */
  42. #include <acpi/acpi.h>
  43. #include "accommon.h"
  44. #include "acdispat.h"
  45. #include "acnamesp.h"
  46. #include "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(u8 type,
  52. u32 index, struct acpi_walk_state *walk_state);
  53. static acpi_status
  54. acpi_ds_method_data_set_value(u8 type,
  55. u32 index,
  56. union acpi_operand_object *object,
  57. struct acpi_walk_state *walk_state);
  58. #ifdef ACPI_OBSOLETE_FUNCTIONS
  59. acpi_object_type
  60. acpi_ds_method_data_get_type(u16 opcode,
  61. u32 index, struct acpi_walk_state *walk_state);
  62. #endif
  63. /*******************************************************************************
  64. *
  65. * FUNCTION: acpi_ds_method_data_init
  66. *
  67. * PARAMETERS: walk_state - Current walk state object
  68. *
  69. * RETURN: Status
  70. *
  71. * DESCRIPTION: Initialize the data structures that hold the method's arguments
  72. * and locals. The data struct is an array of namespace nodes for
  73. * each - this allows ref_of and de_ref_of to work properly for these
  74. * special data types.
  75. *
  76. * NOTES: walk_state fields are initialized to zero by the
  77. * ACPI_ALLOCATE_ZEROED().
  78. *
  79. * A pseudo-Namespace Node is assigned to each argument and local
  80. * so that ref_of() can return a pointer to the Node.
  81. *
  82. ******************************************************************************/
  83. void acpi_ds_method_data_init(struct acpi_walk_state *walk_state)
  84. {
  85. u32 i;
  86. ACPI_FUNCTION_TRACE(ds_method_data_init);
  87. /* Init the method arguments */
  88. for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++) {
  89. ACPI_MOVE_32_TO_32(&walk_state->arguments[i].name,
  90. NAMEOF_ARG_NTE);
  91. walk_state->arguments[i].name.integer |= (i << 24);
  92. walk_state->arguments[i].descriptor_type = ACPI_DESC_TYPE_NAMED;
  93. walk_state->arguments[i].type = ACPI_TYPE_ANY;
  94. walk_state->arguments[i].flags =
  95. ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
  96. }
  97. /* Init the method locals */
  98. for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++) {
  99. ACPI_MOVE_32_TO_32(&walk_state->local_variables[i].name,
  100. NAMEOF_LOCAL_NTE);
  101. walk_state->local_variables[i].name.integer |= (i << 24);
  102. walk_state->local_variables[i].descriptor_type =
  103. ACPI_DESC_TYPE_NAMED;
  104. walk_state->local_variables[i].type = ACPI_TYPE_ANY;
  105. walk_state->local_variables[i].flags =
  106. ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
  107. }
  108. return_VOID;
  109. }
  110. /*******************************************************************************
  111. *
  112. * FUNCTION: acpi_ds_method_data_delete_all
  113. *
  114. * PARAMETERS: walk_state - Current walk state object
  115. *
  116. * RETURN: None
  117. *
  118. * DESCRIPTION: Delete method locals and arguments. Arguments are only
  119. * deleted if this method was called from another method.
  120. *
  121. ******************************************************************************/
  122. void acpi_ds_method_data_delete_all(struct acpi_walk_state *walk_state)
  123. {
  124. u32 index;
  125. ACPI_FUNCTION_TRACE(ds_method_data_delete_all);
  126. /* Detach the locals */
  127. for (index = 0; index < ACPI_METHOD_NUM_LOCALS; index++) {
  128. if (walk_state->local_variables[index].object) {
  129. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
  130. index,
  131. walk_state->local_variables[index].
  132. object));
  133. /* Detach object (if present) and remove a reference */
  134. acpi_ns_detach_object(&walk_state->
  135. local_variables[index]);
  136. }
  137. }
  138. /* Detach the arguments */
  139. for (index = 0; index < ACPI_METHOD_NUM_ARGS; index++) {
  140. if (walk_state->arguments[index].object) {
  141. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
  142. index,
  143. walk_state->arguments[index].object));
  144. /* Detach object (if present) and remove a reference */
  145. acpi_ns_detach_object(&walk_state->arguments[index]);
  146. }
  147. }
  148. return_VOID;
  149. }
  150. /*******************************************************************************
  151. *
  152. * FUNCTION: acpi_ds_method_data_init_args
  153. *
  154. * PARAMETERS: *Params - Pointer to a parameter list for the method
  155. * max_param_count - The arg count for this method
  156. * walk_state - Current walk state object
  157. *
  158. * RETURN: Status
  159. *
  160. * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
  161. * of ACPI operand objects, either null terminated or whose length
  162. * is defined by max_param_count.
  163. *
  164. ******************************************************************************/
  165. acpi_status
  166. acpi_ds_method_data_init_args(union acpi_operand_object **params,
  167. u32 max_param_count,
  168. struct acpi_walk_state *walk_state)
  169. {
  170. acpi_status status;
  171. u32 index = 0;
  172. ACPI_FUNCTION_TRACE_PTR(ds_method_data_init_args, params);
  173. if (!params) {
  174. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  175. "No param list passed to method\n"));
  176. return_ACPI_STATUS(AE_OK);
  177. }
  178. /* Copy passed parameters into the new method stack frame */
  179. while ((index < ACPI_METHOD_NUM_ARGS) &&
  180. (index < max_param_count) && params[index]) {
  181. /*
  182. * A valid parameter.
  183. * Store the argument in the method/walk descriptor.
  184. * Do not copy the arg in order to implement call by reference
  185. */
  186. status = acpi_ds_method_data_set_value(ACPI_REFCLASS_ARG, index,
  187. params[index],
  188. walk_state);
  189. if (ACPI_FAILURE(status)) {
  190. return_ACPI_STATUS(status);
  191. }
  192. index++;
  193. }
  194. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "%d args passed to method\n", index));
  195. return_ACPI_STATUS(AE_OK);
  196. }
  197. /*******************************************************************************
  198. *
  199. * FUNCTION: acpi_ds_method_data_get_node
  200. *
  201. * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
  202. * ACPI_REFCLASS_ARG
  203. * Index - Which Local or Arg whose type to get
  204. * walk_state - Current walk state object
  205. * Node - Where the node is returned.
  206. *
  207. * RETURN: Status and node
  208. *
  209. * DESCRIPTION: Get the Node associated with a local or arg.
  210. *
  211. ******************************************************************************/
  212. acpi_status
  213. acpi_ds_method_data_get_node(u8 type,
  214. u32 index,
  215. struct acpi_walk_state *walk_state,
  216. struct acpi_namespace_node **node)
  217. {
  218. ACPI_FUNCTION_TRACE(ds_method_data_get_node);
  219. /*
  220. * Method Locals and Arguments are supported
  221. */
  222. switch (type) {
  223. case ACPI_REFCLASS_LOCAL:
  224. if (index > ACPI_METHOD_MAX_LOCAL) {
  225. ACPI_ERROR((AE_INFO,
  226. "Local index %d is invalid (max %d)",
  227. index, ACPI_METHOD_MAX_LOCAL));
  228. return_ACPI_STATUS(AE_AML_INVALID_INDEX);
  229. }
  230. /* Return a pointer to the pseudo-node */
  231. *node = &walk_state->local_variables[index];
  232. break;
  233. case ACPI_REFCLASS_ARG:
  234. if (index > ACPI_METHOD_MAX_ARG) {
  235. ACPI_ERROR((AE_INFO,
  236. "Arg index %d is invalid (max %d)",
  237. index, ACPI_METHOD_MAX_ARG));
  238. return_ACPI_STATUS(AE_AML_INVALID_INDEX);
  239. }
  240. /* Return a pointer to the pseudo-node */
  241. *node = &walk_state->arguments[index];
  242. break;
  243. default:
  244. ACPI_ERROR((AE_INFO, "Type %d is invalid", type));
  245. return_ACPI_STATUS(AE_TYPE);
  246. }
  247. return_ACPI_STATUS(AE_OK);
  248. }
  249. /*******************************************************************************
  250. *
  251. * FUNCTION: acpi_ds_method_data_set_value
  252. *
  253. * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
  254. * ACPI_REFCLASS_ARG
  255. * Index - Which Local or Arg to get
  256. * Object - Object to be inserted into the stack entry
  257. * walk_state - Current walk state object
  258. *
  259. * RETURN: Status
  260. *
  261. * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
  262. * Note: There is no "implicit conversion" for locals.
  263. *
  264. ******************************************************************************/
  265. static acpi_status
  266. acpi_ds_method_data_set_value(u8 type,
  267. u32 index,
  268. union acpi_operand_object *object,
  269. struct acpi_walk_state *walk_state)
  270. {
  271. acpi_status status;
  272. struct acpi_namespace_node *node;
  273. ACPI_FUNCTION_TRACE(ds_method_data_set_value);
  274. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  275. "NewObj %p Type %2.2X, Refs=%d [%s]\n", object,
  276. type, object->common.reference_count,
  277. acpi_ut_get_type_name(object->common.type)));
  278. /* Get the namespace node for the arg/local */
  279. status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
  280. if (ACPI_FAILURE(status)) {
  281. return_ACPI_STATUS(status);
  282. }
  283. /*
  284. * Increment ref count so object can't be deleted while installed.
  285. * NOTE: We do not copy the object in order to preserve the call by
  286. * reference semantics of ACPI Control Method invocation.
  287. * (See ACPI Specification 2.0_c)
  288. */
  289. acpi_ut_add_reference(object);
  290. /* Install the object */
  291. node->object = object;
  292. return_ACPI_STATUS(status);
  293. }
  294. /*******************************************************************************
  295. *
  296. * FUNCTION: acpi_ds_method_data_get_value
  297. *
  298. * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
  299. * ACPI_REFCLASS_ARG
  300. * Index - Which local_var or argument to get
  301. * walk_state - Current walk state object
  302. * dest_desc - Where Arg or Local value is returned
  303. *
  304. * RETURN: Status
  305. *
  306. * DESCRIPTION: Retrieve value of selected Arg or Local for this method
  307. * Used only in acpi_ex_resolve_to_value().
  308. *
  309. ******************************************************************************/
  310. acpi_status
  311. acpi_ds_method_data_get_value(u8 type,
  312. u32 index,
  313. struct acpi_walk_state *walk_state,
  314. union acpi_operand_object **dest_desc)
  315. {
  316. acpi_status status;
  317. struct acpi_namespace_node *node;
  318. union acpi_operand_object *object;
  319. ACPI_FUNCTION_TRACE(ds_method_data_get_value);
  320. /* Validate the object descriptor */
  321. if (!dest_desc) {
  322. ACPI_ERROR((AE_INFO, "Null object descriptor pointer"));
  323. return_ACPI_STATUS(AE_BAD_PARAMETER);
  324. }
  325. /* Get the namespace node for the arg/local */
  326. status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
  327. if (ACPI_FAILURE(status)) {
  328. return_ACPI_STATUS(status);
  329. }
  330. /* Get the object from the node */
  331. object = node->object;
  332. /* Examine the returned object, it must be valid. */
  333. if (!object) {
  334. /*
  335. * Index points to uninitialized object.
  336. * This means that either 1) The expected argument was
  337. * not passed to the method, or 2) A local variable
  338. * was referenced by the method (via the ASL)
  339. * before it was initialized. Either case is an error.
  340. */
  341. /* If slack enabled, init the local_x/arg_x to an Integer of value zero */
  342. if (acpi_gbl_enable_interpreter_slack) {
  343. object =
  344. acpi_ut_create_internal_object(ACPI_TYPE_INTEGER);
  345. if (!object) {
  346. return_ACPI_STATUS(AE_NO_MEMORY);
  347. }
  348. object->integer.value = 0;
  349. node->object = object;
  350. }
  351. /* Otherwise, return the error */
  352. else
  353. switch (type) {
  354. case ACPI_REFCLASS_ARG:
  355. ACPI_ERROR((AE_INFO,
  356. "Uninitialized Arg[%d] at node %p",
  357. index, node));
  358. return_ACPI_STATUS(AE_AML_UNINITIALIZED_ARG);
  359. case ACPI_REFCLASS_LOCAL:
  360. ACPI_ERROR((AE_INFO,
  361. "Uninitialized Local[%d] at node %p",
  362. index, node));
  363. return_ACPI_STATUS(AE_AML_UNINITIALIZED_LOCAL);
  364. default:
  365. ACPI_ERROR((AE_INFO,
  366. "Not a Arg/Local opcode: %X",
  367. type));
  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: Type - Either ACPI_REFCLASS_LOCAL or
  384. * ACPI_REFCLASS_ARG
  385. * Index - Which local_var or argument to delete
  386. * walk_state - Current walk state object
  387. *
  388. * RETURN: None
  389. *
  390. * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
  391. * a null into the stack slot after the object is deleted.
  392. *
  393. ******************************************************************************/
  394. static void
  395. acpi_ds_method_data_delete_value(u8 type,
  396. u32 index, struct acpi_walk_state *walk_state)
  397. {
  398. acpi_status status;
  399. struct acpi_namespace_node *node;
  400. union acpi_operand_object *object;
  401. ACPI_FUNCTION_TRACE(ds_method_data_delete_value);
  402. /* Get the namespace node for the arg/local */
  403. status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
  404. if (ACPI_FAILURE(status)) {
  405. return_VOID;
  406. }
  407. /* Get the associated object */
  408. object = acpi_ns_get_attached_object(node);
  409. /*
  410. * Undefine the Arg or Local by setting its descriptor
  411. * pointer to NULL. Locals/Args can contain both
  412. * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
  413. */
  414. node->object = NULL;
  415. if ((object) &&
  416. (ACPI_GET_DESCRIPTOR_TYPE(object) == ACPI_DESC_TYPE_OPERAND)) {
  417. /*
  418. * There is a valid object.
  419. * Decrement the reference count by one to balance the
  420. * increment when the object was stored.
  421. */
  422. acpi_ut_remove_reference(object);
  423. }
  424. return_VOID;
  425. }
  426. /*******************************************************************************
  427. *
  428. * FUNCTION: acpi_ds_store_object_to_local
  429. *
  430. * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
  431. * ACPI_REFCLASS_ARG
  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(u8 type,
  445. u32 index,
  446. union acpi_operand_object *obj_desc,
  447. struct acpi_walk_state *walk_state)
  448. {
  449. acpi_status status;
  450. struct acpi_namespace_node *node;
  451. union acpi_operand_object *current_obj_desc;
  452. union acpi_operand_object *new_obj_desc;
  453. ACPI_FUNCTION_TRACE(ds_store_object_to_local);
  454. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n",
  455. type, index, obj_desc));
  456. /* Parameter validation */
  457. if (!obj_desc) {
  458. return_ACPI_STATUS(AE_BAD_PARAMETER);
  459. }
  460. /* Get the namespace node for the arg/local */
  461. status = acpi_ds_method_data_get_node(type, index, walk_state, &node);
  462. if (ACPI_FAILURE(status)) {
  463. return_ACPI_STATUS(status);
  464. }
  465. current_obj_desc = acpi_ns_get_attached_object(node);
  466. if (current_obj_desc == obj_desc) {
  467. ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Obj=%p already installed!\n",
  468. obj_desc));
  469. return_ACPI_STATUS(status);
  470. }
  471. /*
  472. * If the reference count on the object is more than one, we must
  473. * take a copy of the object before we store. A reference count
  474. * of exactly 1 means that the object was just created during the
  475. * evaluation of an expression, and we can safely use it since it
  476. * is not used anywhere else.
  477. */
  478. new_obj_desc = obj_desc;
  479. if (obj_desc->common.reference_count > 1) {
  480. status =
  481. acpi_ut_copy_iobject_to_iobject(obj_desc, &new_obj_desc,
  482. walk_state);
  483. if (ACPI_FAILURE(status)) {
  484. return_ACPI_STATUS(status);
  485. }
  486. }
  487. /*
  488. * If there is an object already in this slot, we either
  489. * have to delete it, or if this is an argument and there
  490. * is an object reference stored there, we have to do
  491. * an indirect store!
  492. */
  493. if (current_obj_desc) {
  494. /*
  495. * Check for an indirect store if an argument
  496. * contains an object reference (stored as an Node).
  497. * We don't allow this automatic dereferencing for
  498. * locals, since a store to a local should overwrite
  499. * anything there, including an object reference.
  500. *
  501. * If both Arg0 and Local0 contain ref_of (Local4):
  502. *
  503. * Store (1, Arg0) - Causes indirect store to local4
  504. * Store (1, Local0) - Stores 1 in local0, overwriting
  505. * the reference to local4
  506. * Store (1, de_refof (Local0)) - Causes indirect store to local4
  507. *
  508. * Weird, but true.
  509. */
  510. if (type == ACPI_REFCLASS_ARG) {
  511. /*
  512. * If we have a valid reference object that came from ref_of(),
  513. * do the indirect store
  514. */
  515. if ((ACPI_GET_DESCRIPTOR_TYPE(current_obj_desc) ==
  516. ACPI_DESC_TYPE_OPERAND)
  517. && (current_obj_desc->common.type ==
  518. ACPI_TYPE_LOCAL_REFERENCE)
  519. && (current_obj_desc->reference.class ==
  520. ACPI_REFCLASS_REFOF)) {
  521. ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
  522. "Arg (%p) is an ObjRef(Node), storing in node %p\n",
  523. new_obj_desc,
  524. current_obj_desc));
  525. /*
  526. * Store this object to the Node (perform the indirect store)
  527. * NOTE: No implicit conversion is performed, as per the ACPI
  528. * specification rules on storing to Locals/Args.
  529. */
  530. status =
  531. acpi_ex_store_object_to_node(new_obj_desc,
  532. current_obj_desc->
  533. reference.
  534. object,
  535. walk_state,
  536. ACPI_NO_IMPLICIT_CONVERSION);
  537. /* Remove local reference if we copied the object above */
  538. if (new_obj_desc != obj_desc) {
  539. acpi_ut_remove_reference(new_obj_desc);
  540. }
  541. return_ACPI_STATUS(status);
  542. }
  543. }
  544. /* Delete the existing object before storing the new one */
  545. acpi_ds_method_data_delete_value(type, index, walk_state);
  546. }
  547. /*
  548. * Install the Obj descriptor (*new_obj_desc) into
  549. * the descriptor for the Arg or Local.
  550. * (increments the object reference count by one)
  551. */
  552. status =
  553. acpi_ds_method_data_set_value(type, index, new_obj_desc,
  554. walk_state);
  555. /* Remove local reference if we copied the object above */
  556. if (new_obj_desc != obj_desc) {
  557. acpi_ut_remove_reference(new_obj_desc);
  558. }
  559. return_ACPI_STATUS(status);
  560. }
  561. #ifdef ACPI_OBSOLETE_FUNCTIONS
  562. /*******************************************************************************
  563. *
  564. * FUNCTION: acpi_ds_method_data_get_type
  565. *
  566. * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
  567. * Index - Which Local or Arg whose type to get
  568. * walk_state - Current walk state object
  569. *
  570. * RETURN: Data type of current value of the selected Arg or Local
  571. *
  572. * DESCRIPTION: Get the type of the object stored in the Local or Arg
  573. *
  574. ******************************************************************************/
  575. acpi_object_type
  576. acpi_ds_method_data_get_type(u16 opcode,
  577. u32 index, struct acpi_walk_state *walk_state)
  578. {
  579. acpi_status status;
  580. struct acpi_namespace_node *node;
  581. union acpi_operand_object *object;
  582. ACPI_FUNCTION_TRACE(ds_method_data_get_type);
  583. /* Get the namespace node for the arg/local */
  584. status = acpi_ds_method_data_get_node(opcode, index, walk_state, &node);
  585. if (ACPI_FAILURE(status)) {
  586. return_VALUE((ACPI_TYPE_NOT_FOUND));
  587. }
  588. /* Get the object */
  589. object = acpi_ns_get_attached_object(node);
  590. if (!object) {
  591. /* Uninitialized local/arg, return TYPE_ANY */
  592. return_VALUE(ACPI_TYPE_ANY);
  593. }
  594. /* Get the object type */
  595. return_VALUE(object->type);
  596. }
  597. #endif