ReactOS 0.4.15-dev-8219-ge8b88cf
evxface.c
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Module Name: evxface - External interfaces for ACPI events
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2022, 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#define EXPORT_ACPI_INTERFACES
45
46#include "acpi.h"
47#include "accommon.h"
48#include "acnamesp.h"
49#include "acevents.h"
50#include "acinterp.h"
51
52#define _COMPONENT ACPI_EVENTS
53 ACPI_MODULE_NAME ("evxface")
54
55#if (!ACPI_REDUCED_HARDWARE)
56
57/* Local prototypes */
58
59static ACPI_STATUS
61 ACPI_HANDLE GpeDevice,
64 BOOLEAN IsRawHandler,
66 void *Context);
67
68#endif
69
70
71/*******************************************************************************
72 *
73 * FUNCTION: AcpiInstallNotifyHandler
74 *
75 * PARAMETERS: Device - The device for which notifies will be handled
76 * HandlerType - The type of handler:
77 * ACPI_SYSTEM_NOTIFY: System Handler (00-7F)
78 * ACPI_DEVICE_NOTIFY: Device Handler (80-FF)
79 * ACPI_ALL_NOTIFY: Both System and Device
80 * Handler - Address of the handler
81 * Context - Value passed to the handler on each GPE
82 *
83 * RETURN: Status
84 *
85 * DESCRIPTION: Install a handler for notifications on an ACPI Device,
86 * ThermalZone, or Processor object.
87 *
88 * NOTES: The Root namespace object may have only one handler for each
89 * type of notify (System/Device). Device/Thermal/Processor objects
90 * may have one device notify handler, and multiple system notify
91 * handlers.
92 *
93 ******************************************************************************/
94
100 void *Context)
101{
103 ACPI_OPERAND_OBJECT *ObjDesc;
104 ACPI_OPERAND_OBJECT *HandlerObj;
106 UINT32 i;
107
108
110
111
112 /* Parameter validation */
113
114 if ((!Device) || (!Handler) || (!HandlerType) ||
116 {
118 }
119
121 if (ACPI_FAILURE (Status))
122 {
124 }
125
126 /*
127 * Root Object:
128 * Registering a notify handler on the root object indicates that the
129 * caller wishes to receive notifications for all objects. Note that
130 * only one global handler can be registered per notify type.
131 * Ensure that a handler is not already installed.
132 */
134 {
135 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
136 {
137 if (HandlerType & (i+1))
138 {
139 if (AcpiGbl_GlobalNotify[i].Handler)
140 {
142 goto UnlockAndExit;
143 }
144
145 AcpiGbl_GlobalNotify[i].Handler = Handler;
146 AcpiGbl_GlobalNotify[i].Context = Context;
147 }
148 }
149
150 goto UnlockAndExit; /* Global notify handler installed, all done */
151 }
152
153 /*
154 * All Other Objects:
155 * Caller will only receive notifications specific to the target
156 * object. Note that only certain object types are allowed to
157 * receive notifications.
158 */
159
160 /* Are Notifies allowed on this object? */
161
163 {
164 Status = AE_TYPE;
165 goto UnlockAndExit;
166 }
167
168 /* Check for an existing internal object, might not exist */
169
170 ObjDesc = AcpiNsGetAttachedObject (Node);
171 if (!ObjDesc)
172 {
173 /* Create a new object */
174
175 ObjDesc = AcpiUtCreateInternalObject (Node->Type);
176 if (!ObjDesc)
177 {
179 goto UnlockAndExit;
180 }
181
182 /* Attach new object to the Node, remove local reference */
183
184 Status = AcpiNsAttachObject (Device, ObjDesc, Node->Type);
185 AcpiUtRemoveReference (ObjDesc);
186 if (ACPI_FAILURE (Status))
187 {
188 goto UnlockAndExit;
189 }
190 }
191
192 /* Ensure that the handler is not already installed in the lists */
193
194 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
195 {
196 if (HandlerType & (i+1))
197 {
198 HandlerObj = ObjDesc->CommonNotify.NotifyList[i];
199 while (HandlerObj)
200 {
201 if (HandlerObj->Notify.Handler == Handler)
202 {
204 goto UnlockAndExit;
205 }
206
207 HandlerObj = HandlerObj->Notify.Next[i];
208 }
209 }
210 }
211
212 /* Create and populate a new notify handler object */
213
215 if (!HandlerObj)
216 {
218 goto UnlockAndExit;
219 }
220
221 HandlerObj->Notify.Node = Node;
222 HandlerObj->Notify.HandlerType = HandlerType;
223 HandlerObj->Notify.Handler = Handler;
224 HandlerObj->Notify.Context = Context;
225
226 /* Install the handler at the list head(s) */
227
228 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
229 {
230 if (HandlerType & (i+1))
231 {
232 HandlerObj->Notify.Next[i] =
233 ObjDesc->CommonNotify.NotifyList[i];
234
235 ObjDesc->CommonNotify.NotifyList[i] = HandlerObj;
236 }
237 }
238
239 /* Add an extra reference if handler was installed in both lists */
240
242 {
243 AcpiUtAddReference (HandlerObj);
244 }
245
246
247UnlockAndExit:
250}
251
253
254
255/*******************************************************************************
256 *
257 * FUNCTION: AcpiRemoveNotifyHandler
258 *
259 * PARAMETERS: Device - The device for which the handler is installed
260 * HandlerType - The type of handler:
261 * ACPI_SYSTEM_NOTIFY: System Handler (00-7F)
262 * ACPI_DEVICE_NOTIFY: Device Handler (80-FF)
263 * ACPI_ALL_NOTIFY: Both System and Device
264 * Handler - Address of the handler
265 *
266 * RETURN: Status
267 *
268 * DESCRIPTION: Remove a handler for notifies on an ACPI device
269 *
270 ******************************************************************************/
271
277{
279 ACPI_OPERAND_OBJECT *ObjDesc;
280 ACPI_OPERAND_OBJECT *HandlerObj;
281 ACPI_OPERAND_OBJECT *PreviousHandlerObj;
283 UINT32 i;
284
285
287
288
289 /* Parameter validation */
290
291 if ((!Device) || (!Handler) || (!HandlerType) ||
293 {
295 }
296
297 /* Root Object. Global handlers are removed here */
298
300 {
301 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
302 {
303 if (HandlerType & (i+1))
304 {
306 if (ACPI_FAILURE (Status))
307 {
309 }
310
311 if (!AcpiGbl_GlobalNotify[i].Handler ||
312 (AcpiGbl_GlobalNotify[i].Handler != Handler))
313 {
315 goto UnlockAndExit;
316 }
317
319 "Removing global notify handler\n"));
320
321 AcpiGbl_GlobalNotify[i].Handler = NULL;
322 AcpiGbl_GlobalNotify[i].Context = NULL;
323
325
326 /* Make sure all deferred notify tasks are completed */
327
329 }
330 }
331
333 }
334
335 /* All other objects: Are Notifies allowed on this object? */
336
338 {
340 }
341
342 /* Must have an existing internal object */
343
344 ObjDesc = AcpiNsGetAttachedObject (Node);
345 if (!ObjDesc)
346 {
348 }
349
350 /* Internal object exists. Find the handler and remove it */
351
352 for (i = 0; i < ACPI_NUM_NOTIFY_TYPES; i++)
353 {
354 if (HandlerType & (i+1))
355 {
357 if (ACPI_FAILURE (Status))
358 {
360 }
361
362 HandlerObj = ObjDesc->CommonNotify.NotifyList[i];
363 PreviousHandlerObj = NULL;
364
365 /* Attempt to find the handler in the handler list */
366
367 while (HandlerObj &&
368 (HandlerObj->Notify.Handler != Handler))
369 {
370 PreviousHandlerObj = HandlerObj;
371 HandlerObj = HandlerObj->Notify.Next[i];
372 }
373
374 if (!HandlerObj)
375 {
377 goto UnlockAndExit;
378 }
379
380 /* Remove the handler object from the list */
381
382 if (PreviousHandlerObj) /* Handler is not at the list head */
383 {
384 PreviousHandlerObj->Notify.Next[i] =
385 HandlerObj->Notify.Next[i];
386 }
387 else /* Handler is at the list head */
388 {
389 ObjDesc->CommonNotify.NotifyList[i] =
390 HandlerObj->Notify.Next[i];
391 }
392
394
395 /* Make sure all deferred notify tasks are completed */
396
398 AcpiUtRemoveReference (HandlerObj);
399 }
400 }
401
403
404
405UnlockAndExit:
408}
409
411
412
413/*******************************************************************************
414 *
415 * FUNCTION: AcpiInstallExceptionHandler
416 *
417 * PARAMETERS: Handler - Pointer to the handler function for the
418 * event
419 *
420 * RETURN: Status
421 *
422 * DESCRIPTION: Saves the pointer to the handler function
423 *
424 ******************************************************************************/
425
429{
431
432
434
435
437 if (ACPI_FAILURE (Status))
438 {
440 }
441
442 /* Don't allow two handlers. */
443
444 if (AcpiGbl_ExceptionHandler)
445 {
447 goto Cleanup;
448 }
449
450 /* Install the handler */
451
452 AcpiGbl_ExceptionHandler = Handler;
453
454Cleanup:
457}
458
460
461
462#if (!ACPI_REDUCED_HARDWARE)
463/*******************************************************************************
464 *
465 * FUNCTION: AcpiInstallSciHandler
466 *
467 * PARAMETERS: Address - Address of the handler
468 * Context - Value passed to the handler on each SCI
469 *
470 * RETURN: Status
471 *
472 * DESCRIPTION: Install a handler for a System Control Interrupt.
473 *
474 ******************************************************************************/
475
479 void *Context)
480{
481 ACPI_SCI_HANDLER_INFO *NewSciHandler;
482 ACPI_SCI_HANDLER_INFO *SciHandler;
485
486
488
489
490 if (!Address)
491 {
493 }
494
495 /* Allocate and init a handler object */
496
497 NewSciHandler = ACPI_ALLOCATE (sizeof (ACPI_SCI_HANDLER_INFO));
498 if (!NewSciHandler)
499 {
501 }
502
503 NewSciHandler->Address = Address;
504 NewSciHandler->Context = Context;
505
507 if (ACPI_FAILURE (Status))
508 {
509 goto Exit;
510 }
511
512 /* Lock list during installation */
513
514 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
515 SciHandler = AcpiGbl_SciHandlerList;
516
517 /* Ensure handler does not already exist */
518
519 while (SciHandler)
520 {
521 if (Address == SciHandler->Address)
522 {
524 goto UnlockAndExit;
525 }
526
527 SciHandler = SciHandler->Next;
528 }
529
530 /* Install the new handler into the global list (at head) */
531
532 NewSciHandler->Next = AcpiGbl_SciHandlerList;
533 AcpiGbl_SciHandlerList = NewSciHandler;
534
535
536UnlockAndExit:
537
538 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
540
541Exit:
542 if (ACPI_FAILURE (Status))
543 {
544 ACPI_FREE (NewSciHandler);
545 }
547}
548
550
551
552/*******************************************************************************
553 *
554 * FUNCTION: AcpiRemoveSciHandler
555 *
556 * PARAMETERS: Address - Address of the handler
557 *
558 * RETURN: Status
559 *
560 * DESCRIPTION: Remove a handler for a System Control Interrupt.
561 *
562 ******************************************************************************/
563
567{
568 ACPI_SCI_HANDLER_INFO *PrevSciHandler;
569 ACPI_SCI_HANDLER_INFO *NextSciHandler;
572
573
575
576
577 if (!Address)
578 {
580 }
581
583 if (ACPI_FAILURE (Status))
584 {
586 }
587
588 /* Remove the SCI handler with lock */
589
590 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
591
592 PrevSciHandler = NULL;
593 NextSciHandler = AcpiGbl_SciHandlerList;
594 while (NextSciHandler)
595 {
596 if (NextSciHandler->Address == Address)
597 {
598 /* Unlink and free the SCI handler info block */
599
600 if (PrevSciHandler)
601 {
602 PrevSciHandler->Next = NextSciHandler->Next;
603 }
604 else
605 {
606 AcpiGbl_SciHandlerList = NextSciHandler->Next;
607 }
608
609 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
610 ACPI_FREE (NextSciHandler);
611 goto UnlockAndExit;
612 }
613
614 PrevSciHandler = NextSciHandler;
615 NextSciHandler = NextSciHandler->Next;
616 }
617
618 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
620
621
622UnlockAndExit:
625}
626
628
629
630/*******************************************************************************
631 *
632 * FUNCTION: AcpiInstallGlobalEventHandler
633 *
634 * PARAMETERS: Handler - Pointer to the global event handler function
635 * Context - Value passed to the handler on each event
636 *
637 * RETURN: Status
638 *
639 * DESCRIPTION: Saves the pointer to the handler function. The global handler
640 * is invoked upon each incoming GPE and Fixed Event. It is
641 * invoked at interrupt level at the time of the event dispatch.
642 * Can be used to update event counters, etc.
643 *
644 ******************************************************************************/
645
649 void *Context)
650{
652
653
655
656
657 /* Parameter validation */
658
659 if (!Handler)
660 {
662 }
663
665 if (ACPI_FAILURE (Status))
666 {
668 }
669
670 /* Don't allow two handlers. */
671
672 if (AcpiGbl_GlobalEventHandler)
673 {
675 goto Cleanup;
676 }
677
678 AcpiGbl_GlobalEventHandler = Handler;
679 AcpiGbl_GlobalEventHandlerContext = Context;
680
681
682Cleanup:
685}
686
688
689
690/*******************************************************************************
691 *
692 * FUNCTION: AcpiInstallFixedEventHandler
693 *
694 * PARAMETERS: Event - Event type to enable.
695 * Handler - Pointer to the handler function for the
696 * event
697 * Context - Value passed to the handler on each GPE
698 *
699 * RETURN: Status
700 *
701 * DESCRIPTION: Saves the pointer to the handler function and then enables the
702 * event.
703 *
704 ******************************************************************************/
705
710 void *Context)
711{
713
714
716
717
718 /* Parameter validation */
719
720 if (Event > ACPI_EVENT_MAX)
721 {
723 }
724
726 if (ACPI_FAILURE (Status))
727 {
729 }
730
731 /* Do not allow multiple handlers */
732
733 if (AcpiGbl_FixedEventHandlers[Event].Handler)
734 {
736 goto Cleanup;
737 }
738
739 /* Install the handler before enabling the event */
740
741 AcpiGbl_FixedEventHandlers[Event].Handler = Handler;
742 AcpiGbl_FixedEventHandlers[Event].Context = Context;
743
745 if (ACPI_FAILURE (Status))
746 {
748 "Could not enable fixed event - %s (%u)",
750
751 /* Remove the handler */
752
753 AcpiGbl_FixedEventHandlers[Event].Handler = NULL;
754 AcpiGbl_FixedEventHandlers[Event].Context = NULL;
755 }
756 else
757 {
759 "Enabled fixed event %s (%X), Handler=%p\n",
761 }
762
763
764Cleanup:
767}
768
770
771
772/*******************************************************************************
773 *
774 * FUNCTION: AcpiRemoveFixedEventHandler
775 *
776 * PARAMETERS: Event - Event type to disable.
777 * Handler - Address of the handler
778 *
779 * RETURN: Status
780 *
781 * DESCRIPTION: Disables the event and unregisters the event handler.
782 *
783 ******************************************************************************/
784
789{
791
792
794
795
796 /* Parameter validation */
797
798 if (Event > ACPI_EVENT_MAX)
799 {
801 }
802
804 if (ACPI_FAILURE (Status))
805 {
807 }
808
809 /* Disable the event before removing the handler */
810
812
813 /* Always Remove the handler */
814
815 AcpiGbl_FixedEventHandlers[Event].Handler = NULL;
816 AcpiGbl_FixedEventHandlers[Event].Context = NULL;
817
818 if (ACPI_FAILURE (Status))
819 {
821 "Could not disable fixed event - %s (%u)",
823 }
824 else
825 {
827 "Disabled fixed event - %s (%X)\n",
829 }
830
833}
834
836
837
838/*******************************************************************************
839 *
840 * FUNCTION: AcpiEvInstallGpeHandler
841 *
842 * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT
843 * defined GPEs)
844 * GpeNumber - The GPE number within the GPE block
845 * Type - Whether this GPE should be treated as an
846 * edge- or level-triggered interrupt.
847 * IsRawHandler - Whether this GPE should be handled using
848 * the special GPE handler mode.
849 * Address - Address of the handler
850 * Context - Value passed to the handler on each GPE
851 *
852 * RETURN: Status
853 *
854 * DESCRIPTION: Internal function to install a handler for a General Purpose
855 * Event.
856 *
857 ******************************************************************************/
858
859static ACPI_STATUS
861 ACPI_HANDLE GpeDevice,
863 UINT32 Type,
864 BOOLEAN IsRawHandler,
866 void *Context)
867{
872
873
874 ACPI_FUNCTION_TRACE (EvInstallGpeHandler);
875
876
877 /* Parameter validation */
878
880 {
882 }
883
885 if (ACPI_FAILURE (Status))
886 {
888 }
889
890 /* Allocate and init handler object (before lock) */
891
893 if (!Handler)
894 {
896 goto UnlockAndExit;
897 }
898
899 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
900
901 /* Ensure that we have a valid GPE number */
902
904 if (!GpeEventInfo)
905 {
907 goto FreeAndExit;
908 }
909
910 /* Make sure that there isn't a handler there already */
911
916 {
918 goto FreeAndExit;
919 }
920
921 Handler->Address = Address;
922 Handler->Context = Context;
924 Handler->OriginalFlags = (UINT8) (GpeEventInfo->Flags &
926
927 /*
928 * If the GPE is associated with a method, it may have been enabled
929 * automatically during initialization, in which case it has to be
930 * disabled now to avoid spurious execution of the handler.
931 */
932 if (((ACPI_GPE_DISPATCH_TYPE (Handler->OriginalFlags) ==
934 (ACPI_GPE_DISPATCH_TYPE (Handler->OriginalFlags) ==
937 {
938 Handler->OriginallyEnabled = TRUE;
940
941 /* Sanity check of original type against new type */
942
944 {
945 ACPI_WARNING ((AE_INFO, "GPE type mismatch (level/edge)"));
946 }
947 }
948
949 /* Install the handler */
950
952
953 /* Setup up dispatch flags to indicate handler (vs. method/notify) */
954
956 GpeEventInfo->Flags |= (UINT8) (Type | (IsRawHandler ?
958
959 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
960
961
962UnlockAndExit:
965
966FreeAndExit:
967 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
969 goto UnlockAndExit;
970}
971
972
973/*******************************************************************************
974 *
975 * FUNCTION: AcpiInstallGpeHandler
976 *
977 * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT
978 * defined GPEs)
979 * GpeNumber - The GPE number within the GPE block
980 * Type - Whether this GPE should be treated as an
981 * edge- or level-triggered interrupt.
982 * Address - Address of the handler
983 * Context - Value passed to the handler on each GPE
984 *
985 * RETURN: Status
986 *
987 * DESCRIPTION: Install a handler for a General Purpose Event.
988 *
989 ******************************************************************************/
990
993 ACPI_HANDLE GpeDevice,
995 UINT32 Type,
997 void *Context)
998{
1000
1001
1003
1004
1007
1009}
1010
1012
1013
1014/*******************************************************************************
1015 *
1016 * FUNCTION: AcpiInstallGpeRawHandler
1017 *
1018 * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT
1019 * defined GPEs)
1020 * GpeNumber - The GPE number within the GPE block
1021 * Type - Whether this GPE should be treated as an
1022 * edge- or level-triggered interrupt.
1023 * Address - Address of the handler
1024 * Context - Value passed to the handler on each GPE
1025 *
1026 * RETURN: Status
1027 *
1028 * DESCRIPTION: Install a handler for a General Purpose Event.
1029 *
1030 ******************************************************************************/
1031
1034 ACPI_HANDLE GpeDevice,
1036 UINT32 Type,
1038 void *Context)
1039{
1041
1042
1044
1045
1047 TRUE, Address, Context);
1048
1050}
1051
1053
1054
1055/*******************************************************************************
1056 *
1057 * FUNCTION: AcpiRemoveGpeHandler
1058 *
1059 * PARAMETERS: GpeDevice - Namespace node for the GPE (NULL for FADT
1060 * defined GPEs)
1061 * GpeNumber - The event to remove a handler
1062 * Address - Address of the handler
1063 *
1064 * RETURN: Status
1065 *
1066 * DESCRIPTION: Remove a handler for a General Purpose AcpiEvent.
1067 *
1068 ******************************************************************************/
1069
1072 ACPI_HANDLE GpeDevice,
1075{
1080
1081
1083
1084
1085 /* Parameter validation */
1086
1087 if (!Address)
1088 {
1090 }
1091
1093 if (ACPI_FAILURE (Status))
1094 {
1096 }
1097
1098 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
1099
1100 /* Ensure that we have a valid GPE number */
1101
1103 if (!GpeEventInfo)
1104 {
1106 goto UnlockAndExit;
1107 }
1108
1109 /* Make sure that a handler is indeed installed */
1110
1115 {
1117 goto UnlockAndExit;
1118 }
1119
1120 /* Make sure that the installed handler is the same */
1121
1123 {
1125 goto UnlockAndExit;
1126 }
1127
1128 /* Remove the handler */
1129
1132
1133 /* Restore Method node (if any), set dispatch flags */
1134
1135 GpeEventInfo->Dispatch.MethodNode = Handler->MethodNode;
1138 GpeEventInfo->Flags |= Handler->OriginalFlags;
1139
1140 /*
1141 * If the GPE was previously associated with a method and it was
1142 * enabled, it should be enabled at this point to restore the
1143 * post-initialization configuration.
1144 */
1145 if (((ACPI_GPE_DISPATCH_TYPE (Handler->OriginalFlags) ==
1147 (ACPI_GPE_DISPATCH_TYPE (Handler->OriginalFlags) ==
1149 Handler->OriginallyEnabled)
1150 {
1153 {
1154 /* Poll edge triggered GPEs to handle existing events */
1155
1156 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
1158 GpeDevice, GpeEventInfo, GpeNumber);
1159 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
1160 }
1161 }
1162
1163 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
1165
1166 /* Make sure all deferred GPE tasks are completed */
1167
1169
1170 /* Now we can free the handler object */
1171
1174
1175UnlockAndExit:
1176 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
1179}
1180
1182
1183
1184/*******************************************************************************
1185 *
1186 * FUNCTION: AcpiAcquireGlobalLock
1187 *
1188 * PARAMETERS: Timeout - How long the caller is willing to wait
1189 * Handle - Where the handle to the lock is returned
1190 * (if acquired)
1191 *
1192 * RETURN: Status
1193 *
1194 * DESCRIPTION: Acquire the ACPI Global Lock
1195 *
1196 * Note: Allows callers with the same thread ID to acquire the global lock
1197 * multiple times. In other words, externally, the behavior of the global lock
1198 * is identical to an AML mutex. On the first acquire, a new handle is
1199 * returned. On any subsequent calls to acquire by the same thread, the same
1200 * handle is returned.
1201 *
1202 ******************************************************************************/
1203
1207 UINT32 *Handle)
1208{
1210
1211
1212 if (!Handle)
1213 {
1214 return (AE_BAD_PARAMETER);
1215 }
1216
1217 /* Must lock interpreter to prevent race conditions */
1218
1220
1222 AcpiGbl_GlobalLockMutex, AcpiOsGetThreadId ());
1223
1224 if (ACPI_SUCCESS (Status))
1225 {
1226 /* Return the global lock handle (updated in AcpiEvAcquireGlobalLock) */
1227
1228 *Handle = AcpiGbl_GlobalLockHandle;
1229 }
1230
1232 return (Status);
1233}
1234
1236
1237
1238/*******************************************************************************
1239 *
1240 * FUNCTION: AcpiReleaseGlobalLock
1241 *
1242 * PARAMETERS: Handle - Returned from AcpiAcquireGlobalLock
1243 *
1244 * RETURN: Status
1245 *
1246 * DESCRIPTION: Release the ACPI Global Lock. The handle must be valid.
1247 *
1248 ******************************************************************************/
1249
1252 UINT32 Handle)
1253{
1255
1256
1257 if (!Handle || (Handle != AcpiGbl_GlobalLockHandle))
1258 {
1259 return (AE_NOT_ACQUIRED);
1260 }
1261
1262 Status = AcpiExReleaseMutexObject (AcpiGbl_GlobalLockMutex);
1263 return (Status);
1264}
1265
1267
1268#endif /* !ACPI_REDUCED_HARDWARE */
unsigned short UINT16
unsigned char BOOLEAN
unsigned char UINT8
unsigned int UINT32
Type
Definition: Type.h:7
#define ACPI_GPE_IS_POLLING_NEEDED(__gpe__)
Definition: acevents.h:59
ACPI_GPE_EVENT_INFO * GpeEventInfo
Definition: acevents.h:195
ACPI_GPE_EVENT_INFO UINT32 GpeNumber
Definition: acevents.h:196
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define AE_ALREADY_EXISTS
Definition: acexcep.h:115
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_NOT_EXIST
Definition: acexcep.h:114
#define AE_NOT_ACQUIRED
Definition: acexcep.h:128
#define AE_TYPE
Definition: acexcep.h:116
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
#define AE_OK
Definition: acexcep.h:97
#define ACPI_MTX_NAMESPACE
Definition: aclocal.h:85
#define ACPI_MTX_EVENTS
Definition: aclocal.h:87
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
ACPI_STATUS AcpiNsAttachObject(ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *Object, ACPI_OBJECT_TYPE Type)
Definition: nsobject.c:76
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
#define ACPI_WARNING(plist)
Definition: acoutput.h:238
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_DB_INFO
Definition: acoutput.h:153
ACPI_THREAD_ID AcpiOsGetThreadId(void)
Definition: osl.c:217
void AcpiOsReleaseLock(ACPI_SPINLOCK Handle, ACPI_CPU_FLAGS Flags)
Definition: osl.c:516
ACPI_CPU_FLAGS AcpiOsAcquireLock(ACPI_SPINLOCK Handle)
Definition: osl.c:498
void AcpiOsWaitEventsComplete(void)
Definition: osl.c:894
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 HandlerType
Definition: acpixf.h:817
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:672
#define ACPI_MAX_NOTIFY_HANDLER_TYPE
Definition: actypes.h:847
#define ACPI_GPE_DISPATCH_MASK
Definition: actypes.h:824
#define ACPI_TYPE_LOCAL_NOTIFY
Definition: actypes.h:722
#define ACPI_CPU_FLAGS
Definition: actypes.h:252
#define ACPI_FREE(a)
Definition: actypes.h:386
ACPI_STATUS(* ACPI_EXCEPTION_HANDLER)(ACPI_STATUS AmlStatus, ACPI_NAME Name, UINT16 Opcode, UINT32 AmlOffset, void *Context)
Definition: actypes.h:1175
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_NUM_NOTIFY_TYPES
Definition: actypes.h:848
UINT32(* ACPI_SCI_HANDLER)(void *Context)
Definition: actypes.h:1133
#define ACPI_GPE_DISPATCH_TYPE(flags)
Definition: actypes.h:825
#define ACPI_GPE_DISPATCH_METHOD
Definition: actypes.h:820
#define ACPI_GPE_DISPATCH_NOTIFY
Definition: actypes.h:822
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
#define ACPI_EXPORT_SYMBOL(Symbol)
Definition: actypes.h:343
void(* ACPI_NOTIFY_HANDLER)(ACPI_HANDLE Device, UINT32 Value, void *Context)
Definition: actypes.h:1157
UINT32(* ACPI_GPE_HANDLER)(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, void *Context)
Definition: actypes.h:1151
UINT32(* ACPI_EVENT_HANDLER)(void *Context)
Definition: actypes.h:1147
#define ACPI_GPE_DISPATCH_RAW_HANDLER
Definition: actypes.h:823
#define ACPI_ALL_NOTIFY
Definition: actypes.h:846
void(* ACPI_GBL_EVENT_HANDLER)(UINT32 EventType, ACPI_HANDLE Device, UINT32 EventNumber, void *Context)
Definition: actypes.h:1137
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
#define ACPI_GPE_XRUPT_TYPE_MASK
Definition: actypes.h:829
#define ACPI_ALLOCATE(a)
Definition: actypes.h:384
#define ACPI_EVENT_MAX
Definition: actypes.h:769
#define ACPI_ROOT_OBJECT
Definition: actypes.h:500
#define ACPI_GPE_DISPATCH_HANDLER
Definition: actypes.h:821
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:681
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256
ACPI_STATUS AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:348
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:790
void AcpiUtAddReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:752
const char * AcpiUtGetEventName(UINT32 EventId)
Definition: utdecode.c:175
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
union node Node
Definition: types.h:1255
static const WCHAR Cleanup[]
Definition: register.c:80
ACPI_GPE_EVENT_INFO * AcpiEvGetGpeEventInfo(ACPI_HANDLE GpeDevice, UINT32 GpeNumber)
Definition: evgpe.c:372
UINT32 AcpiEvDetectGpe(ACPI_NAMESPACE_NODE *GpeDevice, ACPI_GPE_EVENT_INFO *GpeEventInfo, UINT32 GpeNumber)
Definition: evgpe.c:722
ACPI_STATUS AcpiEvRemoveGpeReference(ACPI_GPE_EVENT_INFO *GpeEventInfo)
Definition: evgpe.c:276
ACPI_STATUS AcpiEvAddGpeReference(ACPI_GPE_EVENT_INFO *GpeEventInfo, BOOLEAN ClearOnEnable)
Definition: evgpe.c:221
BOOLEAN AcpiEvIsNotifyObject(ACPI_NAMESPACE_NODE *Node)
Definition: evmisc.c:75
ACPI_STATUS AcpiInstallExceptionHandler(ACPI_EXCEPTION_HANDLER Handler)
Definition: evxface.c:427
ACPI_STATUS AcpiInstallGpeHandler(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, UINT32 Type, ACPI_GPE_HANDLER Address, void *Context)
Definition: evxface.c:992
ACPI_STATUS AcpiRemoveNotifyHandler(ACPI_HANDLE Device, UINT32 HandlerType, ACPI_NOTIFY_HANDLER Handler)
Definition: evxface.c:273
ACPI_STATUS AcpiInstallGlobalEventHandler(ACPI_GBL_EVENT_HANDLER Handler, void *Context)
Definition: evxface.c:647
ACPI_STATUS AcpiInstallGpeRawHandler(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, UINT32 Type, ACPI_GPE_HANDLER Address, void *Context)
Definition: evxface.c:1033
ACPI_STATUS AcpiReleaseGlobalLock(UINT32 Handle)
Definition: evxface.c:1251
ACPI_STATUS AcpiRemoveGpeHandler(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, ACPI_GPE_HANDLER Address)
Definition: evxface.c:1071
ACPI_STATUS AcpiInstallNotifyHandler(ACPI_HANDLE Device, UINT32 HandlerType, ACPI_NOTIFY_HANDLER Handler, void *Context)
Definition: evxface.c:96
static ACPI_STATUS AcpiEvInstallGpeHandler(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, UINT32 Type, BOOLEAN IsRawHandler, ACPI_GPE_HANDLER Address, void *Context)
Definition: evxface.c:860
ACPI_STATUS AcpiRemoveFixedEventHandler(UINT32 Event, ACPI_EVENT_HANDLER Handler)
Definition: evxface.c:786
ACPI_STATUS AcpiInstallSciHandler(ACPI_SCI_HANDLER Address, void *Context)
Definition: evxface.c:477
ACPI_STATUS AcpiRemoveSciHandler(ACPI_SCI_HANDLER Address)
Definition: evxface.c:565
ACPI_STATUS AcpiInstallFixedEventHandler(UINT32 Event, ACPI_EVENT_HANDLER Handler, void *Context)
Definition: evxface.c:707
ACPI_STATUS AcpiAcquireGlobalLock(UINT16 Timeout, UINT32 *Handle)
Definition: evxface.c:1205
ACPI_STATUS AcpiEnableEvent(UINT32 Event, UINT32 Flags)
Definition: evxfevnt.c:190
ACPI_STATUS AcpiDisableEvent(UINT32 Event, UINT32 Flags)
Definition: evxfevnt.c:263
ACPI_STATUS AcpiExAcquireMutexObject(UINT16 Timeout, ACPI_OPERAND_OBJECT *ObjDesc, ACPI_THREAD_ID ThreadId)
Definition: exmutex.c:176
ACPI_STATUS AcpiExReleaseMutexObject(ACPI_OPERAND_OBJECT *ObjDesc)
Definition: exmutex.c:344
void AcpiExExitInterpreter(void)
Definition: exutils.c:139
void AcpiExEnterInterpreter(void)
Definition: exutils.c:91
ULONG Handle
Definition: gdb_input.c:15
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static WCHAR Address[46]
Definition: ping.c:68
static ULONG Timeout
Definition: ping.c:61
static void Exit(void)
Definition: sock.c:1330
union acpi_gpe_dispatch_info Dispatch
Definition: aclocal.h:554
ACPI_GPE_HANDLER Address
Definition: aclocal.h:519
ACPI_OBJECT_COMMON_HEADER ACPI_NAMESPACE_NODE * Node
Definition: acobject.h:400
ACPI_NOTIFY_HANDLER Handler
Definition: acobject.h:402
union acpi_operand_object * Next[2]
Definition: acobject.h:404
struct acpi_sci_handler_info * Next
Definition: aclocal.h:509
ACPI_SCI_HANDLER Address
Definition: aclocal.h:510
ACPI_GPE_HANDLER_INFO * Handler
Definition: aclocal.h:543
ACPI_NAMESPACE_NODE * MethodNode
Definition: aclocal.h:542
ACPI_OBJECT_NOTIFY_HANDLER Notify
Definition: acobject.h:538
ACPI_OBJECT_NOTIFY_COMMON CommonNotify
Definition: acobject.h:528
Definition: dlist.c:348
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170