1 /****************************************************************************** 2 * 3 * Module Name: aeexec - Support routines for AcpiExec utility 4 * 5 *****************************************************************************/ 6 7 /****************************************************************************** 8 * 9 * 1. Copyright Notice 10 * 11 * Some or all of this work - Copyright (c) 1999 - 2017, 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 * Alternatively, you may choose to be licensed under the terms of the 117 * following license: 118 * 119 * Redistribution and use in source and binary forms, with or without 120 * modification, are permitted provided that the following conditions 121 * are met: 122 * 1. Redistributions of source code must retain the above copyright 123 * notice, this list of conditions, and the following disclaimer, 124 * without modification. 125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126 * substantially similar to the "NO WARRANTY" disclaimer below 127 * ("Disclaimer") and any redistribution must be conditioned upon 128 * including a substantially similar Disclaimer requirement for further 129 * binary redistribution. 130 * 3. Neither the names of the above-listed copyright holders nor the names 131 * of any contributors may be used to endorse or promote products derived 132 * from this software without specific prior written permission. 133 * 134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145 * 146 * Alternatively, you may choose to be licensed under the terms of the 147 * GNU General Public License ("GPL") version 2 as published by the Free 148 * Software Foundation. 149 * 150 *****************************************************************************/ 151 152 #include "aecommon.h" 153 154 #define _COMPONENT ACPI_TOOLS 155 ACPI_MODULE_NAME ("aeexec") 156 157 /* Local prototypes */ 158 159 static ACPI_STATUS 160 AeSetupConfiguration ( 161 void *RegionAddr); 162 163 static void 164 AeTestBufferArgument ( 165 void); 166 167 static void 168 AeTestPackageArgument ( 169 void); 170 171 static ACPI_STATUS 172 AeGetDevices ( 173 ACPI_HANDLE ObjHandle, 174 UINT32 NestingLevel, 175 void *Context, 176 void **ReturnValue); 177 178 static ACPI_STATUS 179 ExecuteOSI ( 180 char *OsiString, 181 UINT64 ExpectedResult); 182 183 static void 184 AeMutexInterfaces ( 185 void); 186 187 static void 188 AeHardwareInterfaces ( 189 void); 190 191 static void 192 AeGenericRegisters ( 193 void); 194 195 static void 196 AeTestSleepData ( 197 void); 198 199 #if (!ACPI_REDUCED_HARDWARE) 200 static void 201 AfInstallGpeBlock ( 202 void); 203 #endif /* !ACPI_REDUCED_HARDWARE */ 204 205 extern unsigned char Ssdt2Code[]; 206 extern unsigned char Ssdt3Code[]; 207 extern unsigned char Ssdt4Code[]; 208 209 210 /****************************************************************************** 211 * 212 * FUNCTION: AeSetupConfiguration 213 * 214 * PARAMETERS: RegionAddr - Address for an ACPI table to be loaded 215 * dynamically. Test purposes only. 216 * 217 * RETURN: Status 218 * 219 * DESCRIPTION: Call AML _CFG configuration control method 220 * 221 *****************************************************************************/ 222 223 static ACPI_STATUS 224 AeSetupConfiguration ( 225 void *RegionAddr) 226 { 227 ACPI_OBJECT_LIST ArgList; 228 ACPI_OBJECT Arg[3]; 229 230 231 /* 232 * Invoke _CFG method if present 233 */ 234 ArgList.Count = 1; 235 ArgList.Pointer = Arg; 236 237 Arg[0].Type = ACPI_TYPE_INTEGER; 238 Arg[0].Integer.Value = ACPI_TO_INTEGER (RegionAddr); 239 240 (void) AcpiEvaluateObject (NULL, "\\_CFG", &ArgList, NULL); 241 return (AE_OK); 242 } 243 244 245 #if (!ACPI_REDUCED_HARDWARE) 246 /****************************************************************************** 247 * 248 * FUNCTION: AfInstallGpeBlock 249 * 250 * PARAMETERS: None 251 * 252 * RETURN: None 253 * 254 * DESCRIPTION: Test GPE block device initialization. Requires test ASL with 255 * A \GPE2 device. 256 * 257 *****************************************************************************/ 258 259 static void 260 AfInstallGpeBlock ( 261 void) 262 { 263 ACPI_STATUS Status; 264 ACPI_HANDLE Handle; 265 ACPI_GENERIC_ADDRESS BlockAddress; 266 ACPI_HANDLE GpeDevice; 267 ACPI_OBJECT_TYPE Type; 268 269 270 /* _GPE should always exist */ 271 272 Status = AcpiGetHandle (NULL, "\\_GPE", &Handle); 273 ACPI_CHECK_OK (AcpiGetHandle, Status); 274 if (ACPI_FAILURE (Status)) 275 { 276 return; 277 } 278 279 memset (&BlockAddress, 0, sizeof (ACPI_GENERIC_ADDRESS)); 280 BlockAddress.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY; 281 BlockAddress.Address = 0x76540000; 282 283 /* Attempt to install a GPE block on GPE2 (if present) */ 284 285 Status = AcpiGetHandle (NULL, "\\GPE2", &Handle); 286 if (ACPI_SUCCESS (Status)) 287 { 288 Status = AcpiGetType (Handle, &Type); 289 if (ACPI_FAILURE (Status) || 290 (Type != ACPI_TYPE_DEVICE)) 291 { 292 return; 293 } 294 295 Status = AcpiInstallGpeBlock (Handle, &BlockAddress, 7, 8); 296 ACPI_CHECK_OK (AcpiInstallGpeBlock, Status); 297 298 Status = AcpiInstallGpeHandler (Handle, 8, 299 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); 300 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); 301 302 Status = AcpiEnableGpe (Handle, 8); 303 ACPI_CHECK_OK (AcpiEnableGpe, Status); 304 305 Status = AcpiGetGpeDevice (0x30, &GpeDevice); 306 ACPI_CHECK_OK (AcpiGetGpeDevice, Status); 307 308 Status = AcpiGetGpeDevice (0x42, &GpeDevice); 309 ACPI_CHECK_OK (AcpiGetGpeDevice, Status); 310 311 Status = AcpiGetGpeDevice (AcpiCurrentGpeCount-1, &GpeDevice); 312 ACPI_CHECK_OK (AcpiGetGpeDevice, Status); 313 314 Status = AcpiGetGpeDevice (AcpiCurrentGpeCount, &GpeDevice); 315 ACPI_CHECK_STATUS (AcpiGetGpeDevice, Status, AE_NOT_EXIST); 316 317 Status = AcpiRemoveGpeHandler (Handle, 8, AeGpeHandler); 318 ACPI_CHECK_OK (AcpiRemoveGpeHandler, Status); 319 } 320 321 /* Attempt to install a GPE block on GPE3 (if present) */ 322 323 Status = AcpiGetHandle (NULL, "\\GPE3", &Handle); 324 if (ACPI_SUCCESS (Status)) 325 { 326 Status = AcpiGetType (Handle, &Type); 327 if (ACPI_FAILURE (Status) || 328 (Type != ACPI_TYPE_DEVICE)) 329 { 330 return; 331 } 332 333 Status = AcpiInstallGpeBlock (Handle, &BlockAddress, 8, 11); 334 ACPI_CHECK_OK (AcpiInstallGpeBlock, Status); 335 } 336 } 337 #endif /* !ACPI_REDUCED_HARDWARE */ 338 339 340 /* Test using a Buffer object as a method argument */ 341 342 static void 343 AeTestBufferArgument ( 344 void) 345 { 346 ACPI_OBJECT_LIST Params; 347 ACPI_OBJECT BufArg; 348 UINT8 Buffer[] = 349 { 350 0,0,0,0, 351 4,0,0,0, 352 1,2,3,4 353 }; 354 355 356 BufArg.Type = ACPI_TYPE_BUFFER; 357 BufArg.Buffer.Length = 12; 358 BufArg.Buffer.Pointer = Buffer; 359 360 Params.Count = 1; 361 Params.Pointer = &BufArg; 362 363 (void) AcpiEvaluateObject (NULL, "\\BUF", &Params, NULL); 364 } 365 366 367 static ACPI_OBJECT PkgArg; 368 static ACPI_OBJECT PkgElements[5]; 369 static ACPI_OBJECT Pkg2Elements[5]; 370 static ACPI_OBJECT_LIST Params; 371 372 373 /* 374 * Test using a Package object as an method argument 375 */ 376 static void 377 AeTestPackageArgument ( 378 void) 379 { 380 381 /* Main package */ 382 383 PkgArg.Type = ACPI_TYPE_PACKAGE; 384 PkgArg.Package.Count = 4; 385 PkgArg.Package.Elements = PkgElements; 386 387 /* Main package elements */ 388 389 PkgElements[0].Type = ACPI_TYPE_INTEGER; 390 PkgElements[0].Integer.Value = 0x22228888; 391 392 PkgElements[1].Type = ACPI_TYPE_STRING; 393 PkgElements[1].String.Length = sizeof ("Top-level package"); 394 PkgElements[1].String.Pointer = "Top-level package"; 395 396 PkgElements[2].Type = ACPI_TYPE_BUFFER; 397 PkgElements[2].Buffer.Length = sizeof ("XXXX"); 398 PkgElements[2].Buffer.Pointer = (UINT8 *) "XXXX"; 399 400 PkgElements[3].Type = ACPI_TYPE_PACKAGE; 401 PkgElements[3].Package.Count = 2; 402 PkgElements[3].Package.Elements = Pkg2Elements; 403 404 /* Subpackage elements */ 405 406 Pkg2Elements[0].Type = ACPI_TYPE_INTEGER; 407 Pkg2Elements[0].Integer.Value = 0xAAAABBBB; 408 409 Pkg2Elements[1].Type = ACPI_TYPE_STRING; 410 Pkg2Elements[1].String.Length = sizeof ("Nested Package"); 411 Pkg2Elements[1].String.Pointer = "Nested Package"; 412 413 /* Parameter object */ 414 415 Params.Count = 1; 416 Params.Pointer = &PkgArg; 417 418 (void) AcpiEvaluateObject (NULL, "\\_PKG", &Params, NULL); 419 } 420 421 422 static ACPI_STATUS 423 AeGetDevices ( 424 ACPI_HANDLE ObjHandle, 425 UINT32 NestingLevel, 426 void *Context, 427 void **ReturnValue) 428 { 429 430 return (AE_OK); 431 } 432 433 434 /****************************************************************************** 435 * 436 * FUNCTION: ExecuteOSI 437 * 438 * PARAMETERS: OsiString - String passed to _OSI method 439 * ExpectedResult - 0 (FALSE) or ACPI_UINT64_MAX (TRUE) 440 * 441 * RETURN: Status 442 * 443 * DESCRIPTION: Execute the internally implemented (in ACPICA) _OSI method. 444 * 445 *****************************************************************************/ 446 447 static ACPI_STATUS 448 ExecuteOSI ( 449 char *OsiString, 450 UINT64 ExpectedResult) 451 { 452 ACPI_STATUS Status; 453 ACPI_OBJECT_LIST ArgList; 454 ACPI_OBJECT Arg[1]; 455 ACPI_BUFFER ReturnValue; 456 ACPI_OBJECT *Obj; 457 458 459 /* Setup input argument */ 460 461 ArgList.Count = 1; 462 ArgList.Pointer = Arg; 463 464 Arg[0].Type = ACPI_TYPE_STRING; 465 Arg[0].String.Pointer = OsiString; 466 Arg[0].String.Length = strlen (Arg[0].String.Pointer); 467 468 /* Ask ACPICA to allocate space for the return object */ 469 470 ReturnValue.Length = ACPI_ALLOCATE_BUFFER; 471 472 Status = AcpiEvaluateObject (NULL, "\\_OSI", &ArgList, &ReturnValue); 473 474 if (ACPI_FAILURE (Status)) 475 { 476 AcpiOsPrintf ( 477 "Could not execute _OSI method, %s\n", 478 AcpiFormatException (Status)); 479 return (Status); 480 } 481 482 Status = AE_ERROR; 483 484 if (ReturnValue.Length < sizeof (ACPI_OBJECT)) 485 { 486 AcpiOsPrintf ( 487 "Return value from _OSI method too small, %.8X\n", 488 ReturnValue.Length); 489 goto ErrorExit; 490 } 491 492 Obj = ReturnValue.Pointer; 493 if (Obj->Type != ACPI_TYPE_INTEGER) 494 { 495 AcpiOsPrintf ( 496 "Invalid return type from _OSI method, %.2X\n", Obj->Type); 497 goto ErrorExit; 498 } 499 500 if (Obj->Integer.Value != ExpectedResult) 501 { 502 AcpiOsPrintf ( 503 "Invalid return value from _OSI, expected %8.8X%8.8X found %8.8X%8.8X\n", 504 ACPI_FORMAT_UINT64 (ExpectedResult), 505 ACPI_FORMAT_UINT64 (Obj->Integer.Value)); 506 goto ErrorExit; 507 } 508 509 Status = AE_OK; 510 511 /* Reset the OSI data */ 512 513 AcpiGbl_OsiData = 0; 514 515 ErrorExit: 516 517 /* Free a buffer created via ACPI_ALLOCATE_BUFFER */ 518 519 AcpiOsFree (ReturnValue.Pointer); 520 return (Status); 521 } 522 523 524 /****************************************************************************** 525 * 526 * FUNCTION: AeGenericRegisters 527 * 528 * DESCRIPTION: Call the AcpiRead/Write interfaces. 529 * 530 *****************************************************************************/ 531 532 static ACPI_GENERIC_ADDRESS GenericRegister; 533 534 static void 535 AeGenericRegisters ( 536 void) 537 { 538 ACPI_STATUS Status; 539 UINT64 Value; 540 541 542 GenericRegister.Address = 0x1234; 543 GenericRegister.BitWidth = 64; 544 GenericRegister.BitOffset = 0; 545 GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_IO; 546 547 Status = AcpiRead (&Value, &GenericRegister); 548 ACPI_CHECK_OK (AcpiRead, Status); 549 550 Status = AcpiWrite (Value, &GenericRegister); 551 ACPI_CHECK_OK (AcpiWrite, Status); 552 553 GenericRegister.Address = 0x12345678; 554 GenericRegister.BitOffset = 0; 555 GenericRegister.SpaceId = ACPI_ADR_SPACE_SYSTEM_MEMORY; 556 557 Status = AcpiRead (&Value, &GenericRegister); 558 ACPI_CHECK_OK (AcpiRead, Status); 559 560 Status = AcpiWrite (Value, &GenericRegister); 561 ACPI_CHECK_OK (AcpiWrite, Status); 562 } 563 564 565 /****************************************************************************** 566 * 567 * FUNCTION: AeMutexInterfaces 568 * 569 * DESCRIPTION: Exercise the AML mutex access interfaces 570 * 571 *****************************************************************************/ 572 573 static void 574 AeMutexInterfaces ( 575 void) 576 { 577 ACPI_STATUS Status; 578 ACPI_HANDLE MutexHandle; 579 580 581 /* Get a handle to an AML mutex */ 582 583 Status = AcpiGetHandle (NULL, "\\MTX1", &MutexHandle); 584 if (Status == AE_NOT_FOUND) 585 { 586 return; 587 } 588 589 ACPI_CHECK_OK (AcpiGetHandle, Status); 590 if (ACPI_FAILURE (Status)) 591 { 592 return; 593 } 594 595 /* Acquire the mutex */ 596 597 Status = AcpiAcquireMutex (NULL, "\\MTX1", 0xFFFF); 598 ACPI_CHECK_OK (AcpiAcquireMutex, Status); 599 if (ACPI_FAILURE (Status)) 600 { 601 return; 602 } 603 604 /* Release mutex with different parameters */ 605 606 Status = AcpiReleaseMutex (MutexHandle, NULL); 607 ACPI_CHECK_OK (AcpiReleaseMutex, Status); 608 } 609 610 611 /****************************************************************************** 612 * 613 * FUNCTION: AeHardwareInterfaces 614 * 615 * DESCRIPTION: Call various hardware support interfaces 616 * 617 *****************************************************************************/ 618 619 static void 620 AeHardwareInterfaces ( 621 void) 622 { 623 #if (!ACPI_REDUCED_HARDWARE) 624 625 ACPI_STATUS Status; 626 UINT32 Value; 627 628 629 /* If Hardware Reduced flag is set, we are all done */ 630 631 if (AcpiGbl_ReducedHardware) 632 { 633 return; 634 } 635 636 Status = AcpiWriteBitRegister (ACPI_BITREG_WAKE_STATUS, 1); 637 ACPI_CHECK_OK (AcpiWriteBitRegister, Status); 638 639 Status = AcpiWriteBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, 1); 640 ACPI_CHECK_OK (AcpiWriteBitRegister, Status); 641 642 Status = AcpiWriteBitRegister (ACPI_BITREG_SLEEP_ENABLE, 1); 643 ACPI_CHECK_OK (AcpiWriteBitRegister, Status); 644 645 Status = AcpiWriteBitRegister (ACPI_BITREG_ARB_DISABLE, 1); 646 ACPI_CHECK_OK (AcpiWriteBitRegister, Status); 647 648 649 Status = AcpiReadBitRegister (ACPI_BITREG_WAKE_STATUS, &Value); 650 ACPI_CHECK_OK (AcpiReadBitRegister, Status); 651 652 Status = AcpiReadBitRegister (ACPI_BITREG_GLOBAL_LOCK_ENABLE, &Value); 653 ACPI_CHECK_OK (AcpiReadBitRegister, Status); 654 655 Status = AcpiReadBitRegister (ACPI_BITREG_SLEEP_ENABLE, &Value); 656 ACPI_CHECK_OK (AcpiReadBitRegister, Status); 657 658 Status = AcpiReadBitRegister (ACPI_BITREG_ARB_DISABLE, &Value); 659 ACPI_CHECK_OK (AcpiReadBitRegister, Status); 660 661 #endif /* !ACPI_REDUCED_HARDWARE */ 662 } 663 664 665 /****************************************************************************** 666 * 667 * FUNCTION: AeTestSleepData 668 * 669 * DESCRIPTION: Exercise the sleep/wake support (_S0, _S1, etc.) 670 * 671 *****************************************************************************/ 672 673 static void 674 AeTestSleepData ( 675 void) 676 { 677 int State; 678 UINT8 TypeA; 679 UINT8 TypeB; 680 ACPI_STATUS Status; 681 682 683 /* Attempt to get sleep data for all known sleep states */ 684 685 for (State = ACPI_STATE_S0; State <= ACPI_S_STATES_MAX; State++) 686 { 687 Status = AcpiGetSleepTypeData ((UINT8) State, &TypeA, &TypeB); 688 689 /* All sleep methods are optional */ 690 691 if (Status != AE_NOT_FOUND) 692 { 693 ACPI_CHECK_OK (AcpiGetSleepTypeData, Status); 694 } 695 } 696 } 697 698 699 /****************************************************************************** 700 * 701 * FUNCTION: AeMiscellaneousTests 702 * 703 * DESCRIPTION: Various ACPICA validation tests. 704 * 705 *****************************************************************************/ 706 707 void 708 AeMiscellaneousTests ( 709 void) 710 { 711 ACPI_BUFFER ReturnBuf; 712 char Buffer[32]; 713 ACPI_STATUS Status; 714 ACPI_STATISTICS Stats; 715 ACPI_HANDLE Handle; 716 717 #if (!ACPI_REDUCED_HARDWARE) 718 UINT32 LockHandle1; 719 UINT32 LockHandle2; 720 ACPI_VENDOR_UUID Uuid = 721 {0, {ACPI_INIT_UUID (0,0,0,0,0,0,0,0,0,0,0)}}; 722 #endif /* !ACPI_REDUCED_HARDWARE */ 723 724 725 Status = AcpiGetHandle (NULL, "\\", &Handle); 726 ACPI_CHECK_OK (AcpiGetHandle, Status); 727 728 if (AcpiGbl_DoInterfaceTests) 729 { 730 /* 731 * Tests for AcpiLoadTable and AcpiUnloadParentTable 732 */ 733 734 /* Attempt unload of DSDT, should fail */ 735 736 Status = AcpiGetHandle (NULL, "\\_SB_", &Handle); 737 ACPI_CHECK_OK (AcpiGetHandle, Status); 738 739 Status = AcpiUnloadParentTable (Handle); 740 ACPI_CHECK_STATUS (AcpiUnloadParentTable, Status, AE_TYPE); 741 742 /* Load and unload SSDT4 */ 743 744 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code); 745 ACPI_CHECK_OK (AcpiLoadTable, Status); 746 747 Status = AcpiGetHandle (NULL, "\\_T96", &Handle); 748 ACPI_CHECK_OK (AcpiGetHandle, Status); 749 750 Status = AcpiUnloadParentTable (Handle); 751 ACPI_CHECK_OK (AcpiUnloadParentTable, Status); 752 753 /* Re-load SSDT4 */ 754 755 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt4Code); 756 ACPI_CHECK_OK (AcpiLoadTable, Status); 757 758 /* Unload and re-load SSDT2 (SSDT2 is in the XSDT) */ 759 760 Status = AcpiGetHandle (NULL, "\\_T99", &Handle); 761 ACPI_CHECK_OK (AcpiGetHandle, Status); 762 763 Status = AcpiUnloadParentTable (Handle); 764 ACPI_CHECK_OK (AcpiUnloadParentTable, Status); 765 766 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt2Code); 767 ACPI_CHECK_OK (AcpiLoadTable, Status); 768 769 /* Load OEM9 table (causes table override) */ 770 771 Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) Ssdt3Code); 772 ACPI_CHECK_OK (AcpiLoadTable, Status); 773 } 774 775 AeHardwareInterfaces (); 776 AeGenericRegisters (); 777 AeSetupConfiguration (Ssdt3Code); 778 779 AeTestBufferArgument(); 780 AeTestPackageArgument (); 781 AeMutexInterfaces (); 782 AeTestSleepData (); 783 784 /* Test _OSI install/remove */ 785 786 Status = AcpiInstallInterface (""); 787 ACPI_CHECK_STATUS (AcpiInstallInterface, Status, AE_BAD_PARAMETER); 788 789 Status = AcpiInstallInterface ("TestString"); 790 ACPI_CHECK_OK (AcpiInstallInterface, Status); 791 792 Status = AcpiInstallInterface ("TestString"); 793 ACPI_CHECK_STATUS (AcpiInstallInterface, Status, AE_ALREADY_EXISTS); 794 795 Status = AcpiRemoveInterface ("Windows 2006"); 796 ACPI_CHECK_OK (AcpiRemoveInterface, Status); 797 798 Status = AcpiRemoveInterface ("TestString"); 799 ACPI_CHECK_OK (AcpiRemoveInterface, Status); 800 801 Status = AcpiRemoveInterface ("XXXXXX"); 802 ACPI_CHECK_STATUS (AcpiRemoveInterface, Status, AE_NOT_EXIST); 803 804 Status = AcpiInstallInterface ("AnotherTestString"); 805 ACPI_CHECK_OK (AcpiInstallInterface, Status); 806 807 /* Test _OSI execution */ 808 809 Status = ExecuteOSI ("Extended Address Space Descriptor", ACPI_UINT64_MAX); 810 ACPI_CHECK_OK (ExecuteOSI, Status); 811 812 Status = ExecuteOSI ("Windows 2001", ACPI_UINT64_MAX); 813 ACPI_CHECK_OK (ExecuteOSI, Status); 814 815 Status = ExecuteOSI ("MichiganTerminalSystem", 0); 816 ACPI_CHECK_OK (ExecuteOSI, Status); 817 818 819 ReturnBuf.Length = 32; 820 ReturnBuf.Pointer = Buffer; 821 822 Status = AcpiGetName (ACPI_ROOT_OBJECT, 823 ACPI_FULL_PATHNAME_NO_TRAILING, &ReturnBuf); 824 ACPI_CHECK_OK (AcpiGetName, Status); 825 826 /* Get Devices */ 827 828 Status = AcpiGetDevices (NULL, AeGetDevices, NULL, NULL); 829 ACPI_CHECK_OK (AcpiGetDevices, Status); 830 831 Status = AcpiGetStatistics (&Stats); 832 ACPI_CHECK_OK (AcpiGetStatistics, Status); 833 834 835 #if (!ACPI_REDUCED_HARDWARE) 836 837 Status = AcpiInstallGlobalEventHandler (AeGlobalEventHandler, NULL); 838 ACPI_CHECK_OK (AcpiInstallGlobalEventHandler, Status); 839 840 /* If Hardware Reduced flag is set, we are all done */ 841 842 if (AcpiGbl_ReducedHardware) 843 { 844 return; 845 } 846 847 Status = AcpiEnableEvent (ACPI_EVENT_GLOBAL, 0); 848 ACPI_CHECK_OK (AcpiEnableEvent, Status); 849 850 /* 851 * GPEs: Handlers, enable/disable, etc. 852 */ 853 Status = AcpiInstallGpeHandler (NULL, 0, 854 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); 855 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); 856 857 Status = AcpiEnableGpe (NULL, 0); 858 ACPI_CHECK_OK (AcpiEnableGpe, Status); 859 860 Status = AcpiRemoveGpeHandler (NULL, 0, AeGpeHandler); 861 ACPI_CHECK_OK (AcpiRemoveGpeHandler, Status); 862 863 Status = AcpiInstallGpeHandler (NULL, 0, 864 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); 865 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); 866 867 Status = AcpiEnableGpe (NULL, 0); 868 ACPI_CHECK_OK (AcpiEnableGpe, Status); 869 870 Status = AcpiSetGpe (NULL, 0, ACPI_GPE_DISABLE); 871 ACPI_CHECK_OK (AcpiSetGpe, Status); 872 873 Status = AcpiSetGpe (NULL, 0, ACPI_GPE_ENABLE); 874 ACPI_CHECK_OK (AcpiSetGpe, Status); 875 876 877 Status = AcpiInstallGpeHandler (NULL, 1, 878 ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); 879 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); 880 881 Status = AcpiEnableGpe (NULL, 1); 882 ACPI_CHECK_OK (AcpiEnableGpe, Status); 883 884 885 Status = AcpiInstallGpeHandler (NULL, 2, 886 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); 887 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); 888 889 Status = AcpiEnableGpe (NULL, 2); 890 ACPI_CHECK_OK (AcpiEnableGpe, Status); 891 892 893 Status = AcpiInstallGpeHandler (NULL, 3, 894 ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); 895 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); 896 897 Status = AcpiInstallGpeHandler (NULL, 4, 898 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); 899 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); 900 901 Status = AcpiInstallGpeHandler (NULL, 5, 902 ACPI_GPE_EDGE_TRIGGERED, AeGpeHandler, NULL); 903 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); 904 905 Status = AcpiGetHandle (NULL, "\\_SB", &Handle); 906 ACPI_CHECK_OK (AcpiGetHandle, Status); 907 908 Status = AcpiSetupGpeForWake (Handle, NULL, 5); 909 ACPI_CHECK_OK (AcpiSetupGpeForWake, Status); 910 911 Status = AcpiSetGpeWakeMask (NULL, 5, ACPI_GPE_ENABLE); 912 ACPI_CHECK_OK (AcpiSetGpeWakeMask, Status); 913 914 Status = AcpiSetupGpeForWake (Handle, NULL, 6); 915 ACPI_CHECK_OK (AcpiSetupGpeForWake, Status); 916 917 Status = AcpiSetupGpeForWake (ACPI_ROOT_OBJECT, NULL, 6); 918 ACPI_CHECK_OK (AcpiSetupGpeForWake, Status); 919 920 Status = AcpiSetupGpeForWake (Handle, NULL, 9); 921 ACPI_CHECK_OK (AcpiSetupGpeForWake, Status); 922 923 Status = AcpiInstallGpeHandler (NULL, 0x19, 924 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); 925 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); 926 927 Status = AcpiEnableGpe (NULL, 0x19); 928 ACPI_CHECK_OK (AcpiEnableGpe, Status); 929 930 931 /* GPE block 1 */ 932 933 Status = AcpiInstallGpeHandler (NULL, 101, 934 ACPI_GPE_LEVEL_TRIGGERED, AeGpeHandler, NULL); 935 ACPI_CHECK_OK (AcpiInstallGpeHandler, Status); 936 937 Status = AcpiEnableGpe (NULL, 101); 938 ACPI_CHECK_OK (AcpiEnableGpe, Status); 939 940 Status = AcpiDisableGpe (NULL, 101); 941 ACPI_CHECK_OK (AcpiDisableGpe, Status); 942 943 AfInstallGpeBlock (); 944 945 /* Here is where the GPEs are actually "enabled" */ 946 947 Status = AcpiUpdateAllGpes (); 948 ACPI_CHECK_OK (AcpiUpdateAllGpes, Status); 949 950 Status = AcpiGetHandle (NULL, "RSRC", &Handle); 951 if (ACPI_SUCCESS (Status)) 952 { 953 ReturnBuf.Length = ACPI_ALLOCATE_BUFFER; 954 955 Status = AcpiGetVendorResource (Handle, "_CRS", &Uuid, &ReturnBuf); 956 if (ACPI_SUCCESS (Status)) 957 { 958 AcpiOsFree (ReturnBuf.Pointer); 959 } 960 } 961 962 /* Test global lock */ 963 964 Status = AcpiAcquireGlobalLock (0xFFFF, &LockHandle1); 965 ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status); 966 967 Status = AcpiAcquireGlobalLock (0x5, &LockHandle2); 968 ACPI_CHECK_OK (AcpiAcquireGlobalLock, Status); 969 970 Status = AcpiReleaseGlobalLock (LockHandle1); 971 ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status); 972 973 Status = AcpiReleaseGlobalLock (LockHandle2); 974 ACPI_CHECK_OK (AcpiReleaseGlobalLock, Status); 975 976 #endif /* !ACPI_REDUCED_HARDWARE */ 977 } 978