Print this page
acpica-unix2-20130823
PANKOVs restructure

@@ -1,14 +1,13 @@
-
 /******************************************************************************
  *
  * Module Name: exoparg1 - AML execution - opcodes with 1 argument
  *
  *****************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2011, Intel Corp.
+ * Copyright (C) 2000 - 2013, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:

@@ -179,41 +178,35 @@
     case AML_RELEASE_OP:    /*  Release (MutexObject) */
 
         Status = AcpiExReleaseMutex (Operand[0], WalkState);
         break;
 
-
     case AML_RESET_OP:      /*  Reset (EventObject) */
 
         Status = AcpiExSystemResetEvent (Operand[0]);
         break;
 
-
     case AML_SIGNAL_OP:     /*  Signal (EventObject) */
 
         Status = AcpiExSystemSignalEvent (Operand[0]);
         break;
 
-
     case AML_SLEEP_OP:      /*  Sleep (MsecTime) */
 
         Status = AcpiExSystemDoSleep (Operand[0]->Integer.Value);
         break;
 
-
     case AML_STALL_OP:      /*  Stall (UsecTime) */
 
         Status = AcpiExSystemDoStall ((UINT32) Operand[0]->Integer.Value);
         break;
 
-
     case AML_UNLOAD_OP:     /*  Unload (Handle) */
 
         Status = AcpiExUnloadTable (Operand[0]);
         break;
 
-
     default:                /*  Unknown opcode  */
 
         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
             WalkState->Opcode));
         Status = AE_AML_BAD_OPCODE;

@@ -329,11 +322,10 @@
         case AML_BIT_NOT_OP:            /* Not (Operand, Result)  */
 
             ReturnDesc->Integer.Value = ~Operand[0]->Integer.Value;
             break;
 
-
         case AML_FIND_SET_LEFT_BIT_OP:  /* FindSetLeftBit (Operand, Result) */
 
             ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
 
             /*

@@ -347,11 +339,10 @@
             }
 
             ReturnDesc->Integer.Value = Temp32;
             break;
 
-
         case AML_FIND_SET_RIGHT_BIT_OP: /* FindSetRightBit (Operand, Result) */
 
             ReturnDesc->Integer.Value = Operand[0]->Integer.Value;
 
             /*

@@ -368,13 +359,11 @@
 
             ReturnDesc->Integer.Value =
                 Temp32 == 0 ? 0 : (ACPI_INTEGER_BIT_SIZE + 1) - Temp32;
             break;
 
-
         case AML_FROM_BCD_OP:           /* FromBcd (BCDValue, Result)  */
-
             /*
              * The 64-bit ACPI integer can hold 16 4-bit BCD characters
              * (if table is 32-bit, integer can hold 8 BCD characters)
              * Convert each 4-bit BCD value
              */

@@ -415,11 +404,10 @@
 
                 PowerOfTen *= 10;
             }
             break;
 
-
         case AML_TO_BCD_OP:             /* ToBcd (Operand, Result)  */
 
             ReturnDesc->Integer.Value = 0;
             Digit = Operand[0]->Integer.Value;
 

@@ -447,13 +435,11 @@
                 Status = AE_AML_NUMERIC_OVERFLOW;
                 goto Cleanup;
             }
             break;
 
-
         case AML_COND_REF_OF_OP:        /* CondRefOf (SourceObject, Result)  */
-
             /*
              * This op is a little strange because the internal return value is
              * different than the return value stored in the result descriptor
              * (There are really two return values)
              */

@@ -484,18 +470,18 @@
             ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
             goto Cleanup;
 
 
         default:
+
             /* No other opcodes get here */
+
             break;
         }
         break;
 
-
     case AML_STORE_OP:              /* Store (Source, Target) */
-
         /*
          * A store operand is typically a number, string, buffer or lvalue
          * Be careful about deleting the source object,
          * since the object itself may have been stored.
          */

@@ -518,21 +504,19 @@
             WalkState->ResultObj = Operand[0];
             WalkState->Operands[0] = NULL;  /* Prevent deletion */
         }
         return_ACPI_STATUS (Status);
 
-
     /*
      * ACPI 2.0 Opcodes
      */
     case AML_COPY_OP:               /* Copy (Source, Target) */
 
         Status = AcpiUtCopyIobjectToIobject (Operand[0], &ReturnDesc,
                     WalkState);
         break;
 
-
     case AML_TO_DECSTRING_OP:       /* ToDecimalString (Data, Result) */
 
         Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
                     ACPI_EXPLICIT_CONVERT_DECIMAL);
         if (ReturnDesc == Operand[0])

@@ -540,11 +524,10 @@
             /* No conversion performed, add ref to handle return value */
             AcpiUtAddReference (ReturnDesc);
         }
         break;
 
-
     case AML_TO_HEXSTRING_OP:       /* ToHexString (Data, Result) */
 
         Status = AcpiExConvertToString (Operand[0], &ReturnDesc,
                     ACPI_EXPLICIT_CONVERT_HEX);
         if (ReturnDesc == Operand[0])

@@ -552,11 +535,10 @@
             /* No conversion performed, add ref to handle return value */
             AcpiUtAddReference (ReturnDesc);
         }
         break;
 
-
     case AML_TO_BUFFER_OP:          /* ToBuffer (Data, Result) */
 
         Status = AcpiExConvertToBuffer (Operand[0], &ReturnDesc);
         if (ReturnDesc == Operand[0])
         {

@@ -563,11 +545,10 @@
             /* No conversion performed, add ref to handle return value */
             AcpiUtAddReference (ReturnDesc);
         }
         break;
 
-
     case AML_TO_INTEGER_OP:         /* ToInteger (Data, Result) */
 
         Status = AcpiExConvertToInteger (Operand[0], &ReturnDesc,
                     ACPI_ANY_BASE);
         if (ReturnDesc == Operand[0])

@@ -575,11 +556,10 @@
             /* No conversion performed, add ref to handle return value */
             AcpiUtAddReference (ReturnDesc);
         }
         break;
 
-
     case AML_SHIFT_LEFT_BIT_OP:     /* ShiftLeftBit (Source, BitNum)  */
     case AML_SHIFT_RIGHT_BIT_OP:    /* ShiftRightBit (Source, BitNum) */
 
         /* These are two obsolete opcodes */
 

@@ -587,11 +567,10 @@
             "%s is obsolete and not implemented",
             AcpiPsGetOpcodeName (WalkState->Opcode)));
         Status = AE_SUPPORT;
         goto Cleanup;
 
-
     default:                        /* Unknown opcode */
 
         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
             WalkState->Opcode));
         Status = AE_AML_BAD_OPCODE;

@@ -675,14 +654,12 @@
         {
             ReturnDesc->Integer.Value = ACPI_UINT64_MAX;
         }
         break;
 
-
     case AML_DECREMENT_OP:          /* Decrement (Operand)  */
     case AML_INCREMENT_OP:          /* Increment (Operand)  */
-
         /*
          * Create a new integer.  Can't just get the base integer and
          * increment it because it may be an Arg or Field.
          */
         ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);

@@ -743,13 +720,11 @@
          * Reference object
          */
         Status = AcpiExStore (ReturnDesc, Operand[0], WalkState);
         break;
 
-
     case AML_TYPE_OP:               /* ObjectType (SourceObject) */
-
         /*
          * Note: The operand is not resolved at this point because we want to
          * get the associated object, not its value.  For example, we don't
          * want to resolve a FieldUnit to its value, we want the actual
          * FieldUnit object.

@@ -771,13 +746,11 @@
             Status = AE_NO_MEMORY;
             goto Cleanup;
         }
         break;
 
-
     case AML_SIZE_OF_OP:            /* SizeOf (SourceObject)  */
-
         /*
          * Note: The operand is not resolved at this point because we want to
          * get the associated object, not its value.
          */
 

@@ -800,14 +773,16 @@
          * global (4 or 8 bytes).
          */
         switch (Type)
         {
         case ACPI_TYPE_INTEGER:
+
             Value = AcpiGbl_IntegerByteWidth;
             break;
 
         case ACPI_TYPE_STRING:
+
             Value = TempDesc->String.Length;
             break;
 
         case ACPI_TYPE_BUFFER:
 

@@ -824,10 +799,11 @@
             Status = AcpiDsGetPackageArguments (TempDesc);
             Value = TempDesc->Package.Count;
             break;
 
         default:
+
             ACPI_ERROR ((AE_INFO,
                 "Operand must be Buffer/Integer/String/Package - found type %s",
                 AcpiUtGetTypeName (Type)));
             Status = AE_AML_OPERAND_TYPE;
             goto Cleanup;

@@ -931,13 +907,15 @@
                     break;
                 }
                 break;
 
             case ACPI_TYPE_STRING:
+
                 break;
 
             default:
+
                 Status = AE_AML_OPERAND_TYPE;
                 goto Cleanup;
             }
         }
 

@@ -992,11 +970,10 @@
              * Index() or RefOf() operator
              */
             switch (Operand[0]->Reference.Class)
             {
             case ACPI_REFCLASS_INDEX:
-
                 /*
                  * The target type for the Index operator must be
                  * either a Buffer or a Package
                  */
                 switch (Operand[0]->Reference.TargetType)

@@ -1024,25 +1001,29 @@
                         Status = AE_NO_MEMORY;
                         goto Cleanup;
                     }
                     break;
 
-
                 case ACPI_TYPE_PACKAGE:
-
                     /*
                      * Return the referenced element of the package.  We must
                      * add another reference to the referenced object, however.
                      */
                     ReturnDesc = *(Operand[0]->Reference.Where);
-                    if (ReturnDesc)
+                    if (!ReturnDesc)
                     {
-                        AcpiUtAddReference (ReturnDesc);
+                        /*
+                         * Element is NULL, do not allow the dereference.
+                         * This provides compatibility with other ACPI
+                         * implementations.
+                         */
+                        return_ACPI_STATUS (AE_AML_UNINITIALIZED_ELEMENT);
                     }
+
+                    AcpiUtAddReference (ReturnDesc);
                     break;
 
-
                 default:
 
                     ACPI_ERROR ((AE_INFO,
                         "Unknown Index TargetType 0x%X in reference object %p",
                         Operand[0]->Reference.TargetType, Operand[0]));

@@ -1049,29 +1030,57 @@
                     Status = AE_AML_OPERAND_TYPE;
                     goto Cleanup;
                 }
                 break;
 
-
             case ACPI_REFCLASS_REFOF:
 
                 ReturnDesc = Operand[0]->Reference.Object;
 
                 if (ACPI_GET_DESCRIPTOR_TYPE (ReturnDesc) ==
                         ACPI_DESC_TYPE_NAMED)
                 {
                     ReturnDesc = AcpiNsGetAttachedObject (
                                     (ACPI_NAMESPACE_NODE *) ReturnDesc);
+                    if (!ReturnDesc)
+                    {
+                        break;
                 }
 
-                /* Add another reference to the object! */
+                   /*
+                    * June 2013:
+                    * BufferFields/FieldUnits require additional resolution
+                    */
+                    switch (ReturnDesc->Common.Type)
+                    {
+                    case ACPI_TYPE_BUFFER_FIELD:
+                    case ACPI_TYPE_LOCAL_REGION_FIELD:
+                    case ACPI_TYPE_LOCAL_BANK_FIELD:
+                    case ACPI_TYPE_LOCAL_INDEX_FIELD:
 
-                AcpiUtAddReference (ReturnDesc);
+                        Status = AcpiExReadDataFromField (WalkState,
+                            ReturnDesc, &TempDesc);
+                        if (ACPI_FAILURE (Status))
+                        {
+                            goto Cleanup;
+                        }
+
+                        ReturnDesc = TempDesc;
                 break;
 
+                    default:
 
+                        /* Add another reference to the object */
+
+                        AcpiUtAddReference (ReturnDesc);
+                        break;
+                    }
+                }
+                break;
+
             default:
+
                 ACPI_ERROR ((AE_INFO,
                     "Unknown class in reference(%p) - 0x%2.2X",
                     Operand[0], Operand[0]->Reference.Class));
 
                 Status = AE_TYPE;

@@ -1078,11 +1087,10 @@
                 goto Cleanup;
             }
         }
         break;
 
-
     default:
 
         ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
             WalkState->Opcode));
         Status = AE_AML_BAD_OPCODE;

@@ -1106,6 +1114,5 @@
         WalkState->ResultObj = ReturnDesc;
     }
 
     return_ACPI_STATUS (Status);
 }
-