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