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 AcpiOsPrintf (" Opcode [%s] @%X\n", AcpiPsGetOpcodeName (Opcode), AmlOffset); 367 368 /* 369 * Invoke the _ERR method if present 370 * 371 * Setup parameter object 372 */ 373 ArgList.Count = 3; 374 ArgList.Pointer = Arg; 375 376 Arg[0].Type = ACPI_TYPE_INTEGER; 377 Arg[0].Integer.Value = AmlStatus; 378 379 Arg[1].Type = ACPI_TYPE_STRING; 380 Arg[1].String.Pointer = ACPI_CAST_PTR (char, Exception); 381 Arg[1].String.Length = strlen (Exception); 382 383 Arg[2].Type = ACPI_TYPE_INTEGER; 384 Arg[2].Integer.Value = AcpiOsGetThreadId(); 385 386 /* Setup return buffer */ 387 388 ReturnObj.Pointer = NULL; 389 ReturnObj.Length = ACPI_ALLOCATE_BUFFER; 390 391 Status = AcpiEvaluateObject (NULL, "\\_ERR", &ArgList, &ReturnObj); 392 if (ACPI_SUCCESS (Status)) 393 { 394 if (ReturnObj.Pointer) 395 { 396 /* Override original status */ 397 398 NewAmlStatus = (ACPI_STATUS) 399 ((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value; 400 401 /* Free a buffer created via ACPI_ALLOCATE_BUFFER */ 402 403 AcpiOsFree (ReturnObj.Pointer); 404 } 405 } 406 else if (Status != AE_NOT_FOUND) 407 { 408 AcpiOsPrintf ("[AcpiExec] Could not execute _ERR method, %s\n", 409 AcpiFormatException (Status)); 410 } 411 412 /* Global override */ 413 414 if (AcpiGbl_IgnoreErrors) 415 { 416 NewAmlStatus = AE_OK; 417 } 418 419 if (NewAmlStatus != AmlStatus) 420 { 421 AcpiOsPrintf ("[AcpiExec] Exception override, new status %s\n\n", 422 AcpiFormatException (NewAmlStatus)); 423 } 424 425 return (NewAmlStatus); 426 } 427 428 429 /****************************************************************************** 430 * 431 * FUNCTION: AeTableHandler 432 * 433 * PARAMETERS: Table handler 434 * 435 * RETURN: Status 436 * 437 * DESCRIPTION: System table handler for AcpiExec utility. 438 * 439 *****************************************************************************/ 440 441 static ACPI_STATUS 442 AeTableHandler ( 443 UINT32 Event, 444 void *Table, 445 void *Context) 446 { 447 #if (!ACPI_REDUCED_HARDWARE) 448 ACPI_STATUS Status; 449 #endif /* !ACPI_REDUCED_HARDWARE */ 450 451 452 if (Event > ACPI_NUM_TABLE_EVENTS) 453 { 454 Event = ACPI_NUM_TABLE_EVENTS; 455 } 456 457 #if (!ACPI_REDUCED_HARDWARE) 458 /* Enable any GPEs associated with newly-loaded GPE methods */ 459 460 Status = AcpiUpdateAllGpes (); 461 AE_CHECK_OK (AcpiUpdateAllGpes, Status); 462 463 printf ("[AcpiExec] Table Event %s, [%4.4s] %p\n", 464 TableEvents[Event], ((ACPI_TABLE_HEADER *) Table)->Signature, Table); 465 #endif /* !ACPI_REDUCED_HARDWARE */ 466 467 return (AE_OK); 468 } 469 470 471 /****************************************************************************** 472 * 473 * FUNCTION: AeGpeHandler 474 * 475 * DESCRIPTION: Common GPE handler for acpiexec 476 * 477 *****************************************************************************/ 478 479 UINT32 480 AeGpeHandler ( 481 ACPI_HANDLE GpeDevice, 482 UINT32 GpeNumber, 483 void *Context) 484 { 485 ACPI_NAMESPACE_NODE *DeviceNode = (ACPI_NAMESPACE_NODE *) GpeDevice; 486 487 488 AcpiOsPrintf ("[AcpiExec] GPE Handler received GPE %02X (GPE block %4.4s)\n", 489 GpeNumber, GpeDevice ? DeviceNode->Name.Ascii : "FADT"); 490 491 return (ACPI_REENABLE_GPE); 492 } 493 494 495 /****************************************************************************** 496 * 497 * FUNCTION: AeGlobalEventHandler 498 * 499 * DESCRIPTION: Global GPE/Fixed event handler 500 * 501 *****************************************************************************/ 502 503 void 504 AeGlobalEventHandler ( 505 UINT32 Type, 506 ACPI_HANDLE Device, 507 UINT32 EventNumber, 508 void *Context) 509 { 510 char *TypeName; 511 512 513 switch (Type) 514 { 515 case ACPI_EVENT_TYPE_GPE: 516 517 TypeName = "GPE"; 518 break; 519 520 case ACPI_EVENT_TYPE_FIXED: 521 522 TypeName = "FixedEvent"; 523 break; 524 525 default: 526 527 TypeName = "UNKNOWN"; 528 break; 529 } 530 531 AcpiOsPrintf ("[AcpiExec] Global Event Handler received: Type %s Number %.2X Dev %p\n", 532 TypeName, EventNumber, Device); 533 } 534 535 536 /****************************************************************************** 537 * 538 * FUNCTION: AeAttachedDataHandler 539 * 540 * DESCRIPTION: Handler for deletion of nodes with attached data (attached via 541 * AcpiAttachData) 542 * 543 *****************************************************************************/ 544 545 static void 546 AeAttachedDataHandler ( 547 ACPI_HANDLE Object, 548 void *Data) 549 { 550 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data); 551 552 553 AcpiOsPrintf ("Received an attached data deletion (1) on %4.4s\n", 554 Node->Name.Ascii); 555 } 556 557 558 /****************************************************************************** 559 * 560 * FUNCTION: AeAttachedDataHandler2 561 * 562 * DESCRIPTION: Handler for deletion of nodes with attached data (attached via 563 * AcpiAttachData) 564 * 565 *****************************************************************************/ 566 567 static void 568 AeAttachedDataHandler2 ( 569 ACPI_HANDLE Object, 570 void *Data) 571 { 572 ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data); 573 574 575 AcpiOsPrintf ("Received an attached data deletion (2) on %4.4s\n", 576 Node->Name.Ascii); 577 } 578 579 580 /****************************************************************************** 581 * 582 * FUNCTION: AeInterfaceHandler 583 * 584 * DESCRIPTION: Handler for _OSI invocations 585 * 586 *****************************************************************************/ 587 588 static UINT32 589 AeInterfaceHandler ( 590 ACPI_STRING InterfaceName, 591 UINT32 Supported) 592 { 593 ACPI_FUNCTION_NAME (AeInterfaceHandler); 594 595 596 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 597 "Received _OSI (\"%s\"), is %ssupported\n", 598 InterfaceName, Supported == 0 ? "not " : "")); 599 600 return (Supported); 601 } 602 603 604 #if (!ACPI_REDUCED_HARDWARE) 605 /****************************************************************************** 606 * 607 * FUNCTION: AeEventHandler, AeSciHandler 608 * 609 * DESCRIPTION: Handler for Fixed Events and SCIs 610 * 611 *****************************************************************************/ 612 613 static UINT32 614 AeEventHandler ( 615 void *Context) 616 { 617 return (0); 618 } 619 620 static UINT32 621 AeSciHandler ( 622 void *Context) 623 { 624 625 AcpiOsPrintf ("[AcpiExec] Received an SCI at handler\n"); 626 return (0); 627 } 628 629 #endif /* !ACPI_REDUCED_HARDWARE */ 630 631 632 /******************************************************************************* 633 * 634 * FUNCTION: AeInstallSciHandler 635 * 636 * PARAMETERS: None 637 * 638 * RETURN: Status 639 * 640 * DESCRIPTION: Install handler for SCIs. Exercise the code by doing an 641 * install/remove/install. 642 * 643 ******************************************************************************/ 644 645 static ACPI_STATUS 646 AeInstallSciHandler ( 647 void) 648 { 649 ACPI_STATUS Status; 650 651 652 Status = AcpiInstallSciHandler (AeSciHandler, &AeMyContext); 653 if (ACPI_FAILURE (Status)) 654 { 655 ACPI_EXCEPTION ((AE_INFO, Status, 656 "Could not install an SCI handler (1)")); 657 } 658 659 Status = AcpiRemoveSciHandler (AeSciHandler); 660 if (ACPI_FAILURE (Status)) 661 { 662 ACPI_EXCEPTION ((AE_INFO, Status, 663 "Could not remove an SCI handler")); 664 } 665 666 Status = AcpiInstallSciHandler (AeSciHandler, &AeMyContext); 667 if (ACPI_FAILURE (Status)) 668 { 669 ACPI_EXCEPTION ((AE_INFO, Status, 670 "Could not install an SCI handler (2)")); 671 } 672 673 return (Status); 674 } 675 676 677 /****************************************************************************** 678 * 679 * FUNCTION: AeInstallLateHandlers 680 * 681 * PARAMETERS: None 682 * 683 * RETURN: Status 684 * 685 * DESCRIPTION: Install handlers for the AcpiExec utility. 686 * 687 *****************************************************************************/ 688 689 ACPI_STATUS 690 AeInstallLateHandlers ( 691 void) 692 { 693 ACPI_STATUS Status; 694 695 696 #if (!ACPI_REDUCED_HARDWARE) 697 if (!AcpiGbl_ReducedHardware) 698 { 699 /* Install a user SCI handler */ 700 701 Status = AeInstallSciHandler (); 702 AE_CHECK_OK (AeInstallSciHandler, Status); 703 704 /* Install some fixed event handlers */ 705 706 Status = AcpiInstallFixedEventHandler (ACPI_EVENT_GLOBAL, AeEventHandler, NULL); 707 AE_CHECK_OK (AcpiInstallFixedEventHandler, Status); 708 709 Status = AcpiInstallFixedEventHandler (ACPI_EVENT_RTC, AeEventHandler, NULL); 710 AE_CHECK_OK (AcpiInstallFixedEventHandler, Status); 711 } 712 #endif /* !ACPI_REDUCED_HARDWARE */ 713 714 AeMyContext.Connection = NULL; 715 AeMyContext.AccessLength = 0xA5; 716 717 /* 718 * We will install a handler for each EC device, directly under the EC 719 * device definition. This is unlike the other handlers which we install 720 * at the root node. Also install memory and I/O handlers at any PCI 721 * devices. 722 */ 723 AeInstallDeviceHandlers (); 724 725 /* 726 * Install handlers for some of the "device driver" address spaces 727 * such as SMBus, etc. 728 */ 729 AeInstallRegionHandlers (); 730 return (AE_OK); 731 } 732 733 734 /****************************************************************************** 735 * 736 * FUNCTION: AeInstallEarlyHandlers 737 * 738 * PARAMETERS: None 739 * 740 * RETURN: Status 741 * 742 * DESCRIPTION: Install handlers for the AcpiExec utility. 743 * 744 * Notes: Don't install handler for PCI_Config, we want to use the 745 * default handler to exercise that code. 746 * 747 *****************************************************************************/ 748 749 ACPI_STATUS 750 AeInstallEarlyHandlers ( 751 void) 752 { 753 ACPI_STATUS Status; 754 ACPI_HANDLE Handle; 755 756 757 ACPI_FUNCTION_ENTRY (); 758 759 760 Status = AcpiInstallInterfaceHandler (AeInterfaceHandler); 761 if (ACPI_FAILURE (Status)) 762 { 763 printf ("Could not install interface handler, %s\n", 764 AcpiFormatException (Status)); 765 } 766 767 Status = AcpiInstallTableHandler (AeTableHandler, NULL); 768 if (ACPI_FAILURE (Status)) 769 { 770 printf ("Could not install table handler, %s\n", 771 AcpiFormatException (Status)); 772 } 773 774 Status = AcpiInstallExceptionHandler (AeExceptionHandler); 775 if (ACPI_FAILURE (Status)) 776 { 777 printf ("Could not install exception handler, %s\n", 778 AcpiFormatException (Status)); 779 } 780 781 /* Install global notify handlers */ 782 783 Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY, 784 AeSystemNotifyHandler, NULL); 785 if (ACPI_FAILURE (Status)) 786 { 787 printf ("Could not install a global system notify handler, %s\n", 788 AcpiFormatException (Status)); 789 } 790 791 Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_DEVICE_NOTIFY, 792 AeDeviceNotifyHandler, NULL); 793 if (ACPI_FAILURE (Status)) 794 { 795 printf ("Could not install a global notify handler, %s\n", 796 AcpiFormatException (Status)); 797 } 798 799 Status = AcpiGetHandle (NULL, "\\_SB", &Handle); 800 if (ACPI_SUCCESS (Status)) 801 { 802 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 803 AeNotifyHandler1, NULL); 804 if (ACPI_FAILURE (Status)) 805 { 806 printf ("Could not install a notify handler, %s\n", 807 AcpiFormatException (Status)); 808 } 809 810 Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 811 AeNotifyHandler1); 812 if (ACPI_FAILURE (Status)) 813 { 814 printf ("Could not remove a notify handler, %s\n", 815 AcpiFormatException (Status)); 816 } 817 818 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 819 AeNotifyHandler1, NULL); 820 AE_CHECK_OK (AcpiInstallNotifyHandler, Status); 821 822 Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, 823 AeNotifyHandler1); 824 AE_CHECK_OK (AcpiRemoveNotifyHandler, Status); 825 826 #if 0 827 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 828 AeNotifyHandler1, NULL); 829 if (ACPI_FAILURE (Status)) 830 { 831 printf ("Could not install a notify handler, %s\n", 832 AcpiFormatException (Status)); 833 } 834 #endif 835 836 /* Install two handlers for _SB_ */ 837 838 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 839 AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567)); 840 841 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 842 AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF)); 843 844 /* Attempt duplicate handler installation, should fail */ 845 846 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 847 AeNotifyHandler1, ACPI_CAST_PTR (void, 0x77777777)); 848 849 Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); 850 AE_CHECK_OK (AcpiAttachData, Status); 851 852 Status = AcpiDetachData (Handle, AeAttachedDataHandler); 853 AE_CHECK_OK (AcpiDetachData, Status); 854 855 /* Test attach data at the root object */ 856 857 Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler, 858 AcpiGbl_RootNode); 859 AE_CHECK_OK (AcpiAttachData, Status); 860 861 Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2, 862 AcpiGbl_RootNode); 863 AE_CHECK_OK (AcpiAttachData, Status); 864 865 /* Test support for multiple attaches */ 866 867 Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle); 868 AE_CHECK_OK (AcpiAttachData, Status); 869 870 Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle); 871 AE_CHECK_OK (AcpiAttachData, Status); 872 } 873 else 874 { 875 printf ("No _SB_ found, %s\n", AcpiFormatException (Status)); 876 } 877 878 879 Status = AcpiGetHandle (NULL, "\\_TZ.TZ1", &Handle); 880 if (ACPI_SUCCESS (Status)) 881 { 882 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 883 AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567)); 884 885 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 886 AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF)); 887 888 Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, 889 AeNotifyHandler1); 890 Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY, 891 AeNotifyHandler2); 892 893 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 894 AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF)); 895 896 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 897 AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567)); 898 } 899 900 Status = AcpiGetHandle (NULL, "\\_PR.CPU0", &Handle); 901 if (ACPI_SUCCESS (Status)) 902 { 903 Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY, 904 AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567)); 905 906 Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY, 907 AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF)); 908 } 909 910 /* 911 * Install handlers that will override the default handlers for some of 912 * the space IDs. 913 */ 914 AeOverrideRegionHandlers (); 915 916 /* 917 * Initialize the global Region Handler space 918 * MCW 3/23/00 919 */ 920 AeRegions.NumberOfRegions = 0; 921 AeRegions.RegionList = NULL; 922 return (AE_OK); 923 } 924