Back to home page

Quest Cross Reference

 
 

    


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

0001 
0002 /******************************************************************************
0003  *
0004  * Module Name: exresnte - AML Interpreter object resolution
0005  *
0006  *****************************************************************************/
0007 
0008 /******************************************************************************
0009  *
0010  * 1. Copyright Notice
0011  *
0012  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
0013  * All rights reserved.
0014  *
0015  * 2. License
0016  *
0017  * 2.1. This is your license from Intel Corp. under its intellectual property
0018  * rights.  You may have additional license terms from the party that provided
0019  * you this software, covering your right to use that party's intellectual
0020  * property rights.
0021  *
0022  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0023  * copy of the source code appearing in this file ("Covered Code") an
0024  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0025  * base code distributed originally by Intel ("Original Intel Code") to copy,
0026  * make derivatives, distribute, use and display any portion of the Covered
0027  * Code in any form, with the right to sublicense such rights; and
0028  *
0029  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0030  * license (with the right to sublicense), under only those claims of Intel
0031  * patents that are infringed by the Original Intel Code, to make, use, sell,
0032  * offer to sell, and import the Covered Code and derivative works thereof
0033  * solely to the minimum extent necessary to exercise the above copyright
0034  * license, and in no event shall the patent license extend to any additions
0035  * to or modifications of the Original Intel Code.  No other license or right
0036  * is granted directly or by implication, estoppel or otherwise;
0037  *
0038  * The above copyright and patent license is granted only if the following
0039  * conditions are met:
0040  *
0041  * 3. Conditions
0042  *
0043  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0044  * Redistribution of source code of any substantial portion of the Covered
0045  * Code or modification with rights to further distribute source must include
0046  * the above Copyright Notice, the above License, this list of Conditions,
0047  * and the following Disclaimer and Export Compliance provision.  In addition,
0048  * Licensee must cause all Covered Code to which Licensee contributes to
0049  * contain a file documenting the changes Licensee made to create that Covered
0050  * Code and the date of any change.  Licensee must include in that file the
0051  * documentation of any changes made by any predecessor Licensee.  Licensee
0052  * must include a prominent statement that the modification is derived,
0053  * directly or indirectly, from Original Intel Code.
0054  *
0055  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0056  * Redistribution of source code of any substantial portion of the Covered
0057  * Code or modification without rights to further distribute source must
0058  * include the following Disclaimer and Export Compliance provision in the
0059  * documentation and/or other materials provided with distribution.  In
0060  * addition, Licensee may not authorize further sublicense of source of any
0061  * portion of the Covered Code, and must include terms to the effect that the
0062  * license from Licensee to its licensee is limited to the intellectual
0063  * property embodied in the software Licensee provides to its licensee, and
0064  * not to intellectual property embodied in modifications its licensee may
0065  * make.
0066  *
0067  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0068  * substantial portion of the Covered Code or modification must reproduce the
0069  * above Copyright Notice, and the following Disclaimer and Export Compliance
0070  * provision in the documentation and/or other materials provided with the
0071  * distribution.
0072  *
0073  * 3.4. Intel retains all right, title, and interest in and to the Original
0074  * Intel Code.
0075  *
0076  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0077  * Intel shall be used in advertising or otherwise to promote the sale, use or
0078  * other dealings in products derived from or relating to the Covered Code
0079  * without prior written authorization from Intel.
0080  *
0081  * 4. Disclaimer and Export Compliance
0082  *
0083  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0084  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0085  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
0086  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
0087  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
0088  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0089  * PARTICULAR PURPOSE.
0090  *
0091  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0092  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0093  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0094  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0095  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0096  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
0097  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0098  * LIMITED REMEDY.
0099  *
0100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0101  * software or system incorporating such software without first obtaining any
0102  * required license or other approval from the U. S. Department of Commerce or
0103  * any other agency or department of the United States Government.  In the
0104  * event Licensee exports any such software from the United States or
0105  * re-exports any such software from a foreign destination, Licensee shall
0106  * ensure that the distribution and export/re-export of the software is in
0107  * compliance with all laws, regulations, orders, or other restrictions of the
0108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0109  * any of its subsidiaries will export/re-export any technical data, process,
0110  * software, or service, directly or indirectly, to any country for which the
0111  * United States government or any agency thereof requires an export license,
0112  * other governmental approval, or letter of assurance, without first obtaining
0113  * such license, approval or letter.
0114  *
0115  *****************************************************************************/
0116 
0117 #define __EXRESNTE_C__
0118 
0119 #include "acpi.h"
0120 #include "accommon.h"
0121 #include "acdispat.h"
0122 #include "acinterp.h"
0123 #include "acnamesp.h"
0124 
0125 
0126 #define _COMPONENT          ACPI_EXECUTER
0127         ACPI_MODULE_NAME    ("exresnte")
0128 
0129 
0130 /*******************************************************************************
0131  *
0132  * FUNCTION:    AcpiExResolveNodeToValue
0133  *
0134  * PARAMETERS:  ObjectPtr       - Pointer to a location that contains
0135  *                                a pointer to a NS node, and will receive a
0136  *                                pointer to the resolved object.
0137  *              WalkState       - Current state.  Valid only if executing AML
0138  *                                code.  NULL if simply resolving an object
0139  *
0140  * RETURN:      Status
0141  *
0142  * DESCRIPTION: Resolve a Namespace node to a valued object
0143  *
0144  * Note: for some of the data types, the pointer attached to the Node
0145  * can be either a pointer to an actual internal object or a pointer into the
0146  * AML stream itself.  These types are currently:
0147  *
0148  *      ACPI_TYPE_INTEGER
0149  *      ACPI_TYPE_STRING
0150  *      ACPI_TYPE_BUFFER
0151  *      ACPI_TYPE_MUTEX
0152  *      ACPI_TYPE_PACKAGE
0153  *
0154  ******************************************************************************/
0155 
0156 ACPI_STATUS
0157 AcpiExResolveNodeToValue (
0158     ACPI_NAMESPACE_NODE     **ObjectPtr,
0159     ACPI_WALK_STATE         *WalkState)
0160 
0161 {
0162     ACPI_STATUS             Status = AE_OK;
0163     ACPI_OPERAND_OBJECT     *SourceDesc;
0164     ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
0165     ACPI_NAMESPACE_NODE     *Node;
0166     ACPI_OBJECT_TYPE        EntryType;
0167 
0168 
0169     ACPI_FUNCTION_TRACE (ExResolveNodeToValue);
0170 
0171 
0172     /*
0173      * The stack pointer points to a ACPI_NAMESPACE_NODE (Node).  Get the
0174      * object that is attached to the Node.
0175      */
0176     Node       = *ObjectPtr;
0177     SourceDesc = AcpiNsGetAttachedObject (Node);
0178     EntryType  = AcpiNsGetType ((ACPI_HANDLE) Node);
0179 
0180     ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
0181          Node, SourceDesc, AcpiUtGetTypeName (EntryType)));
0182 
0183     if ((EntryType == ACPI_TYPE_LOCAL_ALIAS) ||
0184         (EntryType == ACPI_TYPE_LOCAL_METHOD_ALIAS))
0185     {
0186         /* There is always exactly one level of indirection */
0187 
0188         Node       = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Node->Object);
0189         SourceDesc = AcpiNsGetAttachedObject (Node);
0190         EntryType  = AcpiNsGetType ((ACPI_HANDLE) Node);
0191         *ObjectPtr = Node;
0192     }
0193 
0194     /*
0195      * Several object types require no further processing:
0196      * 1) Device/Thermal objects don't have a "real" subobject, return the Node
0197      * 2) Method locals and arguments have a pseudo-Node
0198      * 3) 10/2007: Added method type to assist with Package construction.
0199      */
0200     if ((EntryType == ACPI_TYPE_DEVICE)  ||
0201         (EntryType == ACPI_TYPE_THERMAL) ||
0202         (EntryType == ACPI_TYPE_METHOD)  ||
0203         (Node->Flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL)))
0204     {
0205         return_ACPI_STATUS (AE_OK);
0206     }
0207 
0208     if (!SourceDesc)
0209     {
0210         ACPI_ERROR ((AE_INFO, "No object attached to node %p",
0211             Node));
0212         return_ACPI_STATUS (AE_AML_NO_OPERAND);
0213     }
0214 
0215     /*
0216      * Action is based on the type of the Node, which indicates the type
0217      * of the attached object or pointer
0218      */
0219     switch (EntryType)
0220     {
0221     case ACPI_TYPE_PACKAGE:
0222 
0223         if (SourceDesc->Common.Type != ACPI_TYPE_PACKAGE)
0224         {
0225             ACPI_ERROR ((AE_INFO, "Object not a Package, type %s",
0226                 AcpiUtGetObjectTypeName (SourceDesc)));
0227             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
0228         }
0229 
0230         Status = AcpiDsGetPackageArguments (SourceDesc);
0231         if (ACPI_SUCCESS (Status))
0232         {
0233             /* Return an additional reference to the object */
0234 
0235             ObjDesc = SourceDesc;
0236             AcpiUtAddReference (ObjDesc);
0237         }
0238         break;
0239 
0240 
0241     case ACPI_TYPE_BUFFER:
0242 
0243         if (SourceDesc->Common.Type != ACPI_TYPE_BUFFER)
0244         {
0245             ACPI_ERROR ((AE_INFO, "Object not a Buffer, type %s",
0246                 AcpiUtGetObjectTypeName (SourceDesc)));
0247             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
0248         }
0249 
0250         Status = AcpiDsGetBufferArguments (SourceDesc);
0251         if (ACPI_SUCCESS (Status))
0252         {
0253             /* Return an additional reference to the object */
0254 
0255             ObjDesc = SourceDesc;
0256             AcpiUtAddReference (ObjDesc);
0257         }
0258         break;
0259 
0260 
0261     case ACPI_TYPE_STRING:
0262 
0263         if (SourceDesc->Common.Type != ACPI_TYPE_STRING)
0264         {
0265             ACPI_ERROR ((AE_INFO, "Object not a String, type %s",
0266                 AcpiUtGetObjectTypeName (SourceDesc)));
0267             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
0268         }
0269 
0270         /* Return an additional reference to the object */
0271 
0272         ObjDesc = SourceDesc;
0273         AcpiUtAddReference (ObjDesc);
0274         break;
0275 
0276 
0277     case ACPI_TYPE_INTEGER:
0278 
0279         if (SourceDesc->Common.Type != ACPI_TYPE_INTEGER)
0280         {
0281             ACPI_ERROR ((AE_INFO, "Object not a Integer, type %s",
0282                 AcpiUtGetObjectTypeName (SourceDesc)));
0283             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
0284         }
0285 
0286         /* Return an additional reference to the object */
0287 
0288         ObjDesc = SourceDesc;
0289         AcpiUtAddReference (ObjDesc);
0290         break;
0291 
0292 
0293     case ACPI_TYPE_BUFFER_FIELD:
0294     case ACPI_TYPE_LOCAL_REGION_FIELD:
0295     case ACPI_TYPE_LOCAL_BANK_FIELD:
0296     case ACPI_TYPE_LOCAL_INDEX_FIELD:
0297 
0298         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
0299             "FieldRead Node=%p SourceDesc=%p Type=%X\n",
0300             Node, SourceDesc, EntryType));
0301 
0302         Status = AcpiExReadDataFromField (WalkState, SourceDesc, &ObjDesc);
0303         break;
0304 
0305     /* For these objects, just return the object attached to the Node */
0306 
0307     case ACPI_TYPE_MUTEX:
0308     case ACPI_TYPE_POWER:
0309     case ACPI_TYPE_PROCESSOR:
0310     case ACPI_TYPE_EVENT:
0311     case ACPI_TYPE_REGION:
0312 
0313         /* Return an additional reference to the object */
0314 
0315         ObjDesc = SourceDesc;
0316         AcpiUtAddReference (ObjDesc);
0317         break;
0318 
0319     /* TYPE_ANY is untyped, and thus there is no object associated with it */
0320 
0321     case ACPI_TYPE_ANY:
0322 
0323         ACPI_ERROR ((AE_INFO,
0324             "Untyped entry %p, no attached object!", Node));
0325 
0326         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);  /* Cannot be AE_TYPE */
0327 
0328 
0329     case ACPI_TYPE_LOCAL_REFERENCE:
0330 
0331         switch (SourceDesc->Reference.Class)
0332         {
0333         case ACPI_REFCLASS_TABLE:   /* This is a DdbHandle */
0334         case ACPI_REFCLASS_REFOF:
0335         case ACPI_REFCLASS_INDEX:
0336 
0337             /* Return an additional reference to the object */
0338 
0339             ObjDesc = SourceDesc;
0340             AcpiUtAddReference (ObjDesc);
0341             break;
0342 
0343         default:
0344             /* No named references are allowed here */
0345 
0346             ACPI_ERROR ((AE_INFO,
0347                 "Unsupported Reference type %X",
0348                 SourceDesc->Reference.Class));
0349 
0350             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
0351         }
0352         break;
0353 
0354 
0355     default:
0356 
0357         /* Default case is for unknown types */
0358 
0359         ACPI_ERROR ((AE_INFO,
0360             "Node %p - Unknown object type %X",
0361             Node, EntryType));
0362 
0363         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
0364 
0365     } /* switch (EntryType) */
0366 
0367 
0368     /* Return the object descriptor */
0369 
0370     *ObjectPtr = (void *) ObjDesc;
0371     return_ACPI_STATUS (Status);
0372 }
0373 
0374