1 /****************************************************************************** 2 * 3 * Module Name: utosi - Support for the _OSI predefined control method 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2016, Intel Corp. 12 * All rights reserved. 13 * 14 * 2. License 15 * 16 * 2.1. This is your license from Intel Corp. under its intellectual property 17 * rights. You may have additional license terms from the party that provided 18 * you this software, covering your right to use that party's intellectual 19 * property rights. 20 * 21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22 * copy of the source code appearing in this file ("Covered Code") an 23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24 * base code distributed originally by Intel ("Original Intel Code") to copy, 25 * make derivatives, distribute, use and display any portion of the Covered 26 * Code in any form, with the right to sublicense such rights; and 27 * 28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29 * license (with the right to sublicense), under only those claims of Intel 30 * patents that are infringed by the Original Intel Code, to make, use, sell, 31 * offer to sell, and import the Covered Code and derivative works thereof 32 * solely to the minimum extent necessary to exercise the above copyright 33 * license, and in no event shall the patent license extend to any additions 34 * to or modifications of the Original Intel Code. No other license or right 35 * is granted directly or by implication, estoppel or otherwise; 36 * 37 * The above copyright and patent license is granted only if the following 38 * conditions are met: 39 * 40 * 3. Conditions 41 * 42 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43 * Redistribution of source code of any substantial portion of the Covered 44 * Code or modification with rights to further distribute source must include 45 * the above Copyright Notice, the above License, this list of Conditions, 46 * and the following Disclaimer and Export Compliance provision. In addition, 47 * Licensee must cause all Covered Code to which Licensee contributes to 48 * contain a file documenting the changes Licensee made to create that Covered 49 * Code and the date of any change. Licensee must include in that file the 50 * documentation of any changes made by any predecessor Licensee. Licensee 51 * must include a prominent statement that the modification is derived, 52 * directly or indirectly, from Original Intel Code. 53 * 54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55 * Redistribution of source code of any substantial portion of the Covered 56 * Code or modification without rights to further distribute source must 57 * include the following Disclaimer and Export Compliance provision in the 58 * documentation and/or other materials provided with distribution. In 59 * addition, Licensee may not authorize further sublicense of source of any 60 * portion of the Covered Code, and must include terms to the effect that the 61 * license from Licensee to its licensee is limited to the intellectual 62 * property embodied in the software Licensee provides to its licensee, and 63 * not to intellectual property embodied in modifications its licensee may 64 * make. 65 * 66 * 3.3. Redistribution of Executable. Redistribution in executable form of any 67 * substantial portion of the Covered Code or modification must reproduce the 68 * above Copyright Notice, and the following Disclaimer and Export Compliance 69 * provision in the documentation and/or other materials provided with the 70 * distribution. 71 * 72 * 3.4. Intel retains all right, title, and interest in and to the Original 73 * Intel Code. 74 * 75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76 * Intel shall be used in advertising or otherwise to promote the sale, use or 77 * other dealings in products derived from or relating to the Covered Code 78 * without prior written authorization from Intel. 79 * 80 * 4. Disclaimer and Export Compliance 81 * 82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88 * PARTICULAR PURPOSE. 89 * 90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97 * LIMITED REMEDY. 98 * 99 * 4.3. Licensee shall not export, either directly or indirectly, any of this 100 * software or system incorporating such software without first obtaining any 101 * required license or other approval from the U. S. Department of Commerce or 102 * any other agency or department of the United States Government. In the 103 * event Licensee exports any such software from the United States or 104 * re-exports any such software from a foreign destination, Licensee shall 105 * ensure that the distribution and export/re-export of the software is in 106 * compliance with all laws, regulations, orders, or other restrictions of the 107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108 * any of its subsidiaries will export/re-export any technical data, process, 109 * software, or service, directly or indirectly, to any country for which the 110 * United States government or any agency thereof requires an export license, 111 * other governmental approval, or letter of assurance, without first obtaining 112 * such license, approval or letter. 113 * 114 *****************************************************************************/ 115 116 #include "acpi.h" 117 #include "accommon.h" 118 119 120 #define _COMPONENT ACPI_UTILITIES 121 ACPI_MODULE_NAME ("utosi") 122 123 124 /****************************************************************************** 125 * 126 * ACPICA policy for new _OSI strings: 127 * 128 * It is the stated policy of ACPICA that new _OSI strings will be integrated 129 * into this module as soon as possible after they are defined. It is strongly 130 * recommended that all ACPICA hosts mirror this policy and integrate any 131 * changes to this module as soon as possible. There are several historical 132 * reasons behind this policy: 133 * 134 * 1) New BIOSs tend to test only the case where the host responds TRUE to 135 * the latest version of Windows, which would respond to the latest/newest 136 * _OSI string. Not responding TRUE to the latest version of Windows will 137 * risk executing untested code paths throughout the DSDT and SSDTs. 138 * 139 * 2) If a new _OSI string is recognized only after a significant delay, this 140 * has the potential to cause problems on existing working machines because 141 * of the possibility that a new and different path through the ASL code 142 * will be executed. 143 * 144 * 3) New _OSI strings are tending to come out about once per year. A delay 145 * in recognizing a new string for a significant amount of time risks the 146 * release of another string which only compounds the initial problem. 147 * 148 *****************************************************************************/ 149 150 151 /* 152 * Strings supported by the _OSI predefined control method (which is 153 * implemented internally within this module.) 154 * 155 * March 2009: Removed "Linux" as this host no longer wants to respond true 156 * for this string. Basically, the only safe OS strings are windows-related 157 * and in many or most cases represent the only test path within the 158 * BIOS-provided ASL code. 159 * 160 * The last element of each entry is used to track the newest version of 161 * Windows that the BIOS has requested. 162 */ 163 static ACPI_INTERFACE_INFO AcpiDefaultSupportedInterfaces[] = 164 { 165 /* Operating System Vendor Strings */ 166 167 {"Windows 2000", NULL, 0, ACPI_OSI_WIN_2000}, /* Windows 2000 */ 168 {"Windows 2001", NULL, 0, ACPI_OSI_WIN_XP}, /* Windows XP */ 169 {"Windows 2001 SP1", NULL, 0, ACPI_OSI_WIN_XP_SP1}, /* Windows XP SP1 */ 170 {"Windows 2001.1", NULL, 0, ACPI_OSI_WINSRV_2003}, /* Windows Server 2003 */ 171 {"Windows 2001 SP2", NULL, 0, ACPI_OSI_WIN_XP_SP2}, /* Windows XP SP2 */ 172 {"Windows 2001.1 SP1", NULL, 0, ACPI_OSI_WINSRV_2003_SP1}, /* Windows Server 2003 SP1 - Added 03/2006 */ 173 {"Windows 2006", NULL, 0, ACPI_OSI_WIN_VISTA}, /* Windows Vista - Added 03/2006 */ 174 {"Windows 2006.1", NULL, 0, ACPI_OSI_WINSRV_2008}, /* Windows Server 2008 - Added 09/2009 */ 175 {"Windows 2006 SP1", NULL, 0, ACPI_OSI_WIN_VISTA_SP1}, /* Windows Vista SP1 - Added 09/2009 */ 176 {"Windows 2006 SP2", NULL, 0, ACPI_OSI_WIN_VISTA_SP2}, /* Windows Vista SP2 - Added 09/2010 */ 177 {"Windows 2009", NULL, 0, ACPI_OSI_WIN_7}, /* Windows 7 and Server 2008 R2 - Added 09/2009 */ 178 {"Windows 2012", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8 and Server 2012 - Added 08/2012 */ 179 {"Windows 2013", NULL, 0, ACPI_OSI_WIN_8}, /* Windows 8.1 and Server 2012 R2 - Added 01/2014 */ 180 {"Windows 2015", NULL, 0, ACPI_OSI_WIN_10}, /* Windows 10 - Added 03/2015 */ 181 182 /* Feature Group Strings */ 183 184 {"Extended Address Space Descriptor", NULL, ACPI_OSI_FEATURE, 0}, 185 186 /* 187 * All "optional" feature group strings (features that are implemented 188 * by the host) should be dynamically modified to VALID by the host via 189 * AcpiInstallInterface or AcpiUpdateInterfaces. Such optional feature 190 * group strings are set as INVALID by default here. 191 */ 192 193 {"Module Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, 194 {"Processor Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, 195 {"3.0 Thermal Model", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, 196 {"3.0 _SCP Extensions", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0}, 197 {"Processor Aggregator Device", NULL, ACPI_OSI_OPTIONAL_FEATURE, 0} 198 }; 199 200 201 /******************************************************************************* 202 * 203 * FUNCTION: AcpiUtInitializeInterfaces 204 * 205 * PARAMETERS: None 206 * 207 * RETURN: Status 208 * 209 * DESCRIPTION: Initialize the global _OSI supported interfaces list 210 * 211 ******************************************************************************/ 212 213 ACPI_STATUS 214 AcpiUtInitializeInterfaces ( 215 void) 216 { 217 ACPI_STATUS Status; 218 UINT32 i; 219 220 221 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); 222 if (ACPI_FAILURE (Status)) 223 { 224 return (Status); 225 } 226 227 AcpiGbl_SupportedInterfaces = AcpiDefaultSupportedInterfaces; 228 229 /* Link the static list of supported interfaces */ 230 231 for (i = 0; 232 i < (ACPI_ARRAY_LENGTH (AcpiDefaultSupportedInterfaces) - 1); 233 i++) 234 { 235 AcpiDefaultSupportedInterfaces[i].Next = 236 &AcpiDefaultSupportedInterfaces[(ACPI_SIZE) i + 1]; 237 } 238 239 AcpiOsReleaseMutex (AcpiGbl_OsiMutex); 240 return (AE_OK); 241 } 242 243 244 /******************************************************************************* 245 * 246 * FUNCTION: AcpiUtInterfaceTerminate 247 * 248 * PARAMETERS: None 249 * 250 * RETURN: Status 251 * 252 * DESCRIPTION: Delete all interfaces in the global list. Sets 253 * AcpiGbl_SupportedInterfaces to NULL. 254 * 255 ******************************************************************************/ 256 257 ACPI_STATUS 258 AcpiUtInterfaceTerminate ( 259 void) 260 { 261 ACPI_STATUS Status; 262 ACPI_INTERFACE_INFO *NextInterface; 263 264 265 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); 266 if (ACPI_FAILURE (Status)) 267 { 268 return (Status); 269 } 270 271 NextInterface = AcpiGbl_SupportedInterfaces; 272 while (NextInterface) 273 { 274 AcpiGbl_SupportedInterfaces = NextInterface->Next; 275 276 if (NextInterface->Flags & ACPI_OSI_DYNAMIC) 277 { 278 /* Only interfaces added at runtime can be freed */ 279 280 ACPI_FREE (NextInterface->Name); 281 ACPI_FREE (NextInterface); 282 } 283 else 284 { 285 /* Interface is in static list. Reset it to invalid or valid. */ 286 287 if (NextInterface->Flags & ACPI_OSI_DEFAULT_INVALID) 288 { 289 NextInterface->Flags |= ACPI_OSI_INVALID; 290 } 291 else 292 { 293 NextInterface->Flags &= ~ACPI_OSI_INVALID; 294 } 295 } 296 297 NextInterface = AcpiGbl_SupportedInterfaces; 298 } 299 300 AcpiOsReleaseMutex (AcpiGbl_OsiMutex); 301 return (AE_OK); 302 } 303 304 305 /******************************************************************************* 306 * 307 * FUNCTION: AcpiUtInstallInterface 308 * 309 * PARAMETERS: InterfaceName - The interface to install 310 * 311 * RETURN: Status 312 * 313 * DESCRIPTION: Install the interface into the global interface list. 314 * Caller MUST hold AcpiGbl_OsiMutex 315 * 316 ******************************************************************************/ 317 318 ACPI_STATUS 319 AcpiUtInstallInterface ( 320 ACPI_STRING InterfaceName) 321 { 322 ACPI_INTERFACE_INFO *InterfaceInfo; 323 324 325 /* Allocate info block and space for the name string */ 326 327 InterfaceInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_INTERFACE_INFO)); 328 if (!InterfaceInfo) 329 { 330 return (AE_NO_MEMORY); 331 } 332 333 InterfaceInfo->Name = ACPI_ALLOCATE_ZEROED (strlen (InterfaceName) + 1); 334 if (!InterfaceInfo->Name) 335 { 336 ACPI_FREE (InterfaceInfo); 337 return (AE_NO_MEMORY); 338 } 339 340 /* Initialize new info and insert at the head of the global list */ 341 342 strcpy (InterfaceInfo->Name, InterfaceName); 343 InterfaceInfo->Flags = ACPI_OSI_DYNAMIC; 344 InterfaceInfo->Next = AcpiGbl_SupportedInterfaces; 345 346 AcpiGbl_SupportedInterfaces = InterfaceInfo; 347 return (AE_OK); 348 } 349 350 351 /******************************************************************************* 352 * 353 * FUNCTION: AcpiUtRemoveInterface 354 * 355 * PARAMETERS: InterfaceName - The interface to remove 356 * 357 * RETURN: Status 358 * 359 * DESCRIPTION: Remove the interface from the global interface list. 360 * Caller MUST hold AcpiGbl_OsiMutex 361 * 362 ******************************************************************************/ 363 364 ACPI_STATUS 365 AcpiUtRemoveInterface ( 366 ACPI_STRING InterfaceName) 367 { 368 ACPI_INTERFACE_INFO *PreviousInterface; 369 ACPI_INTERFACE_INFO *NextInterface; 370 371 372 PreviousInterface = NextInterface = AcpiGbl_SupportedInterfaces; 373 while (NextInterface) 374 { 375 if (!strcmp (InterfaceName, NextInterface->Name)) 376 { 377 /* 378 * Found: name is in either the static list 379 * or was added at runtime 380 */ 381 if (NextInterface->Flags & ACPI_OSI_DYNAMIC) 382 { 383 /* Interface was added dynamically, remove and free it */ 384 385 if (PreviousInterface == NextInterface) 386 { 387 AcpiGbl_SupportedInterfaces = NextInterface->Next; 388 } 389 else 390 { 391 PreviousInterface->Next = NextInterface->Next; 392 } 393 394 ACPI_FREE (NextInterface->Name); 395 ACPI_FREE (NextInterface); 396 } 397 else 398 { 399 /* 400 * Interface is in static list. If marked invalid, then 401 * it does not actually exist. Else, mark it invalid. 402 */ 403 if (NextInterface->Flags & ACPI_OSI_INVALID) 404 { 405 return (AE_NOT_EXIST); 406 } 407 408 NextInterface->Flags |= ACPI_OSI_INVALID; 409 } 410 411 return (AE_OK); 412 } 413 414 PreviousInterface = NextInterface; 415 NextInterface = NextInterface->Next; 416 } 417 418 /* Interface was not found */ 419 420 return (AE_NOT_EXIST); 421 } 422 423 424 /******************************************************************************* 425 * 426 * FUNCTION: AcpiUtUpdateInterfaces 427 * 428 * PARAMETERS: Action - Actions to be performed during the 429 * update 430 * 431 * RETURN: Status 432 * 433 * DESCRIPTION: Update _OSI interface strings, disabling or enabling OS vendor 434 * strings or/and feature group strings. 435 * Caller MUST hold AcpiGbl_OsiMutex 436 * 437 ******************************************************************************/ 438 439 ACPI_STATUS 440 AcpiUtUpdateInterfaces ( 441 UINT8 Action) 442 { 443 ACPI_INTERFACE_INFO *NextInterface; 444 445 446 NextInterface = AcpiGbl_SupportedInterfaces; 447 while (NextInterface) 448 { 449 if (((NextInterface->Flags & ACPI_OSI_FEATURE) && 450 (Action & ACPI_FEATURE_STRINGS)) || 451 (!(NextInterface->Flags & ACPI_OSI_FEATURE) && 452 (Action & ACPI_VENDOR_STRINGS))) 453 { 454 if (Action & ACPI_DISABLE_INTERFACES) 455 { 456 /* Mark the interfaces as invalid */ 457 458 NextInterface->Flags |= ACPI_OSI_INVALID; 459 } 460 else 461 { 462 /* Mark the interfaces as valid */ 463 464 NextInterface->Flags &= ~ACPI_OSI_INVALID; 465 } 466 } 467 468 NextInterface = NextInterface->Next; 469 } 470 471 return (AE_OK); 472 } 473 474 475 /******************************************************************************* 476 * 477 * FUNCTION: AcpiUtGetInterface 478 * 479 * PARAMETERS: InterfaceName - The interface to find 480 * 481 * RETURN: ACPI_INTERFACE_INFO if found. NULL if not found. 482 * 483 * DESCRIPTION: Search for the specified interface name in the global list. 484 * Caller MUST hold AcpiGbl_OsiMutex 485 * 486 ******************************************************************************/ 487 488 ACPI_INTERFACE_INFO * 489 AcpiUtGetInterface ( 490 ACPI_STRING InterfaceName) 491 { 492 ACPI_INTERFACE_INFO *NextInterface; 493 494 495 NextInterface = AcpiGbl_SupportedInterfaces; 496 while (NextInterface) 497 { 498 if (!strcmp (InterfaceName, NextInterface->Name)) 499 { 500 return (NextInterface); 501 } 502 503 NextInterface = NextInterface->Next; 504 } 505 506 return (NULL); 507 } 508 509 510 /******************************************************************************* 511 * 512 * FUNCTION: AcpiUtOsiImplementation 513 * 514 * PARAMETERS: WalkState - Current walk state 515 * 516 * RETURN: Status 517 * 518 * DESCRIPTION: Implementation of the _OSI predefined control method. When 519 * an invocation of _OSI is encountered in the system AML, 520 * control is transferred to this function. 521 * 522 ******************************************************************************/ 523 524 ACPI_STATUS 525 AcpiUtOsiImplementation ( 526 ACPI_WALK_STATE *WalkState) 527 { 528 ACPI_OPERAND_OBJECT *StringDesc; 529 ACPI_OPERAND_OBJECT *ReturnDesc; 530 ACPI_INTERFACE_INFO *InterfaceInfo; 531 ACPI_INTERFACE_HANDLER InterfaceHandler; 532 ACPI_STATUS Status; 533 UINT32 ReturnValue; 534 535 536 ACPI_FUNCTION_TRACE (UtOsiImplementation); 537 538 539 /* Validate the string input argument (from the AML caller) */ 540 541 StringDesc = WalkState->Arguments[0].Object; 542 if (!StringDesc || 543 (StringDesc->Common.Type != ACPI_TYPE_STRING)) 544 { 545 return_ACPI_STATUS (AE_TYPE); 546 } 547 548 /* Create a return object */ 549 550 ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER); 551 if (!ReturnDesc) 552 { 553 return_ACPI_STATUS (AE_NO_MEMORY); 554 } 555 556 /* Default return value is 0, NOT SUPPORTED */ 557 558 ReturnValue = 0; 559 Status = AcpiOsAcquireMutex (AcpiGbl_OsiMutex, ACPI_WAIT_FOREVER); 560 if (ACPI_FAILURE (Status)) 561 { 562 AcpiUtRemoveReference (ReturnDesc); 563 return_ACPI_STATUS (Status); 564 } 565 566 /* Lookup the interface in the global _OSI list */ 567 568 InterfaceInfo = AcpiUtGetInterface (StringDesc->String.Pointer); 569 if (InterfaceInfo && 570 !(InterfaceInfo->Flags & ACPI_OSI_INVALID)) 571 { 572 /* 573 * The interface is supported. 574 * Update the OsiData if necessary. We keep track of the latest 575 * version of Windows that has been requested by the BIOS. 576 */ 577 if (InterfaceInfo->Value > AcpiGbl_OsiData) 578 { 579 AcpiGbl_OsiData = InterfaceInfo->Value; 580 } 581 582 ReturnValue = ACPI_UINT32_MAX; 583 } 584 585 AcpiOsReleaseMutex (AcpiGbl_OsiMutex); 586 587 /* 588 * Invoke an optional _OSI interface handler. The host OS may wish 589 * to do some interface-specific handling. For example, warn about 590 * certain interfaces or override the true/false support value. 591 */ 592 InterfaceHandler = AcpiGbl_InterfaceHandler; 593 if (InterfaceHandler) 594 { 595 ReturnValue = InterfaceHandler ( 596 StringDesc->String.Pointer, ReturnValue); 597 } 598 599 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO, 600 "ACPI: BIOS _OSI(\"%s\") is %ssupported\n", 601 StringDesc->String.Pointer, ReturnValue == 0 ? "not " : "")); 602 603 /* Complete the return object */ 604 605 ReturnDesc->Integer.Value = ReturnValue; 606 WalkState->ReturnDesc = ReturnDesc; 607 return_ACPI_STATUS (AE_OK); 608 } 609