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