xref: /illumos-gate/usr/src/common/acpica/executer/exresolv.c (revision 528737823843346cf95a4a701612f82089135554)
1 /******************************************************************************
2  *
3  * Module Name: exresolv - AML Interpreter object resolution
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2018, 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  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 #include "acpi.h"
153 #include "accommon.h"
154 #include "amlcode.h"
155 #include "acdispat.h"
156 #include "acinterp.h"
157 #include "acnamesp.h"
158 
159 
160 #define _COMPONENT          ACPI_EXECUTER
161         ACPI_MODULE_NAME    ("exresolv")
162 
163 /* Local prototypes */
164 
165 static ACPI_STATUS
166 AcpiExResolveObjectToValue (
167     ACPI_OPERAND_OBJECT     **StackPtr,
168     ACPI_WALK_STATE         *WalkState);
169 
170 
171 /*******************************************************************************
172  *
173  * FUNCTION:    AcpiExResolveToValue
174  *
175  * PARAMETERS:  **StackPtr          - Points to entry on ObjStack, which can
176  *                                    be either an (ACPI_OPERAND_OBJECT *)
177  *                                    or an ACPI_HANDLE.
178  *              WalkState           - Current method state
179  *
180  * RETURN:      Status
181  *
182  * DESCRIPTION: Convert Reference objects to values
183  *
184  ******************************************************************************/
185 
186 ACPI_STATUS
187 AcpiExResolveToValue (
188     ACPI_OPERAND_OBJECT     **StackPtr,
189     ACPI_WALK_STATE         *WalkState)
190 {
191     ACPI_STATUS             Status;
192 
193 
194     ACPI_FUNCTION_TRACE_PTR (ExResolveToValue, StackPtr);
195 
196 
197     if (!StackPtr || !*StackPtr)
198     {
199         ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
200         return_ACPI_STATUS (AE_AML_NO_OPERAND);
201     }
202 
203     /*
204      * The entity pointed to by the StackPtr can be either
205      * 1) A valid ACPI_OPERAND_OBJECT, or
206      * 2) A ACPI_NAMESPACE_NODE (NamedObj)
207      */
208     if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_OPERAND)
209     {
210         Status = AcpiExResolveObjectToValue (StackPtr, WalkState);
211         if (ACPI_FAILURE (Status))
212         {
213             return_ACPI_STATUS (Status);
214         }
215 
216         if (!*StackPtr)
217         {
218             ACPI_ERROR ((AE_INFO, "Internal - null pointer"));
219             return_ACPI_STATUS (AE_AML_NO_OPERAND);
220         }
221     }
222 
223     /*
224      * Object on the stack may have changed if AcpiExResolveObjectToValue()
225      * was called (i.e., we can't use an _else_ here.)
226      */
227     if (ACPI_GET_DESCRIPTOR_TYPE (*StackPtr) == ACPI_DESC_TYPE_NAMED)
228     {
229         Status = AcpiExResolveNodeToValue (
230             ACPI_CAST_INDIRECT_PTR (ACPI_NAMESPACE_NODE, StackPtr),
231             WalkState);
232         if (ACPI_FAILURE (Status))
233         {
234             return_ACPI_STATUS (Status);
235         }
236     }
237 
238     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Resolved object %p\n", *StackPtr));
239     return_ACPI_STATUS (AE_OK);
240 }
241 
242 
243 /*******************************************************************************
244  *
245  * FUNCTION:    AcpiExResolveObjectToValue
246  *
247  * PARAMETERS:  StackPtr        - Pointer to an internal object
248  *              WalkState       - Current method state
249  *
250  * RETURN:      Status
251  *
252  * DESCRIPTION: Retrieve the value from an internal object. The Reference type
253  *              uses the associated AML opcode to determine the value.
254  *
255  ******************************************************************************/
256 
257 static ACPI_STATUS
258 AcpiExResolveObjectToValue (
259     ACPI_OPERAND_OBJECT     **StackPtr,
260     ACPI_WALK_STATE         *WalkState)
261 {
262     ACPI_STATUS             Status = AE_OK;
263     ACPI_OPERAND_OBJECT     *StackDesc;
264     ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
265     UINT8                   RefType;
266 
267 
268     ACPI_FUNCTION_TRACE (ExResolveObjectToValue);
269 
270 
271     StackDesc = *StackPtr;
272 
273     /* This is an object of type ACPI_OPERAND_OBJECT */
274 
275     switch (StackDesc->Common.Type)
276     {
277     case ACPI_TYPE_LOCAL_REFERENCE:
278 
279         RefType = StackDesc->Reference.Class;
280 
281         switch (RefType)
282         {
283         case ACPI_REFCLASS_LOCAL:
284         case ACPI_REFCLASS_ARG:
285             /*
286              * Get the local from the method's state info
287              * Note: this increments the local's object reference count
288              */
289             Status = AcpiDsMethodDataGetValue (RefType,
290                 StackDesc->Reference.Value, WalkState, &ObjDesc);
291             if (ACPI_FAILURE (Status))
292             {
293                 return_ACPI_STATUS (Status);
294             }
295 
296             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n",
297                 StackDesc->Reference.Value, ObjDesc));
298 
299             /*
300              * Now we can delete the original Reference Object and
301              * replace it with the resolved value
302              */
303             AcpiUtRemoveReference (StackDesc);
304             *StackPtr = ObjDesc;
305             break;
306 
307         case ACPI_REFCLASS_INDEX:
308 
309             switch (StackDesc->Reference.TargetType)
310             {
311             case ACPI_TYPE_BUFFER_FIELD:
312 
313                 /* Just return - do not dereference */
314                 break;
315 
316             case ACPI_TYPE_PACKAGE:
317 
318                 /* If method call or CopyObject - do not dereference */
319 
320                 if ((WalkState->Opcode == AML_INT_METHODCALL_OP) ||
321                     (WalkState->Opcode == AML_COPY_OBJECT_OP))
322                 {
323                     break;
324                 }
325 
326                 /* Otherwise, dereference the PackageIndex to a package element */
327 
328                 ObjDesc = *StackDesc->Reference.Where;
329                 if (ObjDesc)
330                 {
331                     /*
332                      * Valid object descriptor, copy pointer to return value
333                      * (i.e., dereference the package index)
334                      * Delete the ref object, increment the returned object
335                      */
336                     AcpiUtAddReference (ObjDesc);
337                     *StackPtr = ObjDesc;
338                 }
339                 else
340                 {
341                     /*
342                      * A NULL object descriptor means an uninitialized element of
343                      * the package, can't dereference it
344                      */
345                     ACPI_ERROR ((AE_INFO,
346                         "Attempt to dereference an Index to "
347                         "NULL package element Idx=%p",
348                         StackDesc));
349                     Status = AE_AML_UNINITIALIZED_ELEMENT;
350                 }
351                 break;
352 
353             default:
354 
355                 /* Invalid reference object */
356 
357                 ACPI_ERROR ((AE_INFO,
358                     "Unknown TargetType 0x%X in Index/Reference object %p",
359                     StackDesc->Reference.TargetType, StackDesc));
360                 Status = AE_AML_INTERNAL;
361                 break;
362             }
363             break;
364 
365         case ACPI_REFCLASS_REFOF:
366         case ACPI_REFCLASS_DEBUG:
367         case ACPI_REFCLASS_TABLE:
368 
369             /* Just leave the object as-is, do not dereference */
370 
371             break;
372 
373         case ACPI_REFCLASS_NAME:   /* Reference to a named object */
374 
375             /* Dereference the name */
376 
377             if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) ||
378                 (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL))
379             {
380                 /* These node types do not have 'real' subobjects */
381 
382                 *StackPtr = (void *) StackDesc->Reference.Node;
383             }
384             else
385             {
386                 /* Get the object pointed to by the namespace node */
387 
388                 *StackPtr = (StackDesc->Reference.Node)->Object;
389                 AcpiUtAddReference (*StackPtr);
390             }
391 
392             AcpiUtRemoveReference (StackDesc);
393             break;
394 
395         default:
396 
397             ACPI_ERROR ((AE_INFO,
398                 "Unknown Reference type 0x%X in %p",
399                 RefType, StackDesc));
400             Status = AE_AML_INTERNAL;
401             break;
402         }
403         break;
404 
405     case ACPI_TYPE_BUFFER:
406 
407         Status = AcpiDsGetBufferArguments (StackDesc);
408         break;
409 
410     case ACPI_TYPE_PACKAGE:
411 
412         Status = AcpiDsGetPackageArguments (StackDesc);
413         break;
414 
415     case ACPI_TYPE_BUFFER_FIELD:
416     case ACPI_TYPE_LOCAL_REGION_FIELD:
417     case ACPI_TYPE_LOCAL_BANK_FIELD:
418     case ACPI_TYPE_LOCAL_INDEX_FIELD:
419 
420         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
421             "FieldRead SourceDesc=%p Type=%X\n",
422             StackDesc, StackDesc->Common.Type));
423 
424         Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc);
425 
426         /* Remove a reference to the original operand, then override */
427 
428         AcpiUtRemoveReference (*StackPtr);
429         *StackPtr = (void *) ObjDesc;
430         break;
431 
432     default:
433 
434         break;
435     }
436 
437     return_ACPI_STATUS (Status);
438 }
439 
440 
441 /*******************************************************************************
442  *
443  * FUNCTION:    AcpiExResolveMultiple
444  *
445  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
446  *              Operand             - Starting point for resolution
447  *              ReturnType          - Where the object type is returned
448  *              ReturnDesc          - Where the resolved object is returned
449  *
450  * RETURN:      Status
451  *
452  * DESCRIPTION: Return the base object and type. Traverse a reference list if
453  *              necessary to get to the base object.
454  *
455  ******************************************************************************/
456 
457 ACPI_STATUS
458 AcpiExResolveMultiple (
459     ACPI_WALK_STATE         *WalkState,
460     ACPI_OPERAND_OBJECT     *Operand,
461     ACPI_OBJECT_TYPE        *ReturnType,
462     ACPI_OPERAND_OBJECT     **ReturnDesc)
463 {
464     ACPI_OPERAND_OBJECT     *ObjDesc = ACPI_CAST_PTR (void, Operand);
465     ACPI_NAMESPACE_NODE     *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Operand);
466     ACPI_OBJECT_TYPE        Type;
467     ACPI_STATUS             Status;
468 
469 
470     ACPI_FUNCTION_TRACE (AcpiExResolveMultiple);
471 
472 
473     /* Operand can be either a namespace node or an operand descriptor */
474 
475     switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
476     {
477     case ACPI_DESC_TYPE_OPERAND:
478 
479         Type = ObjDesc->Common.Type;
480         break;
481 
482     case ACPI_DESC_TYPE_NAMED:
483 
484         Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
485         ObjDesc = AcpiNsGetAttachedObject (Node);
486 
487         /* If we had an Alias node, use the attached object for type info */
488 
489         if (Type == ACPI_TYPE_LOCAL_ALIAS)
490         {
491             Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
492             ObjDesc = AcpiNsGetAttachedObject (
493                 (ACPI_NAMESPACE_NODE *) ObjDesc);
494         }
495 
496         switch (Type)
497         {
498         case ACPI_TYPE_DEVICE:
499         case ACPI_TYPE_THERMAL:
500 
501             /* These types have no attached subobject */
502             break;
503 
504         default:
505 
506             /* All other types require a subobject */
507 
508             if (!ObjDesc)
509             {
510                 ACPI_ERROR ((AE_INFO,
511                     "[%4.4s] Node is unresolved or uninitialized",
512                     AcpiUtGetNodeName (Node)));
513                 return_ACPI_STATUS (AE_AML_UNINITIALIZED_NODE);
514             }
515             break;
516         }
517         break;
518 
519     default:
520         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
521     }
522 
523     /* If type is anything other than a reference, we are done */
524 
525     if (Type != ACPI_TYPE_LOCAL_REFERENCE)
526     {
527         goto Exit;
528     }
529 
530     /*
531      * For reference objects created via the RefOf, Index, or Load/LoadTable
532      * operators, we need to get to the base object (as per the ACPI
533      * specification of the ObjectType and SizeOf operators). This means
534      * traversing the list of possibly many nested references.
535      */
536     while (ObjDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
537     {
538         switch (ObjDesc->Reference.Class)
539         {
540         case ACPI_REFCLASS_REFOF:
541         case ACPI_REFCLASS_NAME:
542 
543             /* Dereference the reference pointer */
544 
545             if (ObjDesc->Reference.Class == ACPI_REFCLASS_REFOF)
546             {
547                 Node = ObjDesc->Reference.Object;
548             }
549             else /* AML_INT_NAMEPATH_OP */
550             {
551                 Node = ObjDesc->Reference.Node;
552             }
553 
554             /* All "References" point to a NS node */
555 
556             if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
557             {
558                 ACPI_ERROR ((AE_INFO,
559                     "Not a namespace node %p [%s]",
560                     Node, AcpiUtGetDescriptorName (Node)));
561                 return_ACPI_STATUS (AE_AML_INTERNAL);
562             }
563 
564             /* Get the attached object */
565 
566             ObjDesc = AcpiNsGetAttachedObject (Node);
567             if (!ObjDesc)
568             {
569                 /* No object, use the NS node type */
570 
571                 Type = AcpiNsGetType (Node);
572                 goto Exit;
573             }
574 
575             /* Check for circular references */
576 
577             if (ObjDesc == Operand)
578             {
579                 return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
580             }
581             break;
582 
583         case ACPI_REFCLASS_INDEX:
584 
585             /* Get the type of this reference (index into another object) */
586 
587             Type = ObjDesc->Reference.TargetType;
588             if (Type != ACPI_TYPE_PACKAGE)
589             {
590                 goto Exit;
591             }
592 
593             /*
594              * The main object is a package, we want to get the type
595              * of the individual package element that is referenced by
596              * the index.
597              *
598              * This could of course in turn be another reference object.
599              */
600             ObjDesc = *(ObjDesc->Reference.Where);
601             if (!ObjDesc)
602             {
603                 /* NULL package elements are allowed */
604 
605                 Type = 0; /* Uninitialized */
606                 goto Exit;
607             }
608             break;
609 
610         case ACPI_REFCLASS_TABLE:
611 
612             Type = ACPI_TYPE_DDB_HANDLE;
613             goto Exit;
614 
615         case ACPI_REFCLASS_LOCAL:
616         case ACPI_REFCLASS_ARG:
617 
618             if (ReturnDesc)
619             {
620                 Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class,
621                     ObjDesc->Reference.Value, WalkState, &ObjDesc);
622                 if (ACPI_FAILURE (Status))
623                 {
624                     return_ACPI_STATUS (Status);
625                 }
626                 AcpiUtRemoveReference (ObjDesc);
627             }
628             else
629             {
630                 Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class,
631                     ObjDesc->Reference.Value, WalkState, &Node);
632                 if (ACPI_FAILURE (Status))
633                 {
634                     return_ACPI_STATUS (Status);
635                 }
636 
637                 ObjDesc = AcpiNsGetAttachedObject (Node);
638                 if (!ObjDesc)
639                 {
640                     Type = ACPI_TYPE_ANY;
641                     goto Exit;
642                 }
643             }
644             break;
645 
646         case ACPI_REFCLASS_DEBUG:
647 
648             /* The Debug Object is of type "DebugObject" */
649 
650             Type = ACPI_TYPE_DEBUG_OBJECT;
651             goto Exit;
652 
653         default:
654 
655             ACPI_ERROR ((AE_INFO,
656                 "Unknown Reference Class 0x%2.2X",
657                 ObjDesc->Reference.Class));
658             return_ACPI_STATUS (AE_AML_INTERNAL);
659         }
660     }
661 
662     /*
663      * Now we are guaranteed to have an object that has not been created
664      * via the RefOf or Index operators.
665      */
666     Type = ObjDesc->Common.Type;
667 
668 
669 Exit:
670     /* Convert internal types to external types */
671 
672     switch (Type)
673     {
674     case ACPI_TYPE_LOCAL_REGION_FIELD:
675     case ACPI_TYPE_LOCAL_BANK_FIELD:
676     case ACPI_TYPE_LOCAL_INDEX_FIELD:
677 
678         Type = ACPI_TYPE_FIELD_UNIT;
679         break;
680 
681     case ACPI_TYPE_LOCAL_SCOPE:
682 
683         /* Per ACPI Specification, Scope is untyped */
684 
685         Type = ACPI_TYPE_ANY;
686         break;
687 
688     default:
689 
690         /* No change to Type required */
691 
692         break;
693     }
694 
695     *ReturnType = Type;
696     if (ReturnDesc)
697     {
698         *ReturnDesc = ObjDesc;
699     }
700     return_ACPI_STATUS (AE_OK);
701 }
702