1 /******************************************************************************
2  *
3  * Module Name: aehandlers - Various handlers for acpiexec
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code. No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision. In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change. Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee. Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution. In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government. In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************
115  *
116  * Alternatively, you may choose to be licensed under the terms of the
117  * following license:
118  *
119  * Redistribution and use in source and binary forms, with or without
120  * modification, are permitted provided that the following conditions
121  * are met:
122  * 1. Redistributions of source code must retain the above copyright
123  *    notice, this list of conditions, and the following disclaimer,
124  *    without modification.
125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126  *    substantially similar to the "NO WARRANTY" disclaimer below
127  *    ("Disclaimer") and any redistribution must be conditioned upon
128  *    including a substantially similar Disclaimer requirement for further
129  *    binary redistribution.
130  * 3. Neither the names of the above-listed copyright holders nor the names
131  *    of any contributors may be used to endorse or promote products derived
132  *    from this software without specific prior written permission.
133  *
134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145  *
146  * Alternatively, you may choose to be licensed under the terms of the
147  * GNU General Public License ("GPL") version 2 as published by the Free
148  * Software Foundation.
149  *
150  *****************************************************************************/
151 
152 #include "aecommon.h"
153 
154 #define _COMPONENT          ACPI_TOOLS
155         ACPI_MODULE_NAME    ("aehandlers")
156 
157 
158 /* Local prototypes */
159 
160 static void
161 AeNotifyHandler1 (
162     ACPI_HANDLE             Device,
163     UINT32                  Value,
164     void                    *Context);
165 
166 static void
167 AeNotifyHandler2 (
168     ACPI_HANDLE             Device,
169     UINT32                  Value,
170     void                    *Context);
171 
172 static void
173 AeCommonNotifyHandler (
174     ACPI_HANDLE             Device,
175     UINT32                  Value,
176     UINT32                  HandlerId);
177 
178 static void
179 AeDeviceNotifyHandler (
180     ACPI_HANDLE             Device,
181     UINT32                  Value,
182     void                    *Context);
183 
184 static ACPI_STATUS
185 AeTableHandler (
186     UINT32                  Event,
187     void                    *Table,
188     void                    *Context);
189 
190 static void
191 AeAttachedDataHandler (
192     ACPI_HANDLE             Object,
193     void                    *Data);
194 
195 static void
196 AeAttachedDataHandler2 (
197     ACPI_HANDLE             Object,
198     void                    *Data);
199 
200 static UINT32
201 AeInterfaceHandler (
202     ACPI_STRING             InterfaceName,
203     UINT32                  Supported);
204 
205 #if (!ACPI_REDUCED_HARDWARE)
206 static UINT32
207 AeEventHandler (
208     void                    *Context);
209 
210 static UINT32
211 AeSciHandler (
212     void                    *Context);
213 
214 static char                *TableEvents[] =
215 {
216     "LOAD",
217     "UNLOAD",
218     "INSTALL",
219     "UNINSTALL",
220     "UNKNOWN"
221 };
222 #endif /* !ACPI_REDUCED_HARDWARE */
223 
224 
225 static AE_DEBUG_REGIONS     AeRegions;
226 
227 
228 /******************************************************************************
229  *
230  * FUNCTION:    AeNotifyHandler(s)
231  *
232  * PARAMETERS:  Standard notify handler parameters
233  *
234  * RETURN:      Status
235  *
236  * DESCRIPTION: Notify handlers for AcpiExec utility. Used by the ASL
237  *              test suite(s) to communicate errors and other information to
238  *              this utility via the Notify() operator. Tests notify handling
239  *              and multiple notify handler support.
240  *
241  *****************************************************************************/
242 
243 static void
244 AeNotifyHandler1 (
245     ACPI_HANDLE             Device,
246     UINT32                  Value,
247     void                    *Context)
248 {
249     AeCommonNotifyHandler (Device, Value, 1);
250 }
251 
252 static void
253 AeNotifyHandler2 (
254     ACPI_HANDLE             Device,
255     UINT32                  Value,
256     void                    *Context)
257 {
258     AeCommonNotifyHandler (Device, Value, 2);
259 }
260 
261 static void
262 AeCommonNotifyHandler (
263     ACPI_HANDLE             Device,
264     UINT32                  Value,
265     UINT32                  HandlerId)
266 {
267     char                    *Type;
268 
269 
270     Type = "Device";
271     if (Value <= ACPI_MAX_SYS_NOTIFY)
272     {
273         Type = "System";
274     }
275 
276     switch (Value)
277     {
278 #if 0
279     case 0:
280 
281         printf (AE_PREFIX
282             "Method Error 0x%X: Results not equal\n", Value);
283         if (AcpiGbl_DebugFile)
284         {
285             AcpiOsPrintf (AE_PREFIX
286                 "Method Error: Results not equal\n");
287         }
288         break;
289 
290     case 1:
291 
292         printf (AE_PREFIX
293             "Method Error: Incorrect numeric result\n");
294         if (AcpiGbl_DebugFile)
295         {
296             AcpiOsPrintf (AE_PREFIX
297                 "Method Error: Incorrect numeric result\n");
298         }
299         break;
300 
301     case 2:
302 
303         printf (AE_PREFIX
304             "Method Error: An operand was overwritten\n");
305         if (AcpiGbl_DebugFile)
306         {
307             AcpiOsPrintf (AE_PREFIX
308                 "Method Error: An operand was overwritten\n");
309         }
310         break;
311 
312 #endif
313 
314     default:
315 
316         printf (AE_PREFIX
317             "Handler %u: Received a %s Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
318             HandlerId, Type, AcpiUtGetNodeName (Device), Device, Value,
319             AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY));
320         if (AcpiGbl_DebugFile)
321         {
322             AcpiOsPrintf (AE_PREFIX
323                 "Handler %u: Received a %s notify, Value 0x%2.2X\n",
324                 HandlerId, Type, Value);
325         }
326 
327         (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL);
328         break;
329     }
330 }
331 
332 
333 /******************************************************************************
334  *
335  * FUNCTION:    AeSystemNotifyHandler
336  *
337  * PARAMETERS:  Standard notify handler parameters
338  *
339  * RETURN:      Status
340  *
341  * DESCRIPTION: System notify handler for AcpiExec utility. Used by the ASL
342  *              test suite(s) to communicate errors and other information to
343  *              this utility via the Notify() operator.
344  *
345  *****************************************************************************/
346 
347 static void
348 AeSystemNotifyHandler (
349     ACPI_HANDLE                 Device,
350     UINT32                      Value,
351     void                        *Context)
352 {
353 
354     printf (AE_PREFIX
355         "Global:    Received a System Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
356         AcpiUtGetNodeName (Device), Device, Value,
357         AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY));
358     if (AcpiGbl_DebugFile)
359     {
360         AcpiOsPrintf (AE_PREFIX
361             "Global:    Received a System Notify, Value 0x%2.2X\n", Value);
362     }
363 
364     (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL);
365 }
366 
367 
368 /******************************************************************************
369  *
370  * FUNCTION:    AeDeviceNotifyHandler
371  *
372  * PARAMETERS:  Standard notify handler parameters
373  *
374  * RETURN:      Status
375  *
376  * DESCRIPTION: Device notify handler for AcpiExec utility. Used by the ASL
377  *              test suite(s) to communicate errors and other information to
378  *              this utility via the Notify() operator.
379  *
380  *****************************************************************************/
381 
382 static void
383 AeDeviceNotifyHandler (
384     ACPI_HANDLE                 Device,
385     UINT32                      Value,
386     void                        *Context)
387 {
388 
389     printf (AE_PREFIX
390         "Global:    Received a Device Notify on [%4.4s] %p Value 0x%2.2X (%s)\n",
391         AcpiUtGetNodeName (Device), Device, Value,
392         AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY));
393     if (AcpiGbl_DebugFile)
394     {
395         AcpiOsPrintf (AE_PREFIX
396             "Global:    Received a Device Notify, Value 0x%2.2X\n", Value);
397     }
398 
399     (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL);
400 }
401 
402 
403 /******************************************************************************
404  *
405  * FUNCTION:    AeTableHandler
406  *
407  * PARAMETERS:  Table handler
408  *
409  * RETURN:      Status
410  *
411  * DESCRIPTION: System table handler for AcpiExec utility.
412  *
413  *****************************************************************************/
414 
415 static ACPI_STATUS
416 AeTableHandler (
417     UINT32                  Event,
418     void                    *Table,
419     void                    *Context)
420 {
421 #if (!ACPI_REDUCED_HARDWARE)
422     ACPI_STATUS             Status;
423 #endif /* !ACPI_REDUCED_HARDWARE */
424 
425 
426     if (Event > ACPI_NUM_TABLE_EVENTS)
427     {
428         Event = ACPI_NUM_TABLE_EVENTS;
429     }
430 
431 #if (!ACPI_REDUCED_HARDWARE)
432     /* Enable any GPEs associated with newly-loaded GPE methods */
433 
434     Status = AcpiUpdateAllGpes ();
435     ACPI_CHECK_OK (AcpiUpdateAllGpes, Status);
436 
437     printf (AE_PREFIX "Table Event %s, [%4.4s] %p\n",
438         TableEvents[Event],
439         ((ACPI_TABLE_HEADER *) Table)->Signature, Table);
440 #endif /* !ACPI_REDUCED_HARDWARE */
441 
442     return (AE_OK);
443 }
444 
445 
446 /******************************************************************************
447  *
448  * FUNCTION:    AeGpeHandler
449  *
450  * DESCRIPTION: Common GPE handler for acpiexec
451  *
452  *****************************************************************************/
453 
454 UINT32
455 AeGpeHandler (
456     ACPI_HANDLE             GpeDevice,
457     UINT32                  GpeNumber,
458     void                    *Context)
459 {
460     ACPI_NAMESPACE_NODE     *DeviceNode = (ACPI_NAMESPACE_NODE *) GpeDevice;
461 
462 
463     AcpiOsPrintf (AE_PREFIX
464         "GPE Handler received GPE %02X (GPE block %4.4s)\n",
465         GpeNumber, GpeDevice ? DeviceNode->Name.Ascii : "FADT");
466 
467     return (ACPI_REENABLE_GPE);
468 }
469 
470 
471 /******************************************************************************
472  *
473  * FUNCTION:    AeGlobalEventHandler
474  *
475  * DESCRIPTION: Global GPE/Fixed event handler
476  *
477  *****************************************************************************/
478 
479 void
480 AeGlobalEventHandler (
481     UINT32                  Type,
482     ACPI_HANDLE             Device,
483     UINT32                  EventNumber,
484     void                    *Context)
485 {
486     char                    *TypeName;
487 
488 
489     switch (Type)
490     {
491     case ACPI_EVENT_TYPE_GPE:
492 
493         TypeName = "GPE";
494         break;
495 
496     case ACPI_EVENT_TYPE_FIXED:
497 
498         TypeName = "FixedEvent";
499         break;
500 
501     default:
502 
503         TypeName = "UNKNOWN";
504         break;
505     }
506 
507     AcpiOsPrintf (AE_PREFIX
508         "Global Event Handler received: Type %s Number %.2X Dev %p\n",
509         TypeName, EventNumber, Device);
510 }
511 
512 
513 /******************************************************************************
514  *
515  * FUNCTION:    AeAttachedDataHandler
516  *
517  * DESCRIPTION: Handler for deletion of nodes with attached data (attached via
518  *              AcpiAttachData)
519  *
520  *****************************************************************************/
521 
522 static void
523 AeAttachedDataHandler (
524     ACPI_HANDLE             Object,
525     void                    *Data)
526 {
527     ACPI_NAMESPACE_NODE     *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data);
528 
529 
530     AcpiOsPrintf (AE_PREFIX
531         "Received an attached data deletion (1) on %4.4s\n",
532         Node->Name.Ascii);
533 }
534 
535 
536 /******************************************************************************
537  *
538  * FUNCTION:    AeAttachedDataHandler2
539  *
540  * DESCRIPTION: Handler for deletion of nodes with attached data (attached via
541  *              AcpiAttachData)
542  *
543  *****************************************************************************/
544 
545 static void
546 AeAttachedDataHandler2 (
547     ACPI_HANDLE             Object,
548     void                    *Data)
549 {
550     ACPI_NAMESPACE_NODE     *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Data);
551 
552 
553     AcpiOsPrintf (AE_PREFIX
554         "Received an attached data deletion (2) on %4.4s\n",
555         Node->Name.Ascii);
556 }
557 
558 
559 /******************************************************************************
560  *
561  * FUNCTION:    AeInterfaceHandler
562  *
563  * DESCRIPTION: Handler for _OSI invocations
564  *
565  *****************************************************************************/
566 
567 static UINT32
568 AeInterfaceHandler (
569     ACPI_STRING             InterfaceName,
570     UINT32                  Supported)
571 {
572     ACPI_FUNCTION_NAME (AeInterfaceHandler);
573 
574 
575     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
576         "Received _OSI (\"%s\"), is %ssupported\n",
577         InterfaceName, Supported == 0 ? "not " : ""));
578 
579     return (Supported);
580 }
581 
582 
583 #if (!ACPI_REDUCED_HARDWARE)
584 /******************************************************************************
585  *
586  * FUNCTION:    AeEventHandler, AeSciHandler
587  *
588  * DESCRIPTION: Handler for Fixed Events and SCIs
589  *
590  *****************************************************************************/
591 
592 static UINT32
593 AeEventHandler (
594     void                    *Context)
595 {
596     return (0);
597 }
598 
599 static UINT32
600 AeSciHandler (
601     void                    *Context)
602 {
603 
604     AcpiOsPrintf (AE_PREFIX
605         "Received an SCI at handler\n");
606     return (0);
607 }
608 
609 #endif /* !ACPI_REDUCED_HARDWARE */
610 
611 
612 /*******************************************************************************
613  *
614  * FUNCTION:    AeInstallSciHandler
615  *
616  * PARAMETERS:  None
617  *
618  * RETURN:      Status
619  *
620  * DESCRIPTION: Install handler for SCIs. Exercise the code by doing an
621  *              install/remove/install.
622  *
623  ******************************************************************************/
624 
625 static ACPI_STATUS
626 AeInstallSciHandler (
627     void)
628 {
629     ACPI_STATUS             Status;
630 
631 
632     Status = AcpiInstallSciHandler (AeSciHandler, &AeMyContext);
633     if (ACPI_FAILURE (Status))
634     {
635         ACPI_EXCEPTION ((AE_INFO, Status,
636             "Could not install an SCI handler (1)"));
637     }
638 
639     Status = AcpiRemoveSciHandler (AeSciHandler);
640     if (ACPI_FAILURE (Status))
641     {
642         ACPI_EXCEPTION ((AE_INFO, Status,
643             "Could not remove an SCI handler"));
644     }
645 
646     Status = AcpiInstallSciHandler (AeSciHandler, &AeMyContext);
647     if (ACPI_FAILURE (Status))
648     {
649         ACPI_EXCEPTION ((AE_INFO, Status,
650             "Could not install an SCI handler (2)"));
651     }
652 
653     return (Status);
654 }
655 
656 
657 /******************************************************************************
658  *
659  * FUNCTION:    AeInstallLateHandlers
660  *
661  * PARAMETERS:  None
662  *
663  * RETURN:      Status
664  *
665  * DESCRIPTION: Install handlers for the AcpiExec utility.
666  *
667  *****************************************************************************/
668 
669 ACPI_STATUS
670 AeInstallLateHandlers (
671     void)
672 {
673     ACPI_STATUS             Status;
674     ACPI_HANDLE             Handle;
675 
676 
677     Status = AcpiGetHandle (NULL, "\\_TZ.TZ1", &Handle);
678     if (ACPI_SUCCESS (Status))
679     {
680         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
681             AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
682 
683         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
684             AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
685 
686         Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
687             AeNotifyHandler1);
688         Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
689             AeNotifyHandler2);
690 
691         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
692             AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
693 
694         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
695             AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
696     }
697 
698     Status = AcpiGetHandle (NULL, "\\_PR.CPU0", &Handle);
699     if (ACPI_SUCCESS (Status))
700     {
701         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
702             AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
703 
704         Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
705             AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
706     }
707 
708 #if (!ACPI_REDUCED_HARDWARE)
709     if (!AcpiGbl_ReducedHardware)
710     {
711         /* Install a user SCI handler */
712 
713         Status = AeInstallSciHandler ();
714         ACPI_CHECK_OK (AeInstallSciHandler, Status);
715 
716         /* Install some fixed event handlers */
717 
718         Status = AcpiInstallFixedEventHandler (
719             ACPI_EVENT_GLOBAL, AeEventHandler, NULL);
720         ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status);
721 
722         Status = AcpiInstallFixedEventHandler (
723             ACPI_EVENT_RTC, AeEventHandler, NULL);
724         ACPI_CHECK_OK (AcpiInstallFixedEventHandler, Status);
725     }
726 #endif /* !ACPI_REDUCED_HARDWARE */
727 
728     AeMyContext.Connection = NULL;
729     AeMyContext.AccessLength = 0xA5;
730 
731     /*
732      * We will install a handler for each EC device, directly under the EC
733      * device definition. This is unlike the other handlers which we install
734      * at the root node. Also install memory and I/O handlers at any PCI
735      * devices.
736      */
737     AeInstallDeviceHandlers ();
738 
739     /*
740      * Install handlers for some of the "device driver" address spaces
741      * such as SMBus, etc.
742      */
743     AeInstallRegionHandlers ();
744     return (AE_OK);
745 }
746 
747 
748 /******************************************************************************
749  *
750  * FUNCTION:    AeInstallEarlyHandlers
751  *
752  * PARAMETERS:  None
753  *
754  * RETURN:      Status
755  *
756  * DESCRIPTION: Install handlers for the AcpiExec utility.
757  *
758  * Notes:       Don't install handler for PCI_Config, we want to use the
759  *              default handler to exercise that code.
760  *
761  *****************************************************************************/
762 
763 ACPI_STATUS
764 AeInstallEarlyHandlers (
765     void)
766 {
767     ACPI_STATUS             Status;
768     ACPI_HANDLE             Handle;
769 
770 
771     ACPI_FUNCTION_ENTRY ();
772 
773 
774     Status = AcpiInstallInterfaceHandler (AeInterfaceHandler);
775     if (ACPI_FAILURE (Status))
776     {
777         printf ("Could not install interface handler, %s\n",
778             AcpiFormatException (Status));
779     }
780 
781     Status = AcpiInstallTableHandler (AeTableHandler, NULL);
782     if (ACPI_FAILURE (Status))
783     {
784         printf ("Could not install table handler, %s\n",
785             AcpiFormatException (Status));
786     }
787 
788     Status = AcpiInstallExceptionHandler (AeExceptionHandler);
789     if (ACPI_FAILURE (Status))
790     {
791         printf ("Could not install exception handler, %s\n",
792             AcpiFormatException (Status));
793     }
794 
795     /* Install global notify handlers */
796 
797     Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT,
798         ACPI_SYSTEM_NOTIFY, AeSystemNotifyHandler, NULL);
799     if (ACPI_FAILURE (Status))
800     {
801         printf ("Could not install a global system notify handler, %s\n",
802             AcpiFormatException (Status));
803     }
804 
805     Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT,
806         ACPI_DEVICE_NOTIFY, AeDeviceNotifyHandler, NULL);
807     if (ACPI_FAILURE (Status))
808     {
809         printf ("Could not install a global notify handler, %s\n",
810             AcpiFormatException (Status));
811     }
812 
813     Status = AcpiGetHandle (NULL, "\\_SB", &Handle);
814     if (ACPI_SUCCESS (Status))
815     {
816         Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
817             AeNotifyHandler1, NULL);
818         if (ACPI_FAILURE (Status))
819         {
820             printf ("Could not install a notify handler, %s\n",
821                 AcpiFormatException (Status));
822         }
823 
824         Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
825             AeNotifyHandler1);
826         if (ACPI_FAILURE (Status))
827         {
828             printf ("Could not remove a notify handler, %s\n",
829                 AcpiFormatException (Status));
830         }
831 
832         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
833             AeNotifyHandler1, NULL);
834         ACPI_CHECK_OK (AcpiInstallNotifyHandler, Status);
835 
836         Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
837             AeNotifyHandler1);
838         ACPI_CHECK_OK (AcpiRemoveNotifyHandler, Status);
839 
840 #if 0
841         Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
842             AeNotifyHandler1, NULL);
843         if (ACPI_FAILURE (Status))
844         {
845             printf ("Could not install a notify handler, %s\n",
846                 AcpiFormatException (Status));
847         }
848 #endif
849 
850         /* Install two handlers for _SB_ */
851 
852         Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
853             AeNotifyHandler1, ACPI_CAST_PTR (void, 0x01234567));
854 
855         Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
856             AeNotifyHandler2, ACPI_CAST_PTR (void, 0x89ABCDEF));
857 
858         /* Attempt duplicate handler installation, should fail */
859 
860         Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
861             AeNotifyHandler1, ACPI_CAST_PTR (void, 0x77777777));
862 
863         Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
864         ACPI_CHECK_OK (AcpiAttachData, Status);
865 
866         Status = AcpiDetachData (Handle, AeAttachedDataHandler);
867         ACPI_CHECK_OK (AcpiDetachData, Status);
868 
869         /* Test attach data at the root object */
870 
871         Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler,
872             AcpiGbl_RootNode);
873         ACPI_CHECK_OK (AcpiAttachData, Status);
874 
875         Status = AcpiAttachData (ACPI_ROOT_OBJECT, AeAttachedDataHandler2,
876             AcpiGbl_RootNode);
877         ACPI_CHECK_OK (AcpiAttachData, Status);
878 
879         /* Test support for multiple attaches */
880 
881         Status = AcpiAttachData (Handle, AeAttachedDataHandler, Handle);
882         ACPI_CHECK_OK (AcpiAttachData, Status);
883 
884         Status = AcpiAttachData (Handle, AeAttachedDataHandler2, Handle);
885         ACPI_CHECK_OK (AcpiAttachData, Status);
886     }
887     else
888     {
889         printf ("No _SB_ found, %s\n", AcpiFormatException (Status));
890     }
891 
892     /*
893      * Install handlers that will override the default handlers for some of
894      * the space IDs.
895      */
896     AeOverrideRegionHandlers ();
897 
898     /*
899      * Initialize the global Region Handler space
900      * MCW 3/23/00
901      */
902     AeRegions.NumberOfRegions = 0;
903     AeRegions.RegionList = NULL;
904     return (AE_OK);
905 }
906