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


  78 {
  79     ACPI_OPERAND_OBJECT     *SourceDesc = *SourceDescPtr;
  80     ACPI_STATUS             Status = AE_OK;
  81 
  82 
  83     ACPI_FUNCTION_TRACE (ExResolveObject);
  84 
  85 
  86     /* Ensure we have a Target that can be stored to */
  87 
  88     switch (TargetType)
  89     {
  90     case ACPI_TYPE_BUFFER_FIELD:
  91     case ACPI_TYPE_LOCAL_REGION_FIELD:
  92     case ACPI_TYPE_LOCAL_BANK_FIELD:
  93     case ACPI_TYPE_LOCAL_INDEX_FIELD:
  94         /*
  95          * These cases all require only Integers or values that
  96          * can be converted to Integers (Strings or Buffers)
  97          */
  98 
  99     case ACPI_TYPE_INTEGER:
 100     case ACPI_TYPE_STRING:
 101     case ACPI_TYPE_BUFFER:
 102 
 103         /*
 104          * Stores into a Field/Region or into a Integer/Buffer/String
 105          * are all essentially the same.  This case handles the
 106          * "interchangeable" types Integer, String, and Buffer.
 107          */
 108         if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
 109         {
 110             /* Resolve a reference object first */
 111 
 112             Status = AcpiExResolveToValue (SourceDescPtr, WalkState);
 113             if (ACPI_FAILURE (Status))
 114             {
 115                 break;
 116             }
 117         }
 118 
 119         /* For CopyObject, no further validation necessary */
 120 
 121         if (WalkState->Opcode == AML_COPY_OP)
 122         {


 124         }
 125 
 126         /* Must have a Integer, Buffer, or String */
 127 
 128         if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER)    &&
 129             (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)     &&
 130             (SourceDesc->Common.Type != ACPI_TYPE_STRING)     &&
 131             !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
 132                     (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE)))
 133         {
 134             /* Conversion successful but still not a valid type */
 135 
 136             ACPI_ERROR ((AE_INFO,
 137                 "Cannot assign type %s to %s (must be type Int/Str/Buf)",
 138                 AcpiUtGetObjectTypeName (SourceDesc),
 139                 AcpiUtGetTypeName (TargetType)));
 140             Status = AE_AML_OPERAND_TYPE;
 141         }
 142         break;
 143 
 144 
 145     case ACPI_TYPE_LOCAL_ALIAS:
 146     case ACPI_TYPE_LOCAL_METHOD_ALIAS:
 147 
 148         /*
 149          * All aliases should have been resolved earlier, during the
 150          * operand resolution phase.
 151          */
 152         ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object"));
 153         Status = AE_AML_INTERNAL;
 154         break;
 155 
 156 
 157     case ACPI_TYPE_PACKAGE:
 158     default:
 159 
 160         /*
 161          * All other types than Alias and the various Fields come here,
 162          * including the untyped case - ACPI_TYPE_ANY.
 163          */
 164         break;
 165     }
 166 
 167     return_ACPI_STATUS (Status);
 168 }
 169 
 170 
 171 /*******************************************************************************
 172  *
 173  * FUNCTION:    AcpiExStoreObjectToObject
 174  *
 175  * PARAMETERS:  SourceDesc          - Object to store
 176  *              DestDesc            - Object to receive a copy of the source
 177  *              NewDesc             - New object if DestDesc is obsoleted
 178  *              WalkState           - Current walk state
 179  *


 253              * No conversion was performed. Return the SourceDesc as the
 254              * new object.
 255              */
 256             *NewDesc = SourceDesc;
 257             return_ACPI_STATUS (AE_OK);
 258         }
 259     }
 260 
 261     /*
 262      * We now have two objects of identical types, and we can perform a
 263      * copy of the *value* of the source object.
 264      */
 265     switch (DestDesc->Common.Type)
 266     {
 267     case ACPI_TYPE_INTEGER:
 268 
 269         DestDesc->Integer.Value = ActualSrcDesc->Integer.Value;
 270 
 271         /* Truncate value if we are executing from a 32-bit ACPI table */
 272 
 273         AcpiExTruncateFor32bitTable (DestDesc);
 274         break;
 275 
 276     case ACPI_TYPE_STRING:
 277 
 278         Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc);
 279         break;
 280 
 281     case ACPI_TYPE_BUFFER:
 282 
 283         Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc);
 284         break;
 285 
 286     case ACPI_TYPE_PACKAGE:
 287 
 288         Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc,
 289                     WalkState);
 290         break;
 291 
 292     default:
 293         /*
 294          * All other types come here.
 295          */
 296         ACPI_WARNING ((AE_INFO, "Store into type %s not implemented",
 297             AcpiUtGetObjectTypeName (DestDesc)));
 298 
 299         Status = AE_NOT_IMPLEMENTED;
 300         break;
 301     }
 302 
 303     if (ActualSrcDesc != SourceDesc)
 304     {
 305         /* Delete the intermediate (temporary) source object */
 306 
 307         AcpiUtRemoveReference (ActualSrcDesc);
 308     }
 309 
 310     *NewDesc = DestDesc;
 311     return_ACPI_STATUS (Status);
 312 }
 313 
 314 

   1 /******************************************************************************
   2  *
   3  * Module Name: exstoren - AML Interpreter object store support,
   4  *                        Store to Node (namespace object)
   5  *
   6  *****************************************************************************/
   7 
   8 /*
   9  * Copyright (C) 2000 - 2013, 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.


  77 {
  78     ACPI_OPERAND_OBJECT     *SourceDesc = *SourceDescPtr;
  79     ACPI_STATUS             Status = AE_OK;
  80 
  81 
  82     ACPI_FUNCTION_TRACE (ExResolveObject);
  83 
  84 
  85     /* Ensure we have a Target that can be stored to */
  86 
  87     switch (TargetType)
  88     {
  89     case ACPI_TYPE_BUFFER_FIELD:
  90     case ACPI_TYPE_LOCAL_REGION_FIELD:
  91     case ACPI_TYPE_LOCAL_BANK_FIELD:
  92     case ACPI_TYPE_LOCAL_INDEX_FIELD:
  93         /*
  94          * These cases all require only Integers or values that
  95          * can be converted to Integers (Strings or Buffers)
  96          */

  97     case ACPI_TYPE_INTEGER:
  98     case ACPI_TYPE_STRING:
  99     case ACPI_TYPE_BUFFER:

 100         /*
 101          * Stores into a Field/Region or into a Integer/Buffer/String
 102          * are all essentially the same. This case handles the
 103          * "interchangeable" types Integer, String, and Buffer.
 104          */
 105         if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
 106         {
 107             /* Resolve a reference object first */
 108 
 109             Status = AcpiExResolveToValue (SourceDescPtr, WalkState);
 110             if (ACPI_FAILURE (Status))
 111             {
 112                 break;
 113             }
 114         }
 115 
 116         /* For CopyObject, no further validation necessary */
 117 
 118         if (WalkState->Opcode == AML_COPY_OP)
 119         {


 121         }
 122 
 123         /* Must have a Integer, Buffer, or String */
 124 
 125         if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER)    &&
 126             (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)     &&
 127             (SourceDesc->Common.Type != ACPI_TYPE_STRING)     &&
 128             !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
 129                     (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE)))
 130         {
 131             /* Conversion successful but still not a valid type */
 132 
 133             ACPI_ERROR ((AE_INFO,
 134                 "Cannot assign type %s to %s (must be type Int/Str/Buf)",
 135                 AcpiUtGetObjectTypeName (SourceDesc),
 136                 AcpiUtGetTypeName (TargetType)));
 137             Status = AE_AML_OPERAND_TYPE;
 138         }
 139         break;
 140 

 141     case ACPI_TYPE_LOCAL_ALIAS:
 142     case ACPI_TYPE_LOCAL_METHOD_ALIAS:

 143         /*
 144          * All aliases should have been resolved earlier, during the
 145          * operand resolution phase.
 146          */
 147         ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object"));
 148         Status = AE_AML_INTERNAL;
 149         break;
 150 

 151     case ACPI_TYPE_PACKAGE:
 152     default:

 153         /*
 154          * All other types than Alias and the various Fields come here,
 155          * including the untyped case - ACPI_TYPE_ANY.
 156          */
 157         break;
 158     }
 159 
 160     return_ACPI_STATUS (Status);
 161 }
 162 
 163 
 164 /*******************************************************************************
 165  *
 166  * FUNCTION:    AcpiExStoreObjectToObject
 167  *
 168  * PARAMETERS:  SourceDesc          - Object to store
 169  *              DestDesc            - Object to receive a copy of the source
 170  *              NewDesc             - New object if DestDesc is obsoleted
 171  *              WalkState           - Current walk state
 172  *


 246              * No conversion was performed. Return the SourceDesc as the
 247              * new object.
 248              */
 249             *NewDesc = SourceDesc;
 250             return_ACPI_STATUS (AE_OK);
 251         }
 252     }
 253 
 254     /*
 255      * We now have two objects of identical types, and we can perform a
 256      * copy of the *value* of the source object.
 257      */
 258     switch (DestDesc->Common.Type)
 259     {
 260     case ACPI_TYPE_INTEGER:
 261 
 262         DestDesc->Integer.Value = ActualSrcDesc->Integer.Value;
 263 
 264         /* Truncate value if we are executing from a 32-bit ACPI table */
 265 
 266         (void) AcpiExTruncateFor32bitTable (DestDesc);
 267         break;
 268 
 269     case ACPI_TYPE_STRING:
 270 
 271         Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc);
 272         break;
 273 
 274     case ACPI_TYPE_BUFFER:
 275 
 276         Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc);
 277         break;
 278 
 279     case ACPI_TYPE_PACKAGE:
 280 
 281         Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc,
 282                     WalkState);
 283         break;
 284 
 285     default:
 286         /*
 287          * All other types come here.
 288          */
 289         ACPI_WARNING ((AE_INFO, "Store into type %s not implemented",
 290             AcpiUtGetObjectTypeName (DestDesc)));
 291 
 292         Status = AE_NOT_IMPLEMENTED;
 293         break;
 294     }
 295 
 296     if (ActualSrcDesc != SourceDesc)
 297     {
 298         /* Delete the intermediate (temporary) source object */
 299 
 300         AcpiUtRemoveReference (ActualSrcDesc);
 301     }
 302 
 303     *NewDesc = DestDesc;
 304     return_ACPI_STATUS (Status);
 305 }