Deleted Added
sdiff udiff text old ( 197104 ) new ( 199337 )
full compact
1/*******************************************************************************
2 *
3 * Module Name: dsmthdat - control method arguments and local variables
4 *
5 ******************************************************************************/
6
7/******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************/
115
116#define __DSMTHDAT_C__
117
118#include <contrib/dev/acpica/include/acpi.h>
119#include <contrib/dev/acpica/include/accommon.h>
120#include <contrib/dev/acpica/include/acdispat.h>
121#include <contrib/dev/acpica/include/acnamesp.h>
122#include <contrib/dev/acpica/include/acinterp.h>
123
124
125#define _COMPONENT ACPI_DISPATCHER
126 ACPI_MODULE_NAME ("dsmthdat")
127
128/* Local prototypes */
129
130static void
131AcpiDsMethodDataDeleteValue (
132 UINT8 Type,
133 UINT32 Index,
134 ACPI_WALK_STATE *WalkState);
135
136static ACPI_STATUS
137AcpiDsMethodDataSetValue (
138 UINT8 Type,
139 UINT32 Index,
140 ACPI_OPERAND_OBJECT *Object,
141 ACPI_WALK_STATE *WalkState);
142
143#ifdef ACPI_OBSOLETE_FUNCTIONS
144ACPI_OBJECT_TYPE
145AcpiDsMethodDataGetType (
146 UINT16 Opcode,
147 UINT32 Index,
148 ACPI_WALK_STATE *WalkState);
149#endif
150
151
152/*******************************************************************************
153 *
154 * FUNCTION: AcpiDsMethodDataInit
155 *
156 * PARAMETERS: WalkState - Current walk state object
157 *
158 * RETURN: Status
159 *
160 * DESCRIPTION: Initialize the data structures that hold the method's arguments
161 * and locals. The data struct is an array of namespace nodes for
162 * each - this allows RefOf and DeRefOf to work properly for these
163 * special data types.
164 *
165 * NOTES: WalkState fields are initialized to zero by the
166 * ACPI_ALLOCATE_ZEROED().
167 *
168 * A pseudo-Namespace Node is assigned to each argument and local
169 * so that RefOf() can return a pointer to the Node.
170 *
171 ******************************************************************************/
172
173void
174AcpiDsMethodDataInit (
175 ACPI_WALK_STATE *WalkState)
176{
177 UINT32 i;
178
179
180 ACPI_FUNCTION_TRACE (DsMethodDataInit);
181
182
183 /* Init the method arguments */
184
185 for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
186 {
187 ACPI_MOVE_32_TO_32 (&WalkState->Arguments[i].Name, NAMEOF_ARG_NTE);
188 WalkState->Arguments[i].Name.Integer |= (i << 24);
189 WalkState->Arguments[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
190 WalkState->Arguments[i].Type = ACPI_TYPE_ANY;
191 WalkState->Arguments[i].Flags =
192 ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_ARG;
193 }
194
195 /* Init the method locals */
196
197 for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
198 {
199 ACPI_MOVE_32_TO_32 (&WalkState->LocalVariables[i].Name, NAMEOF_LOCAL_NTE);
200
201 WalkState->LocalVariables[i].Name.Integer |= (i << 24);
202 WalkState->LocalVariables[i].DescriptorType = ACPI_DESC_TYPE_NAMED;
203 WalkState->LocalVariables[i].Type = ACPI_TYPE_ANY;
204 WalkState->LocalVariables[i].Flags =
205 ANOBJ_END_OF_PEER_LIST | ANOBJ_METHOD_LOCAL;
206 }
207
208 return_VOID;
209}
210
211
212/*******************************************************************************
213 *
214 * FUNCTION: AcpiDsMethodDataDeleteAll
215 *
216 * PARAMETERS: WalkState - Current walk state object
217 *
218 * RETURN: None
219 *
220 * DESCRIPTION: Delete method locals and arguments. Arguments are only
221 * deleted if this method was called from another method.
222 *
223 ******************************************************************************/
224
225void
226AcpiDsMethodDataDeleteAll (
227 ACPI_WALK_STATE *WalkState)
228{
229 UINT32 Index;
230
231
232 ACPI_FUNCTION_TRACE (DsMethodDataDeleteAll);
233
234
235 /* Detach the locals */
236
237 for (Index = 0; Index < ACPI_METHOD_NUM_LOCALS; Index++)
238 {
239 if (WalkState->LocalVariables[Index].Object)
240 {
241 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Local%d=%p\n",
242 Index, WalkState->LocalVariables[Index].Object));
243
244 /* Detach object (if present) and remove a reference */
245
246 AcpiNsDetachObject (&WalkState->LocalVariables[Index]);
247 }
248 }
249
250 /* Detach the arguments */
251
252 for (Index = 0; Index < ACPI_METHOD_NUM_ARGS; Index++)
253 {
254 if (WalkState->Arguments[Index].Object)
255 {
256 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Deleting Arg%d=%p\n",
257 Index, WalkState->Arguments[Index].Object));
258
259 /* Detach object (if present) and remove a reference */
260
261 AcpiNsDetachObject (&WalkState->Arguments[Index]);
262 }
263 }
264
265 return_VOID;
266}
267
268
269/*******************************************************************************
270 *
271 * FUNCTION: AcpiDsMethodDataInitArgs
272 *
273 * PARAMETERS: *Params - Pointer to a parameter list for the method
274 * MaxParamCount - The arg count for this method
275 * WalkState - Current walk state object
276 *
277 * RETURN: Status
278 *
279 * DESCRIPTION: Initialize arguments for a method. The parameter list is a list
280 * of ACPI operand objects, either null terminated or whose length
281 * is defined by MaxParamCount.
282 *
283 ******************************************************************************/
284
285ACPI_STATUS
286AcpiDsMethodDataInitArgs (
287 ACPI_OPERAND_OBJECT **Params,
288 UINT32 MaxParamCount,
289 ACPI_WALK_STATE *WalkState)
290{
291 ACPI_STATUS Status;
292 UINT32 Index = 0;
293
294
295 ACPI_FUNCTION_TRACE_PTR (DsMethodDataInitArgs, Params);
296
297
298 if (!Params)
299 {
300 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "No param list passed to method\n"));
301 return_ACPI_STATUS (AE_OK);
302 }
303
304 /* Copy passed parameters into the new method stack frame */
305
306 while ((Index < ACPI_METHOD_NUM_ARGS) &&
307 (Index < MaxParamCount) &&
308 Params[Index])
309 {
310 /*
311 * A valid parameter.
312 * Store the argument in the method/walk descriptor.
313 * Do not copy the arg in order to implement call by reference
314 */
315 Status = AcpiDsMethodDataSetValue (ACPI_REFCLASS_ARG, Index,
316 Params[Index], WalkState);
317 if (ACPI_FAILURE (Status))
318 {
319 return_ACPI_STATUS (Status);
320 }
321
322 Index++;
323 }
324
325 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%d args passed to method\n", Index));
326 return_ACPI_STATUS (AE_OK);
327}
328
329
330/*******************************************************************************
331 *
332 * FUNCTION: AcpiDsMethodDataGetNode
333 *
334 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
335 * ACPI_REFCLASS_ARG
336 * Index - Which Local or Arg whose type to get
337 * WalkState - Current walk state object
338 * Node - Where the node is returned.
339 *
340 * RETURN: Status and node
341 *
342 * DESCRIPTION: Get the Node associated with a local or arg.
343 *
344 ******************************************************************************/
345
346ACPI_STATUS
347AcpiDsMethodDataGetNode (
348 UINT8 Type,
349 UINT32 Index,
350 ACPI_WALK_STATE *WalkState,
351 ACPI_NAMESPACE_NODE **Node)
352{
353 ACPI_FUNCTION_TRACE (DsMethodDataGetNode);
354
355
356 /*
357 * Method Locals and Arguments are supported
358 */
359 switch (Type)
360 {
361 case ACPI_REFCLASS_LOCAL:
362
363 if (Index > ACPI_METHOD_MAX_LOCAL)
364 {
365 ACPI_ERROR ((AE_INFO,
366 "Local index %d is invalid (max %d)",
367 Index, ACPI_METHOD_MAX_LOCAL));
368 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
369 }
370
371 /* Return a pointer to the pseudo-node */
372
373 *Node = &WalkState->LocalVariables[Index];
374 break;
375
376 case ACPI_REFCLASS_ARG:
377
378 if (Index > ACPI_METHOD_MAX_ARG)
379 {
380 ACPI_ERROR ((AE_INFO,
381 "Arg index %d is invalid (max %d)",
382 Index, ACPI_METHOD_MAX_ARG));
383 return_ACPI_STATUS (AE_AML_INVALID_INDEX);
384 }
385
386 /* Return a pointer to the pseudo-node */
387
388 *Node = &WalkState->Arguments[Index];
389 break;
390
391 default:
392 ACPI_ERROR ((AE_INFO, "Type %d is invalid", Type));
393 return_ACPI_STATUS (AE_TYPE);
394 }
395
396 return_ACPI_STATUS (AE_OK);
397}
398
399
400/*******************************************************************************
401 *
402 * FUNCTION: AcpiDsMethodDataSetValue
403 *
404 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
405 * ACPI_REFCLASS_ARG
406 * Index - Which Local or Arg to get
407 * Object - Object to be inserted into the stack entry
408 * WalkState - Current walk state object
409 *
410 * RETURN: Status
411 *
412 * DESCRIPTION: Insert an object onto the method stack at entry Opcode:Index.
413 * Note: There is no "implicit conversion" for locals.
414 *
415 ******************************************************************************/
416
417static ACPI_STATUS
418AcpiDsMethodDataSetValue (
419 UINT8 Type,
420 UINT32 Index,
421 ACPI_OPERAND_OBJECT *Object,
422 ACPI_WALK_STATE *WalkState)
423{
424 ACPI_STATUS Status;
425 ACPI_NAMESPACE_NODE *Node;
426
427
428 ACPI_FUNCTION_TRACE (DsMethodDataSetValue);
429
430
431 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
432 "NewObj %p Type %2.2X, Refs=%d [%s]\n", Object,
433 Type, Object->Common.ReferenceCount,
434 AcpiUtGetTypeName (Object->Common.Type)));
435
436 /* Get the namespace node for the arg/local */
437
438 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
439 if (ACPI_FAILURE (Status))
440 {
441 return_ACPI_STATUS (Status);
442 }
443
444 /*
445 * Increment ref count so object can't be deleted while installed.
446 * NOTE: We do not copy the object in order to preserve the call by
447 * reference semantics of ACPI Control Method invocation.
448 * (See ACPI Specification 2.0C)
449 */
450 AcpiUtAddReference (Object);
451
452 /* Install the object */
453
454 Node->Object = Object;
455 return_ACPI_STATUS (Status);
456}
457
458
459/*******************************************************************************
460 *
461 * FUNCTION: AcpiDsMethodDataGetValue
462 *
463 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
464 * ACPI_REFCLASS_ARG
465 * Index - Which localVar or argument to get
466 * WalkState - Current walk state object
467 * DestDesc - Where Arg or Local value is returned
468 *
469 * RETURN: Status
470 *
471 * DESCRIPTION: Retrieve value of selected Arg or Local for this method
472 * Used only in AcpiExResolveToValue().
473 *
474 ******************************************************************************/
475
476ACPI_STATUS
477AcpiDsMethodDataGetValue (
478 UINT8 Type,
479 UINT32 Index,
480 ACPI_WALK_STATE *WalkState,
481 ACPI_OPERAND_OBJECT **DestDesc)
482{
483 ACPI_STATUS Status;
484 ACPI_NAMESPACE_NODE *Node;
485 ACPI_OPERAND_OBJECT *Object;
486
487
488 ACPI_FUNCTION_TRACE (DsMethodDataGetValue);
489
490
491 /* Validate the object descriptor */
492
493 if (!DestDesc)
494 {
495 ACPI_ERROR ((AE_INFO, "Null object descriptor pointer"));
496 return_ACPI_STATUS (AE_BAD_PARAMETER);
497 }
498
499 /* Get the namespace node for the arg/local */
500
501 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
502 if (ACPI_FAILURE (Status))
503 {
504 return_ACPI_STATUS (Status);
505 }
506
507 /* Get the object from the node */
508
509 Object = Node->Object;
510
511 /* Examine the returned object, it must be valid. */
512
513 if (!Object)
514 {
515 /*
516 * Index points to uninitialized object.
517 * This means that either 1) The expected argument was
518 * not passed to the method, or 2) A local variable
519 * was referenced by the method (via the ASL)
520 * before it was initialized. Either case is an error.
521 */
522
523 /* If slack enabled, init the LocalX/ArgX to an Integer of value zero */
524
525 if (AcpiGbl_EnableInterpreterSlack)
526 {
527 Object = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
528 if (!Object)
529 {
530 return_ACPI_STATUS (AE_NO_MEMORY);
531 }
532
533 Object->Integer.Value = 0;
534 Node->Object = Object;
535 }
536
537 /* Otherwise, return the error */
538
539 else switch (Type)
540 {
541 case ACPI_REFCLASS_ARG:
542
543 ACPI_ERROR ((AE_INFO,
544 "Uninitialized Arg[%d] at node %p",
545 Index, Node));
546
547 return_ACPI_STATUS (AE_AML_UNINITIALIZED_ARG);
548
549 case ACPI_REFCLASS_LOCAL:
550
551 /*
552 * No error message for this case, will be trapped again later to
553 * detect and ignore cases of Store(LocalX,LocalX)
554 */
555 return_ACPI_STATUS (AE_AML_UNINITIALIZED_LOCAL);
556
557 default:
558
559 ACPI_ERROR ((AE_INFO, "Not a Arg/Local opcode: %X", Type));
560 return_ACPI_STATUS (AE_AML_INTERNAL);
561 }
562 }
563
564 /*
565 * The Index points to an initialized and valid object.
566 * Return an additional reference to the object
567 */
568 *DestDesc = Object;
569 AcpiUtAddReference (Object);
570
571 return_ACPI_STATUS (AE_OK);
572}
573
574
575/*******************************************************************************
576 *
577 * FUNCTION: AcpiDsMethodDataDeleteValue
578 *
579 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
580 * ACPI_REFCLASS_ARG
581 * Index - Which localVar or argument to delete
582 * WalkState - Current walk state object
583 *
584 * RETURN: None
585 *
586 * DESCRIPTION: Delete the entry at Opcode:Index. Inserts
587 * a null into the stack slot after the object is deleted.
588 *
589 ******************************************************************************/
590
591static void
592AcpiDsMethodDataDeleteValue (
593 UINT8 Type,
594 UINT32 Index,
595 ACPI_WALK_STATE *WalkState)
596{
597 ACPI_STATUS Status;
598 ACPI_NAMESPACE_NODE *Node;
599 ACPI_OPERAND_OBJECT *Object;
600
601
602 ACPI_FUNCTION_TRACE (DsMethodDataDeleteValue);
603
604
605 /* Get the namespace node for the arg/local */
606
607 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
608 if (ACPI_FAILURE (Status))
609 {
610 return_VOID;
611 }
612
613 /* Get the associated object */
614
615 Object = AcpiNsGetAttachedObject (Node);
616
617 /*
618 * Undefine the Arg or Local by setting its descriptor
619 * pointer to NULL. Locals/Args can contain both
620 * ACPI_OPERAND_OBJECTS and ACPI_NAMESPACE_NODEs
621 */
622 Node->Object = NULL;
623
624 if ((Object) &&
625 (ACPI_GET_DESCRIPTOR_TYPE (Object) == ACPI_DESC_TYPE_OPERAND))
626 {
627 /*
628 * There is a valid object.
629 * Decrement the reference count by one to balance the
630 * increment when the object was stored.
631 */
632 AcpiUtRemoveReference (Object);
633 }
634
635 return_VOID;
636}
637
638
639/*******************************************************************************
640 *
641 * FUNCTION: AcpiDsStoreObjectToLocal
642 *
643 * PARAMETERS: Type - Either ACPI_REFCLASS_LOCAL or
644 * ACPI_REFCLASS_ARG
645 * Index - Which Local or Arg to set
646 * ObjDesc - Value to be stored
647 * WalkState - Current walk state
648 *
649 * RETURN: Status
650 *
651 * DESCRIPTION: Store a value in an Arg or Local. The ObjDesc is installed
652 * as the new value for the Arg or Local and the reference count
653 * for ObjDesc is incremented.
654 *
655 ******************************************************************************/
656
657ACPI_STATUS
658AcpiDsStoreObjectToLocal (
659 UINT8 Type,
660 UINT32 Index,
661 ACPI_OPERAND_OBJECT *ObjDesc,
662 ACPI_WALK_STATE *WalkState)
663{
664 ACPI_STATUS Status;
665 ACPI_NAMESPACE_NODE *Node;
666 ACPI_OPERAND_OBJECT *CurrentObjDesc;
667 ACPI_OPERAND_OBJECT *NewObjDesc;
668
669
670 ACPI_FUNCTION_TRACE (DsStoreObjectToLocal);
671 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Type=%2.2X Index=%d Obj=%p\n",
672 Type, Index, ObjDesc));
673
674 /* Parameter validation */
675
676 if (!ObjDesc)
677 {
678 return_ACPI_STATUS (AE_BAD_PARAMETER);
679 }
680
681 /* Get the namespace node for the arg/local */
682
683 Status = AcpiDsMethodDataGetNode (Type, Index, WalkState, &Node);
684 if (ACPI_FAILURE (Status))
685 {
686 return_ACPI_STATUS (Status);
687 }
688
689 CurrentObjDesc = AcpiNsGetAttachedObject (Node);
690 if (CurrentObjDesc == ObjDesc)
691 {
692 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Obj=%p already installed!\n",
693 ObjDesc));
694 return_ACPI_STATUS (Status);
695 }
696
697 /*
698 * If the reference count on the object is more than one, we must
699 * take a copy of the object before we store. A reference count
700 * of exactly 1 means that the object was just created during the
701 * evaluation of an expression, and we can safely use it since it
702 * is not used anywhere else.
703 */
704 NewObjDesc = ObjDesc;
705 if (ObjDesc->Common.ReferenceCount > 1)
706 {
707 Status = AcpiUtCopyIobjectToIobject (ObjDesc, &NewObjDesc, WalkState);
708 if (ACPI_FAILURE (Status))
709 {
710 return_ACPI_STATUS (Status);
711 }
712 }
713
714 /*
715 * If there is an object already in this slot, we either
716 * have to delete it, or if this is an argument and there
717 * is an object reference stored there, we have to do
718 * an indirect store!
719 */
720 if (CurrentObjDesc)
721 {
722 /*
723 * Check for an indirect store if an argument
724 * contains an object reference (stored as an Node).
725 * We don't allow this automatic dereferencing for
726 * locals, since a store to a local should overwrite
727 * anything there, including an object reference.
728 *
729 * If both Arg0 and Local0 contain RefOf (Local4):
730 *
731 * Store (1, Arg0) - Causes indirect store to local4
732 * Store (1, Local0) - Stores 1 in local0, overwriting
733 * the reference to local4
734 * Store (1, DeRefof (Local0)) - Causes indirect store to local4
735 *
736 * Weird, but true.
737 */
738 if (Type == ACPI_REFCLASS_ARG)
739 {
740 /*
741 * If we have a valid reference object that came from RefOf(),
742 * do the indirect store
743 */
744 if ((ACPI_GET_DESCRIPTOR_TYPE (CurrentObjDesc) == ACPI_DESC_TYPE_OPERAND) &&
745 (CurrentObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
746 (CurrentObjDesc->Reference.Class == ACPI_REFCLASS_REFOF))
747 {
748 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
749 "Arg (%p) is an ObjRef(Node), storing in node %p\n",
750 NewObjDesc, CurrentObjDesc));
751
752 /*
753 * Store this object to the Node (perform the indirect store)
754 * NOTE: No implicit conversion is performed, as per the ACPI
755 * specification rules on storing to Locals/Args.
756 */
757 Status = AcpiExStoreObjectToNode (NewObjDesc,
758 CurrentObjDesc->Reference.Object, WalkState,
759 ACPI_NO_IMPLICIT_CONVERSION);
760
761 /* Remove local reference if we copied the object above */
762
763 if (NewObjDesc != ObjDesc)
764 {
765 AcpiUtRemoveReference (NewObjDesc);
766 }
767 return_ACPI_STATUS (Status);
768 }
769 }
770
771 /* Delete the existing object before storing the new one */
772
773 AcpiDsMethodDataDeleteValue (Type, Index, WalkState);
774 }
775
776 /*
777 * Install the Obj descriptor (*NewObjDesc) into
778 * the descriptor for the Arg or Local.
779 * (increments the object reference count by one)
780 */
781 Status = AcpiDsMethodDataSetValue (Type, Index, NewObjDesc, WalkState);
782
783 /* Remove local reference if we copied the object above */
784
785 if (NewObjDesc != ObjDesc)
786 {
787 AcpiUtRemoveReference (NewObjDesc);
788 }
789
790 return_ACPI_STATUS (Status);
791}
792
793
794#ifdef ACPI_OBSOLETE_FUNCTIONS
795/*******************************************************************************
796 *
797 * FUNCTION: AcpiDsMethodDataGetType
798 *
799 * PARAMETERS: Opcode - Either AML_LOCAL_OP or AML_ARG_OP
800 * Index - Which Local or Arg whose type to get
801 * WalkState - Current walk state object
802 *
803 * RETURN: Data type of current value of the selected Arg or Local
804 *
805 * DESCRIPTION: Get the type of the object stored in the Local or Arg
806 *
807 ******************************************************************************/
808
809ACPI_OBJECT_TYPE
810AcpiDsMethodDataGetType (
811 UINT16 Opcode,
812 UINT32 Index,
813 ACPI_WALK_STATE *WalkState)
814{
815 ACPI_STATUS Status;
816 ACPI_NAMESPACE_NODE *Node;
817 ACPI_OPERAND_OBJECT *Object;
818
819
820 ACPI_FUNCTION_TRACE (DsMethodDataGetType);
821
822
823 /* Get the namespace node for the arg/local */
824
825 Status = AcpiDsMethodDataGetNode (Opcode, Index, WalkState, &Node);
826 if (ACPI_FAILURE (Status))
827 {
828 return_VALUE ((ACPI_TYPE_NOT_FOUND));
829 }
830
831 /* Get the object */
832
833 Object = AcpiNsGetAttachedObject (Node);
834 if (!Object)
835 {
836 /* Uninitialized local/arg, return TYPE_ANY */
837
838 return_VALUE (ACPI_TYPE_ANY);
839 }
840
841 /* Get the object type */
842
843 return_VALUE (Object->Type);
844}
845#endif
846
847