utosi.c revision 1.12 1 /******************************************************************************
2 *
3 * Module Name: utosi - Support for the _OSI predefined control method
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2019, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
25 *
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.
29 *
30 * NO WARRANTY
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.
42 */
43
44 #include "acpi.h"
45 #include "accommon.h"
46
47
48 #define _COMPONENT ACPI_UTILITIES
49 ACPI_MODULE_NAME ("utosi")
50
51
52 /******************************************************************************
53 *
54 * ACPICA policy for new _OSI strings:
55 *
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:
61 *
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.
66 *
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
70 * will be executed.
71 *
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.
75 *
76 *****************************************************************************/
77
78
79 /*
80 * Strings supported by the _OSI predefined control method (which is
81 * implemented internally within this module.)
82 *
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.
87 *
88 * The last element of each entry is used to track the newest version of
89 * Windows that the BIOS has requested.
90 */
91 static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[] =
92 {
93 /* Operating System Vendor Strings */
94
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 */
108 {"Windows 2015", NULL, 0, ACPI_OSI_WIN_10}, /* Windows 10 - Added 03/2015 */
109 {"Windows 2016", NULL, 0, ACPI_OSI_WIN_10_RS1}, /* Windows 10 version 1607 - Added 12/2017 */
110 {"Windows 2017", NULL, 0, ACPI_OSI_WIN_10_RS2}, /* Windows 10 version 1703 - Added 12/2017 */
111 {"Windows 2017.2", NULL, 0, ACPI_OSI_WIN_10_RS3}, /* Windows 10 version 1709 - Added 02/2018 */
112 {"Windows 2018", NULL, 0, ACPI_OSI_WIN_10_RS4}, /* Windows 10 version 1803 - Added 11/2018 */
113 {"Windows 2018.2", NULL, 0, ACPI_OSI_WIN_10_RS5}, /* Windows 10 version 1809 - Added 11/2018 */
114
115 /* Feature Group Strings */
116
117 {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0},
118
119 /*
120 * All "optional" feature group strings (features that are implemented
121 * by the host) should be dynamically modified to VALID by the host via
122 * AcpiInstallInterface or AcpiUpdateInterfaces. Such optional feature
123 * group strings are set as INVALID by default here.
124 */
125
126 {"Module Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
127 {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
128 {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
129 {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0},
130 {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}
131 };
132
133
134 /*******************************************************************************
135 *
136 * FUNCTION: AcpiUtInitializeInterfaces
137 *
138 * PARAMETERS: None
139 *
140 * RETURN: Status
141 *
142 * DESCRIPTION: Initialize the global _OSI supported interfaces list
143 *
144 ******************************************************************************/
145
146 ACPI_STATUS
147 AcpiUtInitializeInterfaces (
148 void)
149 {
150 ACPI_STATUS Status;
151 UINT32 i;
152
153
154 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
155 if (ACPI_FAILURE (Status))
156 {
157 return (Status);
158 }
159
160 AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces;
161
162 /* Link the static list of supported interfaces */
163
164 for (i = 0;
165 i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1);
166 i++)
167 {
168 AcpiDefaultSupportedInterfaces[i].Next =
169 &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1];
170 }
171
172 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
173 return (AE_OK);
174 }
175
176
177 /*******************************************************************************
178 *
179 * FUNCTION: AcpiUtInterfaceTerminate
180 *
181 * PARAMETERS: None
182 *
183 * RETURN: Status
184 *
185 * DESCRIPTION: Delete all interfaces in the global list. Sets
186 * AcpiGbl_SupportedInterfaces to NULL.
187 *
188 ******************************************************************************/
189
190 ACPI_STATUS
191 AcpiUtInterfaceTerminate (
192 void)
193 {
194 ACPI_STATUS Status;
195 ACPI_INTERFACE_INFO *NextInterface;
196
197
198 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
199 if (ACPI_FAILURE (Status))
200 {
201 return (Status);
202 }
203
204 NextInterface = AcpiGbl_SupportedInterfaces;
205 while (NextInterface)
206 {
207 AcpiGbl_SupportedInterfaces = NextInterface->Next;
208
209 if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
210 {
211 /* Only interfaces added at runtime can be freed */
212
213 ACPI_FREE (__UNCONST(NextInterface->Name));
214 ACPI_FREE (NextInterface);
215 }
216 else
217 {
218 /* Interface is in static list. Reset it to invalid or valid. */
219
220 if (NextInterface->Flags & ACPI_OSI_DEFAULT_INVALID)
221 {
222 NextInterface->Flags |= ACPI_OSI_INVALID;
223 }
224 else
225 {
226 NextInterface->Flags &= ~ACPI_OSI_INVALID;
227 }
228 }
229
230 NextInterface = AcpiGbl_SupportedInterfaces;
231 }
232
233 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
234 return (AE_OK);
235 }
236
237
238 /*******************************************************************************
239 *
240 * FUNCTION: AcpiUtInstallInterface
241 *
242 * PARAMETERS: InterfaceName - The interface to install
243 *
244 * RETURN: Status
245 *
246 * DESCRIPTION: Install the interface into the global interface list.
247 * Caller MUST hold AcpiGbl_OsiMutex
248 *
249 ******************************************************************************/
250
251 ACPI_STATUS
252 AcpiUtInstallInterface (
253 ACPI_STRING InterfaceName)
254 {
255 ACPI_INTERFACE_INFO *InterfaceInfo;
256
257
258 /* Allocate info block and space for the name string */
259
260 InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO));
261 if (!InterfaceInfo)
262 {
263 return (AE_NO_MEMORY);
264 }
265
266 InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (strlen (InterfaceName) + 1);
267 if (!InterfaceInfo->Name)
268 {
269 ACPI_FREE (InterfaceInfo);
270 return (AE_NO_MEMORY);
271 }
272
273 /* Initialize new info and insert at the head of the global list */
274
275 strcpy (__UNCONST(InterfaceInfo->Name), InterfaceName);
276 InterfaceInfo->Flags = ACPI_OSI_DYNAMIC;
277 InterfaceInfo->Next = AcpiGbl_SupportedInterfaces;
278
279 AcpiGbl_SupportedInterfaces = InterfaceInfo;
280 return (AE_OK);
281 }
282
283
284 /*******************************************************************************
285 *
286 * FUNCTION: AcpiUtRemoveInterface
287 *
288 * PARAMETERS: InterfaceName - The interface to remove
289 *
290 * RETURN: Status
291 *
292 * DESCRIPTION: Remove the interface from the global interface list.
293 * Caller MUST hold AcpiGbl_OsiMutex
294 *
295 ******************************************************************************/
296
297 ACPI_STATUS
298 AcpiUtRemoveInterface (
299 ACPI_STRING InterfaceName)
300 {
301 ACPI_INTERFACE_INFO *PreviousInterface;
302 ACPI_INTERFACE_INFO *NextInterface;
303
304
305 PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces;
306 while (NextInterface)
307 {
308 if (!strcmp (InterfaceName, NextInterface->Name))
309 {
310 /*
311 * Found: name is in either the static list
312 * or was added at runtime
313 */
314 if (NextInterface->Flags & ACPI_OSI_DYNAMIC)
315 {
316 /* Interface was added dynamically, remove and free it */
317
318 if (PreviousInterface == NextInterface)
319 {
320 AcpiGbl_SupportedInterfaces = NextInterface->Next;
321 }
322 else
323 {
324 PreviousInterface->Next = NextInterface->Next;
325 }
326
327 ACPI_FREE (__UNCONST(NextInterface->Name));
328 ACPI_FREE (NextInterface);
329 }
330 else
331 {
332 /*
333 * Interface is in static list. If marked invalid, then
334 * it does not actually exist. Else, mark it invalid.
335 */
336 if (NextInterface->Flags & ACPI_OSI_INVALID)
337 {
338 return (AE_NOT_EXIST);
339 }
340
341 NextInterface->Flags |= ACPI_OSI_INVALID;
342 }
343
344 return (AE_OK);
345 }
346
347 PreviousInterface = NextInterface;
348 NextInterface = NextInterface->Next;
349 }
350
351 /* Interface was not found */
352
353 return (AE_NOT_EXIST);
354 }
355
356
357 /*******************************************************************************
358 *
359 * FUNCTION: AcpiUtUpdateInterfaces
360 *
361 * PARAMETERS: Action - Actions to be performed during the
362 * update
363 *
364 * RETURN: Status
365 *
366 * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor
367 * strings or/and feature group strings.
368 * Caller MUST hold AcpiGbl_OsiMutex
369 *
370 ******************************************************************************/
371
372 ACPI_STATUS
373 AcpiUtUpdateInterfaces (
374 UINT8 Action)
375 {
376 ACPI_INTERFACE_INFO *NextInterface;
377
378
379 NextInterface = AcpiGbl_SupportedInterfaces;
380 while (NextInterface)
381 {
382 if (((NextInterface->Flags & ACPI_OSI_FEATURE) &&
383 (Action & ACPI_FEATURE_STRINGS)) ||
384 (!(NextInterface->Flags & ACPI_OSI_FEATURE) &&
385 (Action & ACPI_VENDOR_STRINGS)))
386 {
387 if (Action & ACPI_DISABLE_INTERFACES)
388 {
389 /* Mark the interfaces as invalid */
390
391 NextInterface->Flags |= ACPI_OSI_INVALID;
392 }
393 else
394 {
395 /* Mark the interfaces as valid */
396
397 NextInterface->Flags &= ~ACPI_OSI_INVALID;
398 }
399 }
400
401 NextInterface = NextInterface->Next;
402 }
403
404 return (AE_OK);
405 }
406
407
408 /*******************************************************************************
409 *
410 * FUNCTION: AcpiUtGetInterface
411 *
412 * PARAMETERS: InterfaceName - The interface to find
413 *
414 * RETURN: ACPI_INTERFACE_INFO if found. NULL if not found.
415 *
416 * DESCRIPTION: Search for the specified interface name in the global list.
417 * Caller MUST hold AcpiGbl_OsiMutex
418 *
419 ******************************************************************************/
420
421 ACPI_INTERFACE_INFO *
422 AcpiUtGetInterface (
423 ACPI_STRING InterfaceName)
424 {
425 ACPI_INTERFACE_INFO *NextInterface;
426
427
428 NextInterface = AcpiGbl_SupportedInterfaces;
429 while (NextInterface)
430 {
431 if (!strcmp (InterfaceName, NextInterface->Name))
432 {
433 return (NextInterface);
434 }
435
436 NextInterface = NextInterface->Next;
437 }
438
439 return (NULL);
440 }
441
442
443 /*******************************************************************************
444 *
445 * FUNCTION: AcpiUtOsiImplementation
446 *
447 * PARAMETERS: WalkState - Current walk state
448 *
449 * RETURN: Status
450 * Integer: TRUE (0) if input string is matched
451 * FALSE (-1) if string is not matched
452 *
453 * DESCRIPTION: Implementation of the _OSI predefined control method. When
454 * an invocation of _OSI is encountered in the system AML,
455 * control is transferred to this function.
456 *
457 * (August 2016)
458 * Note: _OSI is now defined to return "Ones" to indicate a match, for
459 * compatibility with other ACPI implementations. On a 32-bit DSDT, Ones
460 * is 0xFFFFFFFF. On a 64-bit DSDT, Ones is 0xFFFFFFFFFFFFFFFF
461 * (ACPI_UINT64_MAX).
462 *
463 * This function always returns ACPI_UINT64_MAX for TRUE, and later code
464 * will truncate this to 32 bits if necessary.
465 *
466 ******************************************************************************/
467
468 ACPI_STATUS
469 AcpiUtOsiImplementation (
470 ACPI_WALK_STATE *WalkState)
471 {
472 ACPI_OPERAND_OBJECT *StringDesc;
473 ACPI_OPERAND_OBJECT *ReturnDesc;
474 ACPI_INTERFACE_INFO *InterfaceInfo;
475 ACPI_INTERFACE_HANDLER InterfaceHandler;
476 ACPI_STATUS Status;
477 UINT64 ReturnValue;
478
479
480 ACPI_FUNCTION_TRACE (UtOsiImplementation);
481
482
483 /* Validate the string input argument (from the AML caller) */
484
485 StringDesc = WalkState->Arguments[0].Object;
486 if (!StringDesc ||
487 (StringDesc->Common.Type != ACPI_TYPE_STRING))
488 {
489 return_ACPI_STATUS (AE_TYPE);
490 }
491
492 /* Create a return object */
493
494 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
495 if (!ReturnDesc)
496 {
497 return_ACPI_STATUS (AE_NO_MEMORY);
498 }
499
500 /* Default return value is 0, NOT SUPPORTED */
501
502 ReturnValue = 0;
503 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER);
504 if (ACPI_FAILURE (Status))
505 {
506 AcpiUtRemoveReference (ReturnDesc);
507 return_ACPI_STATUS (Status);
508 }
509
510 /* Lookup the interface in the global _OSI list */
511
512 InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer);
513 if (InterfaceInfo &&
514 !(InterfaceInfo->Flags & ACPI_OSI_INVALID))
515 {
516 /*
517 * The interface is supported.
518 * Update the OsiData if necessary. We keep track of the latest
519 * version of Windows that has been requested by the BIOS.
520 */
521 if (InterfaceInfo->Value > AcpiGbl_OsiData)
522 {
523 AcpiGbl_OsiData = InterfaceInfo->Value;
524 }
525
526 ReturnValue = ACPI_UINT64_MAX;
527 }
528
529 AcpiOsReleaseMutex (AcpiGbl_OsiMutex);
530
531 /*
532 * Invoke an optional _OSI interface handler. The host OS may wish
533 * to do some interface-specific handling. For example, warn about
534 * certain interfaces or override the true/false support value.
535 */
536 InterfaceHandler = AcpiGbl_InterfaceHandler;
537 if (InterfaceHandler)
538 {
539 if (InterfaceHandler (
540 StringDesc->String.Pointer, (UINT32) ReturnValue))
541 {
542 ReturnValue = ACPI_UINT64_MAX;
543 }
544 }
545
546 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
547 "ACPI: BIOS _OSI(\"%s\") is %ssupported\n",
548 StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
549
550 /* Complete the return object */
551
552 ReturnDesc->Integer.Value = ReturnValue;
553 WalkState->ReturnDesc = ReturnDesc;
554 return_ACPI_STATUS (AE_OK);
555 }
556