dsmthdat.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
  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.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. AcpiDsMethodDataDeleteValue (
  52. UINT8 Type,
  53. UINT32 Index,
  54. ACPI_WALK_STATE *WalkState);
  55. static ACPI_STATUS
  56. AcpiDsMethodDataSetValue (
  57. UINT8 Type,
  58. UINT32 Index,
  59. ACPI_OPERAND_OBJECT *Object,
  60. ACPI_WALK_STATE *WalkState);
  61. #ifdef ACPI_OBSOLETE_FUNCTIONS
  62. ACPI_OBJECT_TYPE
  63. AcpiDsMethodDataGetType (
  64. UINT16 Opcode,
  65. UINT32 Index,
  66. ACPI_WALK_STATE *WalkState);
  67. #endif
  68. /*******************************************************************************
  69. *
  70. * FUNCTION: AcpiDsMethodDataInit
  71. *
  72. * PARAMETERS: WalkState - 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 RefOf and DeRefOf to work properly for these
  79. * special data types.
  80. *
  81. * NOTES: WalkState fields are initialized to zero by the
  82. * ACPI_ALLOCATE_ZEROED().
  83. *
  84. * A pseudo-Namespace Node is assigned to each argument and local
  85. * so that RefOf() can return a pointer to the Node.
  86. *
  87. ******************************************************************************/
  88. void
  89. AcpiDsMethodDataInit (
  90. ACPI_WALK_STATE *WalkState)
  91. {
  92. UINT32 i;
  93. ACPI_FUNCTION_TRACE (DsMethodDataInit);
  94. /* Init the method arguments */
  95. for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
  96. {
  97. ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name,
  98. NAMEOF_ARG_NTE);
  99. WalkState->Arguments[i].Name.Integer |= (i << 24);
  100. WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
  101. WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
  102. WalkState->Arguments[i].Flags = ANOBJ_METHOD_ARG;
  103. }
  104. /* Init the method locals */
  105. for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
  106. {
  107. ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name,
  108. NAMEOF_LOCAL_NTE);
  109. WalkState->LocalVariables[i].Name.Integer |= (i << 24);
  110. WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
  111. WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
  112. WalkState->LocalVariables[i].Flags = ANOBJ_METHOD_LOCAL;
  113. }
  114. return_VOID;
  115. }
  116. /*******************************************************************************
  117. *
  118. * FUNCTION: AcpiDsMethodDataDeleteAll
  119. *
  120. * PARAMETERS: WalkState - 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. AcpiDsMethodDataDeleteAll (
  130. ACPI_WALK_STATE *WalkState)
  131. {
  132. UINT32 Index;
  133. ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll);
  134. /* Detach the locals */
  135. for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++)
  136. {
  137. if (WalkState->LocalVariables[Index].Object)
  138. {
  139. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%u=%p\n",
  140. Index, WalkState->LocalVariables[Index].Object));
  141. /* Detach object (if present) and remove a reference */
  142. AcpiNsDetachObject (&WalkState->LocalVariables[Index]);
  143. }
  144. }
  145. /* Detach the arguments */
  146. for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++)
  147. {
  148. if (WalkState->Arguments[Index].Object)
  149. {
  150. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%u=%p\n",
  151. Index, WalkState->Arguments[Index].Object));
  152. /* Detach object (if present) and remove a reference */
  153. AcpiNsDetachObject (&WalkState->Arguments[Index]);
  154. }
  155. }
  156. return_VOID;
  157. }
  158. /*******************************************************************************
  159. *
  160. * FUNCTION: AcpiDsMethodDataInitArgs
  161. *
  162. * PARAMETERS: *Params - Pointer to a parameter list for the method
  163. * MaxParamCount - The arg count for this method
  164. * WalkState - Current walk state object
  165. *
  166. * RETURN: Status
  167. *
  168. * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
  169. * of ACPI operand objects, either null terminated or whose length
  170. * is defined by MaxParamCount.
  171. *
  172. ******************************************************************************/
  173. ACPI_STATUS
  174. AcpiDsMethodDataInitArgs (
  175. ACPI_OPERAND_OBJECT **Params,
  176. UINT32 MaxParamCount,
  177. ACPI_WALK_STATE *WalkState)
  178. {
  179. ACPI_STATUS Status;
  180. UINT32 Index = 0;
  181. ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params);
  182. if (!Params)
  183. {
  184. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
  185. "No parameter list passed to method\n"));
  186. return_ACPI_STATUS (AE_OK);
  187. }
  188. /* Copy passed parameters into the new method stack frame */
  189. while ((Index < ACPI_METHOD_NUM_ARGS) &&
  190. (Index < MaxParamCount) &&
  191. Params[Index])
  192. {
  193. /*
  194. * A valid parameter.
  195. * Store the argument in the method/walk descriptor.
  196. * Do not copy the arg in order to implement call by reference
  197. */
  198. Status = AcpiDsMethodDataSetValue (
  199. ACPI_REFCLASS_ARG, Index, Params[Index], WalkState);
  200. if (ACPI_FAILURE (Status))
  201. {
  202. return_ACPI_STATUS (Status);
  203. }
  204. Index++;
  205. }
  206. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%u args passed to method\n", Index));
  207. return_ACPI_STATUS (AE_OK);
  208. }
  209. /*******************************************************************************
  210. *
  211. * FUNCTION: AcpiDsMethodDataGetNode
  212. *
  213. * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
  214. * ACPI_REFCLASS_ARG
  215. * Index - Which Local or Arg whose type to get
  216. * WalkState - Current walk state object
  217. * Node - Where the node is returned.
  218. *
  219. * RETURN: Status and node
  220. *
  221. * DESCRIPTION: Get the Node associated with a local or arg.
  222. *
  223. ******************************************************************************/
  224. ACPI_STATUS
  225. AcpiDsMethodDataGetNode (
  226. UINT8 Type,
  227. UINT32 Index,
  228. ACPI_WALK_STATE *WalkState,
  229. ACPI_NAMESPACE_NODE **Node)
  230. {
  231. ACPI_FUNCTION_TRACE (DsMethodDataGetNode);
  232. /*
  233. * Method Locals and Arguments are supported
  234. */
  235. switch (Type)
  236. {
  237. case ACPI_REFCLASS_LOCAL:
  238. if (Index > ACPI_METHOD_MAX_LOCAL)
  239. {
  240. ACPI_ERROR ((AE_INFO,
  241. "Local index %u is invalid (max %u)",
  242. Index, ACPI_METHOD_MAX_LOCAL));
  243. return_ACPI_STATUS (AE_AML_INVALID_INDEX);
  244. }
  245. /* Return a pointer to the pseudo-node */
  246. *Node = &WalkState->LocalVariables[Index];
  247. break;
  248. case ACPI_REFCLASS_ARG:
  249. if (Index > ACPI_METHOD_MAX_ARG)
  250. {
  251. ACPI_ERROR ((AE_INFO,
  252. "Arg index %u is invalid (max %u)",
  253. Index, ACPI_METHOD_MAX_ARG));
  254. return_ACPI_STATUS (AE_AML_INVALID_INDEX);
  255. }
  256. /* Return a pointer to the pseudo-node */
  257. *Node = &WalkState->Arguments[Index];
  258. break;
  259. default:
  260. ACPI_ERROR ((AE_INFO, "Type %u is invalid", Type));
  261. return_ACPI_STATUS (AE_TYPE);
  262. }
  263. return_ACPI_STATUS (AE_OK);
  264. }
  265. /*******************************************************************************
  266. *
  267. * FUNCTION: AcpiDsMethodDataSetValue
  268. *
  269. * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
  270. * ACPI_REFCLASS_ARG
  271. * Index - Which Local or Arg to get
  272. * Object - Object to be inserted into the stack entry
  273. * WalkState - Current walk state object
  274. *
  275. * RETURN: Status
  276. *
  277. * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
  278. * Note: There is no "implicit conversion" for locals.
  279. *
  280. ******************************************************************************/
  281. static ACPI_STATUS
  282. AcpiDsMethodDataSetValue (
  283. UINT8 Type,
  284. UINT32 Index,
  285. ACPI_OPERAND_OBJECT *Object,
  286. ACPI_WALK_STATE *WalkState)
  287. {
  288. ACPI_STATUS Status;
  289. ACPI_NAMESPACE_NODE *Node;
  290. ACPI_FUNCTION_TRACE (DsMethodDataSetValue);
  291. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
  292. "NewObj %p Type %2.2X, Refs=%u [%s]\n", Object,
  293. Type, Object->Common.ReferenceCount,
  294. AcpiUtGetTypeName (Object->Common.Type)));
  295. /* Get the namespace node for the arg/local */
  296. Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
  297. if (ACPI_FAILURE (Status))
  298. {
  299. return_ACPI_STATUS (Status);
  300. }
  301. /*
  302. * Increment ref count so object can't be deleted while installed.
  303. * NOTE: We do not copy the object in order to preserve the call by
  304. * reference semantics of ACPI Control Method invocation.
  305. * (See ACPI Specification 2.0C)
  306. */
  307. AcpiUtAddReference (Object);
  308. /* Install the object */
  309. Node->Object = Object;
  310. return_ACPI_STATUS (Status);
  311. }
  312. /*******************************************************************************
  313. *
  314. * FUNCTION: AcpiDsMethodDataGetValue
  315. *
  316. * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
  317. * ACPI_REFCLASS_ARG
  318. * Index - Which localVar or argument to get
  319. * WalkState - Current walk state object
  320. * DestDesc - Where Arg or Local value is returned
  321. *
  322. * RETURN: Status
  323. *
  324. * DESCRIPTION: Retrieve value of selected Arg or Local for this method
  325. * Used only in AcpiExResolveToValue().
  326. *
  327. ******************************************************************************/
  328. ACPI_STATUS
  329. AcpiDsMethodDataGetValue (
  330. UINT8 Type,
  331. UINT32 Index,
  332. ACPI_WALK_STATE *WalkState,
  333. ACPI_OPERAND_OBJECT **DestDesc)
  334. {
  335. ACPI_STATUS Status;
  336. ACPI_NAMESPACE_NODE *Node;
  337. ACPI_OPERAND_OBJECT *Object;
  338. ACPI_FUNCTION_TRACE (DsMethodDataGetValue);
  339. /* Validate the object descriptor */
  340. if (!DestDesc)
  341. {
  342. ACPI_ERROR ((AE_INFO, "Null object descriptor pointer"));
  343. return_ACPI_STATUS (AE_BAD_PARAMETER);
  344. }
  345. /* Get the namespace node for the arg/local */
  346. Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
  347. if (ACPI_FAILURE (Status))
  348. {
  349. return_ACPI_STATUS (Status);
  350. }
  351. /* Get the object from the node */
  352. Object = Node->Object;
  353. /* Examine the returned object, it must be valid. */
  354. if (!Object)
  355. {
  356. /*
  357. * Index points to uninitialized object.
  358. * This means that either 1) The expected argument was
  359. * not passed to the method, or 2) A local variable
  360. * was referenced by the method (via the ASL)
  361. * before it was initialized. Either case is an error.
  362. */
  363. /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */
  364. if (AcpiGbl_EnableInterpreterSlack)
  365. {
  366. Object = AcpiUtCreateIntegerObject ((UINT64) 0);
  367. if (!Object)
  368. {
  369. return_ACPI_STATUS (AE_NO_MEMORY);
  370. }
  371. Node->Object = Object;
  372. }
  373. /* Otherwise, return the error */
  374. else switch (Type)
  375. {
  376. case ACPI_REFCLASS_ARG:
  377. ACPI_ERROR ((AE_INFO,
  378. "Uninitialized Arg[%u] at node %p",
  379. Index, Node));
  380. return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
  381. case ACPI_REFCLASS_LOCAL:
  382. /*
  383. * No error message for this case, will be trapped again later to
  384. * detect and ignore cases of Store(LocalX,LocalX)
  385. */
  386. return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
  387. default:
  388. ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: 0x%X", Type));
  389. return_ACPI_STATUS (AE_AML_INTERNAL);
  390. }
  391. }
  392. /*
  393. * The Index points to an initialized and valid object.
  394. * Return an additional reference to the object
  395. */
  396. *DestDesc = Object;
  397. AcpiUtAddReference (Object);
  398. return_ACPI_STATUS (AE_OK);
  399. }
  400. /*******************************************************************************
  401. *
  402. * FUNCTION: AcpiDsMethodDataDeleteValue
  403. *
  404. * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
  405. * ACPI_REFCLASS_ARG
  406. * Index - Which localVar or argument to delete
  407. * WalkState - Current walk state object
  408. *
  409. * RETURN: None
  410. *
  411. * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
  412. * a null into the stack slot after the object is deleted.
  413. *
  414. ******************************************************************************/
  415. static void
  416. AcpiDsMethodDataDeleteValue (
  417. UINT8 Type,
  418. UINT32 Index,
  419. ACPI_WALK_STATE *WalkState)
  420. {
  421. ACPI_STATUS Status;
  422. ACPI_NAMESPACE_NODE *Node;
  423. ACPI_OPERAND_OBJECT *Object;
  424. ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue);
  425. /* Get the namespace node for the arg/local */
  426. Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
  427. if (ACPI_FAILURE (Status))
  428. {
  429. return_VOID;
  430. }
  431. /* Get the associated object */
  432. Object = AcpiNsGetAttachedObject (Node);
  433. /*
  434. * Undefine the Arg or Local by setting its descriptor
  435. * pointer to NULL. Locals/Args can contain both
  436. * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
  437. */
  438. Node->Object = NULL;
  439. if ((Object) &&
  440. (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND))
  441. {
  442. /*
  443. * There is a valid object.
  444. * Decrement the reference count by one to balance the
  445. * increment when the object was stored.
  446. */
  447. AcpiUtRemoveReference (Object);
  448. }
  449. return_VOID;
  450. }
  451. /*******************************************************************************
  452. *
  453. * FUNCTION: AcpiDsStoreObjectToLocal
  454. *
  455. * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
  456. * ACPI_REFCLASS_ARG
  457. * Index - Which Local or Arg to set
  458. * ObjDesc - Value to be stored
  459. * WalkState - Current walk state
  460. *
  461. * RETURN: Status
  462. *
  463. * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed
  464. * as the new value for the Arg or Local and the reference count
  465. * for ObjDesc is incremented.
  466. *
  467. ******************************************************************************/
  468. ACPI_STATUS
  469. AcpiDsStoreObjectToLocal (
  470. UINT8 Type,
  471. UINT32 Index,
  472. ACPI_OPERAND_OBJECT *ObjDesc,
  473. ACPI_WALK_STATE *WalkState)
  474. {
  475. ACPI_STATUS Status;
  476. ACPI_NAMESPACE_NODE *Node;
  477. ACPI_OPERAND_OBJECT *CurrentObjDesc;
  478. ACPI_OPERAND_OBJECT *NewObjDesc;
  479. ACPI_FUNCTION_TRACE (DsStoreObjectToLocal);
  480. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",
  481. Type, Index, ObjDesc));
  482. /* Parameter validation */
  483. if (!ObjDesc)
  484. {
  485. return_ACPI_STATUS (AE_BAD_PARAMETER);
  486. }
  487. /* Get the namespace node for the arg/local */
  488. Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
  489. if (ACPI_FAILURE (Status))
  490. {
  491. return_ACPI_STATUS (Status);
  492. }
  493. CurrentObjDesc = AcpiNsGetAttachedObject (Node);
  494. if (CurrentObjDesc == ObjDesc)
  495. {
  496. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
  497. ObjDesc));
  498. return_ACPI_STATUS (Status);
  499. }
  500. /*
  501. * If the reference count on the object is more than one, we must
  502. * take a copy of the object before we store. A reference count
  503. * of exactly 1 means that the object was just created during the
  504. * evaluation of an expression, and we can safely use it since it
  505. * is not used anywhere else.
  506. */
  507. NewObjDesc = ObjDesc;
  508. if (ObjDesc->Common.ReferenceCount > 1)
  509. {
  510. Status = AcpiUtCopyIobjectToIobject (
  511. ObjDesc, &NewObjDesc, WalkState);
  512. if (ACPI_FAILURE (Status))
  513. {
  514. return_ACPI_STATUS (Status);
  515. }
  516. }
  517. /*
  518. * If there is an object already in this slot, we either
  519. * have to delete it, or if this is an argument and there
  520. * is an object reference stored there, we have to do
  521. * an indirect store!
  522. */
  523. if (CurrentObjDesc)
  524. {
  525. /*
  526. * Check for an indirect store if an argument
  527. * contains an object reference (stored as an Node).
  528. * We don't allow this automatic dereferencing for
  529. * locals, since a store to a local should overwrite
  530. * anything there, including an object reference.
  531. *
  532. * If both Arg0 and Local0 contain RefOf (Local4):
  533. *
  534. * Store (1, Arg0) - Causes indirect store to local4
  535. * Store (1, Local0) - Stores 1 in local0, overwriting
  536. * the reference to local4
  537. * Store (1, DeRefof (Local0)) - Causes indirect store to local4
  538. *
  539. * Weird, but true.
  540. */
  541. if (Type == ACPI_REFCLASS_ARG)
  542. {
  543. /*
  544. * If we have a valid reference object that came from RefOf(),
  545. * do the indirect store
  546. */
  547. if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) ==
  548. ACPI_DESC_TYPE_OPERAND) &&
  549. (CurrentObjDesc->Common.Type ==
  550. ACPI_TYPE_LOCAL_REFERENCE) &&
  551. (CurrentObjDesc->Reference.Class ==
  552. ACPI_REFCLASS_REFOF))
  553. {
  554. ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
  555. "Arg (%p) is an ObjRef(Node), storing in node %p\n",
  556. NewObjDesc, CurrentObjDesc));
  557. /*
  558. * Store this object to the Node (perform the indirect store)
  559. * NOTE: No implicit conversion is performed, as per the ACPI
  560. * specification rules on storing to Locals/Args.
  561. */
  562. Status = AcpiExStoreObjectToNode (NewObjDesc,
  563. CurrentObjDesc->Reference.Object, WalkState,
  564. ACPI_NO_IMPLICIT_CONVERSION);
  565. /* Remove local reference if we copied the object above */
  566. if (NewObjDesc != ObjDesc)
  567. {
  568. AcpiUtRemoveReference (NewObjDesc);
  569. }
  570. return_ACPI_STATUS (Status);
  571. }
  572. }
  573. /* Delete the existing object before storing the new one */
  574. AcpiDsMethodDataDeleteValue (Type, Index, WalkState);
  575. }
  576. /*
  577. * Install the Obj descriptor (*NewObjDesc) into
  578. * the descriptor for the Arg or Local.
  579. * (increments the object reference count by one)
  580. */
  581. Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState);
  582. /* Remove local reference if we copied the object above */
  583. if (NewObjDesc != ObjDesc)
  584. {
  585. AcpiUtRemoveReference (NewObjDesc);
  586. }
  587. return_ACPI_STATUS (Status);
  588. }
  589. #ifdef ACPI_OBSOLETE_FUNCTIONS
  590. /*******************************************************************************
  591. *
  592. * FUNCTION: AcpiDsMethodDataGetType
  593. *
  594. * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
  595. * Index - Which Local or Arg whose type to get
  596. * WalkState - Current walk state object
  597. *
  598. * RETURN: Data type of current value of the selected Arg or Local
  599. *
  600. * DESCRIPTION: Get the type of the object stored in the Local or Arg
  601. *
  602. ******************************************************************************/
  603. ACPI_OBJECT_TYPE
  604. AcpiDsMethodDataGetType (
  605. UINT16 Opcode,
  606. UINT32 Index,
  607. ACPI_WALK_STATE *WalkState)
  608. {
  609. ACPI_STATUS Status;
  610. ACPI_NAMESPACE_NODE *Node;
  611. ACPI_OPERAND_OBJECT *Object;
  612. ACPI_FUNCTION_TRACE (DsMethodDataGetType);
  613. /* Get the namespace node for the arg/local */
  614. Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
  615. if (ACPI_FAILURE (Status))
  616. {
  617. return_VALUE ((ACPI_TYPE_NOT_FOUND));
  618. }
  619. /* Get the object */
  620. Object = AcpiNsGetAttachedObject (Node);
  621. if (!Object)
  622. {
  623. /* Uninitialized local/arg, return TYPE_ANY */
  624. return_VALUE (ACPI_TYPE_ANY);
  625. }
  626. /* Get the object type */
  627. return_VALUE (Object->Type);
  628. }
  629. #endif