ReactOS  0.4.14-dev-358-gbef841c
evxfgpe.c
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2019, 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 #define EXPORT_ACPI_INTERFACES
45 
46 #include "acpi.h"
47 #include "accommon.h"
48 #include "acevents.h"
49 #include "acnamesp.h"
50 
51 #define _COMPONENT ACPI_EVENTS
52  ACPI_MODULE_NAME ("evxfgpe")
53 
54 
55 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
56 /*******************************************************************************
57  *
58  * FUNCTION: AcpiUpdateAllGpes
59  *
60  * PARAMETERS: None
61  *
62  * RETURN: Status
63  *
64  * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
65  * associated _Lxx or _Exx methods and are not pointed to by any
66  * device _PRW methods (this indicates that these GPEs are
67  * generally intended for system or device wakeup. Such GPEs
68  * have to be enabled directly when the devices whose _PRW
69  * methods point to them are set up for wakeup signaling.)
70  *
71  * NOTE: Should be called after any GPEs are added to the system. Primarily,
72  * after the system _PRW methods have been run, but also after a GPE Block
73  * Device has been added or if any new GPE methods have been added via a
74  * dynamic table load.
75  *
76  ******************************************************************************/
77 
80  void)
81 {
83  BOOLEAN IsPollingNeeded = FALSE;
84 
85 
87 
88 
90  if (ACPI_FAILURE (Status))
91  {
93  }
94 
95  if (AcpiGbl_AllGpesInitialized)
96  {
97  goto UnlockAndExit;
98  }
99 
101  &IsPollingNeeded);
102  if (ACPI_SUCCESS (Status))
103  {
104  AcpiGbl_AllGpesInitialized = TRUE;
105  }
106 
107 UnlockAndExit:
109 
110  if (IsPollingNeeded && AcpiGbl_AllGpesInitialized)
111  {
112  /* Poll GPEs to handle already triggered events */
113 
114  AcpiEvGpeDetect (AcpiGbl_GpeXruptListHead);
115  }
117 }
118 
120 
121 
122 /*******************************************************************************
123  *
124  * FUNCTION: AcpiEnableGpe
125  *
126  * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
127  * GpeNumber - GPE level within the GPE block
128  *
129  * RETURN: Status
130  *
131  * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
132  * hardware-enabled.
133  *
134  ******************************************************************************/
135 
138  ACPI_HANDLE GpeDevice,
140 {
144 
145 
147 
148 
149  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
150 
151  /*
152  * Ensure that we have a valid GPE number and that there is some way
153  * of handling the GPE (handler or a GPE method). In other words, we
154  * won't allow a valid GPE to be enabled if there is no way to handle it.
155  */
157  if (GpeEventInfo)
158  {
161  {
163  if (ACPI_SUCCESS (Status) &&
165  {
166  /* Poll edge-triggered GPEs to handle existing events */
167 
168  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
170  GpeDevice, GpeEventInfo, GpeNumber);
171  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
172  }
173  }
174  else
175  {
177  }
178  }
179 
180  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
182 }
183 
185 
186 
187 /*******************************************************************************
188  *
189  * FUNCTION: AcpiDisableGpe
190  *
191  * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
192  * GpeNumber - GPE level within the GPE block
193  *
194  * RETURN: Status
195  *
196  * DESCRIPTION: Remove a reference to a GPE. When the last reference is
197  * removed, only then is the GPE disabled (for runtime GPEs), or
198  * the GPE mask bit disabled (for wake GPEs)
199  *
200  ******************************************************************************/
201 
204  ACPI_HANDLE GpeDevice,
206 {
210 
211 
213 
214 
215  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
216 
217  /* Ensure that we have a valid GPE number */
218 
220  if (GpeEventInfo)
221  {
223  }
224 
225  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
227 }
228 
230 
231 
232 /*******************************************************************************
233  *
234  * FUNCTION: AcpiSetGpe
235  *
236  * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
237  * GpeNumber - GPE level within the GPE block
238  * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
239  *
240  * RETURN: Status
241  *
242  * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
243  * the reference count mechanism used in the AcpiEnableGpe(),
244  * AcpiDisableGpe() interfaces.
245  * This API is typically used by the GPE raw handler mode driver
246  * to switch between the polling mode and the interrupt mode after
247  * the driver has enabled the GPE.
248  * The APIs should be invoked in this order:
249  * AcpiEnableGpe() <- Ensure the reference count > 0
250  * AcpiSetGpe(ACPI_GPE_DISABLE) <- Enter polling mode
251  * AcpiSetGpe(ACPI_GPE_ENABLE) <- Leave polling mode
252  * AcpiDisableGpe() <- Decrease the reference count
253  *
254  * Note: If a GPE is shared by 2 silicon components, then both the drivers
255  * should support GPE polling mode or disabling the GPE for long period
256  * for one driver may break the other. So use it with care since all
257  * firmware _Lxx/_Exx handlers currently rely on the GPE interrupt mode.
258  *
259  ******************************************************************************/
260 
263  ACPI_HANDLE GpeDevice,
265  UINT8 Action)
266 {
270 
271 
273 
274 
275  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
276 
277  /* Ensure that we have a valid GPE number */
278 
280  if (!GpeEventInfo)
281  {
283  goto UnlockAndExit;
284  }
285 
286  /* Perform the action */
287 
288  switch (Action)
289  {
290  case ACPI_GPE_ENABLE:
291 
294  break;
295 
296  case ACPI_GPE_DISABLE:
297 
300  break;
301 
302  default:
303 
305  break;
306  }
307 
308 UnlockAndExit:
309  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
311 }
312 
314 
315 
316 /*******************************************************************************
317  *
318  * FUNCTION: AcpiMaskGpe
319  *
320  * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
321  * GpeNumber - GPE level within the GPE block
322  * IsMasked - Whether the GPE is masked or not
323  *
324  * RETURN: Status
325  *
326  * DESCRIPTION: Unconditionally mask/unmask the an individual GPE, ex., to
327  * prevent a GPE flooding.
328  *
329  ******************************************************************************/
330 
333  ACPI_HANDLE GpeDevice,
335  BOOLEAN IsMasked)
336 {
340 
341 
343 
344 
345  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
346 
347  /* Ensure that we have a valid GPE number */
348 
350  if (!GpeEventInfo)
351  {
353  goto UnlockAndExit;
354  }
355 
356  Status = AcpiEvMaskGpe (GpeEventInfo, IsMasked);
357 
358 UnlockAndExit:
359  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
361 }
362 
364 
365 
366 /*******************************************************************************
367  *
368  * FUNCTION: AcpiMarkGpeForWake
369  *
370  * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
371  * GpeNumber - GPE level within the GPE block
372  *
373  * RETURN: Status
374  *
375  * DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply
376  * sets the ACPI_GPE_CAN_WAKE flag.
377  *
378  * Some potential callers of AcpiSetupGpeForWake may know in advance that
379  * there won't be any notify handlers installed for device wake notifications
380  * from the given GPE (one example is a button GPE in Linux). For these cases,
381  * AcpiMarkGpeForWake should be used instead of AcpiSetupGpeForWake.
382  * This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to
383  * setup implicit wake notification for it (since there's no handler method).
384  *
385  ******************************************************************************/
386 
389  ACPI_HANDLE GpeDevice,
391 {
395 
396 
398 
399 
400  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
401 
402  /* Ensure that we have a valid GPE number */
403 
405  if (GpeEventInfo)
406  {
407  /* Mark the GPE as a possible wake event */
408 
410  Status = AE_OK;
411  }
412 
413  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
415 }
416 
418 
419 
420 /*******************************************************************************
421  *
422  * FUNCTION: AcpiSetupGpeForWake
423  *
424  * PARAMETERS: WakeDevice - Device associated with the GPE (via _PRW)
425  * GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
426  * GpeNumber - GPE level within the GPE block
427  *
428  * RETURN: Status
429  *
430  * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
431  * interface is intended to be used as the host executes the
432  * _PRW methods (Power Resources for Wake) in the system tables.
433  * Each _PRW appears under a Device Object (The WakeDevice), and
434  * contains the info for the wake GPE associated with the
435  * WakeDevice.
436  *
437  ******************************************************************************/
438 
441  ACPI_HANDLE WakeDevice,
442  ACPI_HANDLE GpeDevice,
444 {
449  ACPI_GPE_NOTIFY_INFO *NewNotify;
451 
452 
454 
455 
456  /* Parameter Validation */
457 
458  if (!WakeDevice)
459  {
460  /*
461  * By forcing WakeDevice to be valid, we automatically enable the
462  * implicit notify feature on all hosts.
463  */
465  }
466 
467  /* Handle root object case */
468 
469  if (WakeDevice == ACPI_ROOT_OBJECT)
470  {
471  DeviceNode = AcpiGbl_RootNode;
472  }
473  else
474  {
476  }
477 
478  /* Validate WakeDevice is of type Device */
479 
480  if (DeviceNode->Type != ACPI_TYPE_DEVICE)
481  {
483  }
484 
485  /*
486  * Allocate a new notify object up front, in case it is needed.
487  * Memory allocation while holding a spinlock is a big no-no
488  * on some hosts.
489  */
490  NewNotify = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_NOTIFY_INFO));
491  if (!NewNotify)
492  {
494  }
495 
496  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
497 
498  /* Ensure that we have a valid GPE number */
499 
501  if (!GpeEventInfo)
502  {
504  goto UnlockAndExit;
505  }
506 
507  /*
508  * If there is no method or handler for this GPE, then the
509  * WakeDevice will be notified whenever this GPE fires. This is
510  * known as an "implicit notify". Note: The GPE is assumed to be
511  * level-triggered (for windows compatibility).
512  */
515  {
516  /*
517  * This is the first device for implicit notify on this GPE.
518  * Just set the flags here, and enter the NOTIFY block below.
519  */
522  }
524  {
525  /*
526  * A reference to this GPE has been added during the GPE block
527  * initialization, so drop it now to prevent the GPE from being
528  * permanently enabled and clear its ACPI_GPE_AUTO_ENABLED flag.
529  */
532  }
533 
534  /*
535  * If we already have an implicit notify on this GPE, add
536  * this device to the notify list.
537  */
540  {
541  /* Ensure that the device is not already in the list */
542 
544  while (Notify)
545  {
546  if (Notify->DeviceNode == DeviceNode)
547  {
549  goto UnlockAndExit;
550  }
551  Notify = Notify->Next;
552  }
553 
554  /* Add this device to the notify list for this GPE */
555 
556  NewNotify->DeviceNode = DeviceNode;
557  NewNotify->Next = GpeEventInfo->Dispatch.NotifyList;
558  GpeEventInfo->Dispatch.NotifyList = NewNotify;
559  NewNotify = NULL;
560  }
561 
562  /* Mark the GPE as a possible wake event */
563 
565  Status = AE_OK;
566 
567 
568 UnlockAndExit:
569  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
570 
571  /* Delete the notify object if it was not used above */
572 
573  if (NewNotify)
574  {
575  ACPI_FREE (NewNotify);
576  }
578 }
579 
581 
582 
583 /*******************************************************************************
584  *
585  * FUNCTION: AcpiSetGpeWakeMask
586  *
587  * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
588  * GpeNumber - GPE level within the GPE block
589  * Action - Enable or Disable
590  *
591  * RETURN: Status
592  *
593  * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
594  * already be marked as a WAKE GPE.
595  *
596  ******************************************************************************/
597 
600  ACPI_HANDLE GpeDevice,
602  UINT8 Action)
603 {
606  ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
608  UINT32 RegisterBit;
609 
610 
612 
613 
614  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
615 
616  /*
617  * Ensure that we have a valid GPE number and that this GPE is in
618  * fact a wake GPE
619  */
621  if (!GpeEventInfo)
622  {
624  goto UnlockAndExit;
625  }
626 
628  {
629  Status = AE_TYPE;
630  goto UnlockAndExit;
631  }
632 
633  GpeRegisterInfo = GpeEventInfo->RegisterInfo;
634  if (!GpeRegisterInfo)
635  {
637  goto UnlockAndExit;
638  }
639 
640  RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
641 
642  /* Perform the action */
643 
644  switch (Action)
645  {
646  case ACPI_GPE_ENABLE:
647 
648  ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
649  break;
650 
651  case ACPI_GPE_DISABLE:
652 
653  ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
654  break;
655 
656  default:
657 
658  ACPI_ERROR ((AE_INFO, "%u, Invalid action", Action));
660  break;
661  }
662 
663 UnlockAndExit:
664  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
666 }
667 
669 
670 
671 /*******************************************************************************
672  *
673  * FUNCTION: AcpiClearGpe
674  *
675  * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
676  * GpeNumber - GPE level within the GPE block
677  *
678  * RETURN: Status
679  *
680  * DESCRIPTION: Clear an ACPI event (general purpose)
681  *
682  ******************************************************************************/
683 
686  ACPI_HANDLE GpeDevice,
688 {
692 
693 
695 
696 
697  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
698 
699  /* Ensure that we have a valid GPE number */
700 
702  if (!GpeEventInfo)
703  {
705  goto UnlockAndExit;
706  }
707 
709 
710 UnlockAndExit:
711  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
713 }
714 
716 
717 
718 /*******************************************************************************
719  *
720  * FUNCTION: AcpiGetGpeStatus
721  *
722  * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
723  * GpeNumber - GPE level within the GPE block
724  * EventStatus - Where the current status of the event
725  * will be returned
726  *
727  * RETURN: Status
728  *
729  * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
730  *
731  ******************************************************************************/
732 
735  ACPI_HANDLE GpeDevice,
737  ACPI_EVENT_STATUS *EventStatus)
738 {
742 
743 
745 
746 
747  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
748 
749  /* Ensure that we have a valid GPE number */
750 
752  if (!GpeEventInfo)
753  {
755  goto UnlockAndExit;
756  }
757 
758  /* Obtain status on the requested GPE number */
759 
760  Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
761 
762 UnlockAndExit:
763  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
765 }
766 
768 
769 
770 /*******************************************************************************
771  *
772  * FUNCTION: AcpiDispatchGpe
773  *
774  * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
775  * GpeNumber - GPE level within the GPE block
776  *
777  * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
778  *
779  * DESCRIPTION: Detect and dispatch a General Purpose Event to either a function
780  * (e.g. EC) or method (e.g. _Lxx/_Exx) handler.
781  *
782  ******************************************************************************/
783 
784 UINT32
786  ACPI_HANDLE GpeDevice,
788 {
789  ACPI_FUNCTION_TRACE(acpi_dispatch_gpe);
790 
791  return (AcpiEvDetectGpe (GpeDevice, NULL, GpeNumber));
792 }
793 
795 
796 
797 /*******************************************************************************
798  *
799  * FUNCTION: AcpiFinishGpe
800  *
801  * PARAMETERS: GpeDevice - Namespace node for the GPE Block
802  * (NULL for FADT defined GPEs)
803  * GpeNumber - GPE level within the GPE block
804  *
805  * RETURN: Status
806  *
807  * DESCRIPTION: Clear and conditionally re-enable a GPE. This completes the GPE
808  * processing. Intended for use by asynchronous host-installed
809  * GPE handlers. The GPE is only re-enabled if the EnableForRun bit
810  * is set in the GPE info.
811  *
812  ******************************************************************************/
813 
816  ACPI_HANDLE GpeDevice,
818 {
822 
823 
825 
826 
827  Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
828 
829  /* Ensure that we have a valid GPE number */
830 
832  if (!GpeEventInfo)
833  {
835  goto UnlockAndExit;
836  }
837 
839 
840 UnlockAndExit:
841  AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
843 }
844 
846 
847 
848 /******************************************************************************
849  *
850  * FUNCTION: AcpiDisableAllGpes
851  *
852  * PARAMETERS: None
853  *
854  * RETURN: Status
855  *
856  * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
857  *
858  ******************************************************************************/
859 
862  void)
863 {
865 
866 
868 
869 
871  if (ACPI_FAILURE (Status))
872  {
874  }
875 
878 
880 }
881 
883 
884 
885 /******************************************************************************
886  *
887  * FUNCTION: AcpiEnableAllRuntimeGpes
888  *
889  * PARAMETERS: None
890  *
891  * RETURN: Status
892  *
893  * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
894  *
895  ******************************************************************************/
896 
899  void)
900 {
902 
903 
905 
906 
908  if (ACPI_FAILURE (Status))
909  {
911  }
912 
915 
917 }
918 
920 
921 
922 /******************************************************************************
923  *
924  * FUNCTION: AcpiEnableAllWakeupGpes
925  *
926  * PARAMETERS: None
927  *
928  * RETURN: Status
929  *
930  * DESCRIPTION: Enable all "wakeup" GPEs and disable all of the other GPEs, in
931  * all GPE blocks.
932  *
933  ******************************************************************************/
934 
937  void)
938 {
940 
941 
943 
944 
946  if (ACPI_FAILURE (Status))
947  {
949  }
950 
953 
955 }
956 
958 
959 
960 /*******************************************************************************
961  *
962  * FUNCTION: AcpiInstallGpeBlock
963  *
964  * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
965  * GpeBlockAddress - Address and SpaceID
966  * RegisterCount - Number of GPE register pairs in the block
967  * InterruptNumber - H/W interrupt for the block
968  *
969  * RETURN: Status
970  *
971  * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
972  * enabled here.
973  *
974  ******************************************************************************/
975 
978  ACPI_HANDLE GpeDevice,
979  ACPI_GENERIC_ADDRESS *GpeBlockAddress,
980  UINT32 RegisterCount,
981  UINT32 InterruptNumber)
982 {
984  ACPI_OPERAND_OBJECT *ObjDesc;
986  ACPI_GPE_BLOCK_INFO *GpeBlock;
987 
988 
990 
991 
992  if ((!GpeDevice) ||
993  (!GpeBlockAddress) ||
994  (!RegisterCount))
995  {
997  }
998 
1000  if (ACPI_FAILURE (Status))
1001  {
1003  }
1004 
1005  Node = AcpiNsValidateHandle (GpeDevice);
1006  if (!Node)
1007  {
1009  goto UnlockAndExit;
1010  }
1011 
1012  /* Validate the parent device */
1013 
1014  if (Node->Type != ACPI_TYPE_DEVICE)
1015  {
1016  Status = AE_TYPE;
1017  goto UnlockAndExit;
1018  }
1019 
1020  if (Node->Object)
1021  {
1023  goto UnlockAndExit;
1024  }
1025 
1026  /*
1027  * For user-installed GPE Block Devices, the GpeBlockBaseNumber
1028  * is always zero
1029  */
1030  Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress->Address,
1031  GpeBlockAddress->SpaceId, RegisterCount,
1032  0, InterruptNumber, &GpeBlock);
1033  if (ACPI_FAILURE (Status))
1034  {
1035  goto UnlockAndExit;
1036  }
1037 
1038  /* Install block in the DeviceObject attached to the node */
1039 
1040  ObjDesc = AcpiNsGetAttachedObject (Node);
1041  if (!ObjDesc)
1042  {
1043  /*
1044  * No object, create a new one (Device nodes do not always have
1045  * an attached object)
1046  */
1048  if (!ObjDesc)
1049  {
1050  Status = AE_NO_MEMORY;
1051  goto UnlockAndExit;
1052  }
1053 
1055 
1056  /* Remove local reference to the object */
1057 
1058  AcpiUtRemoveReference (ObjDesc);
1059  if (ACPI_FAILURE (Status))
1060  {
1061  goto UnlockAndExit;
1062  }
1063  }
1064 
1065  /* Now install the GPE block in the DeviceObject */
1066 
1067  ObjDesc->Device.GpeBlock = GpeBlock;
1068 
1069 
1070 UnlockAndExit:
1073 }
1074 
1076 
1077 
1078 /*******************************************************************************
1079  *
1080  * FUNCTION: AcpiRemoveGpeBlock
1081  *
1082  * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
1083  *
1084  * RETURN: Status
1085  *
1086  * DESCRIPTION: Remove a previously installed block of GPE registers
1087  *
1088  ******************************************************************************/
1089 
1092  ACPI_HANDLE GpeDevice)
1093 {
1094  ACPI_OPERAND_OBJECT *ObjDesc;
1097 
1098 
1100 
1101 
1102  if (!GpeDevice)
1103  {
1105  }
1106 
1108  if (ACPI_FAILURE (Status))
1109  {
1111  }
1112 
1113  Node = AcpiNsValidateHandle (GpeDevice);
1114  if (!Node)
1115  {
1117  goto UnlockAndExit;
1118  }
1119 
1120  /* Validate the parent device */
1121 
1122  if (Node->Type != ACPI_TYPE_DEVICE)
1123  {
1124  Status = AE_TYPE;
1125  goto UnlockAndExit;
1126  }
1127 
1128  /* Get the DeviceObject attached to the node */
1129 
1130  ObjDesc = AcpiNsGetAttachedObject (Node);
1131  if (!ObjDesc ||
1132  !ObjDesc->Device.GpeBlock)
1133  {
1135  }
1136 
1137  /* Delete the GPE block (but not the DeviceObject) */
1138 
1140  if (ACPI_SUCCESS (Status))
1141  {
1142  ObjDesc->Device.GpeBlock = NULL;
1143  }
1144 
1145 UnlockAndExit:
1148 }
1149 
1151 
1152 
1153 /*******************************************************************************
1154  *
1155  * FUNCTION: AcpiGetGpeDevice
1156  *
1157  * PARAMETERS: Index - System GPE index (0-CurrentGpeCount)
1158  * GpeDevice - Where the parent GPE Device is returned
1159  *
1160  * RETURN: Status
1161  *
1162  * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
1163  * gpe device indicates that the gpe number is contained in one of
1164  * the FADT-defined gpe blocks. Otherwise, the GPE block device.
1165  *
1166  ******************************************************************************/
1167 
1170  UINT32 Index,
1171  ACPI_HANDLE *GpeDevice)
1172 {
1175 
1176 
1178 
1179 
1180  if (!GpeDevice)
1181  {
1183  }
1184 
1185  if (Index >= AcpiCurrentGpeCount)
1186  {
1188  }
1189 
1190  /* Setup and walk the GPE list */
1191 
1192  Info.Index = Index;
1193  Info.Status = AE_NOT_EXIST;
1194  Info.GpeDevice = NULL;
1195  Info.NextBlockBaseIndex = 0;
1196 
1198  if (ACPI_FAILURE (Status))
1199  {
1201  }
1202 
1203  *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
1204  return_ACPI_STATUS (Info.Status);
1205 }
1206 
1208 
1209 #endif /* !ACPI_REDUCED_HARDWARE */
ACPI_STATUS AcpiHwDisableAllGpes(void)
Definition: hwgpe.c:543
BOOL WINAPI SHIM_OBJ_NAME() Notify(DWORD fdwReason, PVOID ptr)
ACPI_GPE_NOTIFY_INFO * NotifyList
Definition: aclocal.h:544
#define AE_NULL_OBJECT
Definition: acexcep.h:117
#define ACPI_FREE(a)
Definition: actypes.h:386
#define ACPI_ALLOCATE_ZEROED(a)
Definition: actypes.h:385
#define TRUE
Definition: types.h:120
ACPI_CPU_FLAGS AcpiOsAcquireLock(ACPI_SPINLOCK Handle)
Definition: osl.c:498
#define ACPI_SUCCESS(a)
Definition: acexcep.h:94
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
ACPI_STATUS AcpiEvGetGpeDevice(ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
Definition: evgpeutil.c:130
ACPI_STATUS AcpiEvMaskGpe(ACPI_GPE_EVENT_INFO *GpeEventInfo, BOOLEAN IsMasked)
Definition: evgpe.c:156
ACPI_STATUS AcpiEvCreateGpeBlock(ACPI_NAMESPACE_NODE *GpeDevice, UINT64 Address, UINT8 SpaceId, UINT32 RegisterCount, UINT16 GpeBlockBaseNumber, UINT32 InterruptNumber, ACPI_GPE_BLOCK_INFO **ReturnGpeBlock)
Definition: evgpeblk.c:371
#define AE_NO_MEMORY
Definition: acexcep.h:112
BOOLEAN DisableForDispatch
Definition: aclocal.h:559
#define AE_BAD_PARAMETER
Definition: acexcep.h:151
#define ACPI_GPE_AUTO_ENABLED
Definition: actypes.h:822
#define ACPI_GPE_DISPATCH_NONE
Definition: actypes.h:809
#define ACPI_SET_BIT(target, bit)
Definition: actypes.h:533
ACPI_STATUS AcpiGetGpeStatus(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, ACPI_EVENT_STATUS *EventStatus)
Definition: evxfgpe.c:734
#define ACPI_GPE_DISPATCH_TYPE(flags)
Definition: actypes.h:815
#define ACPI_GPE_CAN_WAKE
Definition: actypes.h:821
ACPI_GPE_EVENT_INFO * GpeEventInfo
Definition: acevents.h:195
ACPI_STATUS AcpiEvAddGpeReference(ACPI_GPE_EVENT_INFO *GpeEventInfo, BOOLEAN ClearOnEnable)
Definition: evgpe.c:221
ACPI_STATUS AcpiRemoveGpeBlock(ACPI_HANDLE GpeDevice)
Definition: evxfgpe.c:1091
#define ACPI_CPU_FLAGS
Definition: actypes.h:252
ACPI_GPE_EVENT_INFO * AcpiEvGetGpeEventInfo(ACPI_HANDLE GpeDevice, UINT32 GpeNumber)
Definition: evgpe.c:372
UINT32 ACPI_STATUS
Definition: actypes.h:460
ACPI_STATUS AcpiDisableGpe(ACPI_HANDLE GpeDevice, UINT32 GpeNumber)
Definition: evxfgpe.c:203
struct TraceInfo Info
ACPI_STATUS AcpiSetupGpeForWake(ACPI_HANDLE WakeDevice, ACPI_HANDLE GpeDevice, UINT32 GpeNumber)
Definition: evxfgpe.c:440
ACPI_STATUS AcpiUpdateAllGpes(void)
Definition: evxfgpe.c:79
UINT32 AcpiDispatchGpe(ACPI_HANDLE GpeDevice, UINT32 GpeNumber)
Definition: evxfgpe.c:785
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
ACPI_STATUS AcpiUtReleaseMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:348
#define ACPI_GPE_DISPATCH_NOTIFY
Definition: actypes.h:812
ACPI_STATUS AcpiUtAcquireMutex(ACPI_MUTEX_HANDLE MutexId)
Definition: utmutex.c:256
unsigned int UINT32
union acpi_gpe_dispatch_info Dispatch
Definition: aclocal.h:554
union node Node
Definition: types.h:1255
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
#define ACPI_EXPORT_SYMBOL(Symbol)
Definition: actypes.h:343
unsigned char BOOLEAN
#define AE_INFO
Definition: acoutput.h:230
smooth NULL
Definition: ftsmooth.c:416
ACPI_STATUS AcpiHwEnableAllRuntimeGpes(void)
Definition: hwgpe.c:570
ACPI_STATUS AcpiEvRemoveGpeReference(ACPI_GPE_EVENT_INFO *GpeEventInfo)
Definition: evgpe.c:276
#define ACPI_ROOT_OBJECT
Definition: actypes.h:500
UINT32 AcpiHwGetGpeRegisterBit(ACPI_GPE_EVENT_INFO *GpeEventInfo)
Definition: hwgpe.c:81
ACPI_STATUS AcpiEnableGpe(ACPI_HANDLE GpeDevice, UINT32 GpeNumber)
Definition: evxfgpe.c:137
ACPI_STATUS AcpiMarkGpeForWake(ACPI_HANDLE GpeDevice, UINT32 GpeNumber)
Definition: evxfgpe.c:388
#define ACPI_GPE_IS_POLLING_NEEDED(__gpe__)
Definition: acevents.h:59
ACPI_STATUS AcpiSetGpe(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, UINT8 Action)
Definition: evxfgpe.c:262
ACPI_STATUS AcpiHwGetGpeStatus(ACPI_GPE_EVENT_INFO *GpeEventInfo, ACPI_EVENT_STATUS *EventStatus)
Definition: hwgpe.c:233
ACPI_STATUS AcpiEvDeleteGpeBlock(ACPI_GPE_BLOCK_INFO *GpeBlock)
Definition: evgpeblk.c:148
struct acpi_gpe_register_info * RegisterInfo
Definition: aclocal.h:555
ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_NOTIFY_INFO ACPI_GPE_BLOCK_INFO * GpeBlock
Definition: acobject.h:270
#define AE_ALREADY_EXISTS
Definition: acexcep.h:115
_In_ PLIST_ENTRY _In_ PSTRING _In_ USHORT _In_opt_ PSTRING _In_opt_ PSTRING _In_ ULONG _In_ ULONG Action
Definition: fsrtlfuncs.h:738
UINT32 ACPI_EVENT_STATUS
Definition: actypes.h:780
static const UCHAR Index[8]
Definition: usbohci.c:18
#define ACPI_CLEAR_BIT(target, bit)
Definition: actypes.h:534
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
Definition: Node.h:9
ACPI_STATUS AcpiHwEnableAllWakeupGpes(void)
Definition: hwgpe.c:597
#define ACPI_GPE_LEVEL_TRIGGERED
Definition: actypes.h:817
ACPI_STATUS AcpiEnableAllRuntimeGpes(void)
Definition: evxfgpe.c:898
#define AE_NOT_EXIST
Definition: acexcep.h:114
ACPI_STATUS AcpiMaskGpe(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, BOOLEAN IsMasked)
Definition: evxfgpe.c:332
ACPI_GPE_EVENT_INFO UINT32 GpeNumber
Definition: acevents.h:195
ACPI_STATUS AcpiHwClearGpe(ACPI_GPE_EVENT_INFO *GpeEventInfo)
Definition: hwgpe.c:190
ACPI_STATUS AcpiSetGpeWakeMask(ACPI_HANDLE GpeDevice, UINT32 GpeNumber, UINT8 Action)
Definition: evxfgpe.c:599
#define ACPI_GPE_ENABLE
Definition: actypes.h:793
ACPI_STATUS AcpiEnableAllWakeupGpes(void)
Definition: evxfgpe.c:936
#define ACPI_TYPE_DEVICE
Definition: actypes.h:684
ACPI_STATUS AcpiClearGpe(ACPI_HANDLE GpeDevice, UINT32 GpeNumber)
Definition: evxfgpe.c:685
#define AE_TYPE
Definition: acexcep.h:116
Status
Definition: gdiplustypes.h:24
struct acpi_gpe_notify_info * Next
Definition: aclocal.h:532
ACPI_NAMESPACE_NODE * DeviceNode
Definition: aclocal.h:531
ACPI_STATUS AcpiNsAttachObject(ACPI_NAMESPACE_NODE *Node, ACPI_OPERAND_OBJECT *Object, ACPI_OBJECT_TYPE Type)
Definition: nsobject.c:76
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
ACPI_STATUS AcpiGetGpeDevice(UINT32 Index, ACPI_HANDLE *GpeDevice)
Definition: evxfgpe.c:1169
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
UINT32 AcpiEvDetectGpe(ACPI_NAMESPACE_NODE *GpeDevice, ACPI_GPE_EVENT_INFO *GpeEventInfo, UINT32 GpeNumber)
Definition: evgpe.c:722
void AcpiUtRemoveReference(ACPI_OPERAND_OBJECT *Object)
Definition: utdelete.c:784
#define AE_NO_HANDLER
Definition: acexcep.h:134
ACPI_STATUS AcpiEvFinishGpe(ACPI_GPE_EVENT_INFO *GpeEventInfo)
Definition: evgpe.c:670
#define ACPI_MTX_EVENTS
Definition: aclocal.h:87
ACPI_STATUS AcpiEvWalkGpeList(ACPI_GPE_CALLBACK GpeWalkCallback, void *Context)
Definition: evgpeutil.c:67
ACPI_OBJECT_DEVICE Device
Definition: acobject.h:526
ACPI_STATUS AcpiEvInitializeGpeBlock(ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
Definition: evgpeblk.c:481
ACPI_STATUS AcpiDisableAllGpes(void)
Definition: evxfgpe.c:861
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define ACPI_GPE_DISABLE
Definition: actypes.h:794
void AcpiOsReleaseLock(ACPI_SPINLOCK Handle, ACPI_CPU_FLAGS Flags)
Definition: osl.c:516
ACPI_NAMESPACE_NODE * AcpiNsValidateHandle(ACPI_HANDLE Handle)
Definition: nsutils.c:655
#define AcpiUtCreateInternalObject(t)
Definition: acutils.h:655
ACPI_STATUS AcpiFinishGpe(ACPI_HANDLE GpeDevice, UINT32 GpeNumber)
Definition: evxfgpe.c:815
#define ACPI_MTX_NAMESPACE
Definition: aclocal.h:85
#define ACPI_CAST_PTR(t, p)
Definition: actypes.h:544
unsigned char UINT8
#define AE_OK
Definition: acexcep.h:97
ACPI_STATUS AcpiInstallGpeBlock(ACPI_HANDLE GpeDevice, ACPI_GENERIC_ADDRESS *GpeBlockAddress, UINT32 RegisterCount, UINT32 InterruptNumber)
Definition: evxfgpe.c:977
ACPI_STATUS AcpiHwLowSetGpe(ACPI_GPE_EVENT_INFO *GpeEventInfo, UINT32 Action)
Definition: hwgpe.c:106
Definition: dlist.c:348
UINT32 AcpiEvGpeDetect(ACPI_GPE_XRUPT_INFO *GpeXruptList)
Definition: evgpe.c:433