1 /******************************************************************************
3 * Module Name: utosi - Support for the _OSI predefined control method
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
48 #define _COMPONENT ACPI_UTILITIES
49 ACPI_MODULE_NAME ("utosi")
52 /******************************************************************************
54 * ACPICA policy for new _OSI strings:
56 * It is the stated policy of ACPICA that new _OSI strings will be integrated
57 * into this module as soon as possible after they are defined. It is strongly
58 * recommended that all ACPICA hosts mirror this policy and integrate any
59 * changes to this module as soon as possible. There are several historical
60 * reasons behind this policy:
62 * 1) New BIOSs tend to test only the case where the host responds TRUE to
63 * the latest version of Windows, which would respond to the latest/newest
64 * _OSI string. Not responding TRUE to the latest version of Windows will
65 * risk executing untested code paths throughout the DSDT and SSDTs.
67 * 2) If a new _OSI string is recognized only after a significant delay, this
68 * has the potential to cause problems on existing working machines because
69 * of the possibility that a new and different path through the ASL code
72 * 3) New _OSI strings are tending to come out about once per year. A delay
73 * in recognizing a new string for a significant amount of time risks the
74 * release of another string which only compounds the initial problem.
76 *****************************************************************************/
80 * Strings supported by the _OSI predefined control method (which is
81 * implemented internally within this module.)
83 * March 2009: Removed "Linux" as this host no longer wants to respond true
84 * for this string. Basically, the only safe OS strings are windows-related
85 * and in many or most cases represent the only test path within the
86 * BIOS-provided ASL code.
88 * The last element of each entry is used to track the newest version of
89 * Windows that the BIOS has requested.
91 static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[] =
93 /* Operating System Vendor Strings */
95 {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */
96 {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */
97 {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */
98 {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */
99 {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */
100 {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */
101 {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */
102 {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */
103 {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */
104 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */
105 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
106 {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */
107 {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */
109 /* Feature Group Strings */
111 {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0},
114 * All "optional" feature group strings (features that are implemented
115 * by the host) should be dynamically modified to VALID by the host via
116 * AcpiInstallInterface or AcpiUpdateInterfaces. Such optional feature
117 * group strings are set as INVALID by default here.
120 {"Module Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
121 {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
122 {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
123 {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
124 {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}
128 /*******************************************************************************
130 * FUNCTION: AcpiUtInitializeInterfaces
136 * DESCRIPTION: Initialize the global _OSI supported interfaces list
138 ******************************************************************************/
141 AcpiUtInitializeInterfaces (
148 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
149 if (ACPI_FAILURE (Status))
154 AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
156 /* Link the static list of supported interfaces */
158 for (i = 0; i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1); i++)
160 AcpiDefaultSupportedInterfaces[i].Next =
161 &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
164 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
169 /*******************************************************************************
171 * FUNCTION: AcpiUtInterfaceTerminate
177 * DESCRIPTION: Delete all interfaces in the global list. Sets
178 * AcpiGbl_SupportedInterfaces to NULL.
180 ******************************************************************************/
183 AcpiUtInterfaceTerminate (
187 ACPI_INTERFACE_INFO *NextInterface;
190 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
191 if (ACPI_FAILURE (Status))
196 NextInterface = AcpiGbl_SupportedInterfaces;
197 while (NextInterface)
199 AcpiGbl_SupportedInterfaces = NextInterface->Next;
201 if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
203 /* Only interfaces added at runtime can be freed */
205 ACPI_FREE (NextInterface->Name);
206 ACPI_FREE (NextInterface);
210 /* Interface is in static list. Reset it to invalid or valid. */
212 if (NextInterface->Flags & ACPI_OSI_DEFAULT_INVALID)
214 NextInterface->Flags |= ACPI_OSI_INVALID;
218 NextInterface->Flags &= ~ACPI_OSI_INVALID;
222 NextInterface = AcpiGbl_SupportedInterfaces;
225 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
230 /*******************************************************************************
232 * FUNCTION: AcpiUtInstallInterface
234 * PARAMETERS: InterfaceName - The interface to install
238 * DESCRIPTION: Install the interface into the global interface list.
239 * Caller MUST hold AcpiGbl_OsiMutex
241 ******************************************************************************/
244 AcpiUtInstallInterface (
245 ACPI_STRING InterfaceName)
247 ACPI_INTERFACE_INFO *InterfaceInfo;
250 /* Allocate info block and space for the name string */
252 InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
255 return (AE_NO_MEMORY);
258 InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (InterfaceName) + 1);
259 if (!InterfaceInfo->Name)
261 ACPI_FREE (InterfaceInfo);
262 return (AE_NO_MEMORY);
265 /* Initialize new info and insert at the head of the global list */
267 ACPI_STRCPY (InterfaceInfo->Name, InterfaceName);
268 InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
269 InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
271 AcpiGbl_SupportedInterfaces = InterfaceInfo;
276 /*******************************************************************************
278 * FUNCTION: AcpiUtRemoveInterface
280 * PARAMETERS: InterfaceName - The interface to remove
284 * DESCRIPTION: Remove the interface from the global interface list.
285 * Caller MUST hold AcpiGbl_OsiMutex
287 ******************************************************************************/
290 AcpiUtRemoveInterface (
291 ACPI_STRING InterfaceName)
293 ACPI_INTERFACE_INFO *PreviousInterface;
294 ACPI_INTERFACE_INFO *NextInterface;
297 PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
298 while (NextInterface)
300 if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
302 /* Found: name is in either the static list or was added at runtime */
304 if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
306 /* Interface was added dynamically, remove and free it */
308 if (PreviousInterface == NextInterface)
310 AcpiGbl_SupportedInterfaces = NextInterface->Next;
314 PreviousInterface->Next = NextInterface->Next;
317 ACPI_FREE (NextInterface->Name);
318 ACPI_FREE (NextInterface);
323 * Interface is in static list. If marked invalid, then it
324 * does not actually exist. Else, mark it invalid.
326 if (NextInterface->Flags & ACPI_OSI_INVALID)
328 return (AE_NOT_EXIST);
331 NextInterface->Flags |= ACPI_OSI_INVALID;
337 PreviousInterface = NextInterface;
338 NextInterface = NextInterface->Next;
341 /* Interface was not found */
343 return (AE_NOT_EXIST);
347 /*******************************************************************************
349 * FUNCTION: AcpiUtUpdateInterfaces
351 * PARAMETERS: Action - Actions to be performed during the
356 * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
357 * strings or/and feature group strings.
358 * Caller MUST hold AcpiGbl_OsiMutex
360 ******************************************************************************/
363 AcpiUtUpdateInterfaces (
366 ACPI_INTERFACE_INFO *NextInterface;
369 NextInterface = AcpiGbl_SupportedInterfaces;
370 while (NextInterface)
372 if (((NextInterface->Flags & ACPI_OSI_FEATURE) &&
373 (Action & ACPI_FEATURE_STRINGS)) ||
374 (!(NextInterface->Flags & ACPI_OSI_FEATURE) &&
375 (Action & ACPI_VENDOR_STRINGS)))
377 if (Action & ACPI_DISABLE_INTERFACES)
379 /* Mark the interfaces as invalid */
381 NextInterface->Flags |= ACPI_OSI_INVALID;
385 /* Mark the interfaces as valid */
387 NextInterface->Flags &= ~ACPI_OSI_INVALID;
391 NextInterface = NextInterface->Next;
398 /*******************************************************************************
400 * FUNCTION: AcpiUtGetInterface
402 * PARAMETERS: InterfaceName - The interface to find
404 * RETURN: ACPI_INTERFACE_INFO if found. NULL if not found.
406 * DESCRIPTION: Search for the specified interface name in the global list.
407 * Caller MUST hold AcpiGbl_OsiMutex
409 ******************************************************************************/
411 ACPI_INTERFACE_INFO *
413 ACPI_STRING InterfaceName)
415 ACPI_INTERFACE_INFO *NextInterface;
418 NextInterface = AcpiGbl_SupportedInterfaces;
419 while (NextInterface)
421 if (!ACPI_STRCMP (InterfaceName, NextInterface->Name))
423 return (NextInterface);
426 NextInterface = NextInterface->Next;
433 /*******************************************************************************
435 * FUNCTION: AcpiUtOsiImplementation
437 * PARAMETERS: WalkState - Current walk state
441 * DESCRIPTION: Implementation of the _OSI predefined control method. When
442 * an invocation of _OSI is encountered in the system AML,
443 * control is transferred to this function.
445 ******************************************************************************/
448 AcpiUtOsiImplementation (
449 ACPI_WALK_STATE *WalkState)
451 ACPI_OPERAND_OBJECT *StringDesc;
452 ACPI_OPERAND_OBJECT *ReturnDesc;
453 ACPI_INTERFACE_INFO *InterfaceInfo;
454 ACPI_INTERFACE_HANDLER InterfaceHandler;
459 ACPI_FUNCTION_TRACE (UtOsiImplementation);
462 /* Validate the string input argument (from the AML caller) */
464 StringDesc = WalkState->Arguments[0].Object;
466 (StringDesc->Common.Type != ACPI_TYPE_STRING))
468 return_ACPI_STATUS (AE_TYPE);
471 /* Create a return object */
473 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
476 return_ACPI_STATUS (AE_NO_MEMORY);
479 /* Default return value is 0, NOT SUPPORTED */
482 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
483 if (ACPI_FAILURE (Status))
485 AcpiUtRemoveReference (ReturnDesc);
486 return_ACPI_STATUS (Status);
489 /* Lookup the interface in the global _OSI list */
491 InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
493 !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
496 * The interface is supported.
497 * Update the OsiData if necessary. We keep track of the latest
498 * version of Windows that has been requested by the BIOS.
500 if (InterfaceInfo->Value > AcpiGbl_OsiData)
502 AcpiGbl_OsiData = InterfaceInfo->Value;
505 ReturnValue = ACPI_UINT32_MAX;
508 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
511 * Invoke an optional _OSI interface handler. The host OS may wish
512 * to do some interface-specific handling. For example, warn about
513 * certain interfaces or override the true/false support value.
515 InterfaceHandler = AcpiGbl_InterfaceHandler;
516 if (InterfaceHandler)
518 ReturnValue = InterfaceHandler (
519 StringDesc->String.Pointer, ReturnValue);
522 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
523 "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
524 StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
526 /* Complete the return object */
528 ReturnDesc->Integer.Value = ReturnValue;
529 WalkState->ReturnDesc = ReturnDesc;
530 return_ACPI_STATUS (AE_OK);