1 /******************************************************************************
3 * Module Name: utosi - Support for the _OSI predefined control method
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2013, 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.
50 #define _COMPONENT ACPI_UTILITIES
51 ACPI_MODULE_NAME ("utosi")
54 * Strings supported by the _OSI predefined control method (which is
55 * implemented internally within this module.)
57 * March 2009: Removed "Linux" as this host no longer wants to respond true
58 * for this string. Basically, the only safe OS strings are windows-related
59 * and in many or most cases represent the only test path within the
60 * BIOS-provided ASL code.
62 * The last element of each entry is used to track the newest version of
63 * Windows that the BIOS has requested.
65 static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces
[] =
67 /* Operating System Vendor Strings */
69 {"Windows 2000", NULL
, 0, ACPI_OSI_WIN_2000
}, /* Windows 2000 */
70 {"Windows 2001", NULL
, 0, ACPI_OSI_WIN_XP
}, /* Windows XP */
71 {"Windows 2001 SP1", NULL
, 0, ACPI_OSI_WIN_XP_SP1
}, /* Windows XP SP1 */
72 {"Windows 2001.1", NULL
, 0, ACPI_OSI_WINSRV_2003
}, /* Windows Server 2003 */
73 {"Windows 2001 SP2", NULL
, 0, ACPI_OSI_WIN_XP_SP2
}, /* Windows XP SP2 */
74 {"Windows 2001.1 SP1", NULL
, 0, ACPI_OSI_WINSRV_2003_SP1
}, /* Windows Server 2003 SP1 - Added 03/2006 */
75 {"Windows 2006", NULL
, 0, ACPI_OSI_WIN_VISTA
}, /* Windows Vista - Added 03/2006 */
76 {"Windows 2006.1", NULL
, 0, ACPI_OSI_WINSRV_2008
}, /* Windows Server 2008 - Added 09/2009 */
77 {"Windows 2006 SP1", NULL
, 0, ACPI_OSI_WIN_VISTA_SP1
}, /* Windows Vista SP1 - Added 09/2009 */
78 {"Windows 2006 SP2", NULL
, 0, ACPI_OSI_WIN_VISTA_SP2
}, /* Windows Vista SP2 - Added 09/2010 */
79 {"Windows 2009", NULL
, 0, ACPI_OSI_WIN_7
}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */
80 {"Windows 2012", NULL
, 0, ACPI_OSI_WIN_8
}, /* Windows 8 and Server 2012 - Added 08/2012 */
82 /* Feature Group Strings */
84 {"Extended Address Space Descriptor", NULL
, ACPI_OSI_FEATURE
, 0},
87 * All "optional" feature group strings (features that are implemented
88 * by the host) should be dynamically modified to VALID by the host via
89 * AcpiInstallInterface or AcpiUpdateInterfaces. Such optional feature
90 * group strings are set as INVALID by default here.
93 {"Module Device", NULL
, ACPI_OSI_OPTIONAL_FEATURE
, 0},
94 {"Processor Device", NULL
, ACPI_OSI_OPTIONAL_FEATURE
, 0},
95 {"3.0 Thermal Model", NULL
, ACPI_OSI_OPTIONAL_FEATURE
, 0},
96 {"3.0 _SCP Extensions", NULL
, ACPI_OSI_OPTIONAL_FEATURE
, 0},
97 {"Processor Aggregator Device", NULL
, ACPI_OSI_OPTIONAL_FEATURE
, 0}
101 /*******************************************************************************
103 * FUNCTION: AcpiUtInitializeInterfaces
109 * DESCRIPTION: Initialize the global _OSI supported interfaces list
111 ******************************************************************************/
114 AcpiUtInitializeInterfaces (
121 Status
= AcpiOsAcquireMutex (AcpiGbl_OsiMutex
, ACPI_WAIT_FOREVER
);
122 if (ACPI_FAILURE (Status
))
127 AcpiGbl_SupportedInterfaces
= AcpiDefaultSupportedInterfaces
;
129 /* Link the static list of supported interfaces */
131 for (i
= 0; i
< (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces
) - 1); i
++)
133 AcpiDefaultSupportedInterfaces
[i
].Next
=
134 &AcpiDefaultSupportedInterfaces
[(ACPI_SIZE
) i
+ 1];
137 AcpiOsReleaseMutex (AcpiGbl_OsiMutex
);
142 /*******************************************************************************
144 * FUNCTION: AcpiUtInterfaceTerminate
150 * DESCRIPTION: Delete all interfaces in the global list. Sets
151 * AcpiGbl_SupportedInterfaces to NULL.
153 ******************************************************************************/
156 AcpiUtInterfaceTerminate (
160 ACPI_INTERFACE_INFO
*NextInterface
;
163 Status
= AcpiOsAcquireMutex (AcpiGbl_OsiMutex
, ACPI_WAIT_FOREVER
);
164 if (ACPI_FAILURE (Status
))
169 NextInterface
= AcpiGbl_SupportedInterfaces
;
170 while (NextInterface
)
172 AcpiGbl_SupportedInterfaces
= NextInterface
->Next
;
174 if (NextInterface
->Flags
& ACPI_OSI_DYNAMIC
)
176 /* Only interfaces added at runtime can be freed */
178 ACPI_FREE (NextInterface
->Name
);
179 ACPI_FREE (NextInterface
);
183 /* Interface is in static list. Reset it to invalid or valid. */
185 if (NextInterface
->Flags
& ACPI_OSI_DEFAULT_INVALID
)
187 NextInterface
->Flags
|= ACPI_OSI_INVALID
;
191 NextInterface
->Flags
&= ~ACPI_OSI_INVALID
;
195 NextInterface
= AcpiGbl_SupportedInterfaces
;
198 AcpiOsReleaseMutex (AcpiGbl_OsiMutex
);
203 /*******************************************************************************
205 * FUNCTION: AcpiUtInstallInterface
207 * PARAMETERS: InterfaceName - The interface to install
211 * DESCRIPTION: Install the interface into the global interface list.
212 * Caller MUST hold AcpiGbl_OsiMutex
214 ******************************************************************************/
217 AcpiUtInstallInterface (
218 ACPI_STRING InterfaceName
)
220 ACPI_INTERFACE_INFO
*InterfaceInfo
;
223 /* Allocate info block and space for the name string */
225 InterfaceInfo
= ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO
));
228 return (AE_NO_MEMORY
);
231 InterfaceInfo
->Name
= ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (InterfaceName
) + 1);
232 if (!InterfaceInfo
->Name
)
234 ACPI_FREE (InterfaceInfo
);
235 return (AE_NO_MEMORY
);
238 /* Initialize new info and insert at the head of the global list */
240 ACPI_STRCPY (InterfaceInfo
->Name
, InterfaceName
);
241 InterfaceInfo
->Flags
= ACPI_OSI_DYNAMIC
;
242 InterfaceInfo
->Next
= AcpiGbl_SupportedInterfaces
;
244 AcpiGbl_SupportedInterfaces
= InterfaceInfo
;
249 /*******************************************************************************
251 * FUNCTION: AcpiUtRemoveInterface
253 * PARAMETERS: InterfaceName - The interface to remove
257 * DESCRIPTION: Remove the interface from the global interface list.
258 * Caller MUST hold AcpiGbl_OsiMutex
260 ******************************************************************************/
263 AcpiUtRemoveInterface (
264 ACPI_STRING InterfaceName
)
266 ACPI_INTERFACE_INFO
*PreviousInterface
;
267 ACPI_INTERFACE_INFO
*NextInterface
;
270 PreviousInterface
= NextInterface
= AcpiGbl_SupportedInterfaces
;
271 while (NextInterface
)
273 if (!ACPI_STRCMP (InterfaceName
, NextInterface
->Name
))
275 /* Found: name is in either the static list or was added at runtime */
277 if (NextInterface
->Flags
& ACPI_OSI_DYNAMIC
)
279 /* Interface was added dynamically, remove and free it */
281 if (PreviousInterface
== NextInterface
)
283 AcpiGbl_SupportedInterfaces
= NextInterface
->Next
;
287 PreviousInterface
->Next
= NextInterface
->Next
;
290 ACPI_FREE (NextInterface
->Name
);
291 ACPI_FREE (NextInterface
);
296 * Interface is in static list. If marked invalid, then it
297 * does not actually exist. Else, mark it invalid.
299 if (NextInterface
->Flags
& ACPI_OSI_INVALID
)
301 return (AE_NOT_EXIST
);
304 NextInterface
->Flags
|= ACPI_OSI_INVALID
;
310 PreviousInterface
= NextInterface
;
311 NextInterface
= NextInterface
->Next
;
314 /* Interface was not found */
316 return (AE_NOT_EXIST
);
320 /*******************************************************************************
322 * FUNCTION: AcpiUtUpdateInterfaces
324 * PARAMETERS: Action - Actions to be performed during the
329 * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
330 * strings or/and feature group strings.
331 * Caller MUST hold AcpiGbl_OsiMutex
333 ******************************************************************************/
336 AcpiUtUpdateInterfaces (
339 ACPI_INTERFACE_INFO
*NextInterface
;
342 NextInterface
= AcpiGbl_SupportedInterfaces
;
343 while (NextInterface
)
345 if (((NextInterface
->Flags
& ACPI_OSI_FEATURE
) &&
346 (Action
& ACPI_FEATURE_STRINGS
)) ||
347 (!(NextInterface
->Flags
& ACPI_OSI_FEATURE
) &&
348 (Action
& ACPI_VENDOR_STRINGS
)))
350 if (Action
& ACPI_DISABLE_INTERFACES
)
352 /* Mark the interfaces as invalid */
354 NextInterface
->Flags
|= ACPI_OSI_INVALID
;
358 /* Mark the interfaces as valid */
360 NextInterface
->Flags
&= ~ACPI_OSI_INVALID
;
364 NextInterface
= NextInterface
->Next
;
371 /*******************************************************************************
373 * FUNCTION: AcpiUtGetInterface
375 * PARAMETERS: InterfaceName - The interface to find
377 * RETURN: ACPI_INTERFACE_INFO if found. NULL if not found.
379 * DESCRIPTION: Search for the specified interface name in the global list.
380 * Caller MUST hold AcpiGbl_OsiMutex
382 ******************************************************************************/
384 ACPI_INTERFACE_INFO
*
386 ACPI_STRING InterfaceName
)
388 ACPI_INTERFACE_INFO
*NextInterface
;
391 NextInterface
= AcpiGbl_SupportedInterfaces
;
392 while (NextInterface
)
394 if (!ACPI_STRCMP (InterfaceName
, NextInterface
->Name
))
396 return (NextInterface
);
399 NextInterface
= NextInterface
->Next
;
406 /*******************************************************************************
408 * FUNCTION: AcpiUtOsiImplementation
410 * PARAMETERS: WalkState - Current walk state
414 * DESCRIPTION: Implementation of the _OSI predefined control method. When
415 * an invocation of _OSI is encountered in the system AML,
416 * control is transferred to this function.
418 ******************************************************************************/
421 AcpiUtOsiImplementation (
422 ACPI_WALK_STATE
*WalkState
)
424 ACPI_OPERAND_OBJECT
*StringDesc
;
425 ACPI_OPERAND_OBJECT
*ReturnDesc
;
426 ACPI_INTERFACE_INFO
*InterfaceInfo
;
427 ACPI_INTERFACE_HANDLER InterfaceHandler
;
432 ACPI_FUNCTION_TRACE (UtOsiImplementation
);
435 /* Validate the string input argument (from the AML caller) */
437 StringDesc
= WalkState
->Arguments
[0].Object
;
439 (StringDesc
->Common
.Type
!= ACPI_TYPE_STRING
))
441 return_ACPI_STATUS (AE_TYPE
);
444 /* Create a return object */
446 ReturnDesc
= AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER
);
449 return_ACPI_STATUS (AE_NO_MEMORY
);
452 /* Default return value is 0, NOT SUPPORTED */
455 Status
= AcpiOsAcquireMutex (AcpiGbl_OsiMutex
, ACPI_WAIT_FOREVER
);
456 if (ACPI_FAILURE (Status
))
458 AcpiUtRemoveReference (ReturnDesc
);
459 return_ACPI_STATUS (Status
);
462 /* Lookup the interface in the global _OSI list */
464 InterfaceInfo
= AcpiUtGetInterface (StringDesc
->String
.Pointer
);
466 !(InterfaceInfo
->Flags
& ACPI_OSI_INVALID
))
469 * The interface is supported.
470 * Update the OsiData if necessary. We keep track of the latest
471 * version of Windows that has been requested by the BIOS.
473 if (InterfaceInfo
->Value
> AcpiGbl_OsiData
)
475 AcpiGbl_OsiData
= InterfaceInfo
->Value
;
478 ReturnValue
= ACPI_UINT32_MAX
;
481 AcpiOsReleaseMutex (AcpiGbl_OsiMutex
);
484 * Invoke an optional _OSI interface handler. The host OS may wish
485 * to do some interface-specific handling. For example, warn about
486 * certain interfaces or override the true/false support value.
488 InterfaceHandler
= AcpiGbl_InterfaceHandler
;
489 if (InterfaceHandler
)
491 ReturnValue
= InterfaceHandler (
492 StringDesc
->String
.Pointer
, ReturnValue
);
495 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO
,
496 "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
497 StringDesc
->String
.Pointer
, ReturnValue
== 0 ? "not " : ""));
499 /* Complete the return object */
501 ReturnDesc
->Integer
.Value
= ReturnValue
;
502 WalkState
->ReturnDesc
= ReturnDesc
;
503 return_ACPI_STATUS (AE_OK
);