1 /*******************************************************************************
2 *
3 * Module Name: dsmthdat - control method arguments and local variables
4 *
5 ******************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acdispat.h"
47 #include "acnamesp.h"
48 #include "acinterp.h"
49
50
51 #define _COMPONENT ACPI_DISPATCHER
52 ACPI_MODULE_NAME ("dsmthdat")
53
54 /* Local prototypes */
55
56 static void
57 AcpiDsMethodDataDeleteValue (
58 UINT8 Type,
59 UINT32 Index,
60 ACPI_WALK_STATE *WalkState);
61
62 static ACPI_STATUS
63 AcpiDsMethodDataSetValue (
64 UINT8 Type,
65 UINT32 Index,
66 ACPI_OPERAND_OBJECT *Object,
67 ACPI_WALK_STATE *WalkState);
68
69 #ifdef ACPI_OBSOLETE_FUNCTIONS
70 ACPI_OBJECT_TYPE
71 AcpiDsMethodDataGetType (
72 UINT16 Opcode,
73 UINT32 Index,
74 ACPI_WALK_STATE *WalkState);
75 #endif
76
77
78 /*******************************************************************************
79 *
80 * FUNCTION: AcpiDsMethodDataInit
81 *
82 * PARAMETERS: WalkState - Current walk state object
83 *
84 * RETURN: Status
85 *
86 * DESCRIPTION: Initialize the data structures that hold the method's arguments
87 * and locals. The data struct is an array of namespace nodes for
88 * each - this allows RefOf and DeRefOf to work properly for these
89 * special data types.
90 *
91 * NOTES: WalkState fields are initialized to zero by the
92 * ACPI_ALLOCATE_ZEROED().
93 *
94 * A pseudo-Namespace Node is assigned to each argument and local
95 * so that RefOf() can return a pointer to the Node.
96 *
97 ******************************************************************************/
98
99 void
AcpiDsMethodDataInit(ACPI_WALK_STATE * WalkState)100 AcpiDsMethodDataInit (
101 ACPI_WALK_STATE *WalkState)
102 {
103 UINT32 i;
104
105
106 ACPI_FUNCTION_TRACE (DsMethodDataInit);
107
108
109 /* Init the method arguments */
110
111 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
112 {
113 ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE);
114 WalkState->Arguments[i].Name.Integer |= (i << 24);
115 WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
116 WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
117 WalkState->Arguments[i].Flags = ANOBJ_METHOD_ARG;
118 }
119
120 /* Init the method locals */
121
122 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
123 {
124 ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE);
125
126 WalkState->LocalVariables[i].Name.Integer |= (i << 24);
127 WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
128 WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
129 WalkState->LocalVariables[i].Flags = ANOBJ_METHOD_LOCAL;
130 }
131
132 return_VOID;
133 }
134
135
136 /*******************************************************************************
137 *
138 * FUNCTION: AcpiDsMethodDataDeleteAll
139 *
140 * PARAMETERS: WalkState - Current walk state object
141 *
142 * RETURN: None
143 *
144 * DESCRIPTION: Delete method locals and arguments. Arguments are only
145 * deleted if this method was called from another method.
146 *
147 ******************************************************************************/
148
149 void
AcpiDsMethodDataDeleteAll(ACPI_WALK_STATE * WalkState)150 AcpiDsMethodDataDeleteAll (
151 ACPI_WALK_STATE *WalkState)
152 {
153 UINT32 Index;
154
155
156 ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll);
157
158
159 /* Detach the locals */
160
161 for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++)
162 {
163 if (WalkState->LocalVariables[Index].Object)
164 {
165 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%u=%p\n",
166 Index, WalkState->LocalVariables[Index].Object));
167
168 /* Detach object (if present) and remove a reference */
169
170 AcpiNsDetachObject (&WalkState->LocalVariables[Index]);
171 }
172 }
173
174 /* Detach the arguments */
175
176 for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++)
177 {
178 if (WalkState->Arguments[Index].Object)
179 {
180 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%u=%p\n",
181 Index, WalkState->Arguments[Index].Object));
182
183 /* Detach object (if present) and remove a reference */
184
185 AcpiNsDetachObject (&WalkState->Arguments[Index]);
186 }
187 }
188
189 return_VOID;
190 }
191
192
193 /*******************************************************************************
194 *
195 * FUNCTION: AcpiDsMethodDataInitArgs
196 *
197 * PARAMETERS: *Params - Pointer to a parameter list for the method
198 * MaxParamCount - The arg count for this method
199 * WalkState - Current walk state object
200 *
201 * RETURN: Status
202 *
203 * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
204 * of ACPI operand objects, either null terminated or whose length
205 * is defined by MaxParamCount.
206 *
207 ******************************************************************************/
208
209 ACPI_STATUS
AcpiDsMethodDataInitArgs(ACPI_OPERAND_OBJECT ** Params,UINT32 MaxParamCount,ACPI_WALK_STATE * WalkState)210 AcpiDsMethodDataInitArgs (
211 ACPI_OPERAND_OBJECT **Params,
212 UINT32 MaxParamCount,
213 ACPI_WALK_STATE *WalkState)
214 {
215 ACPI_STATUS Status;
216 UINT32 Index = 0;
217
218
219 ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params);
220
221
222 if (!Params)
223 {
224 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n"));
225 return_ACPI_STATUS (AE_OK);
226 }
227
228 /* Copy passed parameters into the new method stack frame */
229
230 while ((Index < ACPI_METHOD_NUM_ARGS) &&
231 (Index < MaxParamCount) &&
232 Params[Index])
233 {
234 /*
235 * A valid parameter.
236 * Store the argument in the method/walk descriptor.
237 * Do not copy the arg in order to implement call by reference
238 */
239 Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index,
240 Params[Index], WalkState);
241 if (ACPI_FAILURE (Status))
242 {
243 return_ACPI_STATUS (Status);
244 }
245
246 Index++;
247 }
248
249 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%u args passed to method\n", Index));
250 return_ACPI_STATUS (AE_OK);
251 }
252
253
254 /*******************************************************************************
255 *
256 * FUNCTION: AcpiDsMethodDataGetNode
257 *
258 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
259 * ACPI_REFCLASS_ARG
260 * Index - Which Local or Arg whose type to get
261 * WalkState - Current walk state object
262 * Node - Where the node is returned.
263 *
264 * RETURN: Status and node
265 *
266 * DESCRIPTION: Get the Node associated with a local or arg.
267 *
268 ******************************************************************************/
269
270 ACPI_STATUS
AcpiDsMethodDataGetNode(UINT8 Type,UINT32 Index,ACPI_WALK_STATE * WalkState,ACPI_NAMESPACE_NODE ** Node)271 AcpiDsMethodDataGetNode (
272 UINT8 Type,
273 UINT32 Index,
274 ACPI_WALK_STATE *WalkState,
275 ACPI_NAMESPACE_NODE **Node)
276 {
277 ACPI_FUNCTION_TRACE (DsMethodDataGetNode);
278
279
280 /*
281 * Method Locals and Arguments are supported
282 */
283 switch (Type)
284 {
285 case ACPI_REFCLASS_LOCAL:
286
287 if (Index > ACPI_METHOD_MAX_LOCAL)
288 {
289 ACPI_ERROR ((AE_INFO,
290 "Local index %u is invalid (max %u)",
291 Index, ACPI_METHOD_MAX_LOCAL));
292 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
293 }
294
295 /* Return a pointer to the pseudo-node */
296
297 *Node = &WalkState->LocalVariables[Index];
298 break;
299
300 case ACPI_REFCLASS_ARG:
301
302 if (Index > ACPI_METHOD_MAX_ARG)
303 {
304 ACPI_ERROR ((AE_INFO,
305 "Arg index %u is invalid (max %u)",
306 Index, ACPI_METHOD_MAX_ARG));
307 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
308 }
309
310 /* Return a pointer to the pseudo-node */
311
312 *Node = &WalkState->Arguments[Index];
313 break;
314
315 default:
316
317 ACPI_ERROR ((AE_INFO, "Type %u is invalid", Type));
318 return_ACPI_STATUS (AE_TYPE);
319 }
320
321 return_ACPI_STATUS (AE_OK);
322 }
323
324
325 /*******************************************************************************
326 *
327 * FUNCTION: AcpiDsMethodDataSetValue
328 *
329 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
330 * ACPI_REFCLASS_ARG
331 * Index - Which Local or Arg to get
332 * Object - Object to be inserted into the stack entry
333 * WalkState - Current walk state object
334 *
335 * RETURN: Status
336 *
337 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
338 * Note: There is no "implicit conversion" for locals.
339 *
340 ******************************************************************************/
341
342 static ACPI_STATUS
AcpiDsMethodDataSetValue(UINT8 Type,UINT32 Index,ACPI_OPERAND_OBJECT * Object,ACPI_WALK_STATE * WalkState)343 AcpiDsMethodDataSetValue (
344 UINT8 Type,
345 UINT32 Index,
346 ACPI_OPERAND_OBJECT *Object,
347 ACPI_WALK_STATE *WalkState)
348 {
349 ACPI_STATUS Status;
350 ACPI_NAMESPACE_NODE *Node;
351
352
353 ACPI_FUNCTION_TRACE (DsMethodDataSetValue);
354
355
356 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
357 "NewObj %p Type %2.2X, Refs=%u [%s]\n", Object,
358 Type, Object->Common.ReferenceCount,
359 AcpiUtGetTypeName (Object->Common.Type)));
360
361 /* Get the namespace node for the arg/local */
362
363 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
364 if (ACPI_FAILURE (Status))
365 {
366 return_ACPI_STATUS (Status);
367 }
368
369 /*
370 * Increment ref count so object can't be deleted while installed.
371 * NOTE: We do not copy the object in order to preserve the call by
372 * reference semantics of ACPI Control Method invocation.
373 * (See ACPI Specification 2.0C)
374 */
375 AcpiUtAddReference (Object);
376
377 /* Install the object */
378
379 Node->Object = Object;
380 return_ACPI_STATUS (Status);
381 }
382
383
384 /*******************************************************************************
385 *
386 * FUNCTION: AcpiDsMethodDataGetValue
387 *
388 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
389 * ACPI_REFCLASS_ARG
390 * Index - Which localVar or argument to get
391 * WalkState - Current walk state object
392 * DestDesc - Where Arg or Local value is returned
393 *
394 * RETURN: Status
395 *
396 * DESCRIPTION: Retrieve value of selected Arg or Local for this method
397 * Used only in AcpiExResolveToValue().
398 *
399 ******************************************************************************/
400
401 ACPI_STATUS
AcpiDsMethodDataGetValue(UINT8 Type,UINT32 Index,ACPI_WALK_STATE * WalkState,ACPI_OPERAND_OBJECT ** DestDesc)402 AcpiDsMethodDataGetValue (
403 UINT8 Type,
404 UINT32 Index,
405 ACPI_WALK_STATE *WalkState,
406 ACPI_OPERAND_OBJECT **DestDesc)
407 {
408 ACPI_STATUS Status;
409 ACPI_NAMESPACE_NODE *Node;
410 ACPI_OPERAND_OBJECT *Object;
411
412
413 ACPI_FUNCTION_TRACE (DsMethodDataGetValue);
414
415
416 /* Validate the object descriptor */
417
418 if (!DestDesc)
419 {
420 ACPI_ERROR ((AE_INFO, "Null object descriptor pointer"));
421 return_ACPI_STATUS (AE_BAD_PARAMETER);
422 }
423
424 /* Get the namespace node for the arg/local */
425
426 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
427 if (ACPI_FAILURE (Status))
428 {
429 return_ACPI_STATUS (Status);
430 }
431
432 /* Get the object from the node */
433
434 Object = Node->Object;
435
436 /* Examine the returned object, it must be valid. */
437
438 if (!Object)
439 {
440 /*
441 * Index points to uninitialized object.
442 * This means that either 1) The expected argument was
443 * not passed to the method, or 2) A local variable
444 * was referenced by the method (via the ASL)
445 * before it was initialized. Either case is an error.
446 */
447
448 /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */
449
450 if (AcpiGbl_EnableInterpreterSlack)
451 {
452 Object = AcpiUtCreateIntegerObject ((UINT64) 0);
453 if (!Object)
454 {
455 return_ACPI_STATUS (AE_NO_MEMORY);
456 }
457
458 Node->Object = Object;
459 }
460
461 /* Otherwise, return the error */
462
463 else switch (Type)
464 {
465 case ACPI_REFCLASS_ARG:
466
467 ACPI_ERROR ((AE_INFO,
468 "Uninitialized Arg[%u] at node %p",
469 Index, Node));
470
471 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
472
473 case ACPI_REFCLASS_LOCAL:
474 /*
475 * No error message for this case, will be trapped again later to
476 * detect and ignore cases of Store(LocalX,LocalX)
477 */
478 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
479
480 default:
481
482 ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: 0x%X", Type));
483 return_ACPI_STATUS (AE_AML_INTERNAL);
484 }
485 }
486
487 /*
488 * The Index points to an initialized and valid object.
489 * Return an additional reference to the object
490 */
491 *DestDesc = Object;
492 AcpiUtAddReference (Object);
493
494 return_ACPI_STATUS (AE_OK);
495 }
496
497
498 /*******************************************************************************
499 *
500 * FUNCTION: AcpiDsMethodDataDeleteValue
501 *
502 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
503 * ACPI_REFCLASS_ARG
504 * Index - Which localVar or argument to delete
505 * WalkState - Current walk state object
506 *
507 * RETURN: None
508 *
509 * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
510 * a null into the stack slot after the object is deleted.
511 *
512 ******************************************************************************/
513
514 static void
AcpiDsMethodDataDeleteValue(UINT8 Type,UINT32 Index,ACPI_WALK_STATE * WalkState)515 AcpiDsMethodDataDeleteValue (
516 UINT8 Type,
517 UINT32 Index,
518 ACPI_WALK_STATE *WalkState)
519 {
520 ACPI_STATUS Status;
521 ACPI_NAMESPACE_NODE *Node;
522 ACPI_OPERAND_OBJECT *Object;
523
524
525 ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue);
526
527
528 /* Get the namespace node for the arg/local */
529
530 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
531 if (ACPI_FAILURE (Status))
532 {
533 return_VOID;
534 }
535
536 /* Get the associated object */
537
538 Object = AcpiNsGetAttachedObject (Node);
539
540 /*
541 * Undefine the Arg or Local by setting its descriptor
542 * pointer to NULL. Locals/Args can contain both
543 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
544 */
545 Node->Object = NULL;
546
547 if ((Object) &&
548 (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND))
549 {
550 /*
551 * There is a valid object.
552 * Decrement the reference count by one to balance the
553 * increment when the object was stored.
554 */
555 AcpiUtRemoveReference (Object);
556 }
557
558 return_VOID;
559 }
560
561
562 /*******************************************************************************
563 *
564 * FUNCTION: AcpiDsStoreObjectToLocal
565 *
566 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
567 * ACPI_REFCLASS_ARG
568 * Index - Which Local or Arg to set
569 * ObjDesc - Value to be stored
570 * WalkState - Current walk state
571 *
572 * RETURN: Status
573 *
574 * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed
575 * as the new value for the Arg or Local and the reference count
576 * for ObjDesc is incremented.
577 *
578 ******************************************************************************/
579
580 ACPI_STATUS
AcpiDsStoreObjectToLocal(UINT8 Type,UINT32 Index,ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)581 AcpiDsStoreObjectToLocal (
582 UINT8 Type,
583 UINT32 Index,
584 ACPI_OPERAND_OBJECT *ObjDesc,
585 ACPI_WALK_STATE *WalkState)
586 {
587 ACPI_STATUS Status;
588 ACPI_NAMESPACE_NODE *Node;
589 ACPI_OPERAND_OBJECT *CurrentObjDesc;
590 ACPI_OPERAND_OBJECT *NewObjDesc;
591
592
593 ACPI_FUNCTION_TRACE (DsStoreObjectToLocal);
594 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%u Obj=%p\n",
595 Type, Index, ObjDesc));
596
597 /* Parameter validation */
598
599 if (!ObjDesc)
600 {
601 return_ACPI_STATUS (AE_BAD_PARAMETER);
602 }
603
604 /* Get the namespace node for the arg/local */
605
606 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
607 if (ACPI_FAILURE (Status))
608 {
609 return_ACPI_STATUS (Status);
610 }
611
612 CurrentObjDesc = AcpiNsGetAttachedObject (Node);
613 if (CurrentObjDesc == ObjDesc)
614 {
615 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
616 ObjDesc));
617 return_ACPI_STATUS (Status);
618 }
619
620 /*
621 * If the reference count on the object is more than one, we must
622 * take a copy of the object before we store. A reference count
623 * of exactly 1 means that the object was just created during the
624 * evaluation of an expression, and we can safely use it since it
625 * is not used anywhere else.
626 */
627 NewObjDesc = ObjDesc;
628 if (ObjDesc->Common.ReferenceCount > 1)
629 {
630 Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState);
631 if (ACPI_FAILURE (Status))
632 {
633 return_ACPI_STATUS (Status);
634 }
635 }
636
637 /*
638 * If there is an object already in this slot, we either
639 * have to delete it, or if this is an argument and there
640 * is an object reference stored there, we have to do
641 * an indirect store!
642 */
643 if (CurrentObjDesc)
644 {
645 /*
646 * Check for an indirect store if an argument
647 * contains an object reference (stored as an Node).
648 * We don't allow this automatic dereferencing for
649 * locals, since a store to a local should overwrite
650 * anything there, including an object reference.
651 *
652 * If both Arg0 and Local0 contain RefOf (Local4):
653 *
654 * Store (1, Arg0) - Causes indirect store to local4
655 * Store (1, Local0) - Stores 1 in local0, overwriting
656 * the reference to local4
657 * Store (1, DeRefof (Local0)) - Causes indirect store to local4
658 *
659 * Weird, but true.
660 */
661 if (Type == ACPI_REFCLASS_ARG)
662 {
663 /*
664 * If we have a valid reference object that came from RefOf(),
665 * do the indirect store
666 */
667 if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
668 (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
669 (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF))
670 {
671 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
672 "Arg (%p) is an ObjRef(Node), storing in node %p\n",
673 NewObjDesc, CurrentObjDesc));
674
675 /*
676 * Store this object to the Node (perform the indirect store)
677 * NOTE: No implicit conversion is performed, as per the ACPI
678 * specification rules on storing to Locals/Args.
679 */
680 Status = AcpiExStoreObjectToNode (NewObjDesc,
681 CurrentObjDesc->Reference.Object, WalkState,
682 ACPI_NO_IMPLICIT_CONVERSION);
683
684 /* Remove local reference if we copied the object above */
685
686 if (NewObjDesc != ObjDesc)
687 {
688 AcpiUtRemoveReference (NewObjDesc);
689 }
690 return_ACPI_STATUS (Status);
691 }
692 }
693
694 /* Delete the existing object before storing the new one */
695
696 AcpiDsMethodDataDeleteValue (Type, Index, WalkState);
697 }
698
699 /*
700 * Install the Obj descriptor (*NewObjDesc) into
701 * the descriptor for the Arg or Local.
702 * (increments the object reference count by one)
703 */
704 Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState);
705
706 /* Remove local reference if we copied the object above */
707
708 if (NewObjDesc != ObjDesc)
709 {
710 AcpiUtRemoveReference (NewObjDesc);
711 }
712
713 return_ACPI_STATUS (Status);
714 }
715
716
717 #ifdef ACPI_OBSOLETE_FUNCTIONS
718 /*******************************************************************************
719 *
720 * FUNCTION: AcpiDsMethodDataGetType
721 *
722 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
723 * Index - Which Local or Arg whose type to get
724 * WalkState - Current walk state object
725 *
726 * RETURN: Data type of current value of the selected Arg or Local
727 *
728 * DESCRIPTION: Get the type of the object stored in the Local or Arg
729 *
730 ******************************************************************************/
731
732 ACPI_OBJECT_TYPE
AcpiDsMethodDataGetType(UINT16 Opcode,UINT32 Index,ACPI_WALK_STATE * WalkState)733 AcpiDsMethodDataGetType (
734 UINT16 Opcode,
735 UINT32 Index,
736 ACPI_WALK_STATE *WalkState)
737 {
738 ACPI_STATUS Status;
739 ACPI_NAMESPACE_NODE *Node;
740 ACPI_OPERAND_OBJECT *Object;
741
742
743 ACPI_FUNCTION_TRACE (DsMethodDataGetType);
744
745
746 /* Get the namespace node for the arg/local */
747
748 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
749 if (ACPI_FAILURE (Status))
750 {
751 return_VALUE ((ACPI_TYPE_NOT_FOUND));
752 }
753
754 /* Get the object */
755
756 Object = AcpiNsGetAttachedObject (Node);
757 if (!Object)
758 {
759 /* Uninitialized local/arg, return TYPE_ANY */
760
761 return_VALUE (ACPI_TYPE_ANY);
762 }
763
764 /* Get the object type */
765
766 return_VALUE (Object->Type);
767 }
768 #endif
769