Home | History | Annotate | Line # | Download | only in utilities
      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.21  christos /******************************************************************************
      8  1.21  christos  *
      9  1.21  christos  * 1. Copyright Notice
     10  1.21  christos  *
     11  1.22  christos  * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
     12   1.1    jruoho  * All rights reserved.
     13   1.1    jruoho  *
     14  1.21  christos  * 2. License
     15  1.21  christos  *
     16  1.21  christos  * 2.1. This is your license from Intel Corp. under its intellectual property
     17  1.21  christos  * rights. You may have additional license terms from the party that provided
     18  1.21  christos  * you this software, covering your right to use that party's intellectual
     19  1.21  christos  * property rights.
     20  1.21  christos  *
     21  1.21  christos  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
     22  1.21  christos  * copy of the source code appearing in this file ("Covered Code") an
     23  1.21  christos  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
     24  1.21  christos  * base code distributed originally by Intel ("Original Intel Code") to copy,
     25  1.21  christos  * make derivatives, distribute, use and display any portion of the Covered
     26  1.21  christos  * Code in any form, with the right to sublicense such rights; and
     27  1.21  christos  *
     28  1.21  christos  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
     29  1.21  christos  * license (with the right to sublicense), under only those claims of Intel
     30  1.21  christos  * patents that are infringed by the Original Intel Code, to make, use, sell,
     31  1.21  christos  * offer to sell, and import the Covered Code and derivative works thereof
     32  1.21  christos  * solely to the minimum extent necessary to exercise the above copyright
     33  1.21  christos  * license, and in no event shall the patent license extend to any additions
     34  1.21  christos  * to or modifications of the Original Intel Code. No other license or right
     35  1.21  christos  * is granted directly or by implication, estoppel or otherwise;
     36  1.21  christos  *
     37  1.21  christos  * The above copyright and patent license is granted only if the following
     38  1.21  christos  * conditions are met:
     39  1.21  christos  *
     40  1.21  christos  * 3. Conditions
     41  1.21  christos  *
     42  1.21  christos  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
     43  1.21  christos  * Redistribution of source code of any substantial portion of the Covered
     44  1.21  christos  * Code or modification with rights to further distribute source must include
     45  1.21  christos  * the above Copyright Notice, the above License, this list of Conditions,
     46  1.21  christos  * and the following Disclaimer and Export Compliance provision. In addition,
     47  1.21  christos  * Licensee must cause all Covered Code to which Licensee contributes to
     48  1.21  christos  * contain a file documenting the changes Licensee made to create that Covered
     49  1.21  christos  * Code and the date of any change. Licensee must include in that file the
     50  1.21  christos  * documentation of any changes made by any predecessor Licensee. Licensee
     51  1.21  christos  * must include a prominent statement that the modification is derived,
     52  1.21  christos  * directly or indirectly, from Original Intel Code.
     53  1.21  christos  *
     54  1.21  christos  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
     55  1.21  christos  * Redistribution of source code of any substantial portion of the Covered
     56  1.21  christos  * Code or modification without rights to further distribute source must
     57  1.21  christos  * include the following Disclaimer and Export Compliance provision in the
     58  1.21  christos  * documentation and/or other materials provided with distribution. In
     59  1.21  christos  * addition, Licensee may not authorize further sublicense of source of any
     60  1.21  christos  * portion of the Covered Code, and must include terms to the effect that the
     61  1.21  christos  * license from Licensee to its licensee is limited to the intellectual
     62  1.21  christos  * property embodied in the software Licensee provides to its licensee, and
     63  1.21  christos  * not to intellectual property embodied in modifications its licensee may
     64  1.21  christos  * make.
     65  1.21  christos  *
     66  1.21  christos  * 3.3. Redistribution of Executable. Redistribution in executable form of any
     67  1.21  christos  * substantial portion of the Covered Code or modification must reproduce the
     68  1.21  christos  * above Copyright Notice, and the following Disclaimer and Export Compliance
     69  1.21  christos  * provision in the documentation and/or other materials provided with the
     70  1.21  christos  * distribution.
     71  1.21  christos  *
     72  1.21  christos  * 3.4. Intel retains all right, title, and interest in and to the Original
     73  1.21  christos  * Intel Code.
     74  1.21  christos  *
     75  1.21  christos  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
     76  1.21  christos  * Intel shall be used in advertising or otherwise to promote the sale, use or
     77  1.21  christos  * other dealings in products derived from or relating to the Covered Code
     78  1.21  christos  * without prior written authorization from Intel.
     79  1.21  christos  *
     80  1.21  christos  * 4. Disclaimer and Export Compliance
     81  1.21  christos  *
     82  1.21  christos  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
     83  1.21  christos  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
     84  1.21  christos  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
     85  1.21  christos  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
     86  1.21  christos  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
     87  1.21  christos  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
     88  1.21  christos  * PARTICULAR PURPOSE.
     89  1.21  christos  *
     90  1.21  christos  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
     91  1.21  christos  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
     92  1.21  christos  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
     93  1.21  christos  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
     94  1.21  christos  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
     95  1.21  christos  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
     96  1.21  christos  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
     97  1.21  christos  * LIMITED REMEDY.
     98  1.21  christos  *
     99  1.21  christos  * 4.3. Licensee shall not export, either directly or indirectly, any of this
    100  1.21  christos  * software or system incorporating such software without first obtaining any
    101  1.21  christos  * required license or other approval from the U. S. Department of Commerce or
    102  1.21  christos  * any other agency or department of the United States Government. In the
    103  1.21  christos  * event Licensee exports any such software from the United States or
    104  1.21  christos  * re-exports any such software from a foreign destination, Licensee shall
    105  1.21  christos  * ensure that the distribution and export/re-export of the software is in
    106  1.21  christos  * compliance with all laws, regulations, orders, or other restrictions of the
    107  1.21  christos  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
    108  1.21  christos  * any of its subsidiaries will export/re-export any technical data, process,
    109  1.21  christos  * software, or service, directly or indirectly, to any country for which the
    110  1.21  christos  * United States government or any agency thereof requires an export license,
    111  1.21  christos  * other governmental approval, or letter of assurance, without first obtaining
    112  1.21  christos  * such license, approval or letter.
    113  1.21  christos  *
    114  1.21  christos  *****************************************************************************
    115  1.21  christos  *
    116  1.21  christos  * Alternatively, you may choose to be licensed under the terms of the
    117  1.21  christos  * following license:
    118  1.21  christos  *
    119   1.1    jruoho  * Redistribution and use in source and binary forms, with or without
    120   1.1    jruoho  * modification, are permitted provided that the following conditions
    121   1.1    jruoho  * are met:
    122   1.1    jruoho  * 1. Redistributions of source code must retain the above copyright
    123   1.1    jruoho  *    notice, this list of conditions, and the following disclaimer,
    124   1.1    jruoho  *    without modification.
    125   1.1    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
    126   1.1    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
    127   1.1    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
    128   1.1    jruoho  *    including a substantially similar Disclaimer requirement for further
    129   1.1    jruoho  *    binary redistribution.
    130   1.1    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
    131   1.1    jruoho  *    of any contributors may be used to endorse or promote products derived
    132   1.1    jruoho  *    from this software without specific prior written permission.
    133   1.1    jruoho  *
    134   1.1    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    135   1.1    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    136  1.16  christos  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    137   1.1    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    138  1.21  christos  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    139  1.21  christos  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    140  1.21  christos  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    141  1.21  christos  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    142  1.21  christos  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    143  1.21  christos  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    144  1.21  christos  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    145  1.21  christos  *
    146  1.21  christos  * Alternatively, you may choose to be licensed under the terms of the
    147  1.21  christos  * GNU General Public License ("GPL") version 2 as published by the Free
    148  1.21  christos  * Software Foundation.
    149  1.21  christos  *
    150  1.21  christos  *****************************************************************************/
    151   1.1    jruoho 
    152   1.1    jruoho #include "acpi.h"
    153   1.1    jruoho #include "accommon.h"
    154   1.1    jruoho 
    155   1.1    jruoho 
    156   1.1    jruoho #define _COMPONENT          ACPI_UTILITIES
    157   1.1    jruoho         ACPI_MODULE_NAME    ("utosi")
    158   1.1    jruoho 
    159   1.4  christos 
    160   1.4  christos /******************************************************************************
    161   1.4  christos  *
    162   1.4  christos  * ACPICA policy for new _OSI strings:
    163   1.4  christos  *
    164   1.4  christos  * It is the stated policy of ACPICA that new _OSI strings will be integrated
    165   1.4  christos  * into this module as soon as possible after they are defined. It is strongly
    166   1.4  christos  * recommended that all ACPICA hosts mirror this policy and integrate any
    167   1.4  christos  * changes to this module as soon as possible. There are several historical
    168   1.4  christos  * reasons behind this policy:
    169   1.4  christos  *
    170   1.4  christos  * 1) New BIOSs tend to test only the case where the host responds TRUE to
    171   1.4  christos  *    the latest version of Windows, which would respond to the latest/newest
    172   1.4  christos  *    _OSI string. Not responding TRUE to the latest version of Windows will
    173   1.4  christos  *    risk executing untested code paths throughout the DSDT and SSDTs.
    174   1.4  christos  *
    175   1.4  christos  * 2) If a new _OSI string is recognized only after a significant delay, this
    176   1.4  christos  *    has the potential to cause problems on existing working machines because
    177   1.4  christos  *    of the possibility that a new and different path through the ASL code
    178   1.4  christos  *    will be executed.
    179   1.4  christos  *
    180   1.4  christos  * 3) New _OSI strings are tending to come out about once per year. A delay
    181   1.4  christos  *    in recognizing a new string for a significant amount of time risks the
    182   1.4  christos  *    release of another string which only compounds the initial problem.
    183   1.4  christos  *
    184   1.4  christos  *****************************************************************************/
    185   1.4  christos 
    186   1.4  christos 
    187   1.1    jruoho /*
    188   1.1    jruoho  * Strings supported by the _OSI predefined control method (which is
    189   1.1    jruoho  * implemented internally within this module.)
    190   1.1    jruoho  *
    191   1.1    jruoho  * March 2009: Removed "Linux" as this host no longer wants to respond true
    192   1.1    jruoho  * for this string. Basically, the only safe OS strings are windows-related
    193   1.1    jruoho  * and in many or most cases represent the only test path within the
    194   1.1    jruoho  * BIOS-provided ASL code.
    195   1.1    jruoho  *
    196   1.1    jruoho  * The last element of each entry is used to track the newest version of
    197   1.1    jruoho  * Windows that the BIOS has requested.
    198   1.1    jruoho  */
    199   1.1    jruoho static ACPI_INTERFACE_INFO    AcpiDefaultSupportedInterfaces[] =
    200   1.1    jruoho {
    201  1.15       rin     /* Operating System Vendor Strings */
    202   1.1    jruoho 
    203  1.10  christos     {"Windows 2000",        NULL, 0, ACPI_OSI_WIN_2000},         /* Windows 2000 */
    204  1.10  christos     {"Windows 2001",        NULL, 0, ACPI_OSI_WIN_XP},           /* Windows XP */
    205  1.10  christos     {"Windows 2001 SP1",    NULL, 0, ACPI_OSI_WIN_XP_SP1},       /* Windows XP SP1 */
    206  1.10  christos     {"Windows 2001.1",      NULL, 0, ACPI_OSI_WINSRV_2003},      /* Windows Server 2003 */
    207  1.10  christos     {"Windows 2001 SP2",    NULL, 0, ACPI_OSI_WIN_XP_SP2},       /* Windows XP SP2 */
    208  1.10  christos     {"Windows 2001.1 SP1",  NULL, 0, ACPI_OSI_WINSRV_2003_SP1},  /* Windows Server 2003 SP1 - Added 03/2006 */
    209  1.10  christos     {"Windows 2006",        NULL, 0, ACPI_OSI_WIN_VISTA},        /* Windows Vista - Added 03/2006 */
    210  1.10  christos     {"Windows 2006.1",      NULL, 0, ACPI_OSI_WINSRV_2008},      /* Windows Server 2008 - Added 09/2009 */
    211  1.10  christos     {"Windows 2006 SP1",    NULL, 0, ACPI_OSI_WIN_VISTA_SP1},    /* Windows Vista SP1 - Added 09/2009 */
    212  1.10  christos     {"Windows 2006 SP2",    NULL, 0, ACPI_OSI_WIN_VISTA_SP2},    /* Windows Vista SP2 - Added 09/2010 */
    213  1.10  christos     {"Windows 2009",        NULL, 0, ACPI_OSI_WIN_7},            /* Windows 7 and Server 2008 R2 - Added 09/2009 */
    214  1.10  christos     {"Windows 2012",        NULL, 0, ACPI_OSI_WIN_8},            /* Windows 8 and Server 2012 - Added 08/2012 */
    215  1.13  christos     {"Windows 2013",        NULL, 0, ACPI_OSI_WIN_8_1},          /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */
    216  1.10  christos     {"Windows 2015",        NULL, 0, ACPI_OSI_WIN_10},           /* Windows 10 - Added 03/2015 */
    217  1.10  christos     {"Windows 2016",        NULL, 0, ACPI_OSI_WIN_10_RS1},       /* Windows 10 version 1607 - Added 12/2017 */
    218  1.10  christos     {"Windows 2017",        NULL, 0, ACPI_OSI_WIN_10_RS2},       /* Windows 10 version 1703 - Added 12/2017 */
    219  1.10  christos     {"Windows 2017.2",      NULL, 0, ACPI_OSI_WIN_10_RS3},       /* Windows 10 version 1709 - Added 02/2018 */
    220  1.11  christos     {"Windows 2018",        NULL, 0, ACPI_OSI_WIN_10_RS4},       /* Windows 10 version 1803 - Added 11/2018 */
    221  1.11  christos     {"Windows 2018.2",      NULL, 0, ACPI_OSI_WIN_10_RS5},       /* Windows 10 version 1809 - Added 11/2018 */
    222  1.13  christos     {"Windows 2019",        NULL, 0, ACPI_OSI_WIN_10_19H1},      /* Windows 10 version 1903 - Added 08/2019 */
    223  1.17  christos     {"Windows 2020",        NULL, 0, ACPI_OSI_WIN_10_20H1},      /* Windows 10 version 2004 - Added 08/2021 */
    224  1.18  christos     {"Windows 2021",        NULL, 0, ACPI_OSI_WIN_11},           /* Windows 11 - Added 01/2022 */
    225  1.20  christos     {"Windows 2022",        NULL, 0, ACPI_OSI_WIN_11_22H2},      /* Windows 11 version 22H2 - Added 04/2024 */
    226   1.1    jruoho 
    227  1.15       rin     /* Feature Group Strings */
    228   1.1    jruoho 
    229  1.10  christos     {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0},
    230   1.1    jruoho 
    231   1.1    jruoho     /*
    232   1.1    jruoho      * All "optional" feature group strings (features that are implemented
    233   1.3  christos      * by the host) should be dynamically modified to VALID by the host via
    234   1.3  christos      * AcpiInstallInterface or AcpiUpdateInterfaces. Such optional feature
    235   1.3  christos      * group strings are set as INVALID by default here.
    236   1.1    jruoho      */
    237   1.3  christos 
    238  1.10  christos     {"Module Device",               NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
    239  1.10  christos     {"Processor Device",            NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
    240  1.10  christos     {"3.0 Thermal Model",           NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
    241  1.10  christos     {"3.0 _SCP Extensions",         NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
    242  1.10  christos     {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}
    243   1.1    jruoho };
    244   1.1    jruoho 
    245   1.1    jruoho 
    246   1.1    jruoho /*******************************************************************************
    247   1.1    jruoho  *
    248   1.1    jruoho  * FUNCTION:    AcpiUtInitializeInterfaces
    249   1.1    jruoho  *
    250   1.1    jruoho  * PARAMETERS:  None
    251   1.1    jruoho  *
    252   1.1    jruoho  * RETURN:      Status
    253   1.1    jruoho  *
    254   1.1    jruoho  * DESCRIPTION: Initialize the global _OSI supported interfaces list
    255   1.1    jruoho  *
    256   1.1    jruoho  ******************************************************************************/
    257   1.1    jruoho 
    258   1.1    jruoho ACPI_STATUS
    259   1.1    jruoho AcpiUtInitializeInterfaces (
    260   1.1    jruoho     void)
    261   1.1    jruoho {
    262   1.3  christos     ACPI_STATUS             Status;
    263   1.1    jruoho     UINT32                  i;
    264   1.1    jruoho 
    265   1.1    jruoho 
    266   1.3  christos     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
    267   1.3  christos     if (ACPI_FAILURE (Status))
    268   1.3  christos     {
    269   1.3  christos         return (Status);
    270   1.3  christos     }
    271   1.3  christos 
    272   1.1    jruoho     AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
    273   1.1    jruoho 
    274   1.1    jruoho     /* Link the static list of supported interfaces */
    275   1.1    jruoho 
    276   1.7  christos     for (i = 0;
    277   1.7  christos         i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1);
    278   1.7  christos         i++)
    279   1.1    jruoho     {
    280   1.1    jruoho         AcpiDefaultSupportedInterfaces[i].Next =
    281   1.1    jruoho             &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
    282   1.1    jruoho     }
    283   1.1    jruoho 
    284   1.1    jruoho     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
    285   1.1    jruoho     return (AE_OK);
    286   1.1    jruoho }
    287   1.1    jruoho 
    288   1.1    jruoho 
    289   1.1    jruoho /*******************************************************************************
    290   1.1    jruoho  *
    291   1.1    jruoho  * FUNCTION:    AcpiUtInterfaceTerminate
    292   1.1    jruoho  *
    293   1.1    jruoho  * PARAMETERS:  None
    294   1.1    jruoho  *
    295   1.3  christos  * RETURN:      Status
    296   1.1    jruoho  *
    297   1.1    jruoho  * DESCRIPTION: Delete all interfaces in the global list. Sets
    298   1.1    jruoho  *              AcpiGbl_SupportedInterfaces to NULL.
    299   1.1    jruoho  *
    300   1.1    jruoho  ******************************************************************************/
    301   1.1    jruoho 
    302   1.3  christos ACPI_STATUS
    303   1.1    jruoho AcpiUtInterfaceTerminate (
    304   1.1    jruoho     void)
    305   1.1    jruoho {
    306   1.3  christos     ACPI_STATUS             Status;
    307   1.1    jruoho     ACPI_INTERFACE_INFO     *NextInterface;
    308   1.1    jruoho 
    309   1.1    jruoho 
    310   1.3  christos     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
    311   1.3  christos     if (ACPI_FAILURE (Status))
    312   1.3  christos     {
    313   1.3  christos         return (Status);
    314   1.3  christos     }
    315   1.3  christos 
    316   1.1    jruoho     NextInterface = AcpiGbl_SupportedInterfaces;
    317   1.1    jruoho     while (NextInterface)
    318   1.1    jruoho     {
    319   1.1    jruoho         AcpiGbl_SupportedInterfaces = NextInterface->Next;
    320   1.1    jruoho 
    321   1.1    jruoho         if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
    322   1.1    jruoho         {
    323   1.3  christos             /* Only interfaces added at runtime can be freed */
    324   1.3  christos 
    325  1.10  christos             ACPI_FREE (__UNCONST(NextInterface->Name));
    326   1.1    jruoho             ACPI_FREE (NextInterface);
    327   1.1    jruoho         }
    328   1.3  christos         else
    329   1.3  christos         {
    330   1.3  christos             /* Interface is in static list. Reset it to invalid or valid. */
    331   1.3  christos 
    332   1.3  christos             if (NextInterface->Flags & ACPI_OSI_DEFAULT_INVALID)
    333   1.3  christos             {
    334   1.3  christos                 NextInterface->Flags |= ACPI_OSI_INVALID;
    335   1.3  christos             }
    336   1.3  christos             else
    337   1.3  christos             {
    338   1.3  christos                 NextInterface->Flags &= ~ACPI_OSI_INVALID;
    339   1.3  christos             }
    340   1.3  christos         }
    341   1.1    jruoho 
    342   1.1    jruoho         NextInterface = AcpiGbl_SupportedInterfaces;
    343   1.1    jruoho     }
    344   1.1    jruoho 
    345   1.1    jruoho     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
    346   1.3  christos     return (AE_OK);
    347   1.1    jruoho }
    348   1.1    jruoho 
    349   1.1    jruoho 
    350   1.1    jruoho /*******************************************************************************
    351   1.1    jruoho  *
    352   1.1    jruoho  * FUNCTION:    AcpiUtInstallInterface
    353   1.1    jruoho  *
    354   1.1    jruoho  * PARAMETERS:  InterfaceName       - The interface to install
    355   1.1    jruoho  *
    356   1.1    jruoho  * RETURN:      Status
    357   1.1    jruoho  *
    358   1.1    jruoho  * DESCRIPTION: Install the interface into the global interface list.
    359   1.1    jruoho  *              Caller MUST hold AcpiGbl_OsiMutex
    360   1.1    jruoho  *
    361   1.1    jruoho  ******************************************************************************/
    362   1.1    jruoho 
    363   1.1    jruoho ACPI_STATUS
    364   1.1    jruoho AcpiUtInstallInterface (
    365   1.1    jruoho     ACPI_STRING             InterfaceName)
    366   1.1    jruoho {
    367   1.1    jruoho     ACPI_INTERFACE_INFO     *InterfaceInfo;
    368   1.1    jruoho 
    369   1.1    jruoho 
    370   1.1    jruoho     /* Allocate info block and space for the name string */
    371   1.1    jruoho 
    372   1.1    jruoho     InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
    373   1.1    jruoho     if (!InterfaceInfo)
    374   1.1    jruoho     {
    375   1.1    jruoho         return (AE_NO_MEMORY);
    376   1.1    jruoho     }
    377   1.1    jruoho 
    378   1.6  christos     InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (strlen (InterfaceName) + 1);
    379   1.1    jruoho     if (!InterfaceInfo->Name)
    380   1.1    jruoho     {
    381   1.1    jruoho         ACPI_FREE (InterfaceInfo);
    382   1.1    jruoho         return (AE_NO_MEMORY);
    383   1.1    jruoho     }
    384   1.1    jruoho 
    385   1.1    jruoho     /* Initialize new info and insert at the head of the global list */
    386   1.1    jruoho 
    387  1.10  christos     strcpy (__UNCONST(InterfaceInfo->Name), InterfaceName);
    388   1.1    jruoho     InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
    389   1.1    jruoho     InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
    390   1.1    jruoho 
    391   1.1    jruoho     AcpiGbl_SupportedInterfaces = InterfaceInfo;
    392   1.1    jruoho     return (AE_OK);
    393   1.1    jruoho }
    394   1.1    jruoho 
    395   1.1    jruoho 
    396   1.1    jruoho /*******************************************************************************
    397   1.1    jruoho  *
    398   1.1    jruoho  * FUNCTION:    AcpiUtRemoveInterface
    399   1.1    jruoho  *
    400   1.1    jruoho  * PARAMETERS:  InterfaceName       - The interface to remove
    401   1.1    jruoho  *
    402   1.1    jruoho  * RETURN:      Status
    403   1.1    jruoho  *
    404   1.1    jruoho  * DESCRIPTION: Remove the interface from the global interface list.
    405   1.1    jruoho  *              Caller MUST hold AcpiGbl_OsiMutex
    406   1.1    jruoho  *
    407   1.1    jruoho  ******************************************************************************/
    408   1.1    jruoho 
    409   1.1    jruoho ACPI_STATUS
    410   1.1    jruoho AcpiUtRemoveInterface (
    411   1.1    jruoho     ACPI_STRING             InterfaceName)
    412   1.1    jruoho {
    413   1.1    jruoho     ACPI_INTERFACE_INFO     *PreviousInterface;
    414   1.1    jruoho     ACPI_INTERFACE_INFO     *NextInterface;
    415   1.1    jruoho 
    416   1.1    jruoho 
    417   1.1    jruoho     PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
    418   1.1    jruoho     while (NextInterface)
    419   1.1    jruoho     {
    420   1.6  christos         if (!strcmp (InterfaceName, NextInterface->Name))
    421   1.1    jruoho         {
    422   1.7  christos             /*
    423   1.7  christos              * Found: name is in either the static list
    424   1.7  christos              * or was added at runtime
    425   1.7  christos              */
    426   1.1    jruoho             if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
    427   1.1    jruoho             {
    428   1.1    jruoho                 /* Interface was added dynamically, remove and free it */
    429   1.1    jruoho 
    430   1.1    jruoho                 if (PreviousInterface == NextInterface)
    431   1.1    jruoho                 {
    432   1.1    jruoho                     AcpiGbl_SupportedInterfaces = NextInterface->Next;
    433   1.1    jruoho                 }
    434   1.1    jruoho                 else
    435   1.1    jruoho                 {
    436   1.1    jruoho                     PreviousInterface->Next = NextInterface->Next;
    437   1.1    jruoho                 }
    438   1.1    jruoho 
    439  1.10  christos                 ACPI_FREE (__UNCONST(NextInterface->Name));
    440   1.1    jruoho                 ACPI_FREE (NextInterface);
    441   1.1    jruoho             }
    442   1.1    jruoho             else
    443   1.1    jruoho             {
    444   1.1    jruoho                 /*
    445   1.7  christos                  * Interface is in static list. If marked invalid, then
    446   1.7  christos                  * it does not actually exist. Else, mark it invalid.
    447   1.1    jruoho                  */
    448   1.1    jruoho                 if (NextInterface->Flags & ACPI_OSI_INVALID)
    449   1.1    jruoho                 {
    450   1.1    jruoho                     return (AE_NOT_EXIST);
    451   1.1    jruoho                 }
    452   1.1    jruoho 
    453   1.1    jruoho                 NextInterface->Flags |= ACPI_OSI_INVALID;
    454   1.1    jruoho             }
    455   1.1    jruoho 
    456   1.1    jruoho             return (AE_OK);
    457   1.1    jruoho         }
    458   1.1    jruoho 
    459   1.1    jruoho         PreviousInterface = NextInterface;
    460   1.1    jruoho         NextInterface = NextInterface->Next;
    461   1.1    jruoho     }
    462   1.1    jruoho 
    463   1.1    jruoho     /* Interface was not found */
    464   1.1    jruoho 
    465   1.1    jruoho     return (AE_NOT_EXIST);
    466   1.1    jruoho }
    467   1.1    jruoho 
    468   1.1    jruoho 
    469   1.1    jruoho /*******************************************************************************
    470   1.1    jruoho  *
    471   1.3  christos  * FUNCTION:    AcpiUtUpdateInterfaces
    472   1.3  christos  *
    473   1.3  christos  * PARAMETERS:  Action              - Actions to be performed during the
    474   1.3  christos  *                                    update
    475   1.3  christos  *
    476   1.3  christos  * RETURN:      Status
    477   1.3  christos  *
    478   1.3  christos  * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
    479   1.3  christos  *              strings or/and feature group strings.
    480   1.3  christos  *              Caller MUST hold AcpiGbl_OsiMutex
    481   1.3  christos  *
    482   1.3  christos  ******************************************************************************/
    483   1.3  christos 
    484   1.3  christos ACPI_STATUS
    485   1.3  christos AcpiUtUpdateInterfaces (
    486   1.3  christos     UINT8                   Action)
    487   1.3  christos {
    488   1.3  christos     ACPI_INTERFACE_INFO     *NextInterface;
    489   1.3  christos 
    490   1.3  christos 
    491   1.3  christos     NextInterface = AcpiGbl_SupportedInterfaces;
    492   1.3  christos     while (NextInterface)
    493   1.3  christos     {
    494   1.3  christos         if (((NextInterface->Flags & ACPI_OSI_FEATURE) &&
    495   1.3  christos              (Action & ACPI_FEATURE_STRINGS)) ||
    496   1.3  christos             (!(NextInterface->Flags & ACPI_OSI_FEATURE) &&
    497   1.3  christos              (Action & ACPI_VENDOR_STRINGS)))
    498   1.3  christos         {
    499   1.3  christos             if (Action & ACPI_DISABLE_INTERFACES)
    500   1.3  christos             {
    501   1.3  christos                 /* Mark the interfaces as invalid */
    502   1.3  christos 
    503   1.3  christos                 NextInterface->Flags |= ACPI_OSI_INVALID;
    504   1.3  christos             }
    505   1.3  christos             else
    506   1.3  christos             {
    507   1.3  christos                 /* Mark the interfaces as valid */
    508   1.3  christos 
    509   1.3  christos                 NextInterface->Flags &= ~ACPI_OSI_INVALID;
    510   1.3  christos             }
    511   1.3  christos         }
    512   1.3  christos 
    513   1.3  christos         NextInterface = NextInterface->Next;
    514   1.3  christos     }
    515   1.3  christos 
    516   1.3  christos     return (AE_OK);
    517   1.3  christos }
    518   1.3  christos 
    519   1.3  christos 
    520   1.3  christos /*******************************************************************************
    521   1.3  christos  *
    522   1.1    jruoho  * FUNCTION:    AcpiUtGetInterface
    523   1.1    jruoho  *
    524   1.1    jruoho  * PARAMETERS:  InterfaceName       - The interface to find
    525   1.1    jruoho  *
    526   1.1    jruoho  * RETURN:      ACPI_INTERFACE_INFO if found. NULL if not found.
    527   1.1    jruoho  *
    528   1.1    jruoho  * DESCRIPTION: Search for the specified interface name in the global list.
    529   1.1    jruoho  *              Caller MUST hold AcpiGbl_OsiMutex
    530   1.1    jruoho  *
    531   1.1    jruoho  ******************************************************************************/
    532   1.1    jruoho 
    533   1.1    jruoho ACPI_INTERFACE_INFO *
    534   1.1    jruoho AcpiUtGetInterface (
    535   1.1    jruoho     ACPI_STRING             InterfaceName)
    536   1.1    jruoho {
    537   1.1    jruoho     ACPI_INTERFACE_INFO     *NextInterface;
    538   1.1    jruoho 
    539   1.1    jruoho 
    540   1.1    jruoho     NextInterface = AcpiGbl_SupportedInterfaces;
    541   1.1    jruoho     while (NextInterface)
    542   1.1    jruoho     {
    543   1.6  christos         if (!strcmp (InterfaceName, NextInterface->Name))
    544   1.1    jruoho         {
    545   1.1    jruoho             return (NextInterface);
    546   1.1    jruoho         }
    547   1.1    jruoho 
    548   1.1    jruoho         NextInterface = NextInterface->Next;
    549   1.1    jruoho     }
    550   1.1    jruoho 
    551   1.1    jruoho     return (NULL);
    552   1.1    jruoho }
    553   1.1    jruoho 
    554   1.1    jruoho 
    555   1.1    jruoho /*******************************************************************************
    556   1.1    jruoho  *
    557   1.1    jruoho  * FUNCTION:    AcpiUtOsiImplementation
    558   1.1    jruoho  *
    559   1.1    jruoho  * PARAMETERS:  WalkState           - Current walk state
    560   1.1    jruoho  *
    561   1.1    jruoho  * RETURN:      Status
    562   1.8  christos  *              Integer: TRUE (0) if input string is matched
    563   1.8  christos  *                       FALSE (-1) if string is not matched
    564   1.1    jruoho  *
    565   1.1    jruoho  * DESCRIPTION: Implementation of the _OSI predefined control method. When
    566   1.1    jruoho  *              an invocation of _OSI is encountered in the system AML,
    567   1.1    jruoho  *              control is transferred to this function.
    568   1.1    jruoho  *
    569   1.8  christos  * (August 2016)
    570   1.8  christos  * Note:  _OSI is now defined to return "Ones" to indicate a match, for
    571   1.8  christos  * compatibility with other ACPI implementations. On a 32-bit DSDT, Ones
    572   1.8  christos  * is 0xFFFFFFFF. On a 64-bit DSDT, Ones is 0xFFFFFFFFFFFFFFFF
    573   1.8  christos  * (ACPI_UINT64_MAX).
    574   1.8  christos  *
    575   1.8  christos  * This function always returns ACPI_UINT64_MAX for TRUE, and later code
    576   1.8  christos  * will truncate this to 32 bits if necessary.
    577   1.8  christos  *
    578   1.1    jruoho  ******************************************************************************/
    579   1.1    jruoho 
    580   1.1    jruoho ACPI_STATUS
    581   1.1    jruoho AcpiUtOsiImplementation (
    582   1.1    jruoho     ACPI_WALK_STATE         *WalkState)
    583   1.1    jruoho {
    584   1.1    jruoho     ACPI_OPERAND_OBJECT     *StringDesc;
    585   1.1    jruoho     ACPI_OPERAND_OBJECT     *ReturnDesc;
    586   1.1    jruoho     ACPI_INTERFACE_INFO     *InterfaceInfo;
    587   1.1    jruoho     ACPI_INTERFACE_HANDLER  InterfaceHandler;
    588   1.3  christos     ACPI_STATUS             Status;
    589   1.8  christos     UINT64                  ReturnValue;
    590   1.1    jruoho 
    591   1.1    jruoho 
    592   1.1    jruoho     ACPI_FUNCTION_TRACE (UtOsiImplementation);
    593   1.1    jruoho 
    594   1.1    jruoho 
    595   1.1    jruoho     /* Validate the string input argument (from the AML caller) */
    596   1.1    jruoho 
    597   1.1    jruoho     StringDesc = WalkState->Arguments[0].Object;
    598   1.1    jruoho     if (!StringDesc ||
    599   1.1    jruoho         (StringDesc->Common.Type != ACPI_TYPE_STRING))
    600   1.1    jruoho     {
    601   1.1    jruoho         return_ACPI_STATUS (AE_TYPE);
    602   1.1    jruoho     }
    603   1.1    jruoho 
    604   1.1    jruoho     /* Create a return object */
    605   1.1    jruoho 
    606   1.1    jruoho     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
    607   1.1    jruoho     if (!ReturnDesc)
    608   1.1    jruoho     {
    609   1.1    jruoho         return_ACPI_STATUS (AE_NO_MEMORY);
    610   1.1    jruoho     }
    611   1.1    jruoho 
    612   1.1    jruoho     /* Default return value is 0, NOT SUPPORTED */
    613   1.1    jruoho 
    614   1.1    jruoho     ReturnValue = 0;
    615   1.3  christos     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
    616   1.3  christos     if (ACPI_FAILURE (Status))
    617   1.3  christos     {
    618   1.3  christos         AcpiUtRemoveReference (ReturnDesc);
    619   1.3  christos         return_ACPI_STATUS (Status);
    620   1.3  christos     }
    621   1.1    jruoho 
    622   1.1    jruoho     /* Lookup the interface in the global _OSI list */
    623   1.1    jruoho 
    624   1.1    jruoho     InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
    625   1.1    jruoho     if (InterfaceInfo &&
    626   1.1    jruoho         !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
    627   1.1    jruoho     {
    628   1.1    jruoho         /*
    629   1.1    jruoho          * The interface is supported.
    630   1.1    jruoho          * Update the OsiData if necessary. We keep track of the latest
    631   1.1    jruoho          * version of Windows that has been requested by the BIOS.
    632   1.1    jruoho          */
    633   1.1    jruoho         if (InterfaceInfo->Value > AcpiGbl_OsiData)
    634   1.1    jruoho         {
    635   1.1    jruoho             AcpiGbl_OsiData = InterfaceInfo->Value;
    636   1.1    jruoho         }
    637   1.1    jruoho 
    638   1.8  christos         ReturnValue = ACPI_UINT64_MAX;
    639   1.1    jruoho     }
    640   1.1    jruoho 
    641   1.1    jruoho     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
    642   1.1    jruoho 
    643   1.1    jruoho     /*
    644   1.1    jruoho      * Invoke an optional _OSI interface handler. The host OS may wish
    645   1.1    jruoho      * to do some interface-specific handling. For example, warn about
    646   1.1    jruoho      * certain interfaces or override the true/false support value.
    647   1.1    jruoho      */
    648   1.1    jruoho     InterfaceHandler = AcpiGbl_InterfaceHandler;
    649   1.1    jruoho     if (InterfaceHandler)
    650   1.1    jruoho     {
    651   1.8  christos         if (InterfaceHandler (
    652   1.8  christos             StringDesc->String.Pointer, (UINT32) ReturnValue))
    653   1.8  christos         {
    654   1.8  christos             ReturnValue = ACPI_UINT64_MAX;
    655   1.8  christos         }
    656   1.1    jruoho     }
    657   1.1    jruoho 
    658   1.1    jruoho     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
    659   1.1    jruoho         "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
    660   1.1    jruoho         StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
    661   1.1    jruoho 
    662   1.1    jruoho     /* Complete the return object */
    663   1.1    jruoho 
    664   1.1    jruoho     ReturnDesc->Integer.Value = ReturnValue;
    665   1.1    jruoho     WalkState->ReturnDesc = ReturnDesc;
    666   1.1    jruoho     return_ACPI_STATUS (AE_OK);
    667   1.1    jruoho }
    668