Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:03

0001 /******************************************************************************
0002  *
0003  * Module Name: utosi - Support for the _OSI predefined control method
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights. You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code. No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision. In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change. Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee. Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution. In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government. In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************
0115  *
0116  * Alternatively, you may choose to be licensed under the terms of the
0117  * following license:
0118  *
0119  * Redistribution and use in source and binary forms, with or without
0120  * modification, are permitted provided that the following conditions
0121  * are met:
0122  * 1. Redistributions of source code must retain the above copyright
0123  *    notice, this list of conditions, and the following disclaimer,
0124  *    without modification.
0125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0126  *    substantially similar to the "NO WARRANTY" disclaimer below
0127  *    ("Disclaimer") and any redistribution must be conditioned upon
0128  *    including a substantially similar Disclaimer requirement for further
0129  *    binary redistribution.
0130  * 3. Neither the names of the above-listed copyright holders nor the names
0131  *    of any contributors may be used to endorse or promote products derived
0132  *    from this software without specific prior written permission.
0133  *
0134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0145  *
0146  * Alternatively, you may choose to be licensed under the terms of the
0147  * GNU General Public License ("GPL") version 2 as published by the Free
0148  * Software Foundation.
0149  *
0150  *****************************************************************************/
0151 
0152 #include "acpi.h"
0153 #include "accommon.h"
0154 
0155 
0156 #define _COMPONENT          ACPI_UTILITIES
0157         ACPI_MODULE_NAME    ("utosi")
0158 
0159 
0160 /******************************************************************************
0161  *
0162  * ACPICA policy for new _OSI strings:
0163  *
0164  * It is the stated policy of ACPICA that new _OSI strings will be integrated
0165  * into this module as soon as possible after they are defined. It is strongly
0166  * recommended that all ACPICA hosts mirror this policy and integrate any
0167  * changes to this module as soon as possible. There are several historical
0168  * reasons behind this policy:
0169  *
0170  * 1) New BIOSs tend to test only the case where the host responds TRUE to
0171  *    the latest version of Windows, which would respond to the latest/newest
0172  *    _OSI string. Not responding TRUE to the latest version of Windows will
0173  *    risk executing untested code paths throughout the DSDT and SSDTs.
0174  *
0175  * 2) If a new _OSI string is recognized only after a significant delay, this
0176  *    has the potential to cause problems on existing working machines because
0177  *    of the possibility that a new and different path through the ASL code
0178  *    will be executed.
0179  *
0180  * 3) New _OSI strings are tending to come out about once per year. A delay
0181  *    in recognizing a new string for a significant amount of time risks the
0182  *    release of another string which only compounds the initial problem.
0183  *
0184  *****************************************************************************/
0185 
0186 
0187 /*
0188  * Strings supported by the _OSI predefined control method (which is
0189  * implemented internally within this module.)
0190  *
0191  * March 2009: Removed "Linux" as this host no longer wants to respond true
0192  * for this string. Basically, the only safe OS strings are windows-related
0193  * and in many or most cases represent the only test path within the
0194  * BIOS-provided ASL code.
0195  *
0196  * The last element of each entry is used to track the newest version of
0197  * Windows that the BIOS has requested.
0198  */
0199 static ACPI_INTERFACE_INFO    AcpiDefaultSupportedInterfaces[] =
0200 {
0201     /* Operating System Vendor Strings */
0202 
0203     {"Windows 2000",        NULL, 0, ACPI_OSI_WIN_2000},         /* Windows 2000 */
0204     {"Windows 2001",        NULL, 0, ACPI_OSI_WIN_XP},           /* Windows XP */
0205     {"Windows 2001 SP1",    NULL, 0, ACPI_OSI_WIN_XP_SP1},       /* Windows XP SP1 */
0206     {"Windows 2001.1",      NULL, 0, ACPI_OSI_WINSRV_2003},      /* Windows Server 2003 */
0207     {"Windows 2001 SP2",    NULL, 0, ACPI_OSI_WIN_XP_SP2},       /* Windows XP SP2 */
0208     {"Windows 2001.1 SP1",  NULL, 0, ACPI_OSI_WINSRV_2003_SP1},  /* Windows Server 2003 SP1 - Added 03/2006 */
0209     {"Windows 2006",        NULL, 0, ACPI_OSI_WIN_VISTA},        /* Windows Vista - Added 03/2006 */
0210     {"Windows 2006.1",      NULL, 0, ACPI_OSI_WINSRV_2008},      /* Windows Server 2008 - Added 09/2009 */
0211     {"Windows 2006 SP1",    NULL, 0, ACPI_OSI_WIN_VISTA_SP1},    /* Windows Vista SP1 - Added 09/2009 */
0212     {"Windows 2006 SP2",    NULL, 0, ACPI_OSI_WIN_VISTA_SP2},    /* Windows Vista SP2 - Added 09/2010 */
0213     {"Windows 2009",        NULL, 0, ACPI_OSI_WIN_7},            /* Windows 7 and Server 2008 R2 - Added 09/2009 */
0214     {"Windows 2012",        NULL, 0, ACPI_OSI_WIN_8},            /* Windows 8 and Server 2012 - Added 08/2012 */
0215     {"Windows 2013",        NULL, 0, ACPI_OSI_WIN_8_1},          /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */
0216     {"Windows 2015",        NULL, 0, ACPI_OSI_WIN_10},           /* Windows 10 - Added 03/2015 */
0217     {"Windows 2016",        NULL, 0, ACPI_OSI_WIN_10_RS1},       /* Windows 10 version 1607 - Added 12/2017 */
0218     {"Windows 2017",        NULL, 0, ACPI_OSI_WIN_10_RS2},       /* Windows 10 version 1703 - Added 12/2017 */
0219     {"Windows 2017.2",      NULL, 0, ACPI_OSI_WIN_10_RS3},       /* Windows 10 version 1709 - Added 02/2018 */
0220     {"Windows 2018",        NULL, 0, ACPI_OSI_WIN_10_RS4},       /* Windows 10 version 1803 - Added 11/2018 */
0221     {"Windows 2018.2",      NULL, 0, ACPI_OSI_WIN_10_RS5},       /* Windows 10 version 1809 - Added 11/2018 */
0222     {"Windows 2019",        NULL, 0, ACPI_OSI_WIN_10_19H1},      /* Windows 10 version 1903 - Added 08/2019 */
0223     {"Windows 2020",        NULL, 0, ACPI_OSI_WIN_10_20H1},      /* Windows 10 version 2004 - Added 08/2021 */
0224     {"Windows 2021",        NULL, 0, ACPI_OSI_WIN_11},           /* Windows 11 - Added 01/2022 */
0225     {"Windows 2022",        NULL, 0, ACPI_OSI_WIN_11_22H2},      /* Windows 11 version 22H2 - Added 04/2024 */
0226 
0227     /* Feature Group Strings */
0228 
0229     {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0},
0230 
0231     /*
0232      * All "optional" feature group strings (features that are implemented
0233      * by the host) should be dynamically modified to VALID by the host via
0234      * AcpiInstallInterface or AcpiUpdateInterfaces. Such optional feature
0235      * group strings are set as INVALID by default here.
0236      */
0237 
0238     {"Module Device",               NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
0239     {"Processor Device",            NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
0240     {"3.0 Thermal Model",           NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
0241     {"3.0 _SCP Extensions",         NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
0242     {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}
0243 };
0244 
0245 
0246 /*******************************************************************************
0247  *
0248  * FUNCTION:    AcpiUtInitializeInterfaces
0249  *
0250  * PARAMETERS:  None
0251  *
0252  * RETURN:      Status
0253  *
0254  * DESCRIPTION: Initialize the global _OSI supported interfaces list
0255  *
0256  ******************************************************************************/
0257 
0258 ACPI_STATUS
0259 AcpiUtInitializeInterfaces (
0260     void)
0261 {
0262     ACPI_STATUS             Status;
0263     UINT32                  i;
0264 
0265 
0266     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
0267     if (ACPI_FAILURE (Status))
0268     {
0269         return (Status);
0270     }
0271 
0272     AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
0273 
0274     /* Link the static list of supported interfaces */
0275 
0276     for (i = 0;
0277         i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1);
0278         i++)
0279     {
0280         AcpiDefaultSupportedInterfaces[i].Next =
0281             &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
0282     }
0283 
0284     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
0285     return (AE_OK);
0286 }
0287 
0288 
0289 /*******************************************************************************
0290  *
0291  * FUNCTION:    AcpiUtInterfaceTerminate
0292  *
0293  * PARAMETERS:  None
0294  *
0295  * RETURN:      Status
0296  *
0297  * DESCRIPTION: Delete all interfaces in the global list. Sets
0298  *              AcpiGbl_SupportedInterfaces to NULL.
0299  *
0300  ******************************************************************************/
0301 
0302 ACPI_STATUS
0303 AcpiUtInterfaceTerminate (
0304     void)
0305 {
0306     ACPI_STATUS             Status;
0307     ACPI_INTERFACE_INFO     *NextInterface;
0308 
0309 
0310     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
0311     if (ACPI_FAILURE (Status))
0312     {
0313         return (Status);
0314     }
0315 
0316     NextInterface = AcpiGbl_SupportedInterfaces;
0317     while (NextInterface)
0318     {
0319         AcpiGbl_SupportedInterfaces = NextInterface->Next;
0320 
0321         if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
0322         {
0323             /* Only interfaces added at runtime can be freed */
0324 
0325             ACPI_FREE (NextInterface->Name);
0326             ACPI_FREE (NextInterface);
0327         }
0328         else
0329         {
0330             /* Interface is in static list. Reset it to invalid or valid. */
0331 
0332             if (NextInterface->Flags & ACPI_OSI_DEFAULT_INVALID)
0333             {
0334                 NextInterface->Flags |= ACPI_OSI_INVALID;
0335             }
0336             else
0337             {
0338                 NextInterface->Flags &= ~ACPI_OSI_INVALID;
0339             }
0340         }
0341 
0342         NextInterface = AcpiGbl_SupportedInterfaces;
0343     }
0344 
0345     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
0346     return (AE_OK);
0347 }
0348 
0349 
0350 /*******************************************************************************
0351  *
0352  * FUNCTION:    AcpiUtInstallInterface
0353  *
0354  * PARAMETERS:  InterfaceName       - The interface to install
0355  *
0356  * RETURN:      Status
0357  *
0358  * DESCRIPTION: Install the interface into the global interface list.
0359  *              Caller MUST hold AcpiGbl_OsiMutex
0360  *
0361  ******************************************************************************/
0362 
0363 ACPI_STATUS
0364 AcpiUtInstallInterface (
0365     ACPI_STRING             InterfaceName)
0366 {
0367     ACPI_INTERFACE_INFO     *InterfaceInfo;
0368 
0369 
0370     /* Allocate info block and space for the name string */
0371 
0372     InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
0373     if (!InterfaceInfo)
0374     {
0375         return (AE_NO_MEMORY);
0376     }
0377 
0378     InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (strlen (InterfaceName) + 1);
0379     if (!InterfaceInfo->Name)
0380     {
0381         ACPI_FREE (InterfaceInfo);
0382         return (AE_NO_MEMORY);
0383     }
0384 
0385     /* Initialize new info and insert at the head of the global list */
0386 
0387     strcpy (InterfaceInfo->Name, InterfaceName);
0388     InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
0389     InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
0390 
0391     AcpiGbl_SupportedInterfaces = InterfaceInfo;
0392     return (AE_OK);
0393 }
0394 
0395 
0396 /*******************************************************************************
0397  *
0398  * FUNCTION:    AcpiUtRemoveInterface
0399  *
0400  * PARAMETERS:  InterfaceName       - The interface to remove
0401  *
0402  * RETURN:      Status
0403  *
0404  * DESCRIPTION: Remove the interface from the global interface list.
0405  *              Caller MUST hold AcpiGbl_OsiMutex
0406  *
0407  ******************************************************************************/
0408 
0409 ACPI_STATUS
0410 AcpiUtRemoveInterface (
0411     ACPI_STRING             InterfaceName)
0412 {
0413     ACPI_INTERFACE_INFO     *PreviousInterface;
0414     ACPI_INTERFACE_INFO     *NextInterface;
0415 
0416 
0417     PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
0418     while (NextInterface)
0419     {
0420         if (!strcmp (InterfaceName, NextInterface->Name))
0421         {
0422             /*
0423              * Found: name is in either the static list
0424              * or was added at runtime
0425              */
0426             if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
0427             {
0428                 /* Interface was added dynamically, remove and free it */
0429 
0430                 if (PreviousInterface == NextInterface)
0431                 {
0432                     AcpiGbl_SupportedInterfaces = NextInterface->Next;
0433                 }
0434                 else
0435                 {
0436                     PreviousInterface->Next = NextInterface->Next;
0437                 }
0438 
0439                 ACPI_FREE (NextInterface->Name);
0440                 ACPI_FREE (NextInterface);
0441             }
0442             else
0443             {
0444                 /*
0445                  * Interface is in static list. If marked invalid, then
0446                  * it does not actually exist. Else, mark it invalid.
0447                  */
0448                 if (NextInterface->Flags & ACPI_OSI_INVALID)
0449                 {
0450                     return (AE_NOT_EXIST);
0451                 }
0452 
0453                 NextInterface->Flags |= ACPI_OSI_INVALID;
0454             }
0455 
0456             return (AE_OK);
0457         }
0458 
0459         PreviousInterface = NextInterface;
0460         NextInterface = NextInterface->Next;
0461     }
0462 
0463     /* Interface was not found */
0464 
0465     return (AE_NOT_EXIST);
0466 }
0467 
0468 
0469 /*******************************************************************************
0470  *
0471  * FUNCTION:    AcpiUtUpdateInterfaces
0472  *
0473  * PARAMETERS:  Action              - Actions to be performed during the
0474  *                                    update
0475  *
0476  * RETURN:      Status
0477  *
0478  * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
0479  *              strings or/and feature group strings.
0480  *              Caller MUST hold AcpiGbl_OsiMutex
0481  *
0482  ******************************************************************************/
0483 
0484 ACPI_STATUS
0485 AcpiUtUpdateInterfaces (
0486     UINT8                   Action)
0487 {
0488     ACPI_INTERFACE_INFO     *NextInterface;
0489 
0490 
0491     NextInterface = AcpiGbl_SupportedInterfaces;
0492     while (NextInterface)
0493     {
0494         if (((NextInterface->Flags & ACPI_OSI_FEATURE) &&
0495              (Action & ACPI_FEATURE_STRINGS)) ||
0496             (!(NextInterface->Flags & ACPI_OSI_FEATURE) &&
0497              (Action & ACPI_VENDOR_STRINGS)))
0498         {
0499             if (Action & ACPI_DISABLE_INTERFACES)
0500             {
0501                 /* Mark the interfaces as invalid */
0502 
0503                 NextInterface->Flags |= ACPI_OSI_INVALID;
0504             }
0505             else
0506             {
0507                 /* Mark the interfaces as valid */
0508 
0509                 NextInterface->Flags &= ~ACPI_OSI_INVALID;
0510             }
0511         }
0512 
0513         NextInterface = NextInterface->Next;
0514     }
0515 
0516     return (AE_OK);
0517 }
0518 
0519 
0520 /*******************************************************************************
0521  *
0522  * FUNCTION:    AcpiUtGetInterface
0523  *
0524  * PARAMETERS:  InterfaceName       - The interface to find
0525  *
0526  * RETURN:      ACPI_INTERFACE_INFO if found. NULL if not found.
0527  *
0528  * DESCRIPTION: Search for the specified interface name in the global list.
0529  *              Caller MUST hold AcpiGbl_OsiMutex
0530  *
0531  ******************************************************************************/
0532 
0533 ACPI_INTERFACE_INFO *
0534 AcpiUtGetInterface (
0535     ACPI_STRING             InterfaceName)
0536 {
0537     ACPI_INTERFACE_INFO     *NextInterface;
0538 
0539 
0540     NextInterface = AcpiGbl_SupportedInterfaces;
0541     while (NextInterface)
0542     {
0543         if (!strcmp (InterfaceName, NextInterface->Name))
0544         {
0545             return (NextInterface);
0546         }
0547 
0548         NextInterface = NextInterface->Next;
0549     }
0550 
0551     return (NULL);
0552 }
0553 
0554 
0555 /*******************************************************************************
0556  *
0557  * FUNCTION:    AcpiUtOsiImplementation
0558  *
0559  * PARAMETERS:  WalkState           - Current walk state
0560  *
0561  * RETURN:      Status
0562  *              Integer: TRUE (0) if input string is matched
0563  *                       FALSE (-1) if string is not matched
0564  *
0565  * DESCRIPTION: Implementation of the _OSI predefined control method. When
0566  *              an invocation of _OSI is encountered in the system AML,
0567  *              control is transferred to this function.
0568  *
0569  * (August 2016)
0570  * Note:  _OSI is now defined to return "Ones" to indicate a match, for
0571  * compatibility with other ACPI implementations. On a 32-bit DSDT, Ones
0572  * is 0xFFFFFFFF. On a 64-bit DSDT, Ones is 0xFFFFFFFFFFFFFFFF
0573  * (ACPI_UINT64_MAX).
0574  *
0575  * This function always returns ACPI_UINT64_MAX for TRUE, and later code
0576  * will truncate this to 32 bits if necessary.
0577  *
0578  ******************************************************************************/
0579 
0580 ACPI_STATUS
0581 AcpiUtOsiImplementation (
0582     ACPI_WALK_STATE         *WalkState)
0583 {
0584     ACPI_OPERAND_OBJECT     *StringDesc;
0585     ACPI_OPERAND_OBJECT     *ReturnDesc;
0586     ACPI_INTERFACE_INFO     *InterfaceInfo;
0587     ACPI_INTERFACE_HANDLER  InterfaceHandler;
0588     ACPI_STATUS             Status;
0589     UINT64                  ReturnValue;
0590 
0591 
0592     ACPI_FUNCTION_TRACE (UtOsiImplementation);
0593 
0594 
0595     /* Validate the string input argument (from the AML caller) */
0596 
0597     StringDesc = WalkState->Arguments[0].Object;
0598     if (!StringDesc ||
0599         (StringDesc->Common.Type != ACPI_TYPE_STRING))
0600     {
0601         return_ACPI_STATUS (AE_TYPE);
0602     }
0603 
0604     /* Create a return object */
0605 
0606     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
0607     if (!ReturnDesc)
0608     {
0609         return_ACPI_STATUS (AE_NO_MEMORY);
0610     }
0611 
0612     /* Default return value is 0, NOT SUPPORTED */
0613 
0614     ReturnValue = 0;
0615     Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
0616     if (ACPI_FAILURE (Status))
0617     {
0618         AcpiUtRemoveReference (ReturnDesc);
0619         return_ACPI_STATUS (Status);
0620     }
0621 
0622     /* Lookup the interface in the global _OSI list */
0623 
0624     InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
0625     if (InterfaceInfo &&
0626         !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
0627     {
0628         /*
0629          * The interface is supported.
0630          * Update the OsiData if necessary. We keep track of the latest
0631          * version of Windows that has been requested by the BIOS.
0632          */
0633         if (InterfaceInfo->Value > AcpiGbl_OsiData)
0634         {
0635             AcpiGbl_OsiData = InterfaceInfo->Value;
0636         }
0637 
0638         ReturnValue = ACPI_UINT64_MAX;
0639     }
0640 
0641     AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
0642 
0643     /*
0644      * Invoke an optional _OSI interface handler. The host OS may wish
0645      * to do some interface-specific handling. For example, warn about
0646      * certain interfaces or override the true/false support value.
0647      */
0648     InterfaceHandler = AcpiGbl_InterfaceHandler;
0649     if (InterfaceHandler)
0650     {
0651         if (InterfaceHandler (
0652             StringDesc->String.Pointer, (UINT32) ReturnValue))
0653         {
0654             ReturnValue = ACPI_UINT64_MAX;
0655         }
0656     }
0657 
0658     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
0659         "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
0660         StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
0661 
0662     /* Complete the return object */
0663 
0664     ReturnDesc->Integer.Value = ReturnValue;
0665     WalkState->ReturnDesc = ReturnDesc;
0666     return_ACPI_STATUS (AE_OK);
0667 }