13446Smrj /******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: uteval - Object evaluation
43446Smrj  *
53446Smrj  *****************************************************************************/
63446Smrj 
73446Smrj /******************************************************************************
83446Smrj  *
93446Smrj  * 1. Copyright Notice
103446Smrj  *
11*9980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj  * All rights reserved.
133446Smrj  *
143446Smrj  * 2. License
153446Smrj  *
163446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj  * rights.  You may have additional license terms from the party that provided
183446Smrj  * you this software, covering your right to use that party's intellectual
193446Smrj  * property rights.
203446Smrj  *
213446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj  * copy of the source code appearing in this file ("Covered Code") an
233446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj  * make derivatives, distribute, use and display any portion of the Covered
263446Smrj  * Code in any form, with the right to sublicense such rights; and
273446Smrj  *
283446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj  * license (with the right to sublicense), under only those claims of Intel
303446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj  * solely to the minimum extent necessary to exercise the above copyright
333446Smrj  * license, and in no event shall the patent license extend to any additions
343446Smrj  * to or modifications of the Original Intel Code.  No other license or right
353446Smrj  * is granted directly or by implication, estoppel or otherwise;
363446Smrj  *
373446Smrj  * The above copyright and patent license is granted only if the following
383446Smrj  * conditions are met:
393446Smrj  *
403446Smrj  * 3. Conditions
413446Smrj  *
423446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj  * Redistribution of source code of any substantial portion of the Covered
443446Smrj  * Code or modification with rights to further distribute source must include
453446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
473446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj  * contain a file documenting the changes Licensee made to create that Covered
493446Smrj  * Code and the date of any change.  Licensee must include in that file the
503446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
513446Smrj  * must include a prominent statement that the modification is derived,
523446Smrj  * directly or indirectly, from Original Intel Code.
533446Smrj  *
543446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj  * Redistribution of source code of any substantial portion of the Covered
563446Smrj  * Code or modification without rights to further distribute source must
573446Smrj  * include the following Disclaimer and Export Compliance provision in the
583446Smrj  * documentation and/or other materials provided with distribution.  In
593446Smrj  * addition, Licensee may not authorize further sublicense of source of any
603446Smrj  * portion of the Covered Code, and must include terms to the effect that the
613446Smrj  * license from Licensee to its licensee is limited to the intellectual
623446Smrj  * property embodied in the software Licensee provides to its licensee, and
633446Smrj  * not to intellectual property embodied in modifications its licensee may
643446Smrj  * make.
653446Smrj  *
663446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj  * substantial portion of the Covered Code or modification must reproduce the
683446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj  * provision in the documentation and/or other materials provided with the
703446Smrj  * distribution.
713446Smrj  *
723446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj  * Intel Code.
743446Smrj  *
753446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj  * other dealings in products derived from or relating to the Covered Code
783446Smrj  * without prior written authorization from Intel.
793446Smrj  *
803446Smrj  * 4. Disclaimer and Export Compliance
813446Smrj  *
823446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
853446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
863446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj  * PARTICULAR PURPOSE.
893446Smrj  *
903446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
963446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj  * LIMITED REMEDY.
983446Smrj  *
993446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj  * software or system incorporating such software without first obtaining any
1013446Smrj  * required license or other approval from the U. S. Department of Commerce or
1023446Smrj  * any other agency or department of the United States Government.  In the
1033446Smrj  * event Licensee exports any such software from the United States or
1043446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj  * ensure that the distribution and export/re-export of the software is in
1063446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj  * software, or service, directly or indirectly, to any country for which the
1103446Smrj  * United States government or any agency thereof requires an export license,
1113446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj  * such license, approval or letter.
1133446Smrj  *
1143446Smrj  *****************************************************************************/
1153446Smrj 
1163446Smrj #define __UTEVAL_C__
1173446Smrj 
1183446Smrj #include "acpi.h"
119*9980SDana.Myers@Sun.COM #include "accommon.h"
1203446Smrj #include "acnamesp.h"
1213446Smrj #include "acinterp.h"
1223446Smrj 
1233446Smrj 
1243446Smrj #define _COMPONENT          ACPI_UTILITIES
1253446Smrj         ACPI_MODULE_NAME    ("uteval")
1263446Smrj 
1273446Smrj /* Local prototypes */
1283446Smrj 
1293446Smrj static void
1303446Smrj AcpiUtCopyIdString (
1313446Smrj     char                    *Destination,
1323446Smrj     char                    *Source,
1333446Smrj     ACPI_SIZE               MaxLength);
1343446Smrj 
1353446Smrj static ACPI_STATUS
1363446Smrj AcpiUtTranslateOneCid (
1373446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc,
1383446Smrj     ACPI_COMPATIBLE_ID      *OneCid);
1393446Smrj 
1403446Smrj 
1413446Smrj /*
1423446Smrj  * Strings supported by the _OSI predefined (internal) method.
143*9980SDana.Myers@Sun.COM  *
144*9980SDana.Myers@Sun.COM  * March 2009: Removed "Linux" as this host no longer wants to respond true
145*9980SDana.Myers@Sun.COM  * for this string. Basically, the only safe OS strings are windows-related
146*9980SDana.Myers@Sun.COM  * and in many or most cases represent the only test path within the
147*9980SDana.Myers@Sun.COM  * BIOS-provided ASL code.
148*9980SDana.Myers@Sun.COM  *
149*9980SDana.Myers@Sun.COM  * The second element of each entry is used to track the newest version of
150*9980SDana.Myers@Sun.COM  * Windows that the BIOS has requested.
1513446Smrj  */
152*9980SDana.Myers@Sun.COM static const ACPI_INTERFACE_INFO    AcpiInterfacesSupported[] =
1533446Smrj {
1543446Smrj     /* Operating System Vendor Strings */
1553446Smrj 
156*9980SDana.Myers@Sun.COM     {"Windows 2000",        ACPI_OSI_WIN_2000},         /* Windows 2000 */
157*9980SDana.Myers@Sun.COM     {"Windows 2001",        ACPI_OSI_WIN_XP},           /* Windows XP */
158*9980SDana.Myers@Sun.COM     {"Windows 2001 SP1",    ACPI_OSI_WIN_XP_SP1},       /* Windows XP SP1 */
159*9980SDana.Myers@Sun.COM     {"Windows 2001.1",      ACPI_OSI_WINSRV_2003},      /* Windows Server 2003 */
160*9980SDana.Myers@Sun.COM     {"Windows 2001 SP2",    ACPI_OSI_WIN_XP_SP2},       /* Windows XP SP2 */
161*9980SDana.Myers@Sun.COM     {"Windows 2001.1 SP1",  ACPI_OSI_WINSRV_2003_SP1},  /* Windows Server 2003 SP1 - Added 03/2006 */
162*9980SDana.Myers@Sun.COM     {"Windows 2006",        ACPI_OSI_WIN_VISTA},        /* Windows Vista - Added 03/2006 */
1633446Smrj 
1643446Smrj     /* Feature Group Strings */
1653446Smrj 
166*9980SDana.Myers@Sun.COM     {"Extended Address Space Descriptor", 0}
1673446Smrj 
1683446Smrj     /*
1693446Smrj      * All "optional" feature group strings (features that are implemented
1703446Smrj      * by the host) should be implemented in the host version of
1713446Smrj      * AcpiOsValidateInterface and should not be added here.
1723446Smrj      */
1733446Smrj };
1743446Smrj 
1753446Smrj 
1763446Smrj /*******************************************************************************
1773446Smrj  *
1783446Smrj  * FUNCTION:    AcpiUtOsiImplementation
1793446Smrj  *
1803446Smrj  * PARAMETERS:  WalkState           - Current walk state
1813446Smrj  *
1823446Smrj  * RETURN:      Status
1833446Smrj  *
1843446Smrj  * DESCRIPTION: Implementation of the _OSI predefined control method
1853446Smrj  *
1863446Smrj  ******************************************************************************/
1873446Smrj 
1883446Smrj ACPI_STATUS
1893446Smrj AcpiUtOsiImplementation (
1903446Smrj     ACPI_WALK_STATE         *WalkState)
1913446Smrj {
1923446Smrj     ACPI_STATUS             Status;
1933446Smrj     ACPI_OPERAND_OBJECT     *StringDesc;
1943446Smrj     ACPI_OPERAND_OBJECT     *ReturnDesc;
195*9980SDana.Myers@Sun.COM     UINT32                  ReturnValue;
1967851SDana.Myers@Sun.COM     UINT32                  i;
1973446Smrj 
1983446Smrj 
1993446Smrj     ACPI_FUNCTION_TRACE (UtOsiImplementation);
2003446Smrj 
2013446Smrj 
2023446Smrj     /* Validate the string input argument */
2033446Smrj 
2043446Smrj     StringDesc = WalkState->Arguments[0].Object;
2053446Smrj     if (!StringDesc || (StringDesc->Common.Type != ACPI_TYPE_STRING))
2063446Smrj     {
2073446Smrj         return_ACPI_STATUS (AE_TYPE);
2083446Smrj     }
2093446Smrj 
2103446Smrj     /* Create a return object */
2113446Smrj 
2123446Smrj     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
2133446Smrj     if (!ReturnDesc)
2143446Smrj     {
2153446Smrj         return_ACPI_STATUS (AE_NO_MEMORY);
2163446Smrj     }
2173446Smrj 
218*9980SDana.Myers@Sun.COM     /* Default return value is 0, NOT SUPPORTED */
2193446Smrj 
220*9980SDana.Myers@Sun.COM     ReturnValue = 0;
2213446Smrj 
2223446Smrj     /* Compare input string to static table of supported interfaces */
2233446Smrj 
2243446Smrj     for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiInterfacesSupported); i++)
2253446Smrj     {
226*9980SDana.Myers@Sun.COM         if (!ACPI_STRCMP (StringDesc->String.Pointer,
227*9980SDana.Myers@Sun.COM                 AcpiInterfacesSupported[i].Name))
2283446Smrj         {
229*9980SDana.Myers@Sun.COM             /*
230*9980SDana.Myers@Sun.COM              * The interface is supported.
231*9980SDana.Myers@Sun.COM              * Update the OsiData if necessary. We keep track of the latest
232*9980SDana.Myers@Sun.COM              * version of Windows that has been requested by the BIOS.
233*9980SDana.Myers@Sun.COM              */
234*9980SDana.Myers@Sun.COM             if (AcpiInterfacesSupported[i].Value > AcpiGbl_OsiData)
235*9980SDana.Myers@Sun.COM             {
236*9980SDana.Myers@Sun.COM                 AcpiGbl_OsiData = AcpiInterfacesSupported[i].Value;
237*9980SDana.Myers@Sun.COM             }
2383446Smrj 
239*9980SDana.Myers@Sun.COM             ReturnValue = ACPI_UINT32_MAX;
240*9980SDana.Myers@Sun.COM             goto Exit;
2413446Smrj         }
2423446Smrj     }
2433446Smrj 
2443446Smrj     /*
2453446Smrj      * Did not match the string in the static table, call the host OSL to
2463446Smrj      * check for a match with one of the optional strings (such as
2473446Smrj      * "Module Device", "3.0 Thermal Model", etc.)
2483446Smrj      */
2493446Smrj     Status = AcpiOsValidateInterface (StringDesc->String.Pointer);
2503446Smrj     if (ACPI_SUCCESS (Status))
2513446Smrj     {
2523446Smrj         /* The interface is supported */
2533446Smrj 
254*9980SDana.Myers@Sun.COM         ReturnValue = ACPI_UINT32_MAX;
2553446Smrj     }
2563446Smrj 
257*9980SDana.Myers@Sun.COM 
258*9980SDana.Myers@Sun.COM Exit:
259*9980SDana.Myers@Sun.COM     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
260*9980SDana.Myers@Sun.COM         "ACPI: BIOS _OSI(%s) is %ssupported\n",
261*9980SDana.Myers@Sun.COM         StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
2623446Smrj 
263*9980SDana.Myers@Sun.COM     /* Complete the return value */
264*9980SDana.Myers@Sun.COM 
265*9980SDana.Myers@Sun.COM     ReturnDesc->Integer.Value = ReturnValue;
266*9980SDana.Myers@Sun.COM     WalkState->ReturnDesc = ReturnDesc;
267*9980SDana.Myers@Sun.COM     return_ACPI_STATUS (AE_OK);
2683446Smrj }
2693446Smrj 
2703446Smrj 
2713446Smrj /*******************************************************************************
2723446Smrj  *
2733446Smrj  * FUNCTION:    AcpiUtEvaluateObject
2743446Smrj  *
2753446Smrj  * PARAMETERS:  PrefixNode          - Starting node
2763446Smrj  *              Path                - Path to object from starting node
2773446Smrj  *              ExpectedReturnTypes - Bitmap of allowed return types
2783446Smrj  *              ReturnDesc          - Where a return value is stored
2793446Smrj  *
2803446Smrj  * RETURN:      Status
2813446Smrj  *
2823446Smrj  * DESCRIPTION: Evaluates a namespace object and verifies the type of the
2833446Smrj  *              return object.  Common code that simplifies accessing objects
2843446Smrj  *              that have required return objects of fixed types.
2853446Smrj  *
2863446Smrj  *              NOTE: Internal function, no parameter validation
2873446Smrj  *
2883446Smrj  ******************************************************************************/
2893446Smrj 
2903446Smrj ACPI_STATUS
2913446Smrj AcpiUtEvaluateObject (
2923446Smrj     ACPI_NAMESPACE_NODE     *PrefixNode,
2933446Smrj     char                    *Path,
2943446Smrj     UINT32                  ExpectedReturnBtypes,
2953446Smrj     ACPI_OPERAND_OBJECT     **ReturnDesc)
2963446Smrj {
2973446Smrj     ACPI_EVALUATE_INFO      *Info;
2983446Smrj     ACPI_STATUS             Status;
2993446Smrj     UINT32                  ReturnBtype;
3003446Smrj 
3013446Smrj 
3023446Smrj     ACPI_FUNCTION_TRACE (UtEvaluateObject);
3033446Smrj 
3043446Smrj 
3053446Smrj     /* Allocate the evaluation information block */
3063446Smrj 
3073446Smrj     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
3083446Smrj     if (!Info)
3093446Smrj     {
3103446Smrj         return_ACPI_STATUS (AE_NO_MEMORY);
3113446Smrj     }
3123446Smrj 
3133446Smrj     Info->PrefixNode = PrefixNode;
3143446Smrj     Info->Pathname = Path;
3153446Smrj 
3163446Smrj     /* Evaluate the object/method */
3173446Smrj 
3183446Smrj     Status = AcpiNsEvaluate (Info);
3193446Smrj     if (ACPI_FAILURE (Status))
3203446Smrj     {
3213446Smrj         if (Status == AE_NOT_FOUND)
3223446Smrj         {
3233446Smrj             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
3243446Smrj                 AcpiUtGetNodeName (PrefixNode), Path));
3253446Smrj         }
3263446Smrj         else
3273446Smrj         {
3283446Smrj             ACPI_ERROR_METHOD ("Method execution failed",
3293446Smrj                 PrefixNode, Path, Status);
3303446Smrj         }
3313446Smrj 
3323446Smrj         goto Cleanup;
3333446Smrj     }
3343446Smrj 
3353446Smrj     /* Did we get a return object? */
3363446Smrj 
3373446Smrj     if (!Info->ReturnObject)
3383446Smrj     {
3393446Smrj         if (ExpectedReturnBtypes)
3403446Smrj         {
3413446Smrj             ACPI_ERROR_METHOD ("No object was returned from",
3423446Smrj                 PrefixNode, Path, AE_NOT_EXIST);
3433446Smrj 
3443446Smrj             Status = AE_NOT_EXIST;
3453446Smrj         }
3463446Smrj 
3473446Smrj         goto Cleanup;
3483446Smrj     }
3493446Smrj 
3503446Smrj     /* Map the return object type to the bitmapped type */
3513446Smrj 
352*9980SDana.Myers@Sun.COM     switch ((Info->ReturnObject)->Common.Type)
3533446Smrj     {
3543446Smrj     case ACPI_TYPE_INTEGER:
3553446Smrj         ReturnBtype = ACPI_BTYPE_INTEGER;
3563446Smrj         break;
3573446Smrj 
3583446Smrj     case ACPI_TYPE_BUFFER:
3593446Smrj         ReturnBtype = ACPI_BTYPE_BUFFER;
3603446Smrj         break;
3613446Smrj 
3623446Smrj     case ACPI_TYPE_STRING:
3633446Smrj         ReturnBtype = ACPI_BTYPE_STRING;
3643446Smrj         break;
3653446Smrj 
3663446Smrj     case ACPI_TYPE_PACKAGE:
3673446Smrj         ReturnBtype = ACPI_BTYPE_PACKAGE;
3683446Smrj         break;
3693446Smrj 
3703446Smrj     default:
3713446Smrj         ReturnBtype = 0;
3723446Smrj         break;
3733446Smrj     }
3743446Smrj 
3753446Smrj     if ((AcpiGbl_EnableInterpreterSlack) &&
3763446Smrj         (!ExpectedReturnBtypes))
3773446Smrj     {
3783446Smrj         /*
3793446Smrj          * We received a return object, but one was not expected.  This can
3803446Smrj          * happen frequently if the "implicit return" feature is enabled.
3813446Smrj          * Just delete the return object and return AE_OK.
3823446Smrj          */
3833446Smrj         AcpiUtRemoveReference (Info->ReturnObject);
3843446Smrj         goto Cleanup;
3853446Smrj     }
3863446Smrj 
3873446Smrj     /* Is the return object one of the expected types? */
3883446Smrj 
3893446Smrj     if (!(ExpectedReturnBtypes & ReturnBtype))
3903446Smrj     {
3913446Smrj         ACPI_ERROR_METHOD ("Return object type is incorrect",
3923446Smrj             PrefixNode, Path, AE_TYPE);
3933446Smrj 
3943446Smrj         ACPI_ERROR ((AE_INFO,
3953446Smrj             "Type returned from %s was incorrect: %s, expected Btypes: %X",
3963446Smrj             Path, AcpiUtGetObjectTypeName (Info->ReturnObject),
3973446Smrj             ExpectedReturnBtypes));
3983446Smrj 
3993446Smrj         /* On error exit, we must delete the return object */
4003446Smrj 
4013446Smrj         AcpiUtRemoveReference (Info->ReturnObject);
4023446Smrj         Status = AE_TYPE;
4033446Smrj         goto Cleanup;
4043446Smrj     }
4053446Smrj 
4063446Smrj     /* Object type is OK, return it */
4073446Smrj 
4083446Smrj     *ReturnDesc = Info->ReturnObject;
4093446Smrj 
4103446Smrj Cleanup:
4113446Smrj     ACPI_FREE (Info);
4123446Smrj     return_ACPI_STATUS (Status);
4133446Smrj }
4143446Smrj 
4153446Smrj 
4163446Smrj /*******************************************************************************
4173446Smrj  *
4183446Smrj  * FUNCTION:    AcpiUtEvaluateNumericObject
4193446Smrj  *
4203446Smrj  * PARAMETERS:  ObjectName          - Object name to be evaluated
4213446Smrj  *              DeviceNode          - Node for the device
4223446Smrj  *              Address             - Where the value is returned
4233446Smrj  *
4243446Smrj  * RETURN:      Status
4253446Smrj  *
4263446Smrj  * DESCRIPTION: Evaluates a numeric namespace object for a selected device
4273446Smrj  *              and stores result in *Address.
4283446Smrj  *
4293446Smrj  *              NOTE: Internal function, no parameter validation
4303446Smrj  *
4313446Smrj  ******************************************************************************/
4323446Smrj 
4333446Smrj ACPI_STATUS
4343446Smrj AcpiUtEvaluateNumericObject (
4353446Smrj     char                    *ObjectName,
4363446Smrj     ACPI_NAMESPACE_NODE     *DeviceNode,
4373446Smrj     ACPI_INTEGER            *Address)
4383446Smrj {
4393446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
4403446Smrj     ACPI_STATUS             Status;
4413446Smrj 
4423446Smrj 
4433446Smrj     ACPI_FUNCTION_TRACE (UtEvaluateNumericObject);
4443446Smrj 
4453446Smrj 
4463446Smrj     Status = AcpiUtEvaluateObject (DeviceNode, ObjectName,
4473446Smrj                 ACPI_BTYPE_INTEGER, &ObjDesc);
4483446Smrj     if (ACPI_FAILURE (Status))
4493446Smrj     {
4503446Smrj         return_ACPI_STATUS (Status);
4513446Smrj     }
4523446Smrj 
4533446Smrj     /* Get the returned Integer */
4543446Smrj 
4553446Smrj     *Address = ObjDesc->Integer.Value;
4563446Smrj 
4573446Smrj     /* On exit, we must delete the return object */
4583446Smrj 
4593446Smrj     AcpiUtRemoveReference (ObjDesc);
4603446Smrj     return_ACPI_STATUS (Status);
4613446Smrj }
4623446Smrj 
4633446Smrj 
4643446Smrj /*******************************************************************************
4653446Smrj  *
4663446Smrj  * FUNCTION:    AcpiUtCopyIdString
4673446Smrj  *
4683446Smrj  * PARAMETERS:  Destination         - Where to copy the string
4693446Smrj  *              Source              - Source string
4703446Smrj  *              MaxLength           - Length of the destination buffer
4713446Smrj  *
4723446Smrj  * RETURN:      None
4733446Smrj  *
4743446Smrj  * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods.
4753446Smrj  *              Performs removal of a leading asterisk if present -- workaround
4763446Smrj  *              for a known issue on a bunch of machines.
4773446Smrj  *
4783446Smrj  ******************************************************************************/
4793446Smrj 
4803446Smrj static void
4813446Smrj AcpiUtCopyIdString (
4823446Smrj     char                    *Destination,
4833446Smrj     char                    *Source,
4843446Smrj     ACPI_SIZE               MaxLength)
4853446Smrj {
4863446Smrj 
4873446Smrj     /*
4883446Smrj      * Workaround for ID strings that have a leading asterisk. This construct
4893446Smrj      * is not allowed by the ACPI specification  (ID strings must be
4903446Smrj      * alphanumeric), but enough existing machines have this embedded in their
4913446Smrj      * ID strings that the following code is useful.
4923446Smrj      */
4933446Smrj     if (*Source == '*')
4943446Smrj     {
4953446Smrj         Source++;
4963446Smrj     }
4973446Smrj 
4983446Smrj     /* Do the actual copy */
4993446Smrj 
5003446Smrj     ACPI_STRNCPY (Destination, Source, MaxLength);
5013446Smrj }
5023446Smrj 
5033446Smrj 
5043446Smrj /*******************************************************************************
5053446Smrj  *
5063446Smrj  * FUNCTION:    AcpiUtExecute_HID
5073446Smrj  *
5083446Smrj  * PARAMETERS:  DeviceNode          - Node for the device
5093446Smrj  *              Hid                 - Where the HID is returned
5103446Smrj  *
5113446Smrj  * RETURN:      Status
5123446Smrj  *
5133446Smrj  * DESCRIPTION: Executes the _HID control method that returns the hardware
5143446Smrj  *              ID of the device.
5153446Smrj  *
5163446Smrj  *              NOTE: Internal function, no parameter validation
5173446Smrj  *
5183446Smrj  ******************************************************************************/
5193446Smrj 
5203446Smrj ACPI_STATUS
5213446Smrj AcpiUtExecute_HID (
5223446Smrj     ACPI_NAMESPACE_NODE     *DeviceNode,
5233446Smrj     ACPI_DEVICE_ID          *Hid)
5243446Smrj {
5253446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
5263446Smrj     ACPI_STATUS             Status;
5273446Smrj 
5283446Smrj 
5293446Smrj     ACPI_FUNCTION_TRACE (UtExecute_HID);
5303446Smrj 
5313446Smrj 
5323446Smrj     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID,
5333446Smrj                 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
5343446Smrj     if (ACPI_FAILURE (Status))
5353446Smrj     {
5363446Smrj         return_ACPI_STATUS (Status);
5373446Smrj     }
5383446Smrj 
539*9980SDana.Myers@Sun.COM     if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
5403446Smrj     {
5413446Smrj         /* Convert the Numeric HID to string */
5423446Smrj 
5433446Smrj         AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Value);
5443446Smrj     }
5453446Smrj     else
5463446Smrj     {
5473446Smrj         /* Copy the String HID from the returned object */
5483446Smrj 
5493446Smrj         AcpiUtCopyIdString (Hid->Value, ObjDesc->String.Pointer,
5503446Smrj                 sizeof (Hid->Value));
5513446Smrj     }
5523446Smrj 
5533446Smrj     /* On exit, we must delete the return object */
5543446Smrj 
5553446Smrj     AcpiUtRemoveReference (ObjDesc);
5563446Smrj     return_ACPI_STATUS (Status);
5573446Smrj }
5583446Smrj 
5593446Smrj 
5603446Smrj /*******************************************************************************
5613446Smrj  *
5623446Smrj  * FUNCTION:    AcpiUtTranslateOneCid
5633446Smrj  *
5643446Smrj  * PARAMETERS:  ObjDesc             - _CID object, must be integer or string
5653446Smrj  *              OneCid              - Where the CID string is returned
5663446Smrj  *
5673446Smrj  * RETURN:      Status
5683446Smrj  *
5693446Smrj  * DESCRIPTION: Return a numeric or string _CID value as a string.
5703446Smrj  *              (Compatible ID)
5713446Smrj  *
5723446Smrj  *              NOTE:  Assumes a maximum _CID string length of
5733446Smrj  *                     ACPI_MAX_CID_LENGTH.
5743446Smrj  *
5753446Smrj  ******************************************************************************/
5763446Smrj 
5773446Smrj static ACPI_STATUS
5783446Smrj AcpiUtTranslateOneCid (
5793446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc,
5803446Smrj     ACPI_COMPATIBLE_ID      *OneCid)
5813446Smrj {
5823446Smrj 
5833446Smrj 
584*9980SDana.Myers@Sun.COM     switch (ObjDesc->Common.Type)
5853446Smrj     {
5863446Smrj     case ACPI_TYPE_INTEGER:
5873446Smrj 
5883446Smrj         /* Convert the Numeric CID to string */
5893446Smrj 
5903446Smrj         AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, OneCid->Value);
5913446Smrj         return (AE_OK);
5923446Smrj 
5933446Smrj     case ACPI_TYPE_STRING:
5943446Smrj 
5953446Smrj         if (ObjDesc->String.Length > ACPI_MAX_CID_LENGTH)
5963446Smrj         {
5973446Smrj             return (AE_AML_STRING_LIMIT);
5983446Smrj         }
5993446Smrj 
6003446Smrj         /* Copy the String CID from the returned object */
6013446Smrj 
6023446Smrj         AcpiUtCopyIdString (OneCid->Value, ObjDesc->String.Pointer,
6033446Smrj                 ACPI_MAX_CID_LENGTH);
6043446Smrj         return (AE_OK);
6053446Smrj 
6063446Smrj     default:
6073446Smrj 
6083446Smrj         return (AE_TYPE);
6093446Smrj     }
6103446Smrj }
6113446Smrj 
6123446Smrj 
6133446Smrj /*******************************************************************************
6143446Smrj  *
6153446Smrj  * FUNCTION:    AcpiUtExecute_CID
6163446Smrj  *
6173446Smrj  * PARAMETERS:  DeviceNode          - Node for the device
6183446Smrj  *              ReturnCidList       - Where the CID list is returned
6193446Smrj  *
6203446Smrj  * RETURN:      Status
6213446Smrj  *
6223446Smrj  * DESCRIPTION: Executes the _CID control method that returns one or more
6233446Smrj  *              compatible hardware IDs for the device.
6243446Smrj  *
6253446Smrj  *              NOTE: Internal function, no parameter validation
6263446Smrj  *
6273446Smrj  ******************************************************************************/
6283446Smrj 
6293446Smrj ACPI_STATUS
6303446Smrj AcpiUtExecute_CID (
6313446Smrj     ACPI_NAMESPACE_NODE     *DeviceNode,
6323446Smrj     ACPI_COMPATIBLE_ID_LIST **ReturnCidList)
6333446Smrj {
6343446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
6353446Smrj     ACPI_STATUS             Status;
6363446Smrj     UINT32                  Count;
6373446Smrj     UINT32                  Size;
6383446Smrj     ACPI_COMPATIBLE_ID_LIST *CidList;
6397851SDana.Myers@Sun.COM     UINT32                  i;
6403446Smrj 
6413446Smrj 
6423446Smrj     ACPI_FUNCTION_TRACE (UtExecute_CID);
6433446Smrj 
6443446Smrj 
6453446Smrj     /* Evaluate the _CID method for this device */
6463446Smrj 
6473446Smrj     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID,
6483446Smrj                 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE,
6493446Smrj                 &ObjDesc);
6503446Smrj     if (ACPI_FAILURE (Status))
6513446Smrj     {
6523446Smrj         return_ACPI_STATUS (Status);
6533446Smrj     }
6543446Smrj 
6553446Smrj     /* Get the number of _CIDs returned */
6563446Smrj 
6573446Smrj     Count = 1;
658*9980SDana.Myers@Sun.COM     if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
6593446Smrj     {
6603446Smrj         Count = ObjDesc->Package.Count;
6613446Smrj     }
6623446Smrj 
6633446Smrj     /* Allocate a worst-case buffer for the _CIDs */
6643446Smrj 
6653446Smrj     Size = (((Count - 1) * sizeof (ACPI_COMPATIBLE_ID)) +
6663446Smrj                            sizeof (ACPI_COMPATIBLE_ID_LIST));
6673446Smrj 
6683446Smrj     CidList = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Size);
6693446Smrj     if (!CidList)
6703446Smrj     {
6713446Smrj         return_ACPI_STATUS (AE_NO_MEMORY);
6723446Smrj     }
6733446Smrj 
6743446Smrj     /* Init CID list */
6753446Smrj 
6763446Smrj     CidList->Count = Count;
6773446Smrj     CidList->Size  = Size;
6783446Smrj 
6793446Smrj     /*
6803446Smrj      *  A _CID can return either a single compatible ID or a package of
6813446Smrj      *  compatible IDs.  Each compatible ID can be one of the following:
6823446Smrj      *  1) Integer (32 bit compressed EISA ID) or
6833446Smrj      *  2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
6843446Smrj      */
6853446Smrj 
6863446Smrj     /* The _CID object can be either a single CID or a package (list) of CIDs */
6873446Smrj 
688*9980SDana.Myers@Sun.COM     if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
6893446Smrj     {
6903446Smrj         /* Translate each package element */
6913446Smrj 
6923446Smrj         for (i = 0; i < Count; i++)
6933446Smrj         {
6943446Smrj             Status = AcpiUtTranslateOneCid (ObjDesc->Package.Elements[i],
6953446Smrj                             &CidList->Id[i]);
6963446Smrj             if (ACPI_FAILURE (Status))
6973446Smrj             {
6983446Smrj                 break;
6993446Smrj             }
7003446Smrj         }
7013446Smrj     }
7023446Smrj     else
7033446Smrj     {
7043446Smrj         /* Only one CID, translate to a string */
7053446Smrj 
7063446Smrj         Status = AcpiUtTranslateOneCid (ObjDesc, CidList->Id);
7073446Smrj     }
7083446Smrj 
7093446Smrj     /* Cleanup on error */
7103446Smrj 
7113446Smrj     if (ACPI_FAILURE (Status))
7123446Smrj     {
7133446Smrj         ACPI_FREE (CidList);
7143446Smrj     }
7153446Smrj     else
7163446Smrj     {
7173446Smrj         *ReturnCidList = CidList;
7183446Smrj     }
7193446Smrj 
7203446Smrj     /* On exit, we must delete the _CID return object */
7213446Smrj 
7223446Smrj     AcpiUtRemoveReference (ObjDesc);
7233446Smrj     return_ACPI_STATUS (Status);
7243446Smrj }
7253446Smrj 
7263446Smrj 
7273446Smrj /*******************************************************************************
7283446Smrj  *
7293446Smrj  * FUNCTION:    AcpiUtExecute_UID
7303446Smrj  *
7313446Smrj  * PARAMETERS:  DeviceNode          - Node for the device
7323446Smrj  *              Uid                 - Where the UID is returned
7333446Smrj  *
7343446Smrj  * RETURN:      Status
7353446Smrj  *
7363446Smrj  * DESCRIPTION: Executes the _UID control method that returns the hardware
7373446Smrj  *              ID of the device.
7383446Smrj  *
7393446Smrj  *              NOTE: Internal function, no parameter validation
7403446Smrj  *
7413446Smrj  ******************************************************************************/
7423446Smrj 
7433446Smrj ACPI_STATUS
7443446Smrj AcpiUtExecute_UID (
7453446Smrj     ACPI_NAMESPACE_NODE     *DeviceNode,
7463446Smrj     ACPI_DEVICE_ID          *Uid)
7473446Smrj {
7483446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
7493446Smrj     ACPI_STATUS             Status;
7503446Smrj 
7513446Smrj 
7523446Smrj     ACPI_FUNCTION_TRACE (UtExecute_UID);
7533446Smrj 
7543446Smrj 
7553446Smrj     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID,
7563446Smrj                 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
7573446Smrj     if (ACPI_FAILURE (Status))
7583446Smrj     {
7593446Smrj         return_ACPI_STATUS (Status);
7603446Smrj     }
7613446Smrj 
762*9980SDana.Myers@Sun.COM     if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
7633446Smrj     {
7643446Smrj         /* Convert the Numeric UID to string */
7653446Smrj 
7663446Smrj         AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Value);
7673446Smrj     }
7683446Smrj     else
7693446Smrj     {
7703446Smrj         /* Copy the String UID from the returned object */
7713446Smrj 
7723446Smrj         AcpiUtCopyIdString (Uid->Value, ObjDesc->String.Pointer,
7733446Smrj                 sizeof (Uid->Value));
7743446Smrj     }
7753446Smrj 
7763446Smrj     /* On exit, we must delete the return object */
7773446Smrj 
7783446Smrj     AcpiUtRemoveReference (ObjDesc);
7793446Smrj     return_ACPI_STATUS (Status);
7803446Smrj }
7813446Smrj 
7823446Smrj 
7833446Smrj /*******************************************************************************
7843446Smrj  *
7853446Smrj  * FUNCTION:    AcpiUtExecute_STA
7863446Smrj  *
7873446Smrj  * PARAMETERS:  DeviceNode          - Node for the device
7883446Smrj  *              Flags               - Where the status flags are returned
7893446Smrj  *
7903446Smrj  * RETURN:      Status
7913446Smrj  *
7923446Smrj  * DESCRIPTION: Executes _STA for selected device and stores results in
7933446Smrj  *              *Flags.
7943446Smrj  *
7953446Smrj  *              NOTE: Internal function, no parameter validation
7963446Smrj  *
7973446Smrj  ******************************************************************************/
7983446Smrj 
7993446Smrj ACPI_STATUS
8003446Smrj AcpiUtExecute_STA (
8013446Smrj     ACPI_NAMESPACE_NODE     *DeviceNode,
8023446Smrj     UINT32                  *Flags)
8033446Smrj {
8043446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
8053446Smrj     ACPI_STATUS             Status;
8063446Smrj 
8073446Smrj 
8083446Smrj     ACPI_FUNCTION_TRACE (UtExecute_STA);
8093446Smrj 
8103446Smrj 
8113446Smrj     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
8123446Smrj                 ACPI_BTYPE_INTEGER, &ObjDesc);
8133446Smrj     if (ACPI_FAILURE (Status))
8143446Smrj     {
8153446Smrj         if (AE_NOT_FOUND == Status)
8163446Smrj         {
8173446Smrj             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
8183446Smrj                 "_STA on %4.4s was not found, assuming device is present\n",
8193446Smrj                 AcpiUtGetNodeName (DeviceNode)));
8203446Smrj 
8213446Smrj             *Flags = ACPI_UINT32_MAX;
8223446Smrj             Status = AE_OK;
8233446Smrj         }
8243446Smrj 
8253446Smrj         return_ACPI_STATUS (Status);
8263446Smrj     }
8273446Smrj 
8283446Smrj     /* Extract the status flags */
8293446Smrj 
8303446Smrj     *Flags = (UINT32) ObjDesc->Integer.Value;
8313446Smrj 
8323446Smrj     /* On exit, we must delete the return object */
8333446Smrj 
8343446Smrj     AcpiUtRemoveReference (ObjDesc);
8353446Smrj     return_ACPI_STATUS (Status);
8363446Smrj }
8373446Smrj 
8383446Smrj 
8393446Smrj /*******************************************************************************
8403446Smrj  *
8413446Smrj  * FUNCTION:    AcpiUtExecute_Sxds
8423446Smrj  *
8433446Smrj  * PARAMETERS:  DeviceNode          - Node for the device
8443446Smrj  *              Flags               - Where the status flags are returned
8453446Smrj  *
8463446Smrj  * RETURN:      Status
8473446Smrj  *
8483446Smrj  * DESCRIPTION: Executes _STA for selected device and stores results in
8493446Smrj  *              *Flags.
8503446Smrj  *
8513446Smrj  *              NOTE: Internal function, no parameter validation
8523446Smrj  *
8533446Smrj  ******************************************************************************/
8543446Smrj 
8553446Smrj ACPI_STATUS
8563446Smrj AcpiUtExecute_Sxds (
8573446Smrj     ACPI_NAMESPACE_NODE     *DeviceNode,
8583446Smrj     UINT8                   *Highest)
8593446Smrj {
8603446Smrj     ACPI_OPERAND_OBJECT     *ObjDesc;
8613446Smrj     ACPI_STATUS             Status;
8623446Smrj     UINT32                  i;
8633446Smrj 
8643446Smrj 
8653446Smrj     ACPI_FUNCTION_TRACE (UtExecute_Sxds);
8663446Smrj 
8673446Smrj 
8683446Smrj     for (i = 0; i < 4; i++)
8693446Smrj     {
8703446Smrj         Highest[i] = 0xFF;
8713446Smrj         Status = AcpiUtEvaluateObject (DeviceNode,
8723446Smrj                     ACPI_CAST_PTR (char, AcpiGbl_HighestDstateNames[i]),
8733446Smrj                     ACPI_BTYPE_INTEGER, &ObjDesc);
8743446Smrj         if (ACPI_FAILURE (Status))
8753446Smrj         {
8763446Smrj             if (Status != AE_NOT_FOUND)
8773446Smrj             {
8783446Smrj                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
8793446Smrj                     "%s on Device %4.4s, %s\n",
8803446Smrj                     ACPI_CAST_PTR (char, AcpiGbl_HighestDstateNames[i]),
8813446Smrj                     AcpiUtGetNodeName (DeviceNode),
8823446Smrj                     AcpiFormatException (Status)));
8833446Smrj 
8843446Smrj                 return_ACPI_STATUS (Status);
8853446Smrj             }
8863446Smrj         }
8873446Smrj         else
8883446Smrj         {
8893446Smrj             /* Extract the Dstate value */
8903446Smrj 
8913446Smrj             Highest[i] = (UINT8) ObjDesc->Integer.Value;
8923446Smrj 
8933446Smrj             /* Delete the return object */
8943446Smrj 
8953446Smrj             AcpiUtRemoveReference (ObjDesc);
8963446Smrj         }
8973446Smrj     }
8983446Smrj 
8993446Smrj     return_ACPI_STATUS (AE_OK);
9003446Smrj }
901