xref: /netbsd-src/sys/external/bsd/acpica/dist/tools/acpiexec/aehandlers.c (revision 046a29855e04359424fd074e8313af6b6be8cfb6)
1 /******************************************************************************
2  *
3  * Module Name: aehandlers - Various handlers for acpiexec
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2023, 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 MERCHANTABILITY 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
AeNotifyHandler1(ACPI_HANDLE Device,UINT32 Value,void * Context)136 AeNotifyHandler1 (
137     ACPI_HANDLE             Device,
138     UINT32                  Value,
139     void                    *Context)
140 {
141     AeCommonNotifyHandler (Device, Value, 1);
142 }
143 
144 static void
AeNotifyHandler2(ACPI_HANDLE Device,UINT32 Value,void * Context)145 AeNotifyHandler2 (
146     ACPI_HANDLE             Device,
147     UINT32                  Value,
148     void                    *Context)
149 {
150     AeCommonNotifyHandler (Device, Value, 2);
151 }
152 
153 static void
AeCommonNotifyHandler(ACPI_HANDLE Device,UINT32 Value,UINT32 HandlerId)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
AeSystemNotifyHandler(ACPI_HANDLE Device,UINT32 Value,void * Context)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
AeDeviceNotifyHandler(ACPI_HANDLE Device,UINT32 Value,void * Context)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
AeTableHandler(UINT32 Event,void * Table,void * Context)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
AeGpeHandler(ACPI_HANDLE GpeDevice,UINT32 GpeNumber,void * Context)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
AeGlobalEventHandler(UINT32 Type,ACPI_HANDLE Device,UINT32 EventNumber,void * Context)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
AeAttachedDataHandler(ACPI_HANDLE Object,void * Data)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
AeAttachedDataHandler2(ACPI_HANDLE Object,void * Data)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
AeInterfaceHandler(ACPI_STRING InterfaceName,UINT32 Supported)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
AeEventHandler(void * Context)489 AeEventHandler (
490     void                    *Context)
491 {
492     return (0);
493 }
494 
495 static UINT32
AeSciHandler(void * Context)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
AeInstallSciHandler(void)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
AeInstallLateHandlers(void)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         ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
579 
580         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
581             AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
582         ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
583 
584         Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
585             AeNotifyHandler1);
586         ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
587 
588         Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
589             AeNotifyHandler2);
590         ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
591 
592         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
593             AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
594         ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
595 
596         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
597             AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
598         ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
599     }
600 
601     Status = AcpiGetHandle (NULL, "\\_PR.CPU0", &Handle);
602     if (ACPI_SUCCESS (Status))
603     {
604         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
605             AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
606         ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
607 
608         Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
609             AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
610         ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
611     }
612 
613 #if (!ACPI_REDUCED_HARDWARE)
614     if (!AcpiGbl_ReducedHardware)
615     {
616         /* Install a user SCI handler */
617 
618         Status = AeInstallSciHandler ();
619         ACPI_CHECK_OK (AeInstallSciHandler, Status);
620 
621         /* Install some fixed event handlers */
622 
623         Status = AcpiInstallFixedEventHandler (
624             ACPI_EVENT_GLOBAL, AeEventHandler, NULL);
625         ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status);
626 
627         Status = AcpiInstallFixedEventHandler (
628             ACPI_EVENT_RTC, AeEventHandler, NULL);
629         ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status);
630     }
631 #endif /* !ACPI_REDUCED_HARDWARE */
632 
633     AeMyContext.Connection = NULL;
634     AeMyContext.AccessLength = 0xA5;
635 
636     /*
637      * We will install a handler for each EC device, directly under the EC
638      * device definition. This is unlike the other handlers which we install
639      * at the root node. Also install memory and I/O handlers at any PCI
640      * devices.
641      */
642     AeInstallDeviceHandlers ();
643 
644     /*
645      * Install handlers for some of the "device driver" address spaces
646      * such as SMBus, etc.
647      */
648     AeInstallRegionHandlers ();
649     return (AE_OK);
650 }
651 
652 
653 /******************************************************************************
654  *
655  * FUNCTION:    AeInstallEarlyHandlers
656  *
657  * PARAMETERS:  None
658  *
659  * RETURN:      Status
660  *
661  * DESCRIPTION: Install handlers for the AcpiExec utility.
662  *
663  * Notes:       Don't install handler for PCI_Config, we want to use the
664  *              default handler to exercise that code.
665  *
666  *****************************************************************************/
667 
668 ACPI_STATUS
AeInstallEarlyHandlers(void)669 AeInstallEarlyHandlers (
670     void)
671 {
672     ACPI_STATUS             Status;
673     ACPI_HANDLE             Handle;
674 
675 
676     ACPI_FUNCTION_ENTRY ();
677 
678 
679     Status = AcpiInstallInterfaceHandler (AeInterfaceHandler);
680     if (ACPI_FAILURE (Status))
681     {
682         printf ("Could not install interface handler, %s\n",
683             AcpiFormatException (Status));
684     }
685 
686     Status = AcpiInstallTableHandler (AeTableHandler, NULL);
687     if (ACPI_FAILURE (Status))
688     {
689         printf ("Could not install table handler, %s\n",
690             AcpiFormatException (Status));
691     }
692 
693     Status = AcpiInstallExceptionHandler (AeExceptionHandler);
694     if (ACPI_FAILURE (Status))
695     {
696         printf ("Could not install exception handler, %s\n",
697             AcpiFormatException (Status));
698     }
699 
700     /* Install global notify handlers */
701 
702     Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT,
703         ACPI_SYSTEM_NOTIFY, AeSystemNotifyHandler, NULL);
704     if (ACPI_FAILURE (Status))
705     {
706         printf ("Could not install a global system notify handler, %s\n",
707             AcpiFormatException (Status));
708     }
709 
710     Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT,
711         ACPI_DEVICE_NOTIFY, AeDeviceNotifyHandler, NULL);
712     if (ACPI_FAILURE (Status))
713     {
714         printf ("Could not install a global notify handler, %s\n",
715             AcpiFormatException (Status));
716     }
717 
718     Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
719     if (ACPI_SUCCESS (Status))
720     {
721         Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
722             AeNotifyHandler1, NULL);
723         if (ACPI_FAILURE (Status))
724         {
725             printf ("Could not install a notify handler, %s\n",
726                 AcpiFormatException (Status));
727         }
728 
729         Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
730             AeNotifyHandler1);
731         if (ACPI_FAILURE (Status))
732         {
733             printf ("Could not remove a notify handler, %s\n",
734                 AcpiFormatException (Status));
735         }
736 
737         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
738             AeNotifyHandler1, NULL);
739         ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
740 
741         Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
742             AeNotifyHandler1);
743         ACPI_CHECK_OK (AcpiRemoveNotifyHandler, Status);
744 
745 #if 0
746         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
747             AeNotifyHandler1, NULL);
748         if (ACPI_FAILURE (Status))
749         {
750             printf ("Could not install a notify handler, %s\n",
751                 AcpiFormatException (Status));
752         }
753 #endif
754 
755         /* Install two handlers for _SB_ */
756 
757         Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
758             AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
759         ACPI_CHECK_OK(AcpiInstallNotifyHandler, Status);
760 
761         Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
762             AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
763         ACPI_CHECK_OK(AcpiInstallNotifyHandler, Status);
764 
765         /* Attempt duplicate handler installation, should fail */
766 
767         (void) AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
768             AeNotifyHandler1, ACPI_CAST_PTR (void, 0x77777777));
769 
770         Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
771         ACPI_CHECK_OK (AcpiAttachData, Status);
772 
773         Status = AcpiDetachData (Handle, AeAttachedDataHandler);
774         ACPI_CHECK_OK (AcpiDetachData, Status);
775 
776         /* Test attach data at the root object */
777 
778         Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler,
779             AcpiGbl_RootNode);
780         ACPI_CHECK_OK (AcpiAttachData, Status);
781 
782         Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2,
783             AcpiGbl_RootNode);
784         ACPI_CHECK_OK (AcpiAttachData, Status);
785 
786         /* Test support for multiple attaches */
787 
788         Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
789         ACPI_CHECK_OK (AcpiAttachData, Status);
790 
791         Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle);
792         ACPI_CHECK_OK (AcpiAttachData, Status);
793     }
794     else
795     {
796         printf ("No _SB_ found, %s\n", AcpiFormatException (Status));
797     }
798 
799     /*
800      * Install handlers that will override the default handlers for some of
801      * the space IDs.
802      */
803     AeOverrideRegionHandlers ();
804 
805     /*
806      * Initialize the global Region Handler space
807      * MCW 3/23/00
808      */
809     AeRegions.NumberOfRegions = 0;
810     AeRegions.RegionList = NULL;
811     return (AE_OK);
812 }
813