dsmthdat.c 21 KB

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