126f3cdf0SGordon Ross /******************************************************************************
226f3cdf0SGordon Ross *
326f3cdf0SGordon Ross * Module Name: utosi - Support for the _OSI predefined control method
426f3cdf0SGordon Ross *
526f3cdf0SGordon Ross *****************************************************************************/
626f3cdf0SGordon Ross
726f3cdf0SGordon Ross /*
8*cb565728SJerry Jelinek * Copyright (C) 2000 - 2016, Intel Corp.
926f3cdf0SGordon Ross * All rights reserved.
1026f3cdf0SGordon Ross *
1126f3cdf0SGordon Ross * Redistribution and use in source and binary forms, with or without
1226f3cdf0SGordon Ross * modification, are permitted provided that the following conditions
1326f3cdf0SGordon Ross * are met:
1426f3cdf0SGordon Ross * 1. Redistributions of source code must retain the above copyright
1526f3cdf0SGordon Ross * notice, this list of conditions, and the following disclaimer,
1626f3cdf0SGordon Ross * without modification.
1726f3cdf0SGordon Ross * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1826f3cdf0SGordon Ross * substantially similar to the "NO WARRANTY" disclaimer below
1926f3cdf0SGordon Ross * ("Disclaimer") and any redistribution must be conditioned upon
2026f3cdf0SGordon Ross * including a substantially similar Disclaimer requirement for further
2126f3cdf0SGordon Ross * binary redistribution.
2226f3cdf0SGordon Ross * 3. Neither the names of the above-listed copyright holders nor the names
2326f3cdf0SGordon Ross * of any contributors may be used to endorse or promote products derived
2426f3cdf0SGordon Ross * from this software without specific prior written permission.
2526f3cdf0SGordon Ross *
2626f3cdf0SGordon Ross * Alternatively, this software may be distributed under the terms of the
2726f3cdf0SGordon Ross * GNU General Public License ("GPL") version 2 as published by the Free
2826f3cdf0SGordon Ross * Software Foundation.
2926f3cdf0SGordon Ross *
3026f3cdf0SGordon Ross * NO WARRANTY
3126f3cdf0SGordon Ross * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3226f3cdf0SGordon Ross * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3326f3cdf0SGordon Ross * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3426f3cdf0SGordon Ross * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3526f3cdf0SGordon Ross * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3626f3cdf0SGordon Ross * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3726f3cdf0SGordon Ross * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3826f3cdf0SGordon Ross * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3926f3cdf0SGordon Ross * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4026f3cdf0SGordon Ross * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4126f3cdf0SGordon Ross * POSSIBILITY OF SUCH DAMAGES.
4226f3cdf0SGordon Ross */
4326f3cdf0SGordon Ross
4426f3cdf0SGordon Ross #include "acpi.h"
4526f3cdf0SGordon Ross #include "accommon.h"
4626f3cdf0SGordon Ross
4726f3cdf0SGordon Ross
4826f3cdf0SGordon Ross #define _COMPONENT ACPI_UTILITIES
4926f3cdf0SGordon Ross ACPI_MODULE_NAME ("utosi")
5026f3cdf0SGordon Ross
51*cb565728SJerry Jelinek
52*cb565728SJerry Jelinek /******************************************************************************
53*cb565728SJerry Jelinek *
54*cb565728SJerry Jelinek * ACPICA policy for new _OSI strings:
55*cb565728SJerry Jelinek *
56*cb565728SJerry Jelinek * It is the stated policy of ACPICA that new _OSI strings will be integrated
57*cb565728SJerry Jelinek * into this module as soon as possible after they are defined. It is strongly
58*cb565728SJerry Jelinek * recommended that all ACPICA hosts mirror this policy and integrate any
59*cb565728SJerry Jelinek * changes to this module as soon as possible. There are several historical
60*cb565728SJerry Jelinek * reasons behind this policy:
61*cb565728SJerry Jelinek *
62*cb565728SJerry Jelinek * 1) New BIOSs tend to test only the case where the host responds TRUE to
63*cb565728SJerry Jelinek * the latest version of Windows, which would respond to the latest/newest
64*cb565728SJerry Jelinek * _OSI string. Not responding TRUE to the latest version of Windows will
65*cb565728SJerry Jelinek * risk executing untested code paths throughout the DSDT and SSDTs.
66*cb565728SJerry Jelinek *
67*cb565728SJerry Jelinek * 2) If a new _OSI string is recognized only after a significant delay, this
68*cb565728SJerry Jelinek * has the potential to cause problems on existing working machines because
69*cb565728SJerry Jelinek * of the possibility that a new and different path through the ASL code
70*cb565728SJerry Jelinek * will be executed.
71*cb565728SJerry Jelinek *
72*cb565728SJerry Jelinek * 3) New _OSI strings are tending to come out about once per year. A delay
73*cb565728SJerry Jelinek * in recognizing a new string for a significant amount of time risks the
74*cb565728SJerry Jelinek * release of another string which only compounds the initial problem.
75*cb565728SJerry Jelinek *
76*cb565728SJerry Jelinek *****************************************************************************/
77*cb565728SJerry Jelinek
78*cb565728SJerry Jelinek
7926f3cdf0SGordon Ross /*
8026f3cdf0SGordon Ross * Strings supported by the _OSI predefined control method (which is
8126f3cdf0SGordon Ross * implemented internally within this module.)
8226f3cdf0SGordon Ross *
8326f3cdf0SGordon Ross * March 2009: Removed "Linux" as this host no longer wants to respond true
8426f3cdf0SGordon Ross * for this string. Basically, the only safe OS strings are windows-related
8526f3cdf0SGordon Ross * and in many or most cases represent the only test path within the
8626f3cdf0SGordon Ross * BIOS-provided ASL code.
8726f3cdf0SGordon Ross *
8826f3cdf0SGordon Ross * The last element of each entry is used to track the newest version of
8926f3cdf0SGordon Ross * Windows that the BIOS has requested.
9026f3cdf0SGordon Ross */
9126f3cdf0SGordon Ross static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[] =
9226f3cdf0SGordon Ross {
9326f3cdf0SGordon Ross /* Operating System Vendor Strings */
9426f3cdf0SGordon Ross
9526f3cdf0SGordon Ross {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */
9626f3cdf0SGordon Ross {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */
9726f3cdf0SGordon Ross {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */
9826f3cdf0SGordon Ross {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */
9926f3cdf0SGordon Ross {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
10026f3cdf0SGordon Ross {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
10126f3cdf0SGordon Ross {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */
10226f3cdf0SGordon Ross {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */
10326f3cdf0SGordon Ross {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */
10426f3cdf0SGordon Ross {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */
10526f3cdf0SGordon Ross {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
106*cb565728SJerry Jelinek /*
107*cb565728SJerry Jelinek * XXX
108*cb565728SJerry Jelinek * The following OSes are temporarily disabled. Windows introduced
109*cb565728SJerry Jelinek * support for xhci (USB 3.0) in Windows 8. When we advertise Windows 8
110*cb565728SJerry Jelinek * and newer support, some vendors use that as a key to automatically
111*cb565728SJerry Jelinek * transition all USB ports to the xhci controller. Until we have
112*cb565728SJerry Jelinek * support for the xhci controller, we should not advertise these
113*cb565728SJerry Jelinek * operating systems. From a brief survey, there isn't too much other
114*cb565728SJerry Jelinek * AML that this impacts at this time.
115*cb565728SJerry Jelinek */
116*cb565728SJerry Jelinek /* {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8},*/ /* Windows 8 and Server 2012 - Added 08/2012 */
117*cb565728SJerry Jelinek /* {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8},*/ /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */
118*cb565728SJerry Jelinek /* {"Windows 2015", NULL, 0, ACPI_OSI_WIN_10},*/ /* Windows 10 - Added 03/2015 */
11926f3cdf0SGordon Ross
12026f3cdf0SGordon Ross /* Feature Group Strings */
12126f3cdf0SGordon Ross
122*cb565728SJerry Jelinek {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0},
12326f3cdf0SGordon Ross
12426f3cdf0SGordon Ross /*
12526f3cdf0SGordon Ross * All "optional" feature group strings (features that are implemented
126*cb565728SJerry Jelinek * by the host) should be dynamically modified to VALID by the host via
127*cb565728SJerry Jelinek * AcpiInstallInterface or AcpiUpdateInterfaces. Such optional feature
128*cb565728SJerry Jelinek * group strings are set as INVALID by default here.
12926f3cdf0SGordon Ross */
130*cb565728SJerry Jelinek
131*cb565728SJerry Jelinek {"Module Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
132*cb565728SJerry Jelinek {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
133*cb565728SJerry Jelinek {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
134*cb565728SJerry Jelinek {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
135*cb565728SJerry Jelinek {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}
13626f3cdf0SGordon Ross };
13726f3cdf0SGordon Ross
13826f3cdf0SGordon Ross
13926f3cdf0SGordon Ross /*******************************************************************************
14026f3cdf0SGordon Ross *
14126f3cdf0SGordon Ross * FUNCTION: AcpiUtInitializeInterfaces
14226f3cdf0SGordon Ross *
14326f3cdf0SGordon Ross * PARAMETERS: None
14426f3cdf0SGordon Ross *
14526f3cdf0SGordon Ross * RETURN: Status
14626f3cdf0SGordon Ross *
14726f3cdf0SGordon Ross * DESCRIPTION: Initialize the global _OSI supported interfaces list
14826f3cdf0SGordon Ross *
14926f3cdf0SGordon Ross ******************************************************************************/
15026f3cdf0SGordon Ross
15126f3cdf0SGordon Ross ACPI_STATUS
AcpiUtInitializeInterfaces(void)15226f3cdf0SGordon Ross AcpiUtInitializeInterfaces (
15326f3cdf0SGordon Ross void)
15426f3cdf0SGordon Ross {
155*cb565728SJerry Jelinek ACPI_STATUS Status;
15626f3cdf0SGordon Ross UINT32 i;
15726f3cdf0SGordon Ross
15826f3cdf0SGordon Ross
159*cb565728SJerry Jelinek Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
160*cb565728SJerry Jelinek if (ACPI_FAILURE (Status))
161*cb565728SJerry Jelinek {
162*cb565728SJerry Jelinek return (Status);
163*cb565728SJerry Jelinek }
164*cb565728SJerry Jelinek
16526f3cdf0SGordon Ross AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
16626f3cdf0SGordon Ross
16726f3cdf0SGordon Ross /* Link the static list of supported interfaces */
16826f3cdf0SGordon Ross
169*cb565728SJerry Jelinek for (i = 0;
170*cb565728SJerry Jelinek i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1);
171*cb565728SJerry Jelinek i++)
17226f3cdf0SGordon Ross {
17326f3cdf0SGordon Ross AcpiDefaultSupportedInterfaces[i].Next =
17426f3cdf0SGordon Ross &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
17526f3cdf0SGordon Ross }
17626f3cdf0SGordon Ross
17726f3cdf0SGordon Ross AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
17826f3cdf0SGordon Ross return (AE_OK);
17926f3cdf0SGordon Ross }
18026f3cdf0SGordon Ross
18126f3cdf0SGordon Ross
18226f3cdf0SGordon Ross /*******************************************************************************
18326f3cdf0SGordon Ross *
18426f3cdf0SGordon Ross * FUNCTION: AcpiUtInterfaceTerminate
18526f3cdf0SGordon Ross *
18626f3cdf0SGordon Ross * PARAMETERS: None
18726f3cdf0SGordon Ross *
188*cb565728SJerry Jelinek * RETURN: Status
18926f3cdf0SGordon Ross *
19026f3cdf0SGordon Ross * DESCRIPTION: Delete all interfaces in the global list. Sets
19126f3cdf0SGordon Ross * AcpiGbl_SupportedInterfaces to NULL.
19226f3cdf0SGordon Ross *
19326f3cdf0SGordon Ross ******************************************************************************/
19426f3cdf0SGordon Ross
195*cb565728SJerry Jelinek ACPI_STATUS
AcpiUtInterfaceTerminate(void)19626f3cdf0SGordon Ross AcpiUtInterfaceTerminate (
19726f3cdf0SGordon Ross void)
19826f3cdf0SGordon Ross {
199*cb565728SJerry Jelinek ACPI_STATUS Status;
20026f3cdf0SGordon Ross ACPI_INTERFACE_INFO *NextInterface;
20126f3cdf0SGordon Ross
20226f3cdf0SGordon Ross
203*cb565728SJerry Jelinek Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
204*cb565728SJerry Jelinek if (ACPI_FAILURE (Status))
205*cb565728SJerry Jelinek {
206*cb565728SJerry Jelinek return (Status);
207*cb565728SJerry Jelinek }
20826f3cdf0SGordon Ross
209*cb565728SJerry Jelinek NextInterface = AcpiGbl_SupportedInterfaces;
21026f3cdf0SGordon Ross while (NextInterface)
21126f3cdf0SGordon Ross {
21226f3cdf0SGordon Ross AcpiGbl_SupportedInterfaces = NextInterface->Next;
21326f3cdf0SGordon Ross
21426f3cdf0SGordon Ross if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
21526f3cdf0SGordon Ross {
216*cb565728SJerry Jelinek /* Only interfaces added at runtime can be freed */
217*cb565728SJerry Jelinek
21826f3cdf0SGordon Ross ACPI_FREE (NextInterface->Name);
21926f3cdf0SGordon Ross ACPI_FREE (NextInterface);
22026f3cdf0SGordon Ross }
221*cb565728SJerry Jelinek else
222*cb565728SJerry Jelinek {
223*cb565728SJerry Jelinek /* Interface is in static list. Reset it to invalid or valid. */
224*cb565728SJerry Jelinek
225*cb565728SJerry Jelinek if (NextInterface->Flags & ACPI_OSI_DEFAULT_INVALID)
226*cb565728SJerry Jelinek {
227*cb565728SJerry Jelinek NextInterface->Flags |= ACPI_OSI_INVALID;
228*cb565728SJerry Jelinek }
229*cb565728SJerry Jelinek else
230*cb565728SJerry Jelinek {
231*cb565728SJerry Jelinek NextInterface->Flags &= ~ACPI_OSI_INVALID;
232*cb565728SJerry Jelinek }
233*cb565728SJerry Jelinek }
23426f3cdf0SGordon Ross
23526f3cdf0SGordon Ross NextInterface = AcpiGbl_SupportedInterfaces;
23626f3cdf0SGordon Ross }
23726f3cdf0SGordon Ross
23826f3cdf0SGordon Ross AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
239*cb565728SJerry Jelinek return (AE_OK);
24026f3cdf0SGordon Ross }
24126f3cdf0SGordon Ross
24226f3cdf0SGordon Ross
24326f3cdf0SGordon Ross /*******************************************************************************
24426f3cdf0SGordon Ross *
24526f3cdf0SGordon Ross * FUNCTION: AcpiUtInstallInterface
24626f3cdf0SGordon Ross *
24726f3cdf0SGordon Ross * PARAMETERS: InterfaceName - The interface to install
24826f3cdf0SGordon Ross *
24926f3cdf0SGordon Ross * RETURN: Status
25026f3cdf0SGordon Ross *
25126f3cdf0SGordon Ross * DESCRIPTION: Install the interface into the global interface list.
25226f3cdf0SGordon Ross * Caller MUST hold AcpiGbl_OsiMutex
25326f3cdf0SGordon Ross *
25426f3cdf0SGordon Ross ******************************************************************************/
25526f3cdf0SGordon Ross
25626f3cdf0SGordon Ross ACPI_STATUS
AcpiUtInstallInterface(ACPI_STRING InterfaceName)25726f3cdf0SGordon Ross AcpiUtInstallInterface (
25826f3cdf0SGordon Ross ACPI_STRING InterfaceName)
25926f3cdf0SGordon Ross {
26026f3cdf0SGordon Ross ACPI_INTERFACE_INFO *InterfaceInfo;
26126f3cdf0SGordon Ross
26226f3cdf0SGordon Ross
26326f3cdf0SGordon Ross /* Allocate info block and space for the name string */
26426f3cdf0SGordon Ross
26526f3cdf0SGordon Ross InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
26626f3cdf0SGordon Ross if (!InterfaceInfo)
26726f3cdf0SGordon Ross {
26826f3cdf0SGordon Ross return (AE_NO_MEMORY);
26926f3cdf0SGordon Ross }
27026f3cdf0SGordon Ross
271*cb565728SJerry Jelinek InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (strlen (InterfaceName) + 1);
27226f3cdf0SGordon Ross if (!InterfaceInfo->Name)
27326f3cdf0SGordon Ross {
27426f3cdf0SGordon Ross ACPI_FREE (InterfaceInfo);
27526f3cdf0SGordon Ross return (AE_NO_MEMORY);
27626f3cdf0SGordon Ross }
27726f3cdf0SGordon Ross
27826f3cdf0SGordon Ross /* Initialize new info and insert at the head of the global list */
27926f3cdf0SGordon Ross
280*cb565728SJerry Jelinek strcpy (InterfaceInfo->Name, InterfaceName);
28126f3cdf0SGordon Ross InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
28226f3cdf0SGordon Ross InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
28326f3cdf0SGordon Ross
28426f3cdf0SGordon Ross AcpiGbl_SupportedInterfaces = InterfaceInfo;
28526f3cdf0SGordon Ross return (AE_OK);
28626f3cdf0SGordon Ross }
28726f3cdf0SGordon Ross
28826f3cdf0SGordon Ross
28926f3cdf0SGordon Ross /*******************************************************************************
29026f3cdf0SGordon Ross *
29126f3cdf0SGordon Ross * FUNCTION: AcpiUtRemoveInterface
29226f3cdf0SGordon Ross *
29326f3cdf0SGordon Ross * PARAMETERS: InterfaceName - The interface to remove
29426f3cdf0SGordon Ross *
29526f3cdf0SGordon Ross * RETURN: Status
29626f3cdf0SGordon Ross *
29726f3cdf0SGordon Ross * DESCRIPTION: Remove the interface from the global interface list.
29826f3cdf0SGordon Ross * Caller MUST hold AcpiGbl_OsiMutex
29926f3cdf0SGordon Ross *
30026f3cdf0SGordon Ross ******************************************************************************/
30126f3cdf0SGordon Ross
30226f3cdf0SGordon Ross ACPI_STATUS
AcpiUtRemoveInterface(ACPI_STRING InterfaceName)30326f3cdf0SGordon Ross AcpiUtRemoveInterface (
30426f3cdf0SGordon Ross ACPI_STRING InterfaceName)
30526f3cdf0SGordon Ross {
30626f3cdf0SGordon Ross ACPI_INTERFACE_INFO *PreviousInterface;
30726f3cdf0SGordon Ross ACPI_INTERFACE_INFO *NextInterface;
30826f3cdf0SGordon Ross
30926f3cdf0SGordon Ross
31026f3cdf0SGordon Ross PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
31126f3cdf0SGordon Ross while (NextInterface)
31226f3cdf0SGordon Ross {
313*cb565728SJerry Jelinek if (!strcmp (InterfaceName, NextInterface->Name))
31426f3cdf0SGordon Ross {
315*cb565728SJerry Jelinek /*
316*cb565728SJerry Jelinek * Found: name is in either the static list
317*cb565728SJerry Jelinek * or was added at runtime
318*cb565728SJerry Jelinek */
31926f3cdf0SGordon Ross if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
32026f3cdf0SGordon Ross {
32126f3cdf0SGordon Ross /* Interface was added dynamically, remove and free it */
32226f3cdf0SGordon Ross
32326f3cdf0SGordon Ross if (PreviousInterface == NextInterface)
32426f3cdf0SGordon Ross {
32526f3cdf0SGordon Ross AcpiGbl_SupportedInterfaces = NextInterface->Next;
32626f3cdf0SGordon Ross }
32726f3cdf0SGordon Ross else
32826f3cdf0SGordon Ross {
32926f3cdf0SGordon Ross PreviousInterface->Next = NextInterface->Next;
33026f3cdf0SGordon Ross }
33126f3cdf0SGordon Ross
33226f3cdf0SGordon Ross ACPI_FREE (NextInterface->Name);
33326f3cdf0SGordon Ross ACPI_FREE (NextInterface);
33426f3cdf0SGordon Ross }
33526f3cdf0SGordon Ross else
33626f3cdf0SGordon Ross {
33726f3cdf0SGordon Ross /*
338*cb565728SJerry Jelinek * Interface is in static list. If marked invalid, then
339*cb565728SJerry Jelinek * it does not actually exist. Else, mark it invalid.
34026f3cdf0SGordon Ross */
34126f3cdf0SGordon Ross if (NextInterface->Flags & ACPI_OSI_INVALID)
34226f3cdf0SGordon Ross {
34326f3cdf0SGordon Ross return (AE_NOT_EXIST);
34426f3cdf0SGordon Ross }
34526f3cdf0SGordon Ross
34626f3cdf0SGordon Ross NextInterface->Flags |= ACPI_OSI_INVALID;
34726f3cdf0SGordon Ross }
34826f3cdf0SGordon Ross
34926f3cdf0SGordon Ross return (AE_OK);
35026f3cdf0SGordon Ross }
35126f3cdf0SGordon Ross
35226f3cdf0SGordon Ross PreviousInterface = NextInterface;
35326f3cdf0SGordon Ross NextInterface = NextInterface->Next;
35426f3cdf0SGordon Ross }
35526f3cdf0SGordon Ross
35626f3cdf0SGordon Ross /* Interface was not found */
35726f3cdf0SGordon Ross
35826f3cdf0SGordon Ross return (AE_NOT_EXIST);
35926f3cdf0SGordon Ross }
36026f3cdf0SGordon Ross
36126f3cdf0SGordon Ross
36226f3cdf0SGordon Ross /*******************************************************************************
36326f3cdf0SGordon Ross *
364*cb565728SJerry Jelinek * FUNCTION: AcpiUtUpdateInterfaces
365*cb565728SJerry Jelinek *
366*cb565728SJerry Jelinek * PARAMETERS: Action - Actions to be performed during the
367*cb565728SJerry Jelinek * update
368*cb565728SJerry Jelinek *
369*cb565728SJerry Jelinek * RETURN: Status
370*cb565728SJerry Jelinek *
371*cb565728SJerry Jelinek * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
372*cb565728SJerry Jelinek * strings or/and feature group strings.
373*cb565728SJerry Jelinek * Caller MUST hold AcpiGbl_OsiMutex
374*cb565728SJerry Jelinek *
375*cb565728SJerry Jelinek ******************************************************************************/
376*cb565728SJerry Jelinek
377*cb565728SJerry Jelinek ACPI_STATUS
AcpiUtUpdateInterfaces(UINT8 Action)378*cb565728SJerry Jelinek AcpiUtUpdateInterfaces (
379*cb565728SJerry Jelinek UINT8 Action)
380*cb565728SJerry Jelinek {
381*cb565728SJerry Jelinek ACPI_INTERFACE_INFO *NextInterface;
382*cb565728SJerry Jelinek
383*cb565728SJerry Jelinek
384*cb565728SJerry Jelinek NextInterface = AcpiGbl_SupportedInterfaces;
385*cb565728SJerry Jelinek while (NextInterface)
386*cb565728SJerry Jelinek {
387*cb565728SJerry Jelinek if (((NextInterface->Flags & ACPI_OSI_FEATURE) &&
388*cb565728SJerry Jelinek (Action & ACPI_FEATURE_STRINGS)) ||
389*cb565728SJerry Jelinek (!(NextInterface->Flags & ACPI_OSI_FEATURE) &&
390*cb565728SJerry Jelinek (Action & ACPI_VENDOR_STRINGS)))
391*cb565728SJerry Jelinek {
392*cb565728SJerry Jelinek if (Action & ACPI_DISABLE_INTERFACES)
393*cb565728SJerry Jelinek {
394*cb565728SJerry Jelinek /* Mark the interfaces as invalid */
395*cb565728SJerry Jelinek
396*cb565728SJerry Jelinek NextInterface->Flags |= ACPI_OSI_INVALID;
397*cb565728SJerry Jelinek }
398*cb565728SJerry Jelinek else
399*cb565728SJerry Jelinek {
400*cb565728SJerry Jelinek /* Mark the interfaces as valid */
401*cb565728SJerry Jelinek
402*cb565728SJerry Jelinek NextInterface->Flags &= ~ACPI_OSI_INVALID;
403*cb565728SJerry Jelinek }
404*cb565728SJerry Jelinek }
405*cb565728SJerry Jelinek
406*cb565728SJerry Jelinek NextInterface = NextInterface->Next;
407*cb565728SJerry Jelinek }
408*cb565728SJerry Jelinek
409*cb565728SJerry Jelinek return (AE_OK);
410*cb565728SJerry Jelinek }
411*cb565728SJerry Jelinek
412*cb565728SJerry Jelinek
413*cb565728SJerry Jelinek /*******************************************************************************
414*cb565728SJerry Jelinek *
41526f3cdf0SGordon Ross * FUNCTION: AcpiUtGetInterface
41626f3cdf0SGordon Ross *
41726f3cdf0SGordon Ross * PARAMETERS: InterfaceName - The interface to find
41826f3cdf0SGordon Ross *
41926f3cdf0SGordon Ross * RETURN: ACPI_INTERFACE_INFO if found. NULL if not found.
42026f3cdf0SGordon Ross *
42126f3cdf0SGordon Ross * DESCRIPTION: Search for the specified interface name in the global list.
42226f3cdf0SGordon Ross * Caller MUST hold AcpiGbl_OsiMutex
42326f3cdf0SGordon Ross *
42426f3cdf0SGordon Ross ******************************************************************************/
42526f3cdf0SGordon Ross
42626f3cdf0SGordon Ross ACPI_INTERFACE_INFO *
AcpiUtGetInterface(ACPI_STRING InterfaceName)42726f3cdf0SGordon Ross AcpiUtGetInterface (
42826f3cdf0SGordon Ross ACPI_STRING InterfaceName)
42926f3cdf0SGordon Ross {
43026f3cdf0SGordon Ross ACPI_INTERFACE_INFO *NextInterface;
43126f3cdf0SGordon Ross
43226f3cdf0SGordon Ross
43326f3cdf0SGordon Ross NextInterface = AcpiGbl_SupportedInterfaces;
43426f3cdf0SGordon Ross while (NextInterface)
43526f3cdf0SGordon Ross {
436*cb565728SJerry Jelinek if (!strcmp (InterfaceName, NextInterface->Name))
43726f3cdf0SGordon Ross {
43826f3cdf0SGordon Ross return (NextInterface);
43926f3cdf0SGordon Ross }
44026f3cdf0SGordon Ross
44126f3cdf0SGordon Ross NextInterface = NextInterface->Next;
44226f3cdf0SGordon Ross }
44326f3cdf0SGordon Ross
44426f3cdf0SGordon Ross return (NULL);
44526f3cdf0SGordon Ross }
44626f3cdf0SGordon Ross
44726f3cdf0SGordon Ross
44826f3cdf0SGordon Ross /*******************************************************************************
44926f3cdf0SGordon Ross *
45026f3cdf0SGordon Ross * FUNCTION: AcpiUtOsiImplementation
45126f3cdf0SGordon Ross *
45226f3cdf0SGordon Ross * PARAMETERS: WalkState - Current walk state
45326f3cdf0SGordon Ross *
45426f3cdf0SGordon Ross * RETURN: Status
45526f3cdf0SGordon Ross *
45626f3cdf0SGordon Ross * DESCRIPTION: Implementation of the _OSI predefined control method. When
45726f3cdf0SGordon Ross * an invocation of _OSI is encountered in the system AML,
45826f3cdf0SGordon Ross * control is transferred to this function.
45926f3cdf0SGordon Ross *
46026f3cdf0SGordon Ross ******************************************************************************/
46126f3cdf0SGordon Ross
46226f3cdf0SGordon Ross ACPI_STATUS
AcpiUtOsiImplementation(ACPI_WALK_STATE * WalkState)46326f3cdf0SGordon Ross AcpiUtOsiImplementation (
46426f3cdf0SGordon Ross ACPI_WALK_STATE *WalkState)
46526f3cdf0SGordon Ross {
46626f3cdf0SGordon Ross ACPI_OPERAND_OBJECT *StringDesc;
46726f3cdf0SGordon Ross ACPI_OPERAND_OBJECT *ReturnDesc;
46826f3cdf0SGordon Ross ACPI_INTERFACE_INFO *InterfaceInfo;
46926f3cdf0SGordon Ross ACPI_INTERFACE_HANDLER InterfaceHandler;
470*cb565728SJerry Jelinek ACPI_STATUS Status;
47126f3cdf0SGordon Ross UINT32 ReturnValue;
47226f3cdf0SGordon Ross
47326f3cdf0SGordon Ross
47426f3cdf0SGordon Ross ACPI_FUNCTION_TRACE (UtOsiImplementation);
47526f3cdf0SGordon Ross
47626f3cdf0SGordon Ross
47726f3cdf0SGordon Ross /* Validate the string input argument (from the AML caller) */
47826f3cdf0SGordon Ross
47926f3cdf0SGordon Ross StringDesc = WalkState->Arguments[0].Object;
48026f3cdf0SGordon Ross if (!StringDesc ||
48126f3cdf0SGordon Ross (StringDesc->Common.Type != ACPI_TYPE_STRING))
48226f3cdf0SGordon Ross {
48326f3cdf0SGordon Ross return_ACPI_STATUS (AE_TYPE);
48426f3cdf0SGordon Ross }
48526f3cdf0SGordon Ross
48626f3cdf0SGordon Ross /* Create a return object */
48726f3cdf0SGordon Ross
48826f3cdf0SGordon Ross ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
48926f3cdf0SGordon Ross if (!ReturnDesc)
49026f3cdf0SGordon Ross {
49126f3cdf0SGordon Ross return_ACPI_STATUS (AE_NO_MEMORY);
49226f3cdf0SGordon Ross }
49326f3cdf0SGordon Ross
49426f3cdf0SGordon Ross /* Default return value is 0, NOT SUPPORTED */
49526f3cdf0SGordon Ross
49626f3cdf0SGordon Ross ReturnValue = 0;
497*cb565728SJerry Jelinek Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
498*cb565728SJerry Jelinek if (ACPI_FAILURE (Status))
499*cb565728SJerry Jelinek {
500*cb565728SJerry Jelinek AcpiUtRemoveReference (ReturnDesc);
501*cb565728SJerry Jelinek return_ACPI_STATUS (Status);
502*cb565728SJerry Jelinek }
50326f3cdf0SGordon Ross
50426f3cdf0SGordon Ross /* Lookup the interface in the global _OSI list */
50526f3cdf0SGordon Ross
50626f3cdf0SGordon Ross InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
50726f3cdf0SGordon Ross if (InterfaceInfo &&
50826f3cdf0SGordon Ross !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
50926f3cdf0SGordon Ross {
51026f3cdf0SGordon Ross /*
51126f3cdf0SGordon Ross * The interface is supported.
51226f3cdf0SGordon Ross * Update the OsiData if necessary. We keep track of the latest
51326f3cdf0SGordon Ross * version of Windows that has been requested by the BIOS.
51426f3cdf0SGordon Ross */
51526f3cdf0SGordon Ross if (InterfaceInfo->Value > AcpiGbl_OsiData)
51626f3cdf0SGordon Ross {
51726f3cdf0SGordon Ross AcpiGbl_OsiData = InterfaceInfo->Value;
51826f3cdf0SGordon Ross }
51926f3cdf0SGordon Ross
52026f3cdf0SGordon Ross ReturnValue = ACPI_UINT32_MAX;
52126f3cdf0SGordon Ross }
52226f3cdf0SGordon Ross
52326f3cdf0SGordon Ross AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
52426f3cdf0SGordon Ross
52526f3cdf0SGordon Ross /*
52626f3cdf0SGordon Ross * Invoke an optional _OSI interface handler. The host OS may wish
52726f3cdf0SGordon Ross * to do some interface-specific handling. For example, warn about
52826f3cdf0SGordon Ross * certain interfaces or override the true/false support value.
52926f3cdf0SGordon Ross */
53026f3cdf0SGordon Ross InterfaceHandler = AcpiGbl_InterfaceHandler;
53126f3cdf0SGordon Ross if (InterfaceHandler)
53226f3cdf0SGordon Ross {
53326f3cdf0SGordon Ross ReturnValue = InterfaceHandler (
53426f3cdf0SGordon Ross StringDesc->String.Pointer, ReturnValue);
53526f3cdf0SGordon Ross }
53626f3cdf0SGordon Ross
53726f3cdf0SGordon Ross ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
53826f3cdf0SGordon Ross "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
53926f3cdf0SGordon Ross StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
54026f3cdf0SGordon Ross
54126f3cdf0SGordon Ross /* Complete the return object */
54226f3cdf0SGordon Ross
54326f3cdf0SGordon Ross ReturnDesc->Integer.Value = ReturnValue;
54426f3cdf0SGordon Ross WalkState->ReturnDesc = ReturnDesc;
54526f3cdf0SGordon Ross return_ACPI_STATUS (AE_OK);
54626f3cdf0SGordon Ross }
547