Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/exstoren.c need to be fixed.

0001 
0002 /******************************************************************************
0003  *
0004  * Module Name: exstoren - AML Interpreter object store support,
0005  *                        Store to Node (namespace object)
0006  *
0007  *****************************************************************************/
0008 
0009 /******************************************************************************
0010  *
0011  * 1. Copyright Notice
0012  *
0013  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
0014  * All rights reserved.
0015  *
0016  * 2. License
0017  *
0018  * 2.1. This is your license from Intel Corp. under its intellectual property
0019  * rights.  You may have additional license terms from the party that provided
0020  * you this software, covering your right to use that party's intellectual
0021  * property rights.
0022  *
0023  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0024  * copy of the source code appearing in this file ("Covered Code") an
0025  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0026  * base code distributed originally by Intel ("Original Intel Code") to copy,
0027  * make derivatives, distribute, use and display any portion of the Covered
0028  * Code in any form, with the right to sublicense such rights; and
0029  *
0030  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0031  * license (with the right to sublicense), under only those claims of Intel
0032  * patents that are infringed by the Original Intel Code, to make, use, sell,
0033  * offer to sell, and import the Covered Code and derivative works thereof
0034  * solely to the minimum extent necessary to exercise the above copyright
0035  * license, and in no event shall the patent license extend to any additions
0036  * to or modifications of the Original Intel Code.  No other license or right
0037  * is granted directly or by implication, estoppel or otherwise;
0038  *
0039  * The above copyright and patent license is granted only if the following
0040  * conditions are met:
0041  *
0042  * 3. Conditions
0043  *
0044  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0045  * Redistribution of source code of any substantial portion of the Covered
0046  * Code or modification with rights to further distribute source must include
0047  * the above Copyright Notice, the above License, this list of Conditions,
0048  * and the following Disclaimer and Export Compliance provision.  In addition,
0049  * Licensee must cause all Covered Code to which Licensee contributes to
0050  * contain a file documenting the changes Licensee made to create that Covered
0051  * Code and the date of any change.  Licensee must include in that file the
0052  * documentation of any changes made by any predecessor Licensee.  Licensee
0053  * must include a prominent statement that the modification is derived,
0054  * directly or indirectly, from Original Intel Code.
0055  *
0056  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0057  * Redistribution of source code of any substantial portion of the Covered
0058  * Code or modification without rights to further distribute source must
0059  * include the following Disclaimer and Export Compliance provision in the
0060  * documentation and/or other materials provided with distribution.  In
0061  * addition, Licensee may not authorize further sublicense of source of any
0062  * portion of the Covered Code, and must include terms to the effect that the
0063  * license from Licensee to its licensee is limited to the intellectual
0064  * property embodied in the software Licensee provides to its licensee, and
0065  * not to intellectual property embodied in modifications its licensee may
0066  * make.
0067  *
0068  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0069  * substantial portion of the Covered Code or modification must reproduce the
0070  * above Copyright Notice, and the following Disclaimer and Export Compliance
0071  * provision in the documentation and/or other materials provided with the
0072  * distribution.
0073  *
0074  * 3.4. Intel retains all right, title, and interest in and to the Original
0075  * Intel Code.
0076  *
0077  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0078  * Intel shall be used in advertising or otherwise to promote the sale, use or
0079  * other dealings in products derived from or relating to the Covered Code
0080  * without prior written authorization from Intel.
0081  *
0082  * 4. Disclaimer and Export Compliance
0083  *
0084  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0085  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0086  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
0087  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
0088  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
0089  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0090  * PARTICULAR PURPOSE.
0091  *
0092  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0093  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0094  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0095  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0096  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0097  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
0098  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0099  * LIMITED REMEDY.
0100  *
0101  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0102  * software or system incorporating such software without first obtaining any
0103  * required license or other approval from the U. S. Department of Commerce or
0104  * any other agency or department of the United States Government.  In the
0105  * event Licensee exports any such software from the United States or
0106  * re-exports any such software from a foreign destination, Licensee shall
0107  * ensure that the distribution and export/re-export of the software is in
0108  * compliance with all laws, regulations, orders, or other restrictions of the
0109  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0110  * any of its subsidiaries will export/re-export any technical data, process,
0111  * software, or service, directly or indirectly, to any country for which the
0112  * United States government or any agency thereof requires an export license,
0113  * other governmental approval, or letter of assurance, without first obtaining
0114  * such license, approval or letter.
0115  *
0116  *****************************************************************************/
0117 
0118 #define __EXSTOREN_C__
0119 
0120 #include "acpi.h"
0121 #include "accommon.h"
0122 #include "acinterp.h"
0123 #include "amlcode.h"
0124 
0125 
0126 #define _COMPONENT          ACPI_EXECUTER
0127         ACPI_MODULE_NAME    ("exstoren")
0128 
0129 
0130 /*******************************************************************************
0131  *
0132  * FUNCTION:    AcpiExResolveObject
0133  *
0134  * PARAMETERS:  SourceDescPtr       - Pointer to the source object
0135  *              TargetType          - Current type of the target
0136  *              WalkState           - Current walk state
0137  *
0138  * RETURN:      Status, resolved object in SourceDescPtr.
0139  *
0140  * DESCRIPTION: Resolve an object.  If the object is a reference, dereference
0141  *              it and return the actual object in the SourceDescPtr.
0142  *
0143  ******************************************************************************/
0144 
0145 ACPI_STATUS
0146 AcpiExResolveObject (
0147     ACPI_OPERAND_OBJECT     **SourceDescPtr,
0148     ACPI_OBJECT_TYPE        TargetType,
0149     ACPI_WALK_STATE         *WalkState)
0150 {
0151     ACPI_OPERAND_OBJECT     *SourceDesc = *SourceDescPtr;
0152     ACPI_STATUS             Status = AE_OK;
0153 
0154 
0155     ACPI_FUNCTION_TRACE (ExResolveObject);
0156 
0157 
0158     /* Ensure we have a Target that can be stored to */
0159 
0160     switch (TargetType)
0161     {
0162     case ACPI_TYPE_BUFFER_FIELD:
0163     case ACPI_TYPE_LOCAL_REGION_FIELD:
0164     case ACPI_TYPE_LOCAL_BANK_FIELD:
0165     case ACPI_TYPE_LOCAL_INDEX_FIELD:
0166         /*
0167          * These cases all require only Integers or values that
0168          * can be converted to Integers (Strings or Buffers)
0169          */
0170 
0171     case ACPI_TYPE_INTEGER:
0172     case ACPI_TYPE_STRING:
0173     case ACPI_TYPE_BUFFER:
0174 
0175         /*
0176          * Stores into a Field/Region or into a Integer/Buffer/String
0177          * are all essentially the same.  This case handles the
0178          * "interchangeable" types Integer, String, and Buffer.
0179          */
0180         if (SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE)
0181         {
0182             /* Resolve a reference object first */
0183 
0184             Status = AcpiExResolveToValue (SourceDescPtr, WalkState);
0185             if (ACPI_FAILURE (Status))
0186             {
0187                 break;
0188             }
0189         }
0190 
0191         /* For CopyObject, no further validation necessary */
0192 
0193         if (WalkState->Opcode == AML_COPY_OP)
0194         {
0195             break;
0196         }
0197 
0198         /* Must have a Integer, Buffer, or String */
0199 
0200         if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER)    &&
0201             (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)     &&
0202             (SourceDesc->Common.Type != ACPI_TYPE_STRING)     &&
0203             !((SourceDesc->Common.Type == ACPI_TYPE_LOCAL_REFERENCE) &&
0204                     (SourceDesc->Reference.Class== ACPI_REFCLASS_TABLE)))
0205         {
0206             /* Conversion successful but still not a valid type */
0207 
0208             ACPI_ERROR ((AE_INFO,
0209                 "Cannot assign type %s to %s (must be type Int/Str/Buf)",
0210                 AcpiUtGetObjectTypeName (SourceDesc),
0211                 AcpiUtGetTypeName (TargetType)));
0212             Status = AE_AML_OPERAND_TYPE;
0213         }
0214         break;
0215 
0216 
0217     case ACPI_TYPE_LOCAL_ALIAS:
0218     case ACPI_TYPE_LOCAL_METHOD_ALIAS:
0219 
0220         /*
0221          * All aliases should have been resolved earlier, during the
0222          * operand resolution phase.
0223          */
0224         ACPI_ERROR ((AE_INFO, "Store into an unresolved Alias object"));
0225         Status = AE_AML_INTERNAL;
0226         break;
0227 
0228 
0229     case ACPI_TYPE_PACKAGE:
0230     default:
0231 
0232         /*
0233          * All other types than Alias and the various Fields come here,
0234          * including the untyped case - ACPI_TYPE_ANY.
0235          */
0236         break;
0237     }
0238 
0239     return_ACPI_STATUS (Status);
0240 }
0241 
0242 
0243 /*******************************************************************************
0244  *
0245  * FUNCTION:    AcpiExStoreObjectToObject
0246  *
0247  * PARAMETERS:  SourceDesc          - Object to store
0248  *              DestDesc            - Object to receive a copy of the source
0249  *              NewDesc             - New object if DestDesc is obsoleted
0250  *              WalkState           - Current walk state
0251  *
0252  * RETURN:      Status
0253  *
0254  * DESCRIPTION: "Store" an object to another object.  This may include
0255  *              converting the source type to the target type (implicit
0256  *              conversion), and a copy of the value of the source to
0257  *              the target.
0258  *
0259  *              The Assignment of an object to another (not named) object
0260  *              is handled here.
0261  *              The Source passed in will replace the current value (if any)
0262  *              with the input value.
0263  *
0264  *              When storing into an object the data is converted to the
0265  *              target object type then stored in the object.  This means
0266  *              that the target object type (for an initialized target) will
0267  *              not be changed by a store operation.
0268  *
0269  *              This module allows destination types of Number, String,
0270  *              Buffer, and Package.
0271  *
0272  *              Assumes parameters are already validated.  NOTE: SourceDesc
0273  *              resolution (from a reference object) must be performed by
0274  *              the caller if necessary.
0275  *
0276  ******************************************************************************/
0277 
0278 ACPI_STATUS
0279 AcpiExStoreObjectToObject (
0280     ACPI_OPERAND_OBJECT     *SourceDesc,
0281     ACPI_OPERAND_OBJECT     *DestDesc,
0282     ACPI_OPERAND_OBJECT     **NewDesc,
0283     ACPI_WALK_STATE         *WalkState)
0284 {
0285     ACPI_OPERAND_OBJECT     *ActualSrcDesc;
0286     ACPI_STATUS             Status = AE_OK;
0287 
0288 
0289     ACPI_FUNCTION_TRACE_PTR (ExStoreObjectToObject, SourceDesc);
0290 
0291 
0292     ActualSrcDesc = SourceDesc;
0293     if (!DestDesc)
0294     {
0295         /*
0296          * There is no destination object (An uninitialized node or
0297          * package element), so we can simply copy the source object
0298          * creating a new destination object
0299          */
0300         Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, NewDesc, WalkState);
0301         return_ACPI_STATUS (Status);
0302     }
0303 
0304     if (SourceDesc->Common.Type != DestDesc->Common.Type)
0305     {
0306         /*
0307          * The source type does not match the type of the destination.
0308          * Perform the "implicit conversion" of the source to the current type
0309          * of the target as per the ACPI specification.
0310          *
0311          * If no conversion performed, ActualSrcDesc = SourceDesc.
0312          * Otherwise, ActualSrcDesc is a temporary object to hold the
0313          * converted object.
0314          */
0315         Status = AcpiExConvertToTargetType (DestDesc->Common.Type,
0316                         SourceDesc, &ActualSrcDesc, WalkState);
0317         if (ACPI_FAILURE (Status))
0318         {
0319             return_ACPI_STATUS (Status);
0320         }
0321 
0322         if (SourceDesc == ActualSrcDesc)
0323         {
0324             /*
0325              * No conversion was performed. Return the SourceDesc as the
0326              * new object.
0327              */
0328             *NewDesc = SourceDesc;
0329             return_ACPI_STATUS (AE_OK);
0330         }
0331     }
0332 
0333     /*
0334      * We now have two objects of identical types, and we can perform a
0335      * copy of the *value* of the source object.
0336      */
0337     switch (DestDesc->Common.Type)
0338     {
0339     case ACPI_TYPE_INTEGER:
0340 
0341         DestDesc->Integer.Value = ActualSrcDesc->Integer.Value;
0342 
0343         /* Truncate value if we are executing from a 32-bit ACPI table */
0344 
0345         AcpiExTruncateFor32bitTable (DestDesc);
0346         break;
0347 
0348     case ACPI_TYPE_STRING:
0349 
0350         Status = AcpiExStoreStringToString (ActualSrcDesc, DestDesc);
0351         break;
0352 
0353     case ACPI_TYPE_BUFFER:
0354 
0355         Status = AcpiExStoreBufferToBuffer (ActualSrcDesc, DestDesc);
0356         break;
0357 
0358     case ACPI_TYPE_PACKAGE:
0359 
0360         Status = AcpiUtCopyIobjectToIobject (ActualSrcDesc, &DestDesc,
0361                     WalkState);
0362         break;
0363 
0364     default:
0365         /*
0366          * All other types come here.
0367          */
0368         ACPI_WARNING ((AE_INFO, "Store into type %s not implemented",
0369             AcpiUtGetObjectTypeName (DestDesc)));
0370 
0371         Status = AE_NOT_IMPLEMENTED;
0372         break;
0373     }
0374 
0375     if (ActualSrcDesc != SourceDesc)
0376     {
0377         /* Delete the intermediate (temporary) source object */
0378 
0379         AcpiUtRemoveReference (ActualSrcDesc);
0380     }
0381 
0382     *NewDesc = DestDesc;
0383     return_ACPI_STATUS (Status);
0384 }
0385 
0386