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