Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
   1 
   2 /******************************************************************************
   3  *
   4  * Module Name: exoparg1 - AML execution - opcodes with 1 argument
   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.


 164 AcpiExOpcode_1A_0T_0R (
 165     ACPI_WALK_STATE         *WalkState)
 166 {
 167     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
 168     ACPI_STATUS             Status = AE_OK;
 169 
 170 
 171     ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
 172         AcpiPsGetOpcodeName (WalkState->Opcode));
 173 
 174 
 175     /* Examine the AML opcode */
 176 
 177     switch (WalkState->Opcode)
 178     {
 179     case AML_RELEASE_OP:    /*  Release (MutexObject) */
 180 
 181         Status = AcpiExReleaseMutex (Operand[0], WalkState);
 182         break;
 183 
 184 
 185     case AML_RESET_OP:      /*  Reset (EventObject) */
 186 
 187         Status = AcpiExSystemResetEvent (Operand[0]);
 188         break;
 189 
 190 
 191     case AML_SIGNAL_OP:     /*  Signal (EventObject) */
 192 
 193         Status = AcpiExSystemSignalEvent (Operand[0]);
 194         break;
 195 
 196 
 197     case AML_SLEEP_OP:      /*  Sleep (MsecTime) */
 198 
 199         Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
 200         break;
 201 
 202 
 203     case AML_STALL_OP:      /*  Stall (UsecTime) */
 204 
 205         Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
 206         break;
 207 
 208 
 209     case AML_UNLOAD_OP:     /*  Unload (Handle) */
 210 
 211         Status = AcpiExUnloadTable (Operand[0]);
 212         break;
 213 
 214 
 215     default:                /*  Unknown opcode  */
 216 
 217         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
 218             WalkState->Opcode));
 219         Status = AE_AML_BAD_OPCODE;
 220         break;
 221     }
 222 
 223     return_ACPI_STATUS (Status);
 224 }
 225 
 226 
 227 /*******************************************************************************
 228  *
 229  * FUNCTION:    AcpiExOpcode_1A_1T_0R
 230  *
 231  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
 232  *
 233  * RETURN:      Status
 234  *


 314     case AML_FROM_BCD_OP:
 315     case AML_TO_BCD_OP:
 316     case AML_COND_REF_OF_OP:
 317 
 318         /* Create a return object of type Integer for these opcodes */
 319 
 320         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
 321         if (!ReturnDesc)
 322         {
 323             Status = AE_NO_MEMORY;
 324             goto Cleanup;
 325         }
 326 
 327         switch (WalkState->Opcode)
 328         {
 329         case AML_BIT_NOT_OP:            /* Not (Operand, Result)  */
 330 
 331             ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
 332             break;
 333 
 334 
 335         case AML_FIND_SET_LEFT_BIT_OP:  /* FindSetLeftBit (Operand, Result) */
 336 
 337             ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
 338 
 339             /*
 340              * Acpi specification describes Integer type as a little
 341              * endian unsigned value, so this boundary condition is valid.
 342              */
 343             for (Temp32 = 0; ReturnDesc->Integer.Value &&
 344                              Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
 345             {
 346                 ReturnDesc->Integer.Value >>= 1;
 347             }
 348 
 349             ReturnDesc->Integer.Value = Temp32;
 350             break;
 351 
 352 
 353         case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
 354 
 355             ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
 356 
 357             /*
 358              * The Acpi specification describes Integer type as a little
 359              * endian unsigned value, so this boundary condition is valid.
 360              */
 361             for (Temp32 = 0; ReturnDesc->Integer.Value &&
 362                              Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
 363             {
 364                 ReturnDesc->Integer.Value <<= 1;
 365             }
 366 
 367             /* Since the bit position is one-based, subtract from 33 (65) */
 368 
 369             ReturnDesc->Integer.Value =
 370                 Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
 371             break;
 372 
 373 
 374         case AML_FROM_BCD_OP:           /* FromBcd (BCDValue, Result)  */
 375 
 376             /*
 377              * The 64-bit ACPI integer can hold 16 4-bit BCD characters
 378              * (if table is 32-bit, integer can hold 8 BCD characters)
 379              * Convert each 4-bit BCD value
 380              */
 381             PowerOfTen = 1;
 382             ReturnDesc->Integer.Value = 0;
 383             Digit = Operand[0]->Integer.Value;
 384 
 385             /* Convert each BCD digit (each is one nybble wide) */
 386 
 387             for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
 388             {
 389                 /* Get the least significant 4-bit BCD digit */
 390 
 391                 Temp32 = ((UINT32) Digit) & 0xF;
 392 
 393                 /* Check the range of the digit */
 394 
 395                 if (Temp32 > 9)


 400 
 401                     Status = AE_AML_NUMERIC_OVERFLOW;
 402                     goto Cleanup;
 403                 }
 404 
 405                 /* Sum the digit into the result with the current power of 10 */
 406 
 407                 ReturnDesc->Integer.Value +=
 408                     (((UINT64) Temp32) * PowerOfTen);
 409 
 410                 /* Shift to next BCD digit */
 411 
 412                 Digit >>= 4;
 413 
 414                 /* Next power of 10 */
 415 
 416                 PowerOfTen *= 10;
 417             }
 418             break;
 419 
 420 
 421         case AML_TO_BCD_OP:             /* ToBcd (Operand, Result)  */
 422 
 423             ReturnDesc->Integer.Value = 0;
 424             Digit = Operand[0]->Integer.Value;
 425 
 426             /* Each BCD digit is one nybble wide */
 427 
 428             for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
 429             {
 430                 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
 431 
 432                 /*
 433                  * Insert the BCD digit that resides in the
 434                  * remainder from above
 435                  */
 436                 ReturnDesc->Integer.Value |=
 437                     (((UINT64) Temp32) << ACPI_MUL_4 (i));
 438             }
 439 
 440             /* Overflow if there is any data left in Digit */
 441 
 442             if (Digit > 0)
 443             {
 444                 ACPI_ERROR ((AE_INFO,
 445                     "Integer too large to convert to BCD: 0x%8.8X%8.8X",
 446                     ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
 447                 Status = AE_AML_NUMERIC_OVERFLOW;
 448                 goto Cleanup;
 449             }
 450             break;
 451 
 452 
 453         case AML_COND_REF_OF_OP:        /* CondRefOf (SourceObject, Result)  */
 454 
 455             /*
 456              * This op is a little strange because the internal return value is
 457              * different than the return value stored in the result descriptor
 458              * (There are really two return values)
 459              */
 460             if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
 461             {
 462                 /*
 463                  * This means that the object does not exist in the namespace,
 464                  * return FALSE
 465                  */
 466                 ReturnDesc->Integer.Value = 0;
 467                 goto Cleanup;
 468             }
 469 
 470             /* Get the object reference, store it, and remove our reference */
 471 
 472             Status = AcpiExGetObjectReference (Operand[0],
 473                         &ReturnDesc2, WalkState);
 474             if (ACPI_FAILURE (Status))
 475             {
 476                 goto Cleanup;
 477             }
 478 
 479             Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
 480             AcpiUtRemoveReference (ReturnDesc2);
 481 
 482             /* The object exists in the namespace, return TRUE */
 483 
 484             ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
 485             goto Cleanup;
 486 
 487 
 488         default:

 489             /* No other opcodes get here */

 490             break;
 491         }
 492         break;
 493 
 494 
 495     case AML_STORE_OP:              /* Store (Source, Target) */
 496 
 497         /*
 498          * A store operand is typically a number, string, buffer or lvalue
 499          * Be careful about deleting the source object,
 500          * since the object itself may have been stored.
 501          */
 502         Status = AcpiExStore (Operand[0], Operand[1], WalkState);
 503         if (ACPI_FAILURE (Status))
 504         {
 505             return_ACPI_STATUS (Status);
 506         }
 507 
 508         /* It is possible that the Store already produced a return object */
 509 
 510         if (!WalkState->ResultObj)
 511         {
 512             /*
 513              * Normally, we would remove a reference on the Operand[0]
 514              * parameter; But since it is being used as the internal return
 515              * object (meaning we would normally increment it), the two
 516              * cancel out, and we simply don't do anything.
 517              */
 518             WalkState->ResultObj = Operand[0];
 519             WalkState->Operands[0] = NULL;  /* Prevent deletion */
 520         }
 521         return_ACPI_STATUS (Status);
 522 
 523 
 524     /*
 525      * ACPI 2.0 Opcodes
 526      */
 527     case AML_COPY_OP:               /* Copy (Source, Target) */
 528 
 529         Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc,
 530                     WalkState);
 531         break;
 532 
 533 
 534     case AML_TO_DECSTRING_OP:       /* ToDecimalString (Data, Result) */
 535 
 536         Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
 537                     ACPI_EXPLICIT_CONVERT_DECIMAL);
 538         if (ReturnDesc == Operand[0])
 539         {
 540             /* No conversion performed, add ref to handle return value */
 541             AcpiUtAddReference (ReturnDesc);
 542         }
 543         break;
 544 
 545 
 546     case AML_TO_HEXSTRING_OP:       /* ToHexString (Data, Result) */
 547 
 548         Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
 549                     ACPI_EXPLICIT_CONVERT_HEX);
 550         if (ReturnDesc == Operand[0])
 551         {
 552             /* No conversion performed, add ref to handle return value */
 553             AcpiUtAddReference (ReturnDesc);
 554         }
 555         break;
 556 
 557 
 558     case AML_TO_BUFFER_OP:          /* ToBuffer (Data, Result) */
 559 
 560         Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
 561         if (ReturnDesc == Operand[0])
 562         {
 563             /* No conversion performed, add ref to handle return value */
 564             AcpiUtAddReference (ReturnDesc);
 565         }
 566         break;
 567 
 568 
 569     case AML_TO_INTEGER_OP:         /* ToInteger (Data, Result) */
 570 
 571         Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc,
 572                     ACPI_ANY_BASE);
 573         if (ReturnDesc == Operand[0])
 574         {
 575             /* No conversion performed, add ref to handle return value */
 576             AcpiUtAddReference (ReturnDesc);
 577         }
 578         break;
 579 
 580 
 581     case AML_SHIFT_LEFT_BIT_OP:     /* ShiftLeftBit (Source, BitNum)  */
 582     case AML_SHIFT_RIGHT_BIT_OP:    /* ShiftRightBit (Source, BitNum) */
 583 
 584         /* These are two obsolete opcodes */
 585 
 586         ACPI_ERROR ((AE_INFO,
 587             "%s is obsolete and not implemented",
 588             AcpiPsGetOpcodeName (WalkState->Opcode)));
 589         Status = AE_SUPPORT;
 590         goto Cleanup;
 591 
 592 
 593     default:                        /* Unknown opcode */
 594 
 595         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
 596             WalkState->Opcode));
 597         Status = AE_AML_BAD_OPCODE;
 598         goto Cleanup;
 599     }
 600 
 601     if (ACPI_SUCCESS (Status))
 602     {
 603         /* Store the return value computed above into the target object */
 604 
 605         Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
 606     }
 607 
 608 
 609 Cleanup:
 610 
 611     /* Delete return object on error */
 612 


 660     {
 661     case AML_LNOT_OP:               /* LNot (Operand) */
 662 
 663         ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
 664         if (!ReturnDesc)
 665         {
 666             Status = AE_NO_MEMORY;
 667             goto Cleanup;
 668         }
 669 
 670         /*
 671          * Set result to ONES (TRUE) if Value == 0.  Note:
 672          * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
 673          */
 674         if (!Operand[0]->Integer.Value)
 675         {
 676             ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
 677         }
 678         break;
 679 
 680 
 681     case AML_DECREMENT_OP:          /* Decrement (Operand)  */
 682     case AML_INCREMENT_OP:          /* Increment (Operand)  */
 683 
 684         /*
 685          * Create a new integer.  Can't just get the base integer and
 686          * increment it because it may be an Arg or Field.
 687          */
 688         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
 689         if (!ReturnDesc)
 690         {
 691             Status = AE_NO_MEMORY;
 692             goto Cleanup;
 693         }
 694 
 695         /*
 696          * Since we are expecting a Reference operand, it can be either a
 697          * NS Node or an internal object.
 698          */
 699         TempDesc = Operand[0];
 700         if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
 701         {
 702             /* Internal reference object - prevent deletion */
 703 


 728         if (WalkState->Opcode == AML_INCREMENT_OP)
 729         {
 730             ReturnDesc->Integer.Value = TempDesc->Integer.Value +1;
 731         }
 732         else
 733         {
 734             ReturnDesc->Integer.Value = TempDesc->Integer.Value -1;
 735         }
 736 
 737         /* Finished with this Integer object */
 738 
 739         AcpiUtRemoveReference (TempDesc);
 740 
 741         /*
 742          * Store the result back (indirectly) through the original
 743          * Reference object
 744          */
 745         Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
 746         break;
 747 
 748 
 749     case AML_TYPE_OP:               /* ObjectType (SourceObject) */
 750 
 751         /*
 752          * Note: The operand is not resolved at this point because we want to
 753          * get the associated object, not its value.  For example, we don't
 754          * want to resolve a FieldUnit to its value, we want the actual
 755          * FieldUnit object.
 756          */
 757 
 758         /* Get the type of the base object */
 759 
 760         Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
 761         if (ACPI_FAILURE (Status))
 762         {
 763             goto Cleanup;
 764         }
 765 
 766         /* Allocate a descriptor to hold the type. */
 767 
 768         ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type);
 769         if (!ReturnDesc)
 770         {
 771             Status = AE_NO_MEMORY;
 772             goto Cleanup;
 773         }
 774         break;
 775 
 776 
 777     case AML_SIZE_OF_OP:            /* SizeOf (SourceObject)  */
 778 
 779         /*
 780          * Note: The operand is not resolved at this point because we want to
 781          * get the associated object, not its value.
 782          */
 783 
 784         /* Get the base object */
 785 
 786         Status = AcpiExResolveMultiple (WalkState,
 787                     Operand[0], &Type, &TempDesc);
 788         if (ACPI_FAILURE (Status))
 789         {
 790             goto Cleanup;
 791         }
 792 
 793         /*
 794          * The type of the base object must be integer, buffer, string, or
 795          * package.  All others are not supported.
 796          *
 797          * NOTE: Integer is not specifically supported by the ACPI spec,
 798          * but is supported implicitly via implicit operand conversion.
 799          * rather than bother with conversion, we just use the byte width
 800          * global (4 or 8 bytes).
 801          */
 802         switch (Type)
 803         {
 804         case ACPI_TYPE_INTEGER:

 805             Value = AcpiGbl_IntegerByteWidth;
 806             break;
 807 
 808         case ACPI_TYPE_STRING:

 809             Value = TempDesc->String.Length;
 810             break;
 811 
 812         case ACPI_TYPE_BUFFER:
 813 
 814             /* Buffer arguments may not be evaluated at this point */
 815 
 816             Status = AcpiDsGetBufferArguments (TempDesc);
 817             Value = TempDesc->Buffer.Length;
 818             break;
 819 
 820         case ACPI_TYPE_PACKAGE:
 821 
 822             /* Package arguments may not be evaluated at this point */
 823 
 824             Status = AcpiDsGetPackageArguments (TempDesc);
 825             Value = TempDesc->Package.Count;
 826             break;
 827 
 828         default:

 829             ACPI_ERROR ((AE_INFO,
 830                 "Operand must be Buffer/Integer/String/Package - found type %s",
 831                 AcpiUtGetTypeName (Type)));
 832             Status = AE_AML_OPERAND_TYPE;
 833             goto Cleanup;
 834         }
 835 
 836         if (ACPI_FAILURE (Status))
 837         {
 838             goto Cleanup;
 839         }
 840 
 841         /*
 842          * Now that we have the size of the object, create a result
 843          * object to hold the value
 844          */
 845         ReturnDesc = AcpiUtCreateIntegerObject (Value);
 846         if (!ReturnDesc)
 847         {
 848             Status = AE_NO_MEMORY;


 916                     Operand[0] = TempDesc;
 917                     break;
 918 
 919                 case ACPI_REFCLASS_REFOF:
 920 
 921                     /* Get the object to which the reference refers */
 922 
 923                     TempDesc = Operand[0]->Reference.Object;
 924                     AcpiUtRemoveReference (Operand[0]);
 925                     Operand[0] = TempDesc;
 926                     break;
 927 
 928                 default:
 929 
 930                     /* Must be an Index op - handled below */
 931                     break;
 932                 }
 933                 break;
 934 
 935             case ACPI_TYPE_STRING:

 936                 break;
 937 
 938             default:

 939                 Status = AE_AML_OPERAND_TYPE;
 940                 goto Cleanup;
 941             }
 942         }
 943 
 944         if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
 945         {
 946             if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
 947             {
 948                 /*
 949                  * This is a DerefOf (String). The string is a reference
 950                  * to a named ACPI object.
 951                  *
 952                  * 1) Find the owning Node
 953                  * 2) Dereference the node to an actual object. Could be a
 954                  *    Field, so we need to resolve the node to a value.
 955                  */
 956                 Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node,
 957                             Operand[0]->String.Pointer,
 958                             ACPI_NS_SEARCH_PARENT,


 977         {
 978             /*
 979              * This is a DerefOf (ObjectReference)
 980              * Get the actual object from the Node (This is the dereference).
 981              * This case may only happen when a LocalX or ArgX is
 982              * dereferenced above.
 983              */
 984             ReturnDesc = AcpiNsGetAttachedObject (
 985                             (ACPI_NAMESPACE_NODE *) Operand[0]);
 986             AcpiUtAddReference (ReturnDesc);
 987         }
 988         else
 989         {
 990             /*
 991              * This must be a reference object produced by either the
 992              * Index() or RefOf() operator
 993              */
 994             switch (Operand[0]->Reference.Class)
 995             {
 996             case ACPI_REFCLASS_INDEX:
 997 
 998                 /*
 999                  * The target type for the Index operator must be
1000                  * either a Buffer or a Package
1001                  */
1002                 switch (Operand[0]->Reference.TargetType)
1003                 {
1004                 case ACPI_TYPE_BUFFER_FIELD:
1005 
1006                     TempDesc = Operand[0]->Reference.Object;
1007 
1008                     /*
1009                      * Create a new object that contains one element of the
1010                      * buffer -- the element pointed to by the index.
1011                      *
1012                      * NOTE: index into a buffer is NOT a pointer to a
1013                      * sub-buffer of the main buffer, it is only a pointer to a
1014                      * single element (byte) of the buffer!
1015                      *
1016                      * Since we are returning the value of the buffer at the
1017                      * indexed location, we don't need to add an additional
1018                      * reference to the buffer itself.
1019                      */
1020                     ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
1021                         TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
1022                     if (!ReturnDesc)
1023                     {
1024                         Status = AE_NO_MEMORY;
1025                         goto Cleanup;
1026                     }
1027                     break;
1028 
1029 
1030                 case ACPI_TYPE_PACKAGE:
1031 
1032                     /*
1033                      * Return the referenced element of the package.  We must
1034                      * add another reference to the referenced object, however.
1035                      */
1036                     ReturnDesc = *(Operand[0]->Reference.Where);
1037                     if (ReturnDesc)
1038                     {
1039                         AcpiUtAddReference (ReturnDesc);





1040                     }


1041                     break;
1042 
1043 
1044                 default:
1045 
1046                     ACPI_ERROR ((AE_INFO,
1047                         "Unknown Index TargetType 0x%X in reference object %p",
1048                         Operand[0]->Reference.TargetType, Operand[0]));
1049                     Status = AE_AML_OPERAND_TYPE;
1050                     goto Cleanup;
1051                 }
1052                 break;
1053 
1054 
1055             case ACPI_REFCLASS_REFOF:
1056 
1057                 ReturnDesc = Operand[0]->Reference.Object;
1058 
1059                 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
1060                         ACPI_DESC_TYPE_NAMED)
1061                 {
1062                     ReturnDesc = AcpiNsGetAttachedObject (
1063                                     (ACPI_NAMESPACE_NODE *) ReturnDesc);



1064                 }
1065 
1066                 /* Add another reference to the object! */









1067 
1068                 AcpiUtAddReference (ReturnDesc);







1069                 break;
1070 

1071 








1072             default:

1073                 ACPI_ERROR ((AE_INFO,
1074                     "Unknown class in reference(%p) - 0x%2.2X",
1075                     Operand[0], Operand[0]->Reference.Class));
1076 
1077                 Status = AE_TYPE;
1078                 goto Cleanup;
1079             }
1080         }
1081         break;
1082 
1083 
1084     default:
1085 
1086         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
1087             WalkState->Opcode));
1088         Status = AE_AML_BAD_OPCODE;
1089         goto Cleanup;
1090     }
1091 
1092 
1093 Cleanup:
1094 
1095     /* Delete return object on error */
1096 
1097     if (ACPI_FAILURE (Status))
1098     {
1099         AcpiUtRemoveReference (ReturnDesc);
1100     }
1101 
1102     /* Save return object on success */
1103 
1104     else
1105     {
1106         WalkState->ResultObj = ReturnDesc;
1107     }
1108 
1109     return_ACPI_STATUS (Status);
1110 }
1111 

   1 /******************************************************************************
   2  *
   3  * Module Name: exoparg1 - AML execution - opcodes with 1 argument
   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.


 163 AcpiExOpcode_1A_0T_0R (
 164     ACPI_WALK_STATE         *WalkState)
 165 {
 166     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
 167     ACPI_STATUS             Status = AE_OK;
 168 
 169 
 170     ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_0T_0R,
 171         AcpiPsGetOpcodeName (WalkState->Opcode));
 172 
 173 
 174     /* Examine the AML opcode */
 175 
 176     switch (WalkState->Opcode)
 177     {
 178     case AML_RELEASE_OP:    /*  Release (MutexObject) */
 179 
 180         Status = AcpiExReleaseMutex (Operand[0], WalkState);
 181         break;
 182 

 183     case AML_RESET_OP:      /*  Reset (EventObject) */
 184 
 185         Status = AcpiExSystemResetEvent (Operand[0]);
 186         break;
 187 

 188     case AML_SIGNAL_OP:     /*  Signal (EventObject) */
 189 
 190         Status = AcpiExSystemSignalEvent (Operand[0]);
 191         break;
 192 

 193     case AML_SLEEP_OP:      /*  Sleep (MsecTime) */
 194 
 195         Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
 196         break;
 197 

 198     case AML_STALL_OP:      /*  Stall (UsecTime) */
 199 
 200         Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
 201         break;
 202 

 203     case AML_UNLOAD_OP:     /*  Unload (Handle) */
 204 
 205         Status = AcpiExUnloadTable (Operand[0]);
 206         break;
 207 

 208     default:                /*  Unknown opcode  */
 209 
 210         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
 211             WalkState->Opcode));
 212         Status = AE_AML_BAD_OPCODE;
 213         break;
 214     }
 215 
 216     return_ACPI_STATUS (Status);
 217 }
 218 
 219 
 220 /*******************************************************************************
 221  *
 222  * FUNCTION:    AcpiExOpcode_1A_1T_0R
 223  *
 224  * PARAMETERS:  WalkState           - Current state (contains AML opcode)
 225  *
 226  * RETURN:      Status
 227  *


 307     case AML_FROM_BCD_OP:
 308     case AML_TO_BCD_OP:
 309     case AML_COND_REF_OF_OP:
 310 
 311         /* Create a return object of type Integer for these opcodes */
 312 
 313         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
 314         if (!ReturnDesc)
 315         {
 316             Status = AE_NO_MEMORY;
 317             goto Cleanup;
 318         }
 319 
 320         switch (WalkState->Opcode)
 321         {
 322         case AML_BIT_NOT_OP:            /* Not (Operand, Result)  */
 323 
 324             ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
 325             break;
 326 

 327         case AML_FIND_SET_LEFT_BIT_OP:  /* FindSetLeftBit (Operand, Result) */
 328 
 329             ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
 330 
 331             /*
 332              * Acpi specification describes Integer type as a little
 333              * endian unsigned value, so this boundary condition is valid.
 334              */
 335             for (Temp32 = 0; ReturnDesc->Integer.Value &&
 336                              Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
 337             {
 338                 ReturnDesc->Integer.Value >>= 1;
 339             }
 340 
 341             ReturnDesc->Integer.Value = Temp32;
 342             break;
 343 

 344         case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
 345 
 346             ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
 347 
 348             /*
 349              * The Acpi specification describes Integer type as a little
 350              * endian unsigned value, so this boundary condition is valid.
 351              */
 352             for (Temp32 = 0; ReturnDesc->Integer.Value &&
 353                              Temp32 < ACPI_INTEGER_BIT_SIZE; ++Temp32)
 354             {
 355                 ReturnDesc->Integer.Value <<= 1;
 356             }
 357 
 358             /* Since the bit position is one-based, subtract from 33 (65) */
 359 
 360             ReturnDesc->Integer.Value =
 361                 Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
 362             break;
 363 

 364         case AML_FROM_BCD_OP:           /* FromBcd (BCDValue, Result)  */

 365             /*
 366              * The 64-bit ACPI integer can hold 16 4-bit BCD characters
 367              * (if table is 32-bit, integer can hold 8 BCD characters)
 368              * Convert each 4-bit BCD value
 369              */
 370             PowerOfTen = 1;
 371             ReturnDesc->Integer.Value = 0;
 372             Digit = Operand[0]->Integer.Value;
 373 
 374             /* Convert each BCD digit (each is one nybble wide) */
 375 
 376             for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
 377             {
 378                 /* Get the least significant 4-bit BCD digit */
 379 
 380                 Temp32 = ((UINT32) Digit) & 0xF;
 381 
 382                 /* Check the range of the digit */
 383 
 384                 if (Temp32 > 9)


 389 
 390                     Status = AE_AML_NUMERIC_OVERFLOW;
 391                     goto Cleanup;
 392                 }
 393 
 394                 /* Sum the digit into the result with the current power of 10 */
 395 
 396                 ReturnDesc->Integer.Value +=
 397                     (((UINT64) Temp32) * PowerOfTen);
 398 
 399                 /* Shift to next BCD digit */
 400 
 401                 Digit >>= 4;
 402 
 403                 /* Next power of 10 */
 404 
 405                 PowerOfTen *= 10;
 406             }
 407             break;
 408 

 409         case AML_TO_BCD_OP:             /* ToBcd (Operand, Result)  */
 410 
 411             ReturnDesc->Integer.Value = 0;
 412             Digit = Operand[0]->Integer.Value;
 413 
 414             /* Each BCD digit is one nybble wide */
 415 
 416             for (i = 0; (i < AcpiGbl_IntegerNybbleWidth) && (Digit > 0); i++)
 417             {
 418                 (void) AcpiUtShortDivide (Digit, 10, &Digit, &Temp32);
 419 
 420                 /*
 421                  * Insert the BCD digit that resides in the
 422                  * remainder from above
 423                  */
 424                 ReturnDesc->Integer.Value |=
 425                     (((UINT64) Temp32) << ACPI_MUL_4 (i));
 426             }
 427 
 428             /* Overflow if there is any data left in Digit */
 429 
 430             if (Digit > 0)
 431             {
 432                 ACPI_ERROR ((AE_INFO,
 433                     "Integer too large to convert to BCD: 0x%8.8X%8.8X",
 434                     ACPI_FORMAT_UINT64 (Operand[0]->Integer.Value)));
 435                 Status = AE_AML_NUMERIC_OVERFLOW;
 436                 goto Cleanup;
 437             }
 438             break;
 439 

 440         case AML_COND_REF_OF_OP:        /* CondRefOf (SourceObject, Result)  */

 441             /*
 442              * This op is a little strange because the internal return value is
 443              * different than the return value stored in the result descriptor
 444              * (There are really two return values)
 445              */
 446             if ((ACPI_NAMESPACE_NODE *) Operand[0] == AcpiGbl_RootNode)
 447             {
 448                 /*
 449                  * This means that the object does not exist in the namespace,
 450                  * return FALSE
 451                  */
 452                 ReturnDesc->Integer.Value = 0;
 453                 goto Cleanup;
 454             }
 455 
 456             /* Get the object reference, store it, and remove our reference */
 457 
 458             Status = AcpiExGetObjectReference (Operand[0],
 459                         &ReturnDesc2, WalkState);
 460             if (ACPI_FAILURE (Status))
 461             {
 462                 goto Cleanup;
 463             }
 464 
 465             Status = AcpiExStore (ReturnDesc2, Operand[1], WalkState);
 466             AcpiUtRemoveReference (ReturnDesc2);
 467 
 468             /* The object exists in the namespace, return TRUE */
 469 
 470             ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
 471             goto Cleanup;
 472 
 473 
 474         default:
 475 
 476             /* No other opcodes get here */
 477 
 478             break;
 479         }
 480         break;
 481 

 482     case AML_STORE_OP:              /* Store (Source, Target) */

 483         /*
 484          * A store operand is typically a number, string, buffer or lvalue
 485          * Be careful about deleting the source object,
 486          * since the object itself may have been stored.
 487          */
 488         Status = AcpiExStore (Operand[0], Operand[1], WalkState);
 489         if (ACPI_FAILURE (Status))
 490         {
 491             return_ACPI_STATUS (Status);
 492         }
 493 
 494         /* It is possible that the Store already produced a return object */
 495 
 496         if (!WalkState->ResultObj)
 497         {
 498             /*
 499              * Normally, we would remove a reference on the Operand[0]
 500              * parameter; But since it is being used as the internal return
 501              * object (meaning we would normally increment it), the two
 502              * cancel out, and we simply don't do anything.
 503              */
 504             WalkState->ResultObj = Operand[0];
 505             WalkState->Operands[0] = NULL;  /* Prevent deletion */
 506         }
 507         return_ACPI_STATUS (Status);
 508 

 509     /*
 510      * ACPI 2.0 Opcodes
 511      */
 512     case AML_COPY_OP:               /* Copy (Source, Target) */
 513 
 514         Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc,
 515                     WalkState);
 516         break;
 517 

 518     case AML_TO_DECSTRING_OP:       /* ToDecimalString (Data, Result) */
 519 
 520         Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
 521                     ACPI_EXPLICIT_CONVERT_DECIMAL);
 522         if (ReturnDesc == Operand[0])
 523         {
 524             /* No conversion performed, add ref to handle return value */
 525             AcpiUtAddReference (ReturnDesc);
 526         }
 527         break;
 528 

 529     case AML_TO_HEXSTRING_OP:       /* ToHexString (Data, Result) */
 530 
 531         Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
 532                     ACPI_EXPLICIT_CONVERT_HEX);
 533         if (ReturnDesc == Operand[0])
 534         {
 535             /* No conversion performed, add ref to handle return value */
 536             AcpiUtAddReference (ReturnDesc);
 537         }
 538         break;
 539 

 540     case AML_TO_BUFFER_OP:          /* ToBuffer (Data, Result) */
 541 
 542         Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
 543         if (ReturnDesc == Operand[0])
 544         {
 545             /* No conversion performed, add ref to handle return value */
 546             AcpiUtAddReference (ReturnDesc);
 547         }
 548         break;
 549 

 550     case AML_TO_INTEGER_OP:         /* ToInteger (Data, Result) */
 551 
 552         Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc,
 553                     ACPI_ANY_BASE);
 554         if (ReturnDesc == Operand[0])
 555         {
 556             /* No conversion performed, add ref to handle return value */
 557             AcpiUtAddReference (ReturnDesc);
 558         }
 559         break;
 560 

 561     case AML_SHIFT_LEFT_BIT_OP:     /* ShiftLeftBit (Source, BitNum)  */
 562     case AML_SHIFT_RIGHT_BIT_OP:    /* ShiftRightBit (Source, BitNum) */
 563 
 564         /* These are two obsolete opcodes */
 565 
 566         ACPI_ERROR ((AE_INFO,
 567             "%s is obsolete and not implemented",
 568             AcpiPsGetOpcodeName (WalkState->Opcode)));
 569         Status = AE_SUPPORT;
 570         goto Cleanup;
 571 

 572     default:                        /* Unknown opcode */
 573 
 574         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
 575             WalkState->Opcode));
 576         Status = AE_AML_BAD_OPCODE;
 577         goto Cleanup;
 578     }
 579 
 580     if (ACPI_SUCCESS (Status))
 581     {
 582         /* Store the return value computed above into the target object */
 583 
 584         Status = AcpiExStore (ReturnDesc, Operand[1], WalkState);
 585     }
 586 
 587 
 588 Cleanup:
 589 
 590     /* Delete return object on error */
 591 


 639     {
 640     case AML_LNOT_OP:               /* LNot (Operand) */
 641 
 642         ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) 0);
 643         if (!ReturnDesc)
 644         {
 645             Status = AE_NO_MEMORY;
 646             goto Cleanup;
 647         }
 648 
 649         /*
 650          * Set result to ONES (TRUE) if Value == 0. Note:
 651          * ReturnDesc->Integer.Value is initially == 0 (FALSE) from above.
 652          */
 653         if (!Operand[0]->Integer.Value)
 654         {
 655             ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
 656         }
 657         break;
 658 

 659     case AML_DECREMENT_OP:          /* Decrement (Operand)  */
 660     case AML_INCREMENT_OP:          /* Increment (Operand)  */

 661         /*
 662          * Create a new integer. Can't just get the base integer and
 663          * increment it because it may be an Arg or Field.
 664          */
 665         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
 666         if (!ReturnDesc)
 667         {
 668             Status = AE_NO_MEMORY;
 669             goto Cleanup;
 670         }
 671 
 672         /*
 673          * Since we are expecting a Reference operand, it can be either a
 674          * NS Node or an internal object.
 675          */
 676         TempDesc = Operand[0];
 677         if (ACPI_GET_DESCRIPTOR_TYPE (TempDesc) == ACPI_DESC_TYPE_OPERAND)
 678         {
 679             /* Internal reference object - prevent deletion */
 680 


 705         if (WalkState->Opcode == AML_INCREMENT_OP)
 706         {
 707             ReturnDesc->Integer.Value = TempDesc->Integer.Value +1;
 708         }
 709         else
 710         {
 711             ReturnDesc->Integer.Value = TempDesc->Integer.Value -1;
 712         }
 713 
 714         /* Finished with this Integer object */
 715 
 716         AcpiUtRemoveReference (TempDesc);
 717 
 718         /*
 719          * Store the result back (indirectly) through the original
 720          * Reference object
 721          */
 722         Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
 723         break;
 724 

 725     case AML_TYPE_OP:               /* ObjectType (SourceObject) */

 726         /*
 727          * Note: The operand is not resolved at this point because we want to
 728          * get the associated object, not its value. For example, we don't
 729          * want to resolve a FieldUnit to its value, we want the actual
 730          * FieldUnit object.
 731          */
 732 
 733         /* Get the type of the base object */
 734 
 735         Status = AcpiExResolveMultiple (WalkState, Operand[0], &Type, NULL);
 736         if (ACPI_FAILURE (Status))
 737         {
 738             goto Cleanup;
 739         }
 740 
 741         /* Allocate a descriptor to hold the type. */
 742 
 743         ReturnDesc = AcpiUtCreateIntegerObject ((UINT64) Type);
 744         if (!ReturnDesc)
 745         {
 746             Status = AE_NO_MEMORY;
 747             goto Cleanup;
 748         }
 749         break;
 750 

 751     case AML_SIZE_OF_OP:            /* SizeOf (SourceObject)  */

 752         /*
 753          * Note: The operand is not resolved at this point because we want to
 754          * get the associated object, not its value.
 755          */
 756 
 757         /* Get the base object */
 758 
 759         Status = AcpiExResolveMultiple (WalkState,
 760                     Operand[0], &Type, &TempDesc);
 761         if (ACPI_FAILURE (Status))
 762         {
 763             goto Cleanup;
 764         }
 765 
 766         /*
 767          * The type of the base object must be integer, buffer, string, or
 768          * package. All others are not supported.
 769          *
 770          * NOTE: Integer is not specifically supported by the ACPI spec,
 771          * but is supported implicitly via implicit operand conversion.
 772          * rather than bother with conversion, we just use the byte width
 773          * global (4 or 8 bytes).
 774          */
 775         switch (Type)
 776         {
 777         case ACPI_TYPE_INTEGER:
 778 
 779             Value = AcpiGbl_IntegerByteWidth;
 780             break;
 781 
 782         case ACPI_TYPE_STRING:
 783 
 784             Value = TempDesc->String.Length;
 785             break;
 786 
 787         case ACPI_TYPE_BUFFER:
 788 
 789             /* Buffer arguments may not be evaluated at this point */
 790 
 791             Status = AcpiDsGetBufferArguments (TempDesc);
 792             Value = TempDesc->Buffer.Length;
 793             break;
 794 
 795         case ACPI_TYPE_PACKAGE:
 796 
 797             /* Package arguments may not be evaluated at this point */
 798 
 799             Status = AcpiDsGetPackageArguments (TempDesc);
 800             Value = TempDesc->Package.Count;
 801             break;
 802 
 803         default:
 804 
 805             ACPI_ERROR ((AE_INFO,
 806                 "Operand must be Buffer/Integer/String/Package - found type %s",
 807                 AcpiUtGetTypeName (Type)));
 808             Status = AE_AML_OPERAND_TYPE;
 809             goto Cleanup;
 810         }
 811 
 812         if (ACPI_FAILURE (Status))
 813         {
 814             goto Cleanup;
 815         }
 816 
 817         /*
 818          * Now that we have the size of the object, create a result
 819          * object to hold the value
 820          */
 821         ReturnDesc = AcpiUtCreateIntegerObject (Value);
 822         if (!ReturnDesc)
 823         {
 824             Status = AE_NO_MEMORY;


 892                     Operand[0] = TempDesc;
 893                     break;
 894 
 895                 case ACPI_REFCLASS_REFOF:
 896 
 897                     /* Get the object to which the reference refers */
 898 
 899                     TempDesc = Operand[0]->Reference.Object;
 900                     AcpiUtRemoveReference (Operand[0]);
 901                     Operand[0] = TempDesc;
 902                     break;
 903 
 904                 default:
 905 
 906                     /* Must be an Index op - handled below */
 907                     break;
 908                 }
 909                 break;
 910 
 911             case ACPI_TYPE_STRING:
 912 
 913                 break;
 914 
 915             default:
 916 
 917                 Status = AE_AML_OPERAND_TYPE;
 918                 goto Cleanup;
 919             }
 920         }
 921 
 922         if (ACPI_GET_DESCRIPTOR_TYPE (Operand[0]) != ACPI_DESC_TYPE_NAMED)
 923         {
 924             if ((Operand[0])->Common.Type == ACPI_TYPE_STRING)
 925             {
 926                 /*
 927                  * This is a DerefOf (String). The string is a reference
 928                  * to a named ACPI object.
 929                  *
 930                  * 1) Find the owning Node
 931                  * 2) Dereference the node to an actual object. Could be a
 932                  *    Field, so we need to resolve the node to a value.
 933                  */
 934                 Status = AcpiNsGetNode (WalkState->ScopeInfo->Scope.Node,
 935                             Operand[0]->String.Pointer,
 936                             ACPI_NS_SEARCH_PARENT,


 955         {
 956             /*
 957              * This is a DerefOf (ObjectReference)
 958              * Get the actual object from the Node (This is the dereference).
 959              * This case may only happen when a LocalX or ArgX is
 960              * dereferenced above.
 961              */
 962             ReturnDesc = AcpiNsGetAttachedObject (
 963                             (ACPI_NAMESPACE_NODE *) Operand[0]);
 964             AcpiUtAddReference (ReturnDesc);
 965         }
 966         else
 967         {
 968             /*
 969              * This must be a reference object produced by either the
 970              * Index() or RefOf() operator
 971              */
 972             switch (Operand[0]->Reference.Class)
 973             {
 974             case ACPI_REFCLASS_INDEX:

 975                 /*
 976                  * The target type for the Index operator must be
 977                  * either a Buffer or a Package
 978                  */
 979                 switch (Operand[0]->Reference.TargetType)
 980                 {
 981                 case ACPI_TYPE_BUFFER_FIELD:
 982 
 983                     TempDesc = Operand[0]->Reference.Object;
 984 
 985                     /*
 986                      * Create a new object that contains one element of the
 987                      * buffer -- the element pointed to by the index.
 988                      *
 989                      * NOTE: index into a buffer is NOT a pointer to a
 990                      * sub-buffer of the main buffer, it is only a pointer to a
 991                      * single element (byte) of the buffer!
 992                      *
 993                      * Since we are returning the value of the buffer at the
 994                      * indexed location, we don't need to add an additional
 995                      * reference to the buffer itself.
 996                      */
 997                     ReturnDesc = AcpiUtCreateIntegerObject ((UINT64)
 998                         TempDesc->Buffer.Pointer[Operand[0]->Reference.Value]);
 999                     if (!ReturnDesc)
1000                     {
1001                         Status = AE_NO_MEMORY;
1002                         goto Cleanup;
1003                     }
1004                     break;
1005 

1006                 case ACPI_TYPE_PACKAGE:

1007                     /*
1008                      * Return the referenced element of the package. We must
1009                      * add another reference to the referenced object, however.
1010                      */
1011                     ReturnDesc = *(Operand[0]->Reference.Where);
1012                     if (!ReturnDesc)
1013                     {
1014                         /*
1015                          * Element is NULL, do not allow the dereference.
1016                          * This provides compatibility with other ACPI
1017                          * implementations.
1018                          */
1019                         return_ACPI_STATUS (AE_AML_UNINITIALIZED_ELEMENT);
1020                     }
1021 
1022                     AcpiUtAddReference (ReturnDesc);
1023                     break;
1024 

1025                 default:
1026 
1027                     ACPI_ERROR ((AE_INFO,
1028                         "Unknown Index TargetType 0x%X in reference object %p",
1029                         Operand[0]->Reference.TargetType, Operand[0]));
1030                     Status = AE_AML_OPERAND_TYPE;
1031                     goto Cleanup;
1032                 }
1033                 break;
1034 

1035             case ACPI_REFCLASS_REFOF:
1036 
1037                 ReturnDesc = Operand[0]->Reference.Object;
1038 
1039                 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
1040                     ACPI_DESC_TYPE_NAMED)
1041                 {
1042                     ReturnDesc = AcpiNsGetAttachedObject (
1043                         (ACPI_NAMESPACE_NODE *) ReturnDesc);
1044                     if (!ReturnDesc)
1045                     {
1046                         break;
1047                     }
1048 
1049                    /*
1050                     * June 2013:
1051                     * BufferFields/FieldUnits require additional resolution
1052                     */
1053                     switch (ReturnDesc->Common.Type)
1054                     {
1055                     case ACPI_TYPE_BUFFER_FIELD:
1056                     case ACPI_TYPE_LOCAL_REGION_FIELD:
1057                     case ACPI_TYPE_LOCAL_BANK_FIELD:
1058                     case ACPI_TYPE_LOCAL_INDEX_FIELD:
1059 
1060                         Status = AcpiExReadDataFromField (WalkState,
1061                             ReturnDesc, &TempDesc);
1062                         if (ACPI_FAILURE (Status))
1063                         {
1064                             goto Cleanup;
1065                         }
1066 
1067                         ReturnDesc = TempDesc;
1068                         break;
1069 
1070                     default:
1071 
1072                         /* Add another reference to the object */
1073 
1074                         AcpiUtAddReference (ReturnDesc);
1075                         break;
1076                     }
1077                 }
1078                 break;
1079 
1080             default:
1081 
1082                 ACPI_ERROR ((AE_INFO,
1083                     "Unknown class in reference(%p) - 0x%2.2X",
1084                     Operand[0], Operand[0]->Reference.Class));
1085 
1086                 Status = AE_TYPE;
1087                 goto Cleanup;
1088             }
1089         }
1090         break;
1091 

1092     default:
1093 
1094         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
1095             WalkState->Opcode));
1096         Status = AE_AML_BAD_OPCODE;
1097         goto Cleanup;
1098     }
1099 
1100 
1101 Cleanup:
1102 
1103     /* Delete return object on error */
1104 
1105     if (ACPI_FAILURE (Status))
1106     {
1107         AcpiUtRemoveReference (ReturnDesc);
1108     }
1109 
1110     /* Save return object on success */
1111 
1112     else
1113     {
1114         WalkState->ResultObj = ReturnDesc;
1115     }
1116 
1117     return_ACPI_STATUS (Status);
1118 }