Back to home page

Quest Cross Reference

 
 

    


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

0001 /******************************************************************************
0002  *
0003  * Module Name: uteval - Object evaluation
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights.  You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code.  No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision.  In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change.  Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee.  Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution.  In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government.  In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************/
0115 
0116 #define __UTEVAL_C__
0117 
0118 #include "acpi.h"
0119 #include "accommon.h"
0120 #include "acnamesp.h"
0121 
0122 
0123 #define _COMPONENT          ACPI_UTILITIES
0124         ACPI_MODULE_NAME    ("uteval")
0125 
0126 
0127 /*
0128  * Strings supported by the _OSI predefined (internal) method.
0129  *
0130  * March 2009: Removed "Linux" as this host no longer wants to respond true
0131  * for this string. Basically, the only safe OS strings are windows-related
0132  * and in many or most cases represent the only test path within the
0133  * BIOS-provided ASL code.
0134  *
0135  * The second element of each entry is used to track the newest version of
0136  * Windows that the BIOS has requested.
0137  */
0138 static const ACPI_INTERFACE_INFO    AcpiInterfacesSupported[] =
0139 {
0140     /* Operating System Vendor Strings */
0141 
0142     {"Windows 2000",        ACPI_OSI_WIN_2000},         /* Windows 2000 */
0143     {"Windows 2001",        ACPI_OSI_WIN_XP},           /* Windows XP */
0144     {"Windows 2001 SP1",    ACPI_OSI_WIN_XP_SP1},       /* Windows XP SP1 */
0145     {"Windows 2001.1",      ACPI_OSI_WINSRV_2003},      /* Windows Server 2003 */
0146     {"Windows 2001 SP2",    ACPI_OSI_WIN_XP_SP2},       /* Windows XP SP2 */
0147     {"Windows 2001.1 SP1",  ACPI_OSI_WINSRV_2003_SP1},  /* Windows Server 2003 SP1 - Added 03/2006 */
0148     {"Windows 2006",        ACPI_OSI_WIN_VISTA},        /* Windows Vista - Added 03/2006 */
0149 
0150     /* Feature Group Strings */
0151 
0152     {"Extended Address Space Descriptor", 0}
0153 
0154     /*
0155      * All "optional" feature group strings (features that are implemented
0156      * by the host) should be implemented in the host version of
0157      * AcpiOsValidateInterface and should not be added here.
0158      */
0159 };
0160 
0161 
0162 /*******************************************************************************
0163  *
0164  * FUNCTION:    AcpiUtOsiImplementation
0165  *
0166  * PARAMETERS:  WalkState           - Current walk state
0167  *
0168  * RETURN:      Status
0169  *
0170  * DESCRIPTION: Implementation of the _OSI predefined control method
0171  *
0172  ******************************************************************************/
0173 
0174 ACPI_STATUS
0175 AcpiUtOsiImplementation (
0176     ACPI_WALK_STATE         *WalkState)
0177 {
0178     ACPI_STATUS             Status;
0179     ACPI_OPERAND_OBJECT     *StringDesc;
0180     ACPI_OPERAND_OBJECT     *ReturnDesc;
0181     UINT32                  ReturnValue;
0182     UINT32                  i;
0183 
0184 
0185     ACPI_FUNCTION_TRACE (UtOsiImplementation);
0186 
0187 
0188     /* Validate the string input argument */
0189 
0190     StringDesc = WalkState->Arguments[0].Object;
0191     if (!StringDesc || (StringDesc->Common.Type != ACPI_TYPE_STRING))
0192     {
0193         return_ACPI_STATUS (AE_TYPE);
0194     }
0195 
0196     /* Create a return object */
0197 
0198     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
0199     if (!ReturnDesc)
0200     {
0201         return_ACPI_STATUS (AE_NO_MEMORY);
0202     }
0203 
0204     /* Default return value is 0, NOT SUPPORTED */
0205 
0206     ReturnValue = 0;
0207 
0208     /* Compare input string to static table of supported interfaces */
0209 
0210     for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiInterfacesSupported); i++)
0211     {
0212         if (!ACPI_STRCMP (StringDesc->String.Pointer,
0213                 AcpiInterfacesSupported[i].Name))
0214         {
0215             /*
0216              * The interface is supported.
0217              * Update the OsiData if necessary. We keep track of the latest
0218              * version of Windows that has been requested by the BIOS.
0219              */
0220             if (AcpiInterfacesSupported[i].Value > AcpiGbl_OsiData)
0221             {
0222                 AcpiGbl_OsiData = AcpiInterfacesSupported[i].Value;
0223             }
0224 
0225             ReturnValue = ACPI_UINT32_MAX;
0226             goto Exit;
0227         }
0228     }
0229 
0230     /*
0231      * Did not match the string in the static table, call the host OSL to
0232      * check for a match with one of the optional strings (such as
0233      * "Module Device", "3.0 Thermal Model", etc.)
0234      */
0235     Status = AcpiOsValidateInterface (StringDesc->String.Pointer);
0236     if (ACPI_SUCCESS (Status))
0237     {
0238         /* The interface is supported */
0239 
0240         ReturnValue = ACPI_UINT32_MAX;
0241     }
0242 
0243 
0244 Exit:
0245     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
0246         "ACPI: BIOS _OSI(%s) is %ssupported\n",
0247         StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
0248 
0249     /* Complete the return value */
0250 
0251     ReturnDesc->Integer.Value = ReturnValue;
0252     WalkState->ReturnDesc = ReturnDesc;
0253     return_ACPI_STATUS (AE_OK);
0254 }
0255 
0256 
0257 /*******************************************************************************
0258  *
0259  * FUNCTION:    AcpiUtEvaluateObject
0260  *
0261  * PARAMETERS:  PrefixNode          - Starting node
0262  *              Path                - Path to object from starting node
0263  *              ExpectedReturnTypes - Bitmap of allowed return types
0264  *              ReturnDesc          - Where a return value is stored
0265  *
0266  * RETURN:      Status
0267  *
0268  * DESCRIPTION: Evaluates a namespace object and verifies the type of the
0269  *              return object. Common code that simplifies accessing objects
0270  *              that have required return objects of fixed types.
0271  *
0272  *              NOTE: Internal function, no parameter validation
0273  *
0274  ******************************************************************************/
0275 
0276 ACPI_STATUS
0277 AcpiUtEvaluateObject (
0278     ACPI_NAMESPACE_NODE     *PrefixNode,
0279     char                    *Path,
0280     UINT32                  ExpectedReturnBtypes,
0281     ACPI_OPERAND_OBJECT     **ReturnDesc)
0282 {
0283     ACPI_EVALUATE_INFO      *Info;
0284     ACPI_STATUS             Status;
0285     UINT32                  ReturnBtype;
0286 
0287 
0288     ACPI_FUNCTION_TRACE (UtEvaluateObject);
0289 
0290 
0291     /* Allocate the evaluation information block */
0292 
0293     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
0294     if (!Info)
0295     {
0296         return_ACPI_STATUS (AE_NO_MEMORY);
0297     }
0298 
0299     Info->PrefixNode = PrefixNode;
0300     Info->Pathname = Path;
0301 
0302     /* Evaluate the object/method */
0303 
0304     Status = AcpiNsEvaluate (Info);
0305     if (ACPI_FAILURE (Status))
0306     {
0307         if (Status == AE_NOT_FOUND)
0308         {
0309             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
0310                 AcpiUtGetNodeName (PrefixNode), Path));
0311         }
0312         else
0313         {
0314             ACPI_ERROR_METHOD ("Method execution failed",
0315                 PrefixNode, Path, Status);
0316         }
0317 
0318         goto Cleanup;
0319     }
0320 
0321     /* Did we get a return object? */
0322 
0323     if (!Info->ReturnObject)
0324     {
0325         if (ExpectedReturnBtypes)
0326         {
0327             ACPI_ERROR_METHOD ("No object was returned from",
0328                 PrefixNode, Path, AE_NOT_EXIST);
0329 
0330             Status = AE_NOT_EXIST;
0331         }
0332 
0333         goto Cleanup;
0334     }
0335 
0336     /* Map the return object type to the bitmapped type */
0337 
0338     switch ((Info->ReturnObject)->Common.Type)
0339     {
0340     case ACPI_TYPE_INTEGER:
0341         ReturnBtype = ACPI_BTYPE_INTEGER;
0342         break;
0343 
0344     case ACPI_TYPE_BUFFER:
0345         ReturnBtype = ACPI_BTYPE_BUFFER;
0346         break;
0347 
0348     case ACPI_TYPE_STRING:
0349         ReturnBtype = ACPI_BTYPE_STRING;
0350         break;
0351 
0352     case ACPI_TYPE_PACKAGE:
0353         ReturnBtype = ACPI_BTYPE_PACKAGE;
0354         break;
0355 
0356     default:
0357         ReturnBtype = 0;
0358         break;
0359     }
0360 
0361     if ((AcpiGbl_EnableInterpreterSlack) &&
0362         (!ExpectedReturnBtypes))
0363     {
0364         /*
0365          * We received a return object, but one was not expected. This can
0366          * happen frequently if the "implicit return" feature is enabled.
0367          * Just delete the return object and return AE_OK.
0368          */
0369         AcpiUtRemoveReference (Info->ReturnObject);
0370         goto Cleanup;
0371     }
0372 
0373     /* Is the return object one of the expected types? */
0374 
0375     if (!(ExpectedReturnBtypes & ReturnBtype))
0376     {
0377         ACPI_ERROR_METHOD ("Return object type is incorrect",
0378             PrefixNode, Path, AE_TYPE);
0379 
0380         ACPI_ERROR ((AE_INFO,
0381             "Type returned from %s was incorrect: %s, expected Btypes: %X",
0382             Path, AcpiUtGetObjectTypeName (Info->ReturnObject),
0383             ExpectedReturnBtypes));
0384 
0385         /* On error exit, we must delete the return object */
0386 
0387         AcpiUtRemoveReference (Info->ReturnObject);
0388         Status = AE_TYPE;
0389         goto Cleanup;
0390     }
0391 
0392     /* Object type is OK, return it */
0393 
0394     *ReturnDesc = Info->ReturnObject;
0395 
0396 Cleanup:
0397     ACPI_FREE (Info);
0398     return_ACPI_STATUS (Status);
0399 }
0400 
0401 
0402 /*******************************************************************************
0403  *
0404  * FUNCTION:    AcpiUtEvaluateNumericObject
0405  *
0406  * PARAMETERS:  ObjectName          - Object name to be evaluated
0407  *              DeviceNode          - Node for the device
0408  *              Value               - Where the value is returned
0409  *
0410  * RETURN:      Status
0411  *
0412  * DESCRIPTION: Evaluates a numeric namespace object for a selected device
0413  *              and stores result in *Value.
0414  *
0415  *              NOTE: Internal function, no parameter validation
0416  *
0417  ******************************************************************************/
0418 
0419 ACPI_STATUS
0420 AcpiUtEvaluateNumericObject (
0421     char                    *ObjectName,
0422     ACPI_NAMESPACE_NODE     *DeviceNode,
0423     ACPI_INTEGER            *Value)
0424 {
0425     ACPI_OPERAND_OBJECT     *ObjDesc;
0426     ACPI_STATUS             Status;
0427 
0428 
0429     ACPI_FUNCTION_TRACE (UtEvaluateNumericObject);
0430 
0431 
0432     Status = AcpiUtEvaluateObject (DeviceNode, ObjectName,
0433                 ACPI_BTYPE_INTEGER, &ObjDesc);
0434     if (ACPI_FAILURE (Status))
0435     {
0436         return_ACPI_STATUS (Status);
0437     }
0438 
0439     /* Get the returned Integer */
0440 
0441     *Value = ObjDesc->Integer.Value;
0442 
0443     /* On exit, we must delete the return object */
0444 
0445     AcpiUtRemoveReference (ObjDesc);
0446     return_ACPI_STATUS (Status);
0447 }
0448 
0449 
0450 /*******************************************************************************
0451  *
0452  * FUNCTION:    AcpiUtExecute_STA
0453  *
0454  * PARAMETERS:  DeviceNode          - Node for the device
0455  *              Flags               - Where the status flags are returned
0456  *
0457  * RETURN:      Status
0458  *
0459  * DESCRIPTION: Executes _STA for selected device and stores results in
0460  *              *Flags.
0461  *
0462  *              NOTE: Internal function, no parameter validation
0463  *
0464  ******************************************************************************/
0465 
0466 ACPI_STATUS
0467 AcpiUtExecute_STA (
0468     ACPI_NAMESPACE_NODE     *DeviceNode,
0469     UINT32                  *Flags)
0470 {
0471     ACPI_OPERAND_OBJECT     *ObjDesc;
0472     ACPI_STATUS             Status;
0473 
0474 
0475     ACPI_FUNCTION_TRACE (UtExecute_STA);
0476 
0477 
0478     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
0479                 ACPI_BTYPE_INTEGER, &ObjDesc);
0480     if (ACPI_FAILURE (Status))
0481     {
0482         if (AE_NOT_FOUND == Status)
0483         {
0484             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
0485                 "_STA on %4.4s was not found, assuming device is present\n",
0486                 AcpiUtGetNodeName (DeviceNode)));
0487 
0488             *Flags = ACPI_UINT32_MAX;
0489             Status = AE_OK;
0490         }
0491 
0492         return_ACPI_STATUS (Status);
0493     }
0494 
0495     /* Extract the status flags */
0496 
0497     *Flags = (UINT32) ObjDesc->Integer.Value;
0498 
0499     /* On exit, we must delete the return object */
0500 
0501     AcpiUtRemoveReference (ObjDesc);
0502     return_ACPI_STATUS (Status);
0503 }
0504 
0505 
0506 /*******************************************************************************
0507  *
0508  * FUNCTION:    AcpiUtExecutePowerMethods
0509  *
0510  * PARAMETERS:  DeviceNode          - Node for the device
0511  *              MethodNames         - Array of power method names
0512  *              MethodCount         - Number of methods to execute
0513  *              OutValues           - Where the power method values are returned
0514  *
0515  * RETURN:      Status, OutValues
0516  *
0517  * DESCRIPTION: Executes the specified power methods for the device and returns
0518  *              the result(s).
0519  *
0520  *              NOTE: Internal function, no parameter validation
0521  *
0522  ******************************************************************************/
0523 
0524 ACPI_STATUS
0525 AcpiUtExecutePowerMethods (
0526     ACPI_NAMESPACE_NODE     *DeviceNode,
0527     const char              **MethodNames,
0528     UINT8                   MethodCount,
0529     UINT8                   *OutValues)
0530 {
0531     ACPI_OPERAND_OBJECT     *ObjDesc;
0532     ACPI_STATUS             Status;
0533     ACPI_STATUS             FinalStatus = AE_NOT_FOUND;
0534     UINT32                  i;
0535 
0536 
0537     ACPI_FUNCTION_TRACE (UtExecutePowerMethods);
0538 
0539 
0540     for (i = 0; i < MethodCount; i++)
0541     {
0542         /*
0543          * Execute the power method (_SxD or _SxW). The only allowable
0544          * return type is an Integer.
0545          */
0546         Status = AcpiUtEvaluateObject (DeviceNode,
0547                     ACPI_CAST_PTR (char, MethodNames[i]),
0548                     ACPI_BTYPE_INTEGER, &ObjDesc);
0549         if (ACPI_SUCCESS (Status))
0550         {
0551             OutValues[i] = (UINT8) ObjDesc->Integer.Value;
0552 
0553             /* Delete the return object */
0554 
0555             AcpiUtRemoveReference (ObjDesc);
0556             FinalStatus = AE_OK;            /* At least one value is valid */
0557             continue;
0558         }
0559 
0560         OutValues[i] = ACPI_UINT8_MAX;
0561         if (Status == AE_NOT_FOUND)
0562         {
0563             continue; /* Ignore if not found */
0564         }
0565 
0566         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n",
0567             ACPI_CAST_PTR (char, MethodNames[i]),
0568             AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status)));
0569     }
0570 
0571     return_ACPI_STATUS (FinalStatus);
0572 }