Home | History | Annotate | Line # | Download | only in utilities
utosi.c revision 1.2.2.2
      1  1.2.2.2  bouyer /******************************************************************************
      2  1.2.2.2  bouyer  *
      3  1.2.2.2  bouyer  * Module Name: utosi - Support for the _OSI predefined control method
      4  1.2.2.2  bouyer  *
      5  1.2.2.2  bouyer  *****************************************************************************/
      6  1.2.2.2  bouyer 
      7  1.2.2.2  bouyer /*
      8  1.2.2.2  bouyer  * Copyright (C) 2000 - 2011, Intel Corp.
      9  1.2.2.2  bouyer  * All rights reserved.
     10  1.2.2.2  bouyer  *
     11  1.2.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
     12  1.2.2.2  bouyer  * modification, are permitted provided that the following conditions
     13  1.2.2.2  bouyer  * are met:
     14  1.2.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     15  1.2.2.2  bouyer  *    notice, this list of conditions, and the following disclaimer,
     16  1.2.2.2  bouyer  *    without modification.
     17  1.2.2.2  bouyer  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.2.2.2  bouyer  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.2.2.2  bouyer  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.2.2.2  bouyer  *    including a substantially similar Disclaimer requirement for further
     21  1.2.2.2  bouyer  *    binary redistribution.
     22  1.2.2.2  bouyer  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.2.2.2  bouyer  *    of any contributors may be used to endorse or promote products derived
     24  1.2.2.2  bouyer  *    from this software without specific prior written permission.
     25  1.2.2.2  bouyer  *
     26  1.2.2.2  bouyer  * Alternatively, this software may be distributed under the terms of the
     27  1.2.2.2  bouyer  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.2.2.2  bouyer  * Software Foundation.
     29  1.2.2.2  bouyer  *
     30  1.2.2.2  bouyer  * NO WARRANTY
     31  1.2.2.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.2.2.2  bouyer  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.2.2.2  bouyer  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.2.2.2  bouyer  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.2.2.2  bouyer  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.2.2.2  bouyer  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.2.2.2  bouyer  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.2.2.2  bouyer  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.2.2.2  bouyer  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.2.2.2  bouyer  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.2.2.2  bouyer  * POSSIBILITY OF SUCH DAMAGES.
     42  1.2.2.2  bouyer  */
     43  1.2.2.2  bouyer 
     44  1.2.2.2  bouyer #define __UTOSI_C__
     45  1.2.2.2  bouyer 
     46  1.2.2.2  bouyer #include "acpi.h"
     47  1.2.2.2  bouyer #include "accommon.h"
     48  1.2.2.2  bouyer 
     49  1.2.2.2  bouyer 
     50  1.2.2.2  bouyer #define _COMPONENT          ACPI_UTILITIES
     51  1.2.2.2  bouyer         ACPI_MODULE_NAME    ("utosi")
     52  1.2.2.2  bouyer 
     53  1.2.2.2  bouyer /*
     54  1.2.2.2  bouyer  * Strings supported by the _OSI predefined control method (which is
     55  1.2.2.2  bouyer  * implemented internally within this module.)
     56  1.2.2.2  bouyer  *
     57  1.2.2.2  bouyer  * March 2009: Removed "Linux" as this host no longer wants to respond true
     58  1.2.2.2  bouyer  * for this string. Basically, the only safe OS strings are windows-related
     59  1.2.2.2  bouyer  * and in many or most cases represent the only test path within the
     60  1.2.2.2  bouyer  * BIOS-provided ASL code.
     61  1.2.2.2  bouyer  *
     62  1.2.2.2  bouyer  * The last element of each entry is used to track the newest version of
     63  1.2.2.2  bouyer  * Windows that the BIOS has requested.
     64  1.2.2.2  bouyer  */
     65  1.2.2.2  bouyer static ACPI_INTERFACE_INFO    AcpiDefaultSupportedInterfaces[] =
     66  1.2.2.2  bouyer {
     67  1.2.2.2  bouyer     /* Operating System Vendor Strings */
     68  1.2.2.2  bouyer 
     69  1.2.2.2  bouyer     {"Windows 2000",        NULL, 0, ACPI_OSI_WIN_2000},         /* Windows 2000 */
     70  1.2.2.2  bouyer     {"Windows 2001",        NULL, 0, ACPI_OSI_WIN_XP},           /* Windows XP */
     71  1.2.2.2  bouyer     {"Windows 2001 SP1",    NULL, 0, ACPI_OSI_WIN_XP_SP1},       /* Windows XP SP1 */
     72  1.2.2.2  bouyer     {"Windows 2001.1",      NULL, 0, ACPI_OSI_WINSRV_2003},      /* Windows Server 2003 */
     73  1.2.2.2  bouyer     {"Windows 2001 SP2",    NULL, 0, ACPI_OSI_WIN_XP_SP2},       /* Windows XP SP2 */
     74  1.2.2.2  bouyer     {"Windows 2001.1 SP1",  NULL, 0, ACPI_OSI_WINSRV_2003_SP1},  /* Windows Server 2003 SP1 - Added 03/2006 */
     75  1.2.2.2  bouyer     {"Windows 2006",        NULL, 0, ACPI_OSI_WIN_VISTA},        /* Windows Vista - Added 03/2006 */
     76  1.2.2.2  bouyer     {"Windows 2006.1",      NULL, 0, ACPI_OSI_WINSRV_2008},      /* Windows Server 2008 - Added 09/2009 */
     77  1.2.2.2  bouyer     {"Windows 2006 SP1",    NULL, 0, ACPI_OSI_WIN_VISTA_SP1},    /* Windows Vista SP1 - Added 09/2009 */
     78  1.2.2.2  bouyer     {"Windows 2006 SP2",    NULL, 0, ACPI_OSI_WIN_VISTA_SP2},    /* Windows Vista SP2 - Added 09/2010 */
     79  1.2.2.2  bouyer     {"Windows 2009",        NULL, 0, ACPI_OSI_WIN_7},            /* Windows 7 and Server 2008 R2 - Added 09/2009 */
     80  1.2.2.2  bouyer 
     81  1.2.2.2  bouyer     /* Feature Group Strings */
     82  1.2.2.2  bouyer 
     83  1.2.2.2  bouyer     {"Extended Address Space Descriptor", NULL, 0, 0}
     84  1.2.2.2  bouyer 
     85  1.2.2.2  bouyer     /*
     86  1.2.2.2  bouyer      * All "optional" feature group strings (features that are implemented
     87  1.2.2.2  bouyer      * by the host) should be dynamically added by the host via
     88  1.2.2.2  bouyer      * AcpiInstallInterface and should not be manually added here.
     89  1.2.2.2  bouyer      *
     90  1.2.2.2  bouyer      * Examples of optional feature group strings:
     91  1.2.2.2  bouyer      *
     92  1.2.2.2  bouyer      * "Module Device"
     93  1.2.2.2  bouyer      * "Processor Device"
     94  1.2.2.2  bouyer      * "3.0 Thermal Model"
     95  1.2.2.2  bouyer      * "3.0 _SCP Extensions"
     96  1.2.2.2  bouyer      * "Processor Aggregator Device"
     97  1.2.2.2  bouyer      */
     98  1.2.2.2  bouyer };
     99  1.2.2.2  bouyer 
    100  1.2.2.2  bouyer 
    101  1.2.2.2  bouyer /*******************************************************************************
    102  1.2.2.2  bouyer  *
    103  1.2.2.2  bouyer  * FUNCTION:    AcpiUtInitializeInterfaces
    104  1.2.2.2  bouyer  *
    105  1.2.2.2  bouyer  * PARAMETERS:  None
    106  1.2.2.2  bouyer  *
    107  1.2.2.2  bouyer  * RETURN:      Status
    108  1.2.2.2  bouyer  *
    109  1.2.2.2  bouyer  * DESCRIPTION: Initialize the global _OSI supported interfaces list
    110  1.2.2.2  bouyer  *
    111  1.2.2.2  bouyer  ******************************************************************************/
    112  1.2.2.2  bouyer 
    113  1.2.2.2  bouyer ACPI_STATUS
    114  1.2.2.2  bouyer AcpiUtInitializeInterfaces (
    115  1.2.2.2  bouyer     void)
    116  1.2.2.2  bouyer {
    117  1.2.2.2  bouyer     UINT32                  i;
    118  1.2.2.2  bouyer 
    119  1.2.2.2  bouyer 
    120  1.2.2.2  bouyer     (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
    121  1.2.2.2  bouyer     AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
    122  1.2.2.2  bouyer 
    123  1.2.2.2  bouyer     /* Link the static list of supported interfaces */
    124  1.2.2.2  bouyer 
    125  1.2.2.2  bouyer     for (i = 0; i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1); i++)
    126  1.2.2.2  bouyer     {
    127  1.2.2.2  bouyer         AcpiDefaultSupportedInterfaces[i].Next =
    128  1.2.2.2  bouyer             &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
    129  1.2.2.2  bouyer     }
    130  1.2.2.2  bouyer 
    131  1.2.2.2  bouyer     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
    132  1.2.2.2  bouyer     return (AE_OK);
    133  1.2.2.2  bouyer }
    134  1.2.2.2  bouyer 
    135  1.2.2.2  bouyer 
    136  1.2.2.2  bouyer /*******************************************************************************
    137  1.2.2.2  bouyer  *
    138  1.2.2.2  bouyer  * FUNCTION:    AcpiUtInterfaceTerminate
    139  1.2.2.2  bouyer  *
    140  1.2.2.2  bouyer  * PARAMETERS:  None
    141  1.2.2.2  bouyer  *
    142  1.2.2.2  bouyer  * RETURN:      None
    143  1.2.2.2  bouyer  *
    144  1.2.2.2  bouyer  * DESCRIPTION: Delete all interfaces in the global list. Sets
    145  1.2.2.2  bouyer  *              AcpiGbl_SupportedInterfaces to NULL.
    146  1.2.2.2  bouyer  *
    147  1.2.2.2  bouyer  ******************************************************************************/
    148  1.2.2.2  bouyer 
    149  1.2.2.2  bouyer void
    150  1.2.2.2  bouyer AcpiUtInterfaceTerminate (
    151  1.2.2.2  bouyer     void)
    152  1.2.2.2  bouyer {
    153  1.2.2.2  bouyer     ACPI_INTERFACE_INFO     *NextInterface;
    154  1.2.2.2  bouyer 
    155  1.2.2.2  bouyer 
    156  1.2.2.2  bouyer     (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
    157  1.2.2.2  bouyer     NextInterface = AcpiGbl_SupportedInterfaces;
    158  1.2.2.2  bouyer 
    159  1.2.2.2  bouyer     while (NextInterface)
    160  1.2.2.2  bouyer     {
    161  1.2.2.2  bouyer         AcpiGbl_SupportedInterfaces = NextInterface->Next;
    162  1.2.2.2  bouyer 
    163  1.2.2.2  bouyer         /* Only interfaces added at runtime can be freed */
    164  1.2.2.2  bouyer 
    165  1.2.2.2  bouyer         if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
    166  1.2.2.2  bouyer         {
    167  1.2.2.2  bouyer             ACPI_FREE (NextInterface->Name);
    168  1.2.2.2  bouyer             ACPI_FREE (NextInterface);
    169  1.2.2.2  bouyer         }
    170  1.2.2.2  bouyer 
    171  1.2.2.2  bouyer         NextInterface = AcpiGbl_SupportedInterfaces;
    172  1.2.2.2  bouyer     }
    173  1.2.2.2  bouyer 
    174  1.2.2.2  bouyer     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
    175  1.2.2.2  bouyer }
    176  1.2.2.2  bouyer 
    177  1.2.2.2  bouyer 
    178  1.2.2.2  bouyer /*******************************************************************************
    179  1.2.2.2  bouyer  *
    180  1.2.2.2  bouyer  * FUNCTION:    AcpiUtInstallInterface
    181  1.2.2.2  bouyer  *
    182  1.2.2.2  bouyer  * PARAMETERS:  InterfaceName       - The interface to install
    183  1.2.2.2  bouyer  *
    184  1.2.2.2  bouyer  * RETURN:      Status
    185  1.2.2.2  bouyer  *
    186  1.2.2.2  bouyer  * DESCRIPTION: Install the interface into the global interface list.
    187  1.2.2.2  bouyer  *              Caller MUST hold AcpiGbl_OsiMutex
    188  1.2.2.2  bouyer  *
    189  1.2.2.2  bouyer  ******************************************************************************/
    190  1.2.2.2  bouyer 
    191  1.2.2.2  bouyer ACPI_STATUS
    192  1.2.2.2  bouyer AcpiUtInstallInterface (
    193  1.2.2.2  bouyer     ACPI_STRING             InterfaceName)
    194  1.2.2.2  bouyer {
    195  1.2.2.2  bouyer     ACPI_INTERFACE_INFO     *InterfaceInfo;
    196  1.2.2.2  bouyer 
    197  1.2.2.2  bouyer 
    198  1.2.2.2  bouyer     /* Allocate info block and space for the name string */
    199  1.2.2.2  bouyer 
    200  1.2.2.2  bouyer     InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
    201  1.2.2.2  bouyer     if (!InterfaceInfo)
    202  1.2.2.2  bouyer     {
    203  1.2.2.2  bouyer         return (AE_NO_MEMORY);
    204  1.2.2.2  bouyer     }
    205  1.2.2.2  bouyer 
    206  1.2.2.2  bouyer     InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (InterfaceName) + 1);
    207  1.2.2.2  bouyer     if (!InterfaceInfo->Name)
    208  1.2.2.2  bouyer     {
    209  1.2.2.2  bouyer         ACPI_FREE (InterfaceInfo);
    210  1.2.2.2  bouyer         return (AE_NO_MEMORY);
    211  1.2.2.2  bouyer     }
    212  1.2.2.2  bouyer 
    213  1.2.2.2  bouyer     /* Initialize new info and insert at the head of the global list */
    214  1.2.2.2  bouyer 
    215  1.2.2.2  bouyer     ACPI_STRCPY (InterfaceInfo->Name, InterfaceName);
    216  1.2.2.2  bouyer     InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
    217  1.2.2.2  bouyer     InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
    218  1.2.2.2  bouyer 
    219  1.2.2.2  bouyer     AcpiGbl_SupportedInterfaces = InterfaceInfo;
    220  1.2.2.2  bouyer     return (AE_OK);
    221  1.2.2.2  bouyer }
    222  1.2.2.2  bouyer 
    223  1.2.2.2  bouyer 
    224  1.2.2.2  bouyer /*******************************************************************************
    225  1.2.2.2  bouyer  *
    226  1.2.2.2  bouyer  * FUNCTION:    AcpiUtRemoveInterface
    227  1.2.2.2  bouyer  *
    228  1.2.2.2  bouyer  * PARAMETERS:  InterfaceName       - The interface to remove
    229  1.2.2.2  bouyer  *
    230  1.2.2.2  bouyer  * RETURN:      Status
    231  1.2.2.2  bouyer  *
    232  1.2.2.2  bouyer  * DESCRIPTION: Remove the interface from the global interface list.
    233  1.2.2.2  bouyer  *              Caller MUST hold AcpiGbl_OsiMutex
    234  1.2.2.2  bouyer  *
    235  1.2.2.2  bouyer  ******************************************************************************/
    236  1.2.2.2  bouyer 
    237  1.2.2.2  bouyer ACPI_STATUS
    238  1.2.2.2  bouyer AcpiUtRemoveInterface (
    239  1.2.2.2  bouyer     ACPI_STRING             InterfaceName)
    240  1.2.2.2  bouyer {
    241  1.2.2.2  bouyer     ACPI_INTERFACE_INFO     *PreviousInterface;
    242  1.2.2.2  bouyer     ACPI_INTERFACE_INFO     *NextInterface;
    243  1.2.2.2  bouyer 
    244  1.2.2.2  bouyer 
    245  1.2.2.2  bouyer     PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
    246  1.2.2.2  bouyer     while (NextInterface)
    247  1.2.2.2  bouyer     {
    248  1.2.2.2  bouyer         if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
    249  1.2.2.2  bouyer         {
    250  1.2.2.2  bouyer             /* Found: name is in either the static list or was added at runtime */
    251  1.2.2.2  bouyer 
    252  1.2.2.2  bouyer             if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
    253  1.2.2.2  bouyer             {
    254  1.2.2.2  bouyer                 /* Interface was added dynamically, remove and free it */
    255  1.2.2.2  bouyer 
    256  1.2.2.2  bouyer                 if (PreviousInterface == NextInterface)
    257  1.2.2.2  bouyer                 {
    258  1.2.2.2  bouyer                     AcpiGbl_SupportedInterfaces = NextInterface->Next;
    259  1.2.2.2  bouyer                 }
    260  1.2.2.2  bouyer                 else
    261  1.2.2.2  bouyer                 {
    262  1.2.2.2  bouyer                     PreviousInterface->Next = NextInterface->Next;
    263  1.2.2.2  bouyer                 }
    264  1.2.2.2  bouyer 
    265  1.2.2.2  bouyer                 ACPI_FREE (NextInterface->Name);
    266  1.2.2.2  bouyer                 ACPI_FREE (NextInterface);
    267  1.2.2.2  bouyer             }
    268  1.2.2.2  bouyer             else
    269  1.2.2.2  bouyer             {
    270  1.2.2.2  bouyer                 /*
    271  1.2.2.2  bouyer                  * Interface is in static list. If marked invalid, then it
    272  1.2.2.2  bouyer                  * does not actually exist. Else, mark it invalid.
    273  1.2.2.2  bouyer                  */
    274  1.2.2.2  bouyer                 if (NextInterface->Flags & ACPI_OSI_INVALID)
    275  1.2.2.2  bouyer                 {
    276  1.2.2.2  bouyer                     return (AE_NOT_EXIST);
    277  1.2.2.2  bouyer                 }
    278  1.2.2.2  bouyer 
    279  1.2.2.2  bouyer                 NextInterface->Flags |= ACPI_OSI_INVALID;
    280  1.2.2.2  bouyer             }
    281  1.2.2.2  bouyer 
    282  1.2.2.2  bouyer             return (AE_OK);
    283  1.2.2.2  bouyer         }
    284  1.2.2.2  bouyer 
    285  1.2.2.2  bouyer         PreviousInterface = NextInterface;
    286  1.2.2.2  bouyer         NextInterface = NextInterface->Next;
    287  1.2.2.2  bouyer     }
    288  1.2.2.2  bouyer 
    289  1.2.2.2  bouyer     /* Interface was not found */
    290  1.2.2.2  bouyer 
    291  1.2.2.2  bouyer     return (AE_NOT_EXIST);
    292  1.2.2.2  bouyer }
    293  1.2.2.2  bouyer 
    294  1.2.2.2  bouyer 
    295  1.2.2.2  bouyer /*******************************************************************************
    296  1.2.2.2  bouyer  *
    297  1.2.2.2  bouyer  * FUNCTION:    AcpiUtGetInterface
    298  1.2.2.2  bouyer  *
    299  1.2.2.2  bouyer  * PARAMETERS:  InterfaceName       - The interface to find
    300  1.2.2.2  bouyer  *
    301  1.2.2.2  bouyer  * RETURN:      ACPI_INTERFACE_INFO if found. NULL if not found.
    302  1.2.2.2  bouyer  *
    303  1.2.2.2  bouyer  * DESCRIPTION: Search for the specified interface name in the global list.
    304  1.2.2.2  bouyer  *              Caller MUST hold AcpiGbl_OsiMutex
    305  1.2.2.2  bouyer  *
    306  1.2.2.2  bouyer  ******************************************************************************/
    307  1.2.2.2  bouyer 
    308  1.2.2.2  bouyer ACPI_INTERFACE_INFO *
    309  1.2.2.2  bouyer AcpiUtGetInterface (
    310  1.2.2.2  bouyer     ACPI_STRING             InterfaceName)
    311  1.2.2.2  bouyer {
    312  1.2.2.2  bouyer     ACPI_INTERFACE_INFO     *NextInterface;
    313  1.2.2.2  bouyer 
    314  1.2.2.2  bouyer 
    315  1.2.2.2  bouyer     NextInterface = AcpiGbl_SupportedInterfaces;
    316  1.2.2.2  bouyer     while (NextInterface)
    317  1.2.2.2  bouyer     {
    318  1.2.2.2  bouyer         if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
    319  1.2.2.2  bouyer         {
    320  1.2.2.2  bouyer             return (NextInterface);
    321  1.2.2.2  bouyer         }
    322  1.2.2.2  bouyer 
    323  1.2.2.2  bouyer         NextInterface = NextInterface->Next;
    324  1.2.2.2  bouyer     }
    325  1.2.2.2  bouyer 
    326  1.2.2.2  bouyer     return (NULL);
    327  1.2.2.2  bouyer }
    328  1.2.2.2  bouyer 
    329  1.2.2.2  bouyer 
    330  1.2.2.2  bouyer /*******************************************************************************
    331  1.2.2.2  bouyer  *
    332  1.2.2.2  bouyer  * FUNCTION:    AcpiUtOsiImplementation
    333  1.2.2.2  bouyer  *
    334  1.2.2.2  bouyer  * PARAMETERS:  WalkState           - Current walk state
    335  1.2.2.2  bouyer  *
    336  1.2.2.2  bouyer  * RETURN:      Status
    337  1.2.2.2  bouyer  *
    338  1.2.2.2  bouyer  * DESCRIPTION: Implementation of the _OSI predefined control method. When
    339  1.2.2.2  bouyer  *              an invocation of _OSI is encountered in the system AML,
    340  1.2.2.2  bouyer  *              control is transferred to this function.
    341  1.2.2.2  bouyer  *
    342  1.2.2.2  bouyer  ******************************************************************************/
    343  1.2.2.2  bouyer 
    344  1.2.2.2  bouyer ACPI_STATUS
    345  1.2.2.2  bouyer AcpiUtOsiImplementation (
    346  1.2.2.2  bouyer     ACPI_WALK_STATE         *WalkState)
    347  1.2.2.2  bouyer {
    348  1.2.2.2  bouyer     ACPI_OPERAND_OBJECT     *StringDesc;
    349  1.2.2.2  bouyer     ACPI_OPERAND_OBJECT     *ReturnDesc;
    350  1.2.2.2  bouyer     ACPI_INTERFACE_INFO     *InterfaceInfo;
    351  1.2.2.2  bouyer     ACPI_INTERFACE_HANDLER  InterfaceHandler;
    352  1.2.2.2  bouyer     UINT32                  ReturnValue;
    353  1.2.2.2  bouyer 
    354  1.2.2.2  bouyer 
    355  1.2.2.2  bouyer     ACPI_FUNCTION_TRACE (UtOsiImplementation);
    356  1.2.2.2  bouyer 
    357  1.2.2.2  bouyer 
    358  1.2.2.2  bouyer     /* Validate the string input argument (from the AML caller) */
    359  1.2.2.2  bouyer 
    360  1.2.2.2  bouyer     StringDesc = WalkState->Arguments[0].Object;
    361  1.2.2.2  bouyer     if (!StringDesc ||
    362  1.2.2.2  bouyer         (StringDesc->Common.Type != ACPI_TYPE_STRING))
    363  1.2.2.2  bouyer     {
    364  1.2.2.2  bouyer         return_ACPI_STATUS (AE_TYPE);
    365  1.2.2.2  bouyer     }
    366  1.2.2.2  bouyer 
    367  1.2.2.2  bouyer     /* Create a return object */
    368  1.2.2.2  bouyer 
    369  1.2.2.2  bouyer     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
    370  1.2.2.2  bouyer     if (!ReturnDesc)
    371  1.2.2.2  bouyer     {
    372  1.2.2.2  bouyer         return_ACPI_STATUS (AE_NO_MEMORY);
    373  1.2.2.2  bouyer     }
    374  1.2.2.2  bouyer 
    375  1.2.2.2  bouyer     /* Default return value is 0, NOT SUPPORTED */
    376  1.2.2.2  bouyer 
    377  1.2.2.2  bouyer     ReturnValue = 0;
    378  1.2.2.2  bouyer     (void) AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
    379  1.2.2.2  bouyer 
    380  1.2.2.2  bouyer     /* Lookup the interface in the global _OSI list */
    381  1.2.2.2  bouyer 
    382  1.2.2.2  bouyer     InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
    383  1.2.2.2  bouyer     if (InterfaceInfo &&
    384  1.2.2.2  bouyer         !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
    385  1.2.2.2  bouyer     {
    386  1.2.2.2  bouyer         /*
    387  1.2.2.2  bouyer          * The interface is supported.
    388  1.2.2.2  bouyer          * Update the OsiData if necessary. We keep track of the latest
    389  1.2.2.2  bouyer          * version of Windows that has been requested by the BIOS.
    390  1.2.2.2  bouyer          */
    391  1.2.2.2  bouyer         if (InterfaceInfo->Value > AcpiGbl_OsiData)
    392  1.2.2.2  bouyer         {
    393  1.2.2.2  bouyer             AcpiGbl_OsiData = InterfaceInfo->Value;
    394  1.2.2.2  bouyer         }
    395  1.2.2.2  bouyer 
    396  1.2.2.2  bouyer         ReturnValue = ACPI_UINT32_MAX;
    397  1.2.2.2  bouyer     }
    398  1.2.2.2  bouyer 
    399  1.2.2.2  bouyer     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
    400  1.2.2.2  bouyer 
    401  1.2.2.2  bouyer     /*
    402  1.2.2.2  bouyer      * Invoke an optional _OSI interface handler. The host OS may wish
    403  1.2.2.2  bouyer      * to do some interface-specific handling. For example, warn about
    404  1.2.2.2  bouyer      * certain interfaces or override the true/false support value.
    405  1.2.2.2  bouyer      */
    406  1.2.2.2  bouyer     InterfaceHandler = AcpiGbl_InterfaceHandler;
    407  1.2.2.2  bouyer     if (InterfaceHandler)
    408  1.2.2.2  bouyer     {
    409  1.2.2.2  bouyer         ReturnValue = InterfaceHandler (
    410  1.2.2.2  bouyer             StringDesc->String.Pointer, ReturnValue);
    411  1.2.2.2  bouyer     }
    412  1.2.2.2  bouyer 
    413  1.2.2.2  bouyer     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
    414  1.2.2.2  bouyer         "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
    415  1.2.2.2  bouyer         StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
    416  1.2.2.2  bouyer 
    417  1.2.2.2  bouyer     /* Complete the return object */
    418  1.2.2.2  bouyer 
    419  1.2.2.2  bouyer     ReturnDesc->Integer.Value = ReturnValue;
    420  1.2.2.2  bouyer     WalkState->ReturnDesc = ReturnDesc;
    421  1.2.2.2  bouyer     return_ACPI_STATUS (AE_OK);
    422  1.2.2.2  bouyer }
    423