dsmthdat.c 21 KB

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