1 /****************************************************************************** 2 * 3 * Module Name: aehandlers - Various handlers for acpiexec 4 * 5 *****************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2015, 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 "aecommon.h" 45 46 #define _COMPONENT ACPI_TOOLS 47 ACPI_MODULE_NAME ("aehandlers") 48 49 50 /* Local prototypes */ 51 52 static void 53 AeNotifyHandler1 ( 54 ACPI_HANDLE Device, 55 UINT32 Value, 56 void *Context); 57 58 static void 59 AeNotifyHandler2 ( 60 ACPI_HANDLE Device, 61 UINT32 Value, 62 void *Context); 63 64 static void 65 AeCommonNotifyHandler ( 66 ACPI_HANDLE Device, 67 UINT32 Value, 68 UINT32 HandlerId); 69 70 static void 71 AeDeviceNotifyHandler ( 72 ACPI_HANDLE Device, 73 UINT32 Value, 74 void *Context); 75 76 static ACPI_STATUS 77 AeExceptionHandler ( 78 ACPI_STATUS AmlStatus, 79 ACPI_NAME Name, 80 UINT16 Opcode, 81 UINT32 AmlOffset, 82 void *Context); 83 84 static ACPI_STATUS 85 AeTableHandler ( 86 UINT32 Event, 87 void *Table, 88 void *Context); 89 90 static void 91 AeAttachedDataHandler ( 92 ACPI_HANDLE Object, 93 void *Data); 94 95 static void 96 AeAttachedDataHandler2 ( 97 ACPI_HANDLE Object, 98 void *Data); 99 100 static UINT32 101 AeInterfaceHandler ( 102 ACPI_STRING InterfaceName, 103 UINT32 Supported); 104 105 #if (!ACPI_REDUCED_HARDWARE) 106 static UINT32 107 AeEventHandler ( 108 void *Context); 109 110 static UINT32 111 AeSciHandler ( 112 void *Context); 113 114 static char *TableEvents[] = 115 { 116 "LOAD", 117 "UNLOAD", 118 "UNKNOWN" 119 }; 120 #endif /* !ACPI_REDUCED_HARDWARE */ 121 122 123 static UINT32 SigintCount = 0; 124 static AE_DEBUG_REGIONS AeRegions; 125 126 127 /****************************************************************************** 128 * 129 * FUNCTION: AeCtrlCHandler 130 * 131 * PARAMETERS: Sig 132 * 133 * RETURN: none 134 * 135 * DESCRIPTION: Control-C handler. Abort running control method if any. 136 * 137 *****************************************************************************/ 138 139 void ACPI_SYSTEM_XFACE 140 AeCtrlCHandler ( 141 int Sig) 142 { 143 144 signal (SIGINT, SIG_IGN); 145 SigintCount++; 146 147 AcpiOsPrintf ("Caught a ctrl-c (#%u)\n\n", SigintCount); 148 149 if (AcpiGbl_MethodExecuting) 150 { 151 AcpiGbl_AbortMethod = TRUE; 152 signal (SIGINT, AeCtrlCHandler); 153 154 if (SigintCount < 10) 155 { 156 return; 157 } 158 } 159 160 (void) AcpiOsTerminate (); 161 exit (0); 162 } 163 164 165 /****************************************************************************** 166 * 167 * FUNCTION: AeNotifyHandler(s) 168 * 169 * PARAMETERS: Standard notify handler parameters 170 * 171 * RETURN: Status 172 * 173 * DESCRIPTION: Notify handlers for AcpiExec utility. Used by the ASL 174 * test suite(s) to communicate errors and other information to 175 * this utility via the Notify() operator. Tests notify handling 176 * and multiple notify handler support. 177 * 178 *****************************************************************************/ 179 180 static void 181 AeNotifyHandler1 ( 182 ACPI_HANDLE Device, 183 UINT32 Value, 184 void *Context) 185 { 186 AeCommonNotifyHandler (Device, Value, 1); 187 } 188 189 static void 190 AeNotifyHandler2 ( 191 ACPI_HANDLE Device, 192 UINT32 Value, 193 void *Context) 194 { 195 AeCommonNotifyHandler (Device, Value, 2); 196 } 197 198 static void 199 AeCommonNotifyHandler ( 200 ACPI_HANDLE Device, 201 UINT32 Value, 202 UINT32 HandlerId) 203 { 204 char *Type; 205 206 207 Type = "Device"; 208 if (Value <= ACPI_MAX_SYS_NOTIFY) 209 { 210 Type = "System"; 211 } 212 213 switch (Value) 214 { 215 #if 0 216 case 0: 217 218 printf ("[AcpiExec] Method Error 0x%X: Results not equal\n", Value); 219 if (AcpiGbl_DebugFile) 220 { 221 AcpiOsPrintf ("[AcpiExec] Method Error: Results not equal\n"); 222 } 223 break; 224 225 case 1: 226 227 printf ("[AcpiExec] Method Error: Incorrect numeric result\n"); 228 if (AcpiGbl_DebugFile) 229 { 230 AcpiOsPrintf ("[AcpiExec] Method Error: Incorrect numeric result\n"); 231 } 232 break; 233 234 case 2: 235 236 printf ("[AcpiExec] Method Error: An operand was overwritten\n"); 237 if (AcpiGbl_DebugFile) 238 { 239 AcpiOsPrintf ("[AcpiExec] Method Error: An operand was overwritten\n"); 240 } 241 break; 242 243 #endif 244 245 default: 246 247 printf ("[AcpiExec] Handler %u: Received a %s Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", 248 HandlerId, Type, AcpiUtGetNodeName (Device), Device, Value, 249 AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY)); 250 if (AcpiGbl_DebugFile) 251 { 252 AcpiOsPrintf ("[AcpiExec] Handler %u: Received a %s notify, Value 0x%2.2X\n", 253 HandlerId, Type, Value); 254 } 255 256 (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); 257 break; 258 } 259 } 260 261 262 /****************************************************************************** 263 * 264 * FUNCTION: AeSystemNotifyHandler 265 * 266 * PARAMETERS: Standard notify handler parameters 267 * 268 * RETURN: Status 269 * 270 * DESCRIPTION: System notify handler for AcpiExec utility. Used by the ASL 271 * test suite(s) to communicate errors and other information to 272 * this utility via the Notify() operator. 273 * 274 *****************************************************************************/ 275 276 static void 277 AeSystemNotifyHandler ( 278 ACPI_HANDLE Device, 279 UINT32 Value, 280 void *Context) 281 { 282 283 printf ("[AcpiExec] Global: Received a System Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", 284 AcpiUtGetNodeName (Device), Device, Value, 285 AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY)); 286 if (AcpiGbl_DebugFile) 287 { 288 AcpiOsPrintf ("[AcpiExec] Global: Received a System Notify, Value 0x%2.2X\n", Value); 289 } 290 291 (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); 292 } 293 294 295 /****************************************************************************** 296 * 297 * FUNCTION: AeDeviceNotifyHandler 298 * 299 * PARAMETERS: Standard notify handler parameters 300 * 301 * RETURN: Status 302 * 303 * DESCRIPTION: Device notify handler for AcpiExec utility. Used by the ASL 304 * test suite(s) to communicate errors and other information to 305 * this utility via the Notify() operator. 306 * 307 *****************************************************************************/ 308 309 static void 310 AeDeviceNotifyHandler ( 311 ACPI_HANDLE Device, 312 UINT32 Value, 313 void *Context) 314 { 315 316 printf ("[AcpiExec] Global: Received a Device Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", 317 AcpiUtGetNodeName (Device), Device, Value, 318 AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY)); 319 if (AcpiGbl_DebugFile) 320 { 321 AcpiOsPrintf ("[AcpiExec] Global: Received a Device Notify, Value 0x%2.2X\n", Value); 322 } 323 324 (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); 325 } 326 327 328 /****************************************************************************** 329 * 330 * FUNCTION: AeExceptionHandler 331 * 332 * PARAMETERS: Standard exception handler parameters 333 * 334 * RETURN: Status 335 * 336 * DESCRIPTION: System exception handler for AcpiExec utility. 337 * 338 *****************************************************************************/ 339 340 static ACPI_STATUS 341 AeExceptionHandler ( 342 ACPI_STATUS AmlStatus, 343 ACPI_NAME Name, 344 UINT16 Opcode, 345 UINT32 AmlOffset, 346 void *Context) 347 { 348 ACPI_STATUS NewAmlStatus = AmlStatus; 349 ACPI_STATUS Status; 350 ACPI_BUFFER ReturnObj; 351 ACPI_OBJECT_LIST ArgList; 352 ACPI_OBJECT Arg[3]; 353 const char *Exception; 354 355 356 Exception = AcpiFormatException (AmlStatus); 357 AcpiOsPrintf ("[AcpiExec] Exception %s during execution ", Exception); 358 if (Name) 359 { 360 AcpiOsPrintf ("of method [%4.4s]", (char *) &Name); 361 } 362 else 363 { 364 AcpiOsPrintf ("at module level (table load)"); 365 } 366 367 AcpiOsPrintf (" Opcode [%s] @%X\n", AcpiPsGetOpcodeName (Opcode), AmlOffset); 368 369 /* 370 * Invoke the _ERR method if present 371 * 372 * Setup parameter object 373 */ 374 ArgList.Count = 3; 375 ArgList.Pointer = Arg; 376 377 Arg[0].Type = ACPI_TYPE_INTEGER; 378 Arg[0].Integer.Value = AmlStatus; 379 380 Arg[1].Type = ACPI_TYPE_STRING; 381 Arg[1].String.Pointer = ACPI_CAST_PTR (char, Exception); 382 Arg[1].String.Length = strlen (Exception); 383 384 Arg[2].Type = ACPI_TYPE_INTEGER; 385 Arg[2].Integer.Value = AcpiOsGetThreadId(); 386 387 /* Setup return buffer */ 388 389 ReturnObj.Pointer = NULL; 390 ReturnObj.Length = ACPI_ALLOCATE_BUFFER; 391 392 Status = AcpiEvaluateObject (NULL, "\\_ERR", &ArgList, &ReturnObj); 393 if (ACPI_SUCCESS (Status)) 394 { 395 if (ReturnObj.Pointer) 396 { 397 /* Override original status */ 398 399 NewAmlStatus = (ACPI_STATUS) 400 ((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value; 401 402 /* Free a buffer created via ACPI_ALLOCATE_BUFFER */ 403 404 AcpiOsFree (ReturnObj.Pointer); 405 } 406 } 407 else if (Status != AE_NOT_FOUND) 408 { 409 AcpiOsPrintf ("[AcpiExec] Could not execute _ERR method, %s\n", 410 AcpiFormatException (Status)); 411 } 412 413 /* Global override */ 414 415 if (AcpiGbl_IgnoreErrors) 416 { 417 NewAmlStatus = AE_OK; 418 } 419 420 if (NewAmlStatus != AmlStatus) 421 { 422 AcpiOsPrintf ("[AcpiExec] Exception override, new status %s\n\n", 423 AcpiFormatException (NewAmlStatus)); 424 } 425 426 return (NewAmlStatus); 427 } 428 429 430 /****************************************************************************** 431 * 432 * FUNCTION: AeTableHandler 433 * 434 * PARAMETERS: Table handler 435 * 436 * RETURN: Status 437 * 438 * DESCRIPTION: System table handler for AcpiExec utility. 439 * 440 *****************************************************************************/ 441 442 static ACPI_STATUS 443 AeTableHandler ( 444 UINT32 Event, 445 void *Table, 446 void *Context) 447 { 448 #if (!ACPI_REDUCED_HARDWARE) 449 ACPI_STATUS Status; 450 #endif /* !ACPI_REDUCED_HARDWARE */ 451 452 453 if (Event > ACPI_NUM_TABLE_EVENTS) 454 { 455 Event = ACPI_NUM_TABLE_EVENTS; 456 } 457 458 #if (!ACPI_REDUCED_HARDWARE) 459 /* Enable any GPEs associated with newly-loaded GPE methods */ 460 461 Status = AcpiUpdateAllGpes (); 462 ACPI_CHECK_OK (AcpiUpdateAllGpes, Status); 463 464 printf ("[AcpiExec] Table Event %s, [%4.4s] %p\n", 465 TableEvents[Event], ((ACPI_TABLE_HEADER *) Table)->Signature, Table); 466 #endif /* !ACPI_REDUCED_HARDWARE */ 467 468 return (AE_OK); 469 } 470 471 472 /****************************************************************************** 473 * 474 * FUNCTION: AeGpeHandler 475 * 476 * DESCRIPTION: Common GPE handler for acpiexec 477 * 478 *****************************************************************************/ 479 480 UINT32 481 AeGpeHandler ( 482 ACPI_HANDLE GpeDevice, 483 UINT32 GpeNumber, 484 void *Context) 485 { 486 ACPI_NAMESPACE_NODE *DeviceNode = (ACPI_NAMESPACE_NODE *) GpeDevice; 487 488 489 AcpiOsPrintf ("[AcpiExec] GPE Handler received GPE %02X (GPE block %4.4s)\n", 490 GpeNumber, GpeDevice ? DeviceNode->Name.Ascii : "FADT"); 491 492 return (ACPI_REENABLE_GPE); 493 } 494 495 496 /****************************************************************************** 497 * 498 * FUNCTION: AeGlobalEventHandler 499 * 500 * DESCRIPTION: Global GPE/Fixed event handler 501 * 502 *****************************************************************************/ 503 504 void 505 AeGlobalEventHandler ( 506 UINT32 Type, 507 ACPI_HANDLE Device, 508 UINT32 EventNumber, 509 void *Context) 510 { 511 char *TypeName; 512 513 514 switch (Type) 515 { 516 case ACPI_EVENT_TYPE_GPE: 517 518 TypeName = "GPE"; 519 break; 520 521 case ACPI_EVENT_TYPE_FIXED: 522 523 TypeName = "FixedEvent"; 524 break; 525 526 default: 527 528 TypeName = "UNKNOWN"; 529 break; 530 } 531 532 AcpiOsPrintf ( 533 "[AcpiExec] Global Event Handler received: Type %s Number %.2X Dev %p\n", 534 TypeName, EventNumber, Device); 535 } 536 537 538 /****************************************************************************** 539 * 540 * FUNCTION: AeAttachedDataHandler 541 * 542 * DESCRIPTION: Handler for deletion of nodes with attached data (attached via 543 * AcpiAttachData) 544 * 545 *****************************************************************************/ 546 547 static void 548 AeAttachedDataHandler ( 549 ACPI_HANDLE Object, 550 void *Data) 551 { 552 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data); 553 554 555 AcpiOsPrintf ("Received an attached data deletion (1) on %4.4s\n", 556 Node->Name.Ascii); 557 } 558 559 560 /****************************************************************************** 561 * 562 * FUNCTION: AeAttachedDataHandler2 563 * 564 * DESCRIPTION: Handler for deletion of nodes with attached data (attached via 565 * AcpiAttachData) 566 * 567 *****************************************************************************/ 568 569 static void 570 AeAttachedDataHandler2 ( 571 ACPI_HANDLE Object, 572 void *Data) 573 { 574 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data); 575 576 577 AcpiOsPrintf ("Received an attached data deletion (2) on %4.4s\n", 578 Node->Name.Ascii); 579 } 580 581 582 /****************************************************************************** 583 * 584 * FUNCTION: AeInterfaceHandler 585 * 586 * DESCRIPTION: Handler for _OSI invocations 587 * 588 *****************************************************************************/ 589 590 static UINT32 591 AeInterfaceHandler ( 592 ACPI_STRING InterfaceName, 593 UINT32 Supported) 594 { 595 ACPI_FUNCTION_NAME (AeInterfaceHandler); 596 597 598 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 599 "Received _OSI (\"%s\"), is %ssupported\n", 600 InterfaceName, Supported == 0 ? "not " : "")); 601 602 return (Supported); 603 } 604 605 606 #if (!ACPI_REDUCED_HARDWARE) 607 /****************************************************************************** 608 * 609 * FUNCTION: AeEventHandler, AeSciHandler 610 * 611 * DESCRIPTION: Handler for Fixed Events and SCIs 612 * 613 *****************************************************************************/ 614 615 static UINT32 616 AeEventHandler ( 617 void *Context) 618 { 619 return (0); 620 } 621 622 static UINT32 623 AeSciHandler ( 624 void *Context) 625 { 626 627 AcpiOsPrintf ("[AcpiExec] Received an SCI at handler\n"); 628 return (0); 629 } 630 631 #endif /* !ACPI_REDUCED_HARDWARE */ 632 633 634 /******************************************************************************* 635 * 636 * FUNCTION: AeInstallSciHandler 637 * 638 * PARAMETERS: None 639 * 640 * RETURN: Status 641 * 642 * DESCRIPTION: Install handler for SCIs. Exercise the code by doing an 643 * install/remove/install. 644 * 645 ******************************************************************************/ 646 647 static ACPI_STATUS 648 AeInstallSciHandler ( 649 void) 650 { 651 ACPI_STATUS Status; 652 653 654 Status = AcpiInstallSciHandler (AeSciHandler, &AeMyContext); 655 if (ACPI_FAILURE (Status)) 656 { 657 ACPI_EXCEPTION ((AE_INFO, Status, 658 "Could not install an SCI handler (1)")); 659 } 660 661 Status = AcpiRemoveSciHandler (AeSciHandler); 662 if (ACPI_FAILURE (Status)) 663 { 664 ACPI_EXCEPTION ((AE_INFO, Status, 665 "Could not remove an SCI handler")); 666 } 667 668 Status = AcpiInstallSciHandler (AeSciHandler, &AeMyContext); 669 if (ACPI_FAILURE (Status)) 670 { 671 ACPI_EXCEPTION ((AE_INFO, Status, 672 "Could not install an SCI handler (2)")); 673 } 674 675 return (Status); 676 } 677 678 679 /****************************************************************************** 680 * 681 * FUNCTION: AeInstallLateHandlers 682 * 683 * PARAMETERS: None 684 * 685 * RETURN: Status 686 * 687 * DESCRIPTION: Install handlers for the AcpiExec utility. 688 * 689 *****************************************************************************/ 690 691 ACPI_STATUS 692 AeInstallLateHandlers ( 693 void) 694 { 695 ACPI_STATUS Status; 696 697 698 #if (!ACPI_REDUCED_HARDWARE) 699 if (!AcpiGbl_ReducedHardware) 700 { 701 /* Install a user SCI handler */ 702 703 Status = AeInstallSciHandler (); 704 ACPI_CHECK_OK (AeInstallSciHandler, Status); 705 706 /* Install some fixed event handlers */ 707 708 Status = AcpiInstallFixedEventHandler ( 709 ACPI_EVENT_GLOBAL, AeEventHandler, NULL); 710 ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status); 711 712 Status = AcpiInstallFixedEventHandler ( 713 ACPI_EVENT_RTC, AeEventHandler, NULL); 714 ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status); 715 } 716 #endif /* !ACPI_REDUCED_HARDWARE */ 717 718 AeMyContext.Connection = NULL; 719 AeMyContext.AccessLength = 0xA5; 720 721 /* 722 * We will install a handler for each EC device, directly under the EC 723 * device definition. This is unlike the other handlers which we install 724 * at the root node. Also install memory and I/O handlers at any PCI 725 * devices. 726 */ 727 AeInstallDeviceHandlers (); 728 729 /* 730 * Install handlers for some of the "device driver" address spaces 731 * such as SMBus, etc. 732 */ 733 AeInstallRegionHandlers (); 734 return (AE_OK); 735 } 736 737 738 /****************************************************************************** 739 * 740 * FUNCTION: AeInstallEarlyHandlers 741 * 742 * PARAMETERS: None 743 * 744 * RETURN: Status 745 * 746 * DESCRIPTION: Install handlers for the AcpiExec utility. 747 * 748 * Notes: Don't install handler for PCI_Config, we want to use the 749 * default handler to exercise that code. 750 * 751 *****************************************************************************/ 752 753 ACPI_STATUS 754 AeInstallEarlyHandlers ( 755 void) 756 { 757 ACPI_STATUS Status; 758 ACPI_HANDLE Handle; 759 760 761 ACPI_FUNCTION_ENTRY (); 762 763 764 Status = AcpiInstallInterfaceHandler (AeInterfaceHandler); 765 if (ACPI_FAILURE (Status)) 766 { 767 printf ("Could not install interface handler, %s\n", 768 AcpiFormatException (Status)); 769 } 770 771 Status = AcpiInstallTableHandler (AeTableHandler, NULL); 772 if (ACPI_FAILURE (Status)) 773 { 774 printf ("Could not install table handler, %s\n", 775 AcpiFormatException (Status)); 776 } 777 778 Status = AcpiInstallExceptionHandler (AeExceptionHandler); 779 if (ACPI_FAILURE (Status)) 780 { 781 printf ("Could not install exception handler, %s\n", 782 AcpiFormatException (Status)); 783 } 784 785 /* Install global notify handlers */ 786 787 Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, 788 AeSystemNotifyHandler, NULL); 789 if (ACPI_FAILURE (Status)) 790 { 791 printf ("Could not install a global system notify handler, %s\n", 792 AcpiFormatException (Status)); 793 } 794 795 Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY, 796 AeDeviceNotifyHandler, NULL); 797 if (ACPI_FAILURE (Status)) 798 { 799 printf ("Could not install a global notify handler, %s\n", 800 AcpiFormatException (Status)); 801 } 802 803 Status = AcpiGetHandle (NULL, "\\_SB", &Handle); 804 if (ACPI_SUCCESS (Status)) 805 { 806 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 807 AeNotifyHandler1, NULL); 808 if (ACPI_FAILURE (Status)) 809 { 810 printf ("Could not install a notify handler, %s\n", 811 AcpiFormatException (Status)); 812 } 813 814 Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 815 AeNotifyHandler1); 816 if (ACPI_FAILURE (Status)) 817 { 818 printf ("Could not remove a notify handler, %s\n", 819 AcpiFormatException (Status)); 820 } 821 822 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 823 AeNotifyHandler1, NULL); 824 ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status); 825 826 Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, 827 AeNotifyHandler1); 828 ACPI_CHECK_OK (AcpiRemoveNotifyHandler, Status); 829 830 #if 0 831 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 832 AeNotifyHandler1, NULL); 833 if (ACPI_FAILURE (Status)) 834 { 835 printf ("Could not install a notify handler, %s\n", 836 AcpiFormatException (Status)); 837 } 838 #endif 839 840 /* Install two handlers for _SB_ */ 841 842 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 843 AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567)); 844 845 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 846 AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF)); 847 848 /* Attempt duplicate handler installation, should fail */ 849 850 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 851 AeNotifyHandler1, ACPI_CAST_PTR (void, 0x77777777)); 852 853 Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); 854 ACPI_CHECK_OK (AcpiAttachData, Status); 855 856 Status = AcpiDetachData (Handle, AeAttachedDataHandler); 857 ACPI_CHECK_OK (AcpiDetachData, Status); 858 859 /* Test attach data at the root object */ 860 861 Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler, 862 AcpiGbl_RootNode); 863 ACPI_CHECK_OK (AcpiAttachData, Status); 864 865 Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2, 866 AcpiGbl_RootNode); 867 ACPI_CHECK_OK (AcpiAttachData, Status); 868 869 /* Test support for multiple attaches */ 870 871 Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); 872 ACPI_CHECK_OK (AcpiAttachData, Status); 873 874 Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle); 875 ACPI_CHECK_OK (AcpiAttachData, Status); 876 } 877 else 878 { 879 printf ("No _SB_ found, %s\n", AcpiFormatException (Status)); 880 } 881 882 Status = AcpiGetHandle (NULL, "\\_TZ.TZ1", &Handle); 883 if (ACPI_SUCCESS (Status)) 884 { 885 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 886 AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567)); 887 888 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 889 AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF)); 890 891 Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, 892 AeNotifyHandler1); 893 Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, 894 AeNotifyHandler2); 895 896 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 897 AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF)); 898 899 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 900 AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567)); 901 } 902 903 Status = AcpiGetHandle (NULL, "\\_PR.CPU0", &Handle); 904 if (ACPI_SUCCESS (Status)) 905 { 906 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 907 AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567)); 908 909 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 910 AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF)); 911 } 912 913 /* 914 * Install handlers that will override the default handlers for some of 915 * the space IDs. 916 */ 917 AeOverrideRegionHandlers (); 918 919 /* 920 * Initialize the global Region Handler space 921 * MCW 3/23/00 922 */ 923 AeRegions.NumberOfRegions = 0; 924 AeRegions.RegionList = NULL; 925 return (AE_OK); 926 } 927