Print this page
acpica-unix2-20130823
PANKOVs restructure
   1 
   2 /******************************************************************************
   3  *
   4  * Module Name: exresolv - AML Interpreter object resolution
   5  *
   6  *****************************************************************************/
   7 
   8 /*
   9  * Copyright (C) 2000 - 2011, Intel Corp.
  10  * All rights reserved.
  11  *
  12  * Redistribution and use in source and binary forms, with or without
  13  * modification, are permitted provided that the following conditions
  14  * are met:
  15  * 1. Redistributions of source code must retain the above copyright
  16  *    notice, this list of conditions, and the following disclaimer,
  17  *    without modification.
  18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  19  *    substantially similar to the "NO WARRANTY" disclaimer below
  20  *    ("Disclaimer") and any redistribution must be conditioned upon
  21  *    including a substantially similar Disclaimer requirement for further
  22  *    binary redistribution.
  23  * 3. Neither the names of the above-listed copyright holders nor the names
  24  *    of any contributors may be used to endorse or promote products derived
  25  *    from this software without specific prior written permission.
  26  *
  27  * Alternatively, this software may be distributed under the terms of the
  28  * GNU General Public License ("GPL") version 2 as published by the Free
  29  * Software Foundation.


 148  *              uses the associated AML opcode to determine the value.
 149  *
 150  ******************************************************************************/
 151 
 152 static ACPI_STATUS
 153 AcpiExResolveObjectToValue (
 154     ACPI_OPERAND_OBJECT     **StackPtr,
 155     ACPI_WALK_STATE         *WalkState)
 156 {
 157     ACPI_STATUS             Status = AE_OK;
 158     ACPI_OPERAND_OBJECT     *StackDesc;
 159     ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
 160     UINT8                   RefType;
 161 
 162 
 163     ACPI_FUNCTION_TRACE (ExResolveObjectToValue);
 164 
 165 
 166     StackDesc = *StackPtr;
 167 
 168     /* This is an ACPI_OPERAND_OBJECT  */
 169 
 170     switch (StackDesc->Common.Type)
 171     {
 172     case ACPI_TYPE_LOCAL_REFERENCE:
 173 
 174         RefType = StackDesc->Reference.Class;
 175 
 176         switch (RefType)
 177         {
 178         case ACPI_REFCLASS_LOCAL:
 179         case ACPI_REFCLASS_ARG:
 180 
 181             /*
 182              * Get the local from the method's state info
 183              * Note: this increments the local's object reference count
 184              */
 185             Status = AcpiDsMethodDataGetValue (RefType,
 186                             StackDesc->Reference.Value, WalkState, &ObjDesc);
 187             if (ACPI_FAILURE (Status))
 188             {
 189                 return_ACPI_STATUS (Status);
 190             }
 191 
 192             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n",
 193                 StackDesc->Reference.Value, ObjDesc));
 194 
 195             /*
 196              * Now we can delete the original Reference Object and
 197              * replace it with the resolved value
 198              */
 199             AcpiUtRemoveReference (StackDesc);
 200             *StackPtr = ObjDesc;
 201             break;
 202 
 203 
 204         case ACPI_REFCLASS_INDEX:
 205 
 206             switch (StackDesc->Reference.TargetType)
 207             {
 208             case ACPI_TYPE_BUFFER_FIELD:
 209 
 210                 /* Just return - do not dereference */
 211                 break;
 212 
 213 
 214             case ACPI_TYPE_PACKAGE:
 215 
 216                 /* If method call or CopyObject - do not dereference */
 217 
 218                 if ((WalkState->Opcode == AML_INT_METHODCALL_OP) ||
 219                     (WalkState->Opcode == AML_COPY_OP))
 220                 {
 221                     break;
 222                 }
 223 
 224                 /* Otherwise, dereference the PackageIndex to a package element */
 225 
 226                 ObjDesc = *StackDesc->Reference.Where;
 227                 if (ObjDesc)
 228                 {
 229                     /*
 230                      * Valid object descriptor, copy pointer to return value
 231                      * (i.e., dereference the package index)
 232                      * Delete the ref object, increment the returned object
 233                      */
 234                     AcpiUtRemoveReference (StackDesc);
 235                     AcpiUtAddReference (ObjDesc);
 236                     *StackPtr = ObjDesc;
 237                 }
 238                 else
 239                 {
 240                     /*
 241                      * A NULL object descriptor means an uninitialized element of
 242                      * the package, can't dereference it
 243                      */
 244                     ACPI_ERROR ((AE_INFO,
 245                         "Attempt to dereference an Index to NULL package element Idx=%p",
 246                         StackDesc));
 247                     Status = AE_AML_UNINITIALIZED_ELEMENT;
 248                 }
 249                 break;
 250 
 251 
 252             default:
 253 
 254                 /* Invalid reference object */
 255 
 256                 ACPI_ERROR ((AE_INFO,
 257                     "Unknown TargetType 0x%X in Index/Reference object %p",
 258                     StackDesc->Reference.TargetType, StackDesc));
 259                 Status = AE_AML_INTERNAL;
 260                 break;
 261             }
 262             break;
 263 
 264 
 265         case ACPI_REFCLASS_REFOF:
 266         case ACPI_REFCLASS_DEBUG:
 267         case ACPI_REFCLASS_TABLE:
 268 
 269             /* Just leave the object as-is, do not dereference */
 270 
 271             break;
 272 
 273         case ACPI_REFCLASS_NAME:   /* Reference to a named object */
 274 
 275             /* Dereference the name */
 276 
 277             if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) ||
 278                 (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL))
 279             {
 280                 /* These node types do not have 'real' subobjects */
 281 
 282                 *StackPtr = (void *) StackDesc->Reference.Node;
 283             }
 284             else
 285             {
 286                 /* Get the object pointed to by the namespace node */
 287 
 288                 *StackPtr = (StackDesc->Reference.Node)->Object;
 289                 AcpiUtAddReference (*StackPtr);
 290             }
 291 
 292             AcpiUtRemoveReference (StackDesc);
 293             break;
 294 
 295         default:
 296 
 297             ACPI_ERROR ((AE_INFO,
 298                 "Unknown Reference type 0x%X in %p", RefType, StackDesc));
 299             Status = AE_AML_INTERNAL;
 300             break;
 301         }
 302         break;
 303 
 304 
 305     case ACPI_TYPE_BUFFER:
 306 
 307         Status = AcpiDsGetBufferArguments (StackDesc);
 308         break;
 309 
 310 
 311     case ACPI_TYPE_PACKAGE:
 312 
 313         Status = AcpiDsGetPackageArguments (StackDesc);
 314         break;
 315 
 316 
 317     case ACPI_TYPE_BUFFER_FIELD:
 318     case ACPI_TYPE_LOCAL_REGION_FIELD:
 319     case ACPI_TYPE_LOCAL_BANK_FIELD:
 320     case ACPI_TYPE_LOCAL_INDEX_FIELD:
 321 
 322         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n",
 323             StackDesc, StackDesc->Common.Type));
 324 
 325         Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc);
 326 
 327         /* Remove a reference to the original operand, then override */
 328 
 329         AcpiUtRemoveReference (*StackPtr);
 330         *StackPtr = (void *) ObjDesc;
 331         break;
 332 
 333     default:

 334         break;
 335     }
 336 
 337     return_ACPI_STATUS (Status);
 338 }
 339 
 340 
 341 /*******************************************************************************
 342  *
 343  * FUNCTION:    AcpiExResolveMultiple
 344  *
 345  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
 346  *              Operand             - Starting point for resolution
 347  *              ReturnType          - Where the object type is returned
 348  *              ReturnDesc          - Where the resolved object is returned
 349  *
 350  * RETURN:      Status
 351  *
 352  * DESCRIPTION: Return the base object and type.  Traverse a reference list if
 353  *              necessary to get to the base object.


 358 AcpiExResolveMultiple (
 359     ACPI_WALK_STATE         *WalkState,
 360     ACPI_OPERAND_OBJECT     *Operand,
 361     ACPI_OBJECT_TYPE        *ReturnType,
 362     ACPI_OPERAND_OBJECT     **ReturnDesc)
 363 {
 364     ACPI_OPERAND_OBJECT     *ObjDesc = (void *) Operand;
 365     ACPI_NAMESPACE_NODE     *Node;
 366     ACPI_OBJECT_TYPE        Type;
 367     ACPI_STATUS             Status;
 368 
 369 
 370     ACPI_FUNCTION_TRACE (AcpiExResolveMultiple);
 371 
 372 
 373     /* Operand can be either a namespace node or an operand descriptor */
 374 
 375     switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
 376     {
 377     case ACPI_DESC_TYPE_OPERAND:

 378         Type = ObjDesc->Common.Type;
 379         break;
 380 
 381     case ACPI_DESC_TYPE_NAMED:

 382         Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
 383         ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
 384 
 385         /* If we had an Alias node, use the attached object for type info */
 386 
 387         if (Type == ACPI_TYPE_LOCAL_ALIAS)
 388         {
 389             Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
 390             ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
 391         }
 392         break;
 393 
 394     default:
 395         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 396     }
 397 
 398     /* If type is anything other than a reference, we are done */
 399 
 400     if (Type != ACPI_TYPE_LOCAL_REFERENCE)
 401     {


 438 
 439             /* Get the attached object */
 440 
 441             ObjDesc = AcpiNsGetAttachedObject (Node);
 442             if (!ObjDesc)
 443             {
 444                 /* No object, use the NS node type */
 445 
 446                 Type = AcpiNsGetType (Node);
 447                 goto Exit;
 448             }
 449 
 450             /* Check for circular references */
 451 
 452             if (ObjDesc == Operand)
 453             {
 454                 return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
 455             }
 456             break;
 457 
 458 
 459         case ACPI_REFCLASS_INDEX:
 460 
 461             /* Get the type of this reference (index into another object) */
 462 
 463             Type = ObjDesc->Reference.TargetType;
 464             if (Type != ACPI_TYPE_PACKAGE)
 465             {
 466                 goto Exit;
 467             }
 468 
 469             /*
 470              * The main object is a package, we want to get the type
 471              * of the individual package element that is referenced by
 472              * the index.
 473              *
 474              * This could of course in turn be another reference object.
 475              */
 476             ObjDesc = *(ObjDesc->Reference.Where);
 477             if (!ObjDesc)
 478             {
 479                 /* NULL package elements are allowed */
 480 
 481                 Type = 0; /* Uninitialized */
 482                 goto Exit;
 483             }
 484             break;
 485 
 486 
 487         case ACPI_REFCLASS_TABLE:
 488 
 489             Type = ACPI_TYPE_DDB_HANDLE;
 490             goto Exit;
 491 
 492 
 493         case ACPI_REFCLASS_LOCAL:
 494         case ACPI_REFCLASS_ARG:
 495 
 496             if (ReturnDesc)
 497             {
 498                 Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class,
 499                             ObjDesc->Reference.Value, WalkState, &ObjDesc);
 500                 if (ACPI_FAILURE (Status))
 501                 {
 502                     return_ACPI_STATUS (Status);
 503                 }
 504                 AcpiUtRemoveReference (ObjDesc);
 505             }
 506             else
 507             {
 508                 Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class,
 509                             ObjDesc->Reference.Value, WalkState, &Node);
 510                 if (ACPI_FAILURE (Status))
 511                 {
 512                     return_ACPI_STATUS (Status);
 513                 }
 514 
 515                 ObjDesc = AcpiNsGetAttachedObject (Node);
 516                 if (!ObjDesc)
 517                 {
 518                     Type = ACPI_TYPE_ANY;
 519                     goto Exit;
 520                 }
 521             }
 522             break;
 523 
 524 
 525         case ACPI_REFCLASS_DEBUG:
 526 
 527             /* The Debug Object is of type "DebugObject" */
 528 
 529             Type = ACPI_TYPE_DEBUG_OBJECT;
 530             goto Exit;
 531 
 532 
 533         default:
 534 
 535             ACPI_ERROR ((AE_INFO,
 536                 "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class));
 537             return_ACPI_STATUS (AE_AML_INTERNAL);
 538         }
 539     }
 540 
 541     /*
 542      * Now we are guaranteed to have an object that has not been created
 543      * via the RefOf or Index operators.
 544      */
 545     Type = ObjDesc->Common.Type;
 546 
 547 
 548 Exit:
 549     /* Convert internal types to external types */
 550 
 551     switch (Type)
 552     {
 553     case ACPI_TYPE_LOCAL_REGION_FIELD:
 554     case ACPI_TYPE_LOCAL_BANK_FIELD:
 555     case ACPI_TYPE_LOCAL_INDEX_FIELD:
 556 
 557         Type = ACPI_TYPE_FIELD_UNIT;
 558         break;
 559 
 560     case ACPI_TYPE_LOCAL_SCOPE:
 561 
 562         /* Per ACPI Specification, Scope is untyped */
 563 
 564         Type = ACPI_TYPE_ANY;
 565         break;
 566 
 567     default:

 568         /* No change to Type required */

 569         break;
 570     }
 571 
 572     *ReturnType = Type;
 573     if (ReturnDesc)
 574     {
 575         *ReturnDesc = ObjDesc;
 576     }
 577     return_ACPI_STATUS (AE_OK);
 578 }
 579 
 580 

   1 /******************************************************************************
   2  *
   3  * Module Name: exresolv - AML Interpreter object resolution
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2013, 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.


 147  *              uses the associated AML opcode to determine the value.
 148  *
 149  ******************************************************************************/
 150 
 151 static ACPI_STATUS
 152 AcpiExResolveObjectToValue (
 153     ACPI_OPERAND_OBJECT     **StackPtr,
 154     ACPI_WALK_STATE         *WalkState)
 155 {
 156     ACPI_STATUS             Status = AE_OK;
 157     ACPI_OPERAND_OBJECT     *StackDesc;
 158     ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
 159     UINT8                   RefType;
 160 
 161 
 162     ACPI_FUNCTION_TRACE (ExResolveObjectToValue);
 163 
 164 
 165     StackDesc = *StackPtr;
 166 
 167     /* This is an object of type ACPI_OPERAND_OBJECT */
 168 
 169     switch (StackDesc->Common.Type)
 170     {
 171     case ACPI_TYPE_LOCAL_REFERENCE:
 172 
 173         RefType = StackDesc->Reference.Class;
 174 
 175         switch (RefType)
 176         {
 177         case ACPI_REFCLASS_LOCAL:
 178         case ACPI_REFCLASS_ARG:

 179             /*
 180              * Get the local from the method's state info
 181              * Note: this increments the local's object reference count
 182              */
 183             Status = AcpiDsMethodDataGetValue (RefType,
 184                             StackDesc->Reference.Value, WalkState, &ObjDesc);
 185             if (ACPI_FAILURE (Status))
 186             {
 187                 return_ACPI_STATUS (Status);
 188             }
 189 
 190             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[Arg/Local %X] ValueObj is %p\n",
 191                 StackDesc->Reference.Value, ObjDesc));
 192 
 193             /*
 194              * Now we can delete the original Reference Object and
 195              * replace it with the resolved value
 196              */
 197             AcpiUtRemoveReference (StackDesc);
 198             *StackPtr = ObjDesc;
 199             break;
 200 

 201         case ACPI_REFCLASS_INDEX:
 202 
 203             switch (StackDesc->Reference.TargetType)
 204             {
 205             case ACPI_TYPE_BUFFER_FIELD:
 206 
 207                 /* Just return - do not dereference */
 208                 break;
 209 

 210             case ACPI_TYPE_PACKAGE:
 211 
 212                 /* If method call or CopyObject - do not dereference */
 213 
 214                 if ((WalkState->Opcode == AML_INT_METHODCALL_OP) ||
 215                     (WalkState->Opcode == AML_COPY_OP))
 216                 {
 217                     break;
 218                 }
 219 
 220                 /* Otherwise, dereference the PackageIndex to a package element */
 221 
 222                 ObjDesc = *StackDesc->Reference.Where;
 223                 if (ObjDesc)
 224                 {
 225                     /*
 226                      * Valid object descriptor, copy pointer to return value
 227                      * (i.e., dereference the package index)
 228                      * Delete the ref object, increment the returned object
 229                      */
 230                     AcpiUtRemoveReference (StackDesc);
 231                     AcpiUtAddReference (ObjDesc);
 232                     *StackPtr = ObjDesc;
 233                 }
 234                 else
 235                 {
 236                     /*
 237                      * A NULL object descriptor means an uninitialized element of
 238                      * the package, can't dereference it
 239                      */
 240                     ACPI_ERROR ((AE_INFO,
 241                         "Attempt to dereference an Index to NULL package element Idx=%p",
 242                         StackDesc));
 243                     Status = AE_AML_UNINITIALIZED_ELEMENT;
 244                 }
 245                 break;
 246 

 247             default:
 248 
 249                 /* Invalid reference object */
 250 
 251                 ACPI_ERROR ((AE_INFO,
 252                     "Unknown TargetType 0x%X in Index/Reference object %p",
 253                     StackDesc->Reference.TargetType, StackDesc));
 254                 Status = AE_AML_INTERNAL;
 255                 break;
 256             }
 257             break;
 258 

 259         case ACPI_REFCLASS_REFOF:
 260         case ACPI_REFCLASS_DEBUG:
 261         case ACPI_REFCLASS_TABLE:
 262 
 263             /* Just leave the object as-is, do not dereference */
 264 
 265             break;
 266 
 267         case ACPI_REFCLASS_NAME:   /* Reference to a named object */
 268 
 269             /* Dereference the name */
 270 
 271             if ((StackDesc->Reference.Node->Type == ACPI_TYPE_DEVICE) ||
 272                 (StackDesc->Reference.Node->Type == ACPI_TYPE_THERMAL))
 273             {
 274                 /* These node types do not have 'real' subobjects */
 275 
 276                 *StackPtr = (void *) StackDesc->Reference.Node;
 277             }
 278             else
 279             {
 280                 /* Get the object pointed to by the namespace node */
 281 
 282                 *StackPtr = (StackDesc->Reference.Node)->Object;
 283                 AcpiUtAddReference (*StackPtr);
 284             }
 285 
 286             AcpiUtRemoveReference (StackDesc);
 287             break;
 288 
 289         default:
 290 
 291             ACPI_ERROR ((AE_INFO,
 292                 "Unknown Reference type 0x%X in %p", RefType, StackDesc));
 293             Status = AE_AML_INTERNAL;
 294             break;
 295         }
 296         break;
 297 

 298     case ACPI_TYPE_BUFFER:
 299 
 300         Status = AcpiDsGetBufferArguments (StackDesc);
 301         break;
 302 

 303     case ACPI_TYPE_PACKAGE:
 304 
 305         Status = AcpiDsGetPackageArguments (StackDesc);
 306         break;
 307 

 308     case ACPI_TYPE_BUFFER_FIELD:
 309     case ACPI_TYPE_LOCAL_REGION_FIELD:
 310     case ACPI_TYPE_LOCAL_BANK_FIELD:
 311     case ACPI_TYPE_LOCAL_INDEX_FIELD:
 312 
 313         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "FieldRead SourceDesc=%p Type=%X\n",
 314             StackDesc, StackDesc->Common.Type));
 315 
 316         Status = AcpiExReadDataFromField (WalkState, StackDesc, &ObjDesc);
 317 
 318         /* Remove a reference to the original operand, then override */
 319 
 320         AcpiUtRemoveReference (*StackPtr);
 321         *StackPtr = (void *) ObjDesc;
 322         break;
 323 
 324     default:
 325 
 326         break;
 327     }
 328 
 329     return_ACPI_STATUS (Status);
 330 }
 331 
 332 
 333 /*******************************************************************************
 334  *
 335  * FUNCTION:    AcpiExResolveMultiple
 336  *
 337  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
 338  *              Operand             - Starting point for resolution
 339  *              ReturnType          - Where the object type is returned
 340  *              ReturnDesc          - Where the resolved object is returned
 341  *
 342  * RETURN:      Status
 343  *
 344  * DESCRIPTION: Return the base object and type. Traverse a reference list if
 345  *              necessary to get to the base object.


 350 AcpiExResolveMultiple (
 351     ACPI_WALK_STATE         *WalkState,
 352     ACPI_OPERAND_OBJECT     *Operand,
 353     ACPI_OBJECT_TYPE        *ReturnType,
 354     ACPI_OPERAND_OBJECT     **ReturnDesc)
 355 {
 356     ACPI_OPERAND_OBJECT     *ObjDesc = (void *) Operand;
 357     ACPI_NAMESPACE_NODE     *Node;
 358     ACPI_OBJECT_TYPE        Type;
 359     ACPI_STATUS             Status;
 360 
 361 
 362     ACPI_FUNCTION_TRACE (AcpiExResolveMultiple);
 363 
 364 
 365     /* Operand can be either a namespace node or an operand descriptor */
 366 
 367     switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
 368     {
 369     case ACPI_DESC_TYPE_OPERAND:
 370 
 371         Type = ObjDesc->Common.Type;
 372         break;
 373 
 374     case ACPI_DESC_TYPE_NAMED:
 375 
 376         Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
 377         ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
 378 
 379         /* If we had an Alias node, use the attached object for type info */
 380 
 381         if (Type == ACPI_TYPE_LOCAL_ALIAS)
 382         {
 383             Type = ((ACPI_NAMESPACE_NODE *) ObjDesc)->Type;
 384             ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjDesc);
 385         }
 386         break;
 387 
 388     default:
 389         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 390     }
 391 
 392     /* If type is anything other than a reference, we are done */
 393 
 394     if (Type != ACPI_TYPE_LOCAL_REFERENCE)
 395     {


 432 
 433             /* Get the attached object */
 434 
 435             ObjDesc = AcpiNsGetAttachedObject (Node);
 436             if (!ObjDesc)
 437             {
 438                 /* No object, use the NS node type */
 439 
 440                 Type = AcpiNsGetType (Node);
 441                 goto Exit;
 442             }
 443 
 444             /* Check for circular references */
 445 
 446             if (ObjDesc == Operand)
 447             {
 448                 return_ACPI_STATUS (AE_AML_CIRCULAR_REFERENCE);
 449             }
 450             break;
 451 

 452         case ACPI_REFCLASS_INDEX:
 453 
 454             /* Get the type of this reference (index into another object) */
 455 
 456             Type = ObjDesc->Reference.TargetType;
 457             if (Type != ACPI_TYPE_PACKAGE)
 458             {
 459                 goto Exit;
 460             }
 461 
 462             /*
 463              * The main object is a package, we want to get the type
 464              * of the individual package element that is referenced by
 465              * the index.
 466              *
 467              * This could of course in turn be another reference object.
 468              */
 469             ObjDesc = *(ObjDesc->Reference.Where);
 470             if (!ObjDesc)
 471             {
 472                 /* NULL package elements are allowed */
 473 
 474                 Type = 0; /* Uninitialized */
 475                 goto Exit;
 476             }
 477             break;
 478 

 479         case ACPI_REFCLASS_TABLE:
 480 
 481             Type = ACPI_TYPE_DDB_HANDLE;
 482             goto Exit;
 483 

 484         case ACPI_REFCLASS_LOCAL:
 485         case ACPI_REFCLASS_ARG:
 486 
 487             if (ReturnDesc)
 488             {
 489                 Status = AcpiDsMethodDataGetValue (ObjDesc->Reference.Class,
 490                             ObjDesc->Reference.Value, WalkState, &ObjDesc);
 491                 if (ACPI_FAILURE (Status))
 492                 {
 493                     return_ACPI_STATUS (Status);
 494                 }
 495                 AcpiUtRemoveReference (ObjDesc);
 496             }
 497             else
 498             {
 499                 Status = AcpiDsMethodDataGetNode (ObjDesc->Reference.Class,
 500                             ObjDesc->Reference.Value, WalkState, &Node);
 501                 if (ACPI_FAILURE (Status))
 502                 {
 503                     return_ACPI_STATUS (Status);
 504                 }
 505 
 506                 ObjDesc = AcpiNsGetAttachedObject (Node);
 507                 if (!ObjDesc)
 508                 {
 509                     Type = ACPI_TYPE_ANY;
 510                     goto Exit;
 511                 }
 512             }
 513             break;
 514 

 515         case ACPI_REFCLASS_DEBUG:
 516 
 517             /* The Debug Object is of type "DebugObject" */
 518 
 519             Type = ACPI_TYPE_DEBUG_OBJECT;
 520             goto Exit;
 521 

 522         default:
 523 
 524             ACPI_ERROR ((AE_INFO,
 525                 "Unknown Reference Class 0x%2.2X", ObjDesc->Reference.Class));
 526             return_ACPI_STATUS (AE_AML_INTERNAL);
 527         }
 528     }
 529 
 530     /*
 531      * Now we are guaranteed to have an object that has not been created
 532      * via the RefOf or Index operators.
 533      */
 534     Type = ObjDesc->Common.Type;
 535 
 536 
 537 Exit:
 538     /* Convert internal types to external types */
 539 
 540     switch (Type)
 541     {
 542     case ACPI_TYPE_LOCAL_REGION_FIELD:
 543     case ACPI_TYPE_LOCAL_BANK_FIELD:
 544     case ACPI_TYPE_LOCAL_INDEX_FIELD:
 545 
 546         Type = ACPI_TYPE_FIELD_UNIT;
 547         break;
 548 
 549     case ACPI_TYPE_LOCAL_SCOPE:
 550 
 551         /* Per ACPI Specification, Scope is untyped */
 552 
 553         Type = ACPI_TYPE_ANY;
 554         break;
 555 
 556     default:
 557 
 558         /* No change to Type required */
 559 
 560         break;
 561     }
 562 
 563     *ReturnType = Type;
 564     if (ReturnDesc)
 565     {
 566         *ReturnDesc = ObjDesc;
 567     }
 568     return_ACPI_STATUS (AE_OK);
 569 }