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