1 /******************************************************************************
3 * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2014, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
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.
46 #define EXPORT_ACPI_INTERFACES
53 #define _COMPONENT ACPI_EVENTS
54 ACPI_MODULE_NAME ("evxfgpe")
57 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
58 /*******************************************************************************
60 * FUNCTION: AcpiUpdateAllGpes
66 * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
67 * associated _Lxx or _Exx methods and are not pointed to by any
68 * device _PRW methods (this indicates that these GPEs are
69 * generally intended for system or device wakeup. Such GPEs
70 * have to be enabled directly when the devices whose _PRW
71 * methods point to them are set up for wakeup signaling.)
73 * NOTE: Should be called after any GPEs are added to the system. Primarily,
74 * after the system _PRW methods have been run, but also after a GPE Block
75 * Device has been added or if any new GPE methods have been added via a
78 ******************************************************************************/
87 ACPI_FUNCTION_TRACE (AcpiUpdateAllGpes);
90 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
91 if (ACPI_FAILURE (Status))
93 return_ACPI_STATUS (Status);
96 if (AcpiGbl_AllGpesInitialized)
101 Status = AcpiEvWalkGpeList (AcpiEvInitializeGpeBlock, NULL);
102 if (ACPI_SUCCESS (Status))
104 AcpiGbl_AllGpesInitialized = TRUE;
108 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
109 return_ACPI_STATUS (Status);
112 ACPI_EXPORT_SYMBOL (AcpiUpdateAllGpes)
115 /*******************************************************************************
117 * FUNCTION: AcpiEnableGpe
119 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
120 * GpeNumber - GPE level within the GPE block
124 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
127 ******************************************************************************/
131 ACPI_HANDLE GpeDevice,
134 ACPI_STATUS Status = AE_BAD_PARAMETER;
135 ACPI_GPE_EVENT_INFO *GpeEventInfo;
136 ACPI_CPU_FLAGS Flags;
139 ACPI_FUNCTION_TRACE (AcpiEnableGpe);
142 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
145 * Ensure that we have a valid GPE number and that there is some way
146 * of handling the GPE (handler or a GPE method). In other words, we
147 * won't allow a valid GPE to be enabled if there is no way to handle it.
149 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
152 if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) !=
153 ACPI_GPE_DISPATCH_NONE)
155 Status = AcpiEvAddGpeReference (GpeEventInfo);
159 Status = AE_NO_HANDLER;
163 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
164 return_ACPI_STATUS (Status);
167 ACPI_EXPORT_SYMBOL (AcpiEnableGpe)
170 /*******************************************************************************
172 * FUNCTION: AcpiDisableGpe
174 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
175 * GpeNumber - GPE level within the GPE block
179 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
180 * removed, only then is the GPE disabled (for runtime GPEs), or
181 * the GPE mask bit disabled (for wake GPEs)
183 ******************************************************************************/
187 ACPI_HANDLE GpeDevice,
190 ACPI_STATUS Status = AE_BAD_PARAMETER;
191 ACPI_GPE_EVENT_INFO *GpeEventInfo;
192 ACPI_CPU_FLAGS Flags;
195 ACPI_FUNCTION_TRACE (AcpiDisableGpe);
198 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
200 /* Ensure that we have a valid GPE number */
202 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
205 Status = AcpiEvRemoveGpeReference (GpeEventInfo);
208 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
209 return_ACPI_STATUS (Status);
212 ACPI_EXPORT_SYMBOL (AcpiDisableGpe)
215 /*******************************************************************************
217 * FUNCTION: AcpiSetGpe
219 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
220 * GpeNumber - GPE level within the GPE block
221 * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
225 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
226 * the reference count mechanism used in the AcpiEnableGpe and
227 * AcpiDisableGpe interfaces -- and should be used with care.
229 * Note: Typically used to disable a runtime GPE for short period of time,
230 * then re-enable it, without disturbing the existing reference counts. This
231 * is useful, for example, in the Embedded Controller (EC) driver.
233 ******************************************************************************/
237 ACPI_HANDLE GpeDevice,
241 ACPI_GPE_EVENT_INFO *GpeEventInfo;
243 ACPI_CPU_FLAGS Flags;
246 ACPI_FUNCTION_TRACE (AcpiSetGpe);
249 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
251 /* Ensure that we have a valid GPE number */
253 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
256 Status = AE_BAD_PARAMETER;
260 /* Perform the action */
264 case ACPI_GPE_ENABLE:
266 Status = AcpiEvEnableGpe (GpeEventInfo);
269 case ACPI_GPE_DISABLE:
271 Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
276 Status = AE_BAD_PARAMETER;
281 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
282 return_ACPI_STATUS (Status);
285 ACPI_EXPORT_SYMBOL (AcpiSetGpe)
288 /*******************************************************************************
290 * FUNCTION: AcpiMarkGpeForWake
292 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
293 * GpeNumber - GPE level within the GPE block
297 * DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply
298 * sets the ACPI_GPE_CAN_WAKE flag.
300 * Some potential callers of AcpiSetupGpeForWake may know in advance that
301 * there won't be any notify handlers installed for device wake notifications
302 * from the given GPE (one example is a button GPE in Linux). For these cases,
303 * AcpiMarkGpeForWake should be used instead of AcpiSetupGpeForWake.
304 * This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to
305 * setup implicit wake notification for it (since there's no handler method).
307 ******************************************************************************/
311 ACPI_HANDLE GpeDevice,
314 ACPI_GPE_EVENT_INFO *GpeEventInfo;
315 ACPI_STATUS Status = AE_BAD_PARAMETER;
316 ACPI_CPU_FLAGS Flags;
319 ACPI_FUNCTION_TRACE (AcpiMarkGpeForWake);
322 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
324 /* Ensure that we have a valid GPE number */
326 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
329 /* Mark the GPE as a possible wake event */
331 GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE;
335 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
336 return_ACPI_STATUS (Status);
339 ACPI_EXPORT_SYMBOL (AcpiMarkGpeForWake)
342 /*******************************************************************************
344 * FUNCTION: AcpiSetupGpeForWake
346 * PARAMETERS: WakeDevice - Device associated with the GPE (via _PRW)
347 * GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
348 * GpeNumber - GPE level within the GPE block
352 * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
353 * interface is intended to be used as the host executes the
354 * _PRW methods (Power Resources for Wake) in the system tables.
355 * Each _PRW appears under a Device Object (The WakeDevice), and
356 * contains the info for the wake GPE associated with the
359 ******************************************************************************/
362 AcpiSetupGpeForWake (
363 ACPI_HANDLE WakeDevice,
364 ACPI_HANDLE GpeDevice,
368 ACPI_GPE_EVENT_INFO *GpeEventInfo;
369 ACPI_NAMESPACE_NODE *DeviceNode;
370 ACPI_GPE_NOTIFY_INFO *Notify;
371 ACPI_GPE_NOTIFY_INFO *NewNotify;
372 ACPI_CPU_FLAGS Flags;
375 ACPI_FUNCTION_TRACE (AcpiSetupGpeForWake);
378 /* Parameter Validation */
383 * By forcing WakeDevice to be valid, we automatically enable the
384 * implicit notify feature on all hosts.
386 return_ACPI_STATUS (AE_BAD_PARAMETER);
389 /* Handle root object case */
391 if (WakeDevice == ACPI_ROOT_OBJECT)
393 DeviceNode = AcpiGbl_RootNode;
397 DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, WakeDevice);
400 /* Validate WakeDevice is of type Device */
402 if (DeviceNode->Type != ACPI_TYPE_DEVICE)
404 return_ACPI_STATUS (AE_BAD_PARAMETER);
408 * Allocate a new notify object up front, in case it is needed.
409 * Memory allocation while holding a spinlock is a big no-no
412 NewNotify = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_NOTIFY_INFO));
415 return_ACPI_STATUS (AE_NO_MEMORY);
418 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
420 /* Ensure that we have a valid GPE number */
422 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
425 Status = AE_BAD_PARAMETER;
430 * If there is no method or handler for this GPE, then the
431 * WakeDevice will be notified whenever this GPE fires. This is
432 * known as an "implicit notify". Note: The GPE is assumed to be
433 * level-triggered (for windows compatibility).
435 if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
436 ACPI_GPE_DISPATCH_NONE)
439 * This is the first device for implicit notify on this GPE.
440 * Just set the flags here, and enter the NOTIFY block below.
442 GpeEventInfo->Flags =
443 (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
447 * If we already have an implicit notify on this GPE, add
448 * this device to the notify list.
450 if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
451 ACPI_GPE_DISPATCH_NOTIFY)
453 /* Ensure that the device is not already in the list */
455 Notify = GpeEventInfo->Dispatch.NotifyList;
458 if (Notify->DeviceNode == DeviceNode)
460 Status = AE_ALREADY_EXISTS;
463 Notify = Notify->Next;
466 /* Add this device to the notify list for this GPE */
468 NewNotify->DeviceNode = DeviceNode;
469 NewNotify->Next = GpeEventInfo->Dispatch.NotifyList;
470 GpeEventInfo->Dispatch.NotifyList = NewNotify;
474 /* Mark the GPE as a possible wake event */
476 GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE;
481 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
483 /* Delete the notify object if it was not used above */
487 ACPI_FREE (NewNotify);
489 return_ACPI_STATUS (Status);
492 ACPI_EXPORT_SYMBOL (AcpiSetupGpeForWake)
495 /*******************************************************************************
497 * FUNCTION: AcpiSetGpeWakeMask
499 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
500 * GpeNumber - GPE level within the GPE block
501 * Action - Enable or Disable
505 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
506 * already be marked as a WAKE GPE.
508 ******************************************************************************/
512 ACPI_HANDLE GpeDevice,
516 ACPI_STATUS Status = AE_OK;
517 ACPI_GPE_EVENT_INFO *GpeEventInfo;
518 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
519 ACPI_CPU_FLAGS Flags;
523 ACPI_FUNCTION_TRACE (AcpiSetGpeWakeMask);
526 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
529 * Ensure that we have a valid GPE number and that this GPE is in
532 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
535 Status = AE_BAD_PARAMETER;
539 if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE))
545 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
546 if (!GpeRegisterInfo)
548 Status = AE_NOT_EXIST;
552 RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
554 /* Perform the action */
558 case ACPI_GPE_ENABLE:
560 ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
563 case ACPI_GPE_DISABLE:
565 ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
570 ACPI_ERROR ((AE_INFO, "%u, Invalid action", Action));
571 Status = AE_BAD_PARAMETER;
576 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
577 return_ACPI_STATUS (Status);
580 ACPI_EXPORT_SYMBOL (AcpiSetGpeWakeMask)
583 /*******************************************************************************
585 * FUNCTION: AcpiClearGpe
587 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
588 * GpeNumber - GPE level within the GPE block
592 * DESCRIPTION: Clear an ACPI event (general purpose)
594 ******************************************************************************/
598 ACPI_HANDLE GpeDevice,
601 ACPI_STATUS Status = AE_OK;
602 ACPI_GPE_EVENT_INFO *GpeEventInfo;
603 ACPI_CPU_FLAGS Flags;
606 ACPI_FUNCTION_TRACE (AcpiClearGpe);
609 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
611 /* Ensure that we have a valid GPE number */
613 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
616 Status = AE_BAD_PARAMETER;
620 Status = AcpiHwClearGpe (GpeEventInfo);
623 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
624 return_ACPI_STATUS (Status);
627 ACPI_EXPORT_SYMBOL (AcpiClearGpe)
630 /*******************************************************************************
632 * FUNCTION: AcpiGetGpeStatus
634 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
635 * GpeNumber - GPE level within the GPE block
636 * EventStatus - Where the current status of the event
641 * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
643 ******************************************************************************/
647 ACPI_HANDLE GpeDevice,
649 ACPI_EVENT_STATUS *EventStatus)
651 ACPI_STATUS Status = AE_OK;
652 ACPI_GPE_EVENT_INFO *GpeEventInfo;
653 ACPI_CPU_FLAGS Flags;
656 ACPI_FUNCTION_TRACE (AcpiGetGpeStatus);
659 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
661 /* Ensure that we have a valid GPE number */
663 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
666 Status = AE_BAD_PARAMETER;
670 /* Obtain status on the requested GPE number */
672 Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
675 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
676 return_ACPI_STATUS (Status);
679 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus)
682 /*******************************************************************************
684 * FUNCTION: AcpiFinishGpe
686 * PARAMETERS: GpeDevice - Namespace node for the GPE Block
687 * (NULL for FADT defined GPEs)
688 * GpeNumber - GPE level within the GPE block
692 * DESCRIPTION: Clear and conditionally reenable a GPE. This completes the GPE
693 * processing. Intended for use by asynchronous host-installed
694 * GPE handlers. The GPE is only reenabled if the EnableForRun bit
695 * is set in the GPE info.
697 ******************************************************************************/
701 ACPI_HANDLE GpeDevice,
704 ACPI_GPE_EVENT_INFO *GpeEventInfo;
706 ACPI_CPU_FLAGS Flags;
709 ACPI_FUNCTION_TRACE (AcpiFinishGpe);
712 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
714 /* Ensure that we have a valid GPE number */
716 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
719 Status = AE_BAD_PARAMETER;
723 Status = AcpiEvFinishGpe (GpeEventInfo);
726 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
727 return_ACPI_STATUS (Status);
730 ACPI_EXPORT_SYMBOL (AcpiFinishGpe)
733 /******************************************************************************
735 * FUNCTION: AcpiDisableAllGpes
741 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
743 ******************************************************************************/
752 ACPI_FUNCTION_TRACE (AcpiDisableAllGpes);
755 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
756 if (ACPI_FAILURE (Status))
758 return_ACPI_STATUS (Status);
761 Status = AcpiHwDisableAllGpes ();
762 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
764 return_ACPI_STATUS (Status);
767 ACPI_EXPORT_SYMBOL (AcpiDisableAllGpes)
770 /******************************************************************************
772 * FUNCTION: AcpiEnableAllRuntimeGpes
778 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
780 ******************************************************************************/
783 AcpiEnableAllRuntimeGpes (
789 ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes);
792 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
793 if (ACPI_FAILURE (Status))
795 return_ACPI_STATUS (Status);
798 Status = AcpiHwEnableAllRuntimeGpes ();
799 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
801 return_ACPI_STATUS (Status);
804 ACPI_EXPORT_SYMBOL (AcpiEnableAllRuntimeGpes)
807 /*******************************************************************************
809 * FUNCTION: AcpiInstallGpeBlock
811 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
812 * GpeBlockAddress - Address and SpaceID
813 * RegisterCount - Number of GPE register pairs in the block
814 * InterruptNumber - H/W interrupt for the block
818 * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
821 ******************************************************************************/
824 AcpiInstallGpeBlock (
825 ACPI_HANDLE GpeDevice,
826 ACPI_GENERIC_ADDRESS *GpeBlockAddress,
827 UINT32 RegisterCount,
828 UINT32 InterruptNumber)
831 ACPI_OPERAND_OBJECT *ObjDesc;
832 ACPI_NAMESPACE_NODE *Node;
833 ACPI_GPE_BLOCK_INFO *GpeBlock;
836 ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock);
840 (!GpeBlockAddress) ||
843 return_ACPI_STATUS (AE_BAD_PARAMETER);
846 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
847 if (ACPI_FAILURE (Status))
849 return_ACPI_STATUS (Status);
852 Node = AcpiNsValidateHandle (GpeDevice);
855 Status = AE_BAD_PARAMETER;
859 /* Validate the parent device */
861 if (Node->Type != ACPI_TYPE_DEVICE)
869 Status = AE_ALREADY_EXISTS;
874 * For user-installed GPE Block Devices, the GpeBlockBaseNumber
877 Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress->Address,
878 GpeBlockAddress->SpaceId, RegisterCount,
879 0, InterruptNumber, &GpeBlock);
880 if (ACPI_FAILURE (Status))
885 /* Install block in the DeviceObject attached to the node */
887 ObjDesc = AcpiNsGetAttachedObject (Node);
891 * No object, create a new one (Device nodes do not always have
892 * an attached object)
894 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE);
897 Status = AE_NO_MEMORY;
901 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE);
903 /* Remove local reference to the object */
905 AcpiUtRemoveReference (ObjDesc);
906 if (ACPI_FAILURE (Status))
912 /* Now install the GPE block in the DeviceObject */
914 ObjDesc->Device.GpeBlock = GpeBlock;
918 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
919 return_ACPI_STATUS (Status);
922 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock)
925 /*******************************************************************************
927 * FUNCTION: AcpiRemoveGpeBlock
929 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
933 * DESCRIPTION: Remove a previously installed block of GPE registers
935 ******************************************************************************/
939 ACPI_HANDLE GpeDevice)
941 ACPI_OPERAND_OBJECT *ObjDesc;
943 ACPI_NAMESPACE_NODE *Node;
946 ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock);
951 return_ACPI_STATUS (AE_BAD_PARAMETER);
954 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
955 if (ACPI_FAILURE (Status))
957 return_ACPI_STATUS (Status);
960 Node = AcpiNsValidateHandle (GpeDevice);
963 Status = AE_BAD_PARAMETER;
967 /* Validate the parent device */
969 if (Node->Type != ACPI_TYPE_DEVICE)
975 /* Get the DeviceObject attached to the node */
977 ObjDesc = AcpiNsGetAttachedObject (Node);
979 !ObjDesc->Device.GpeBlock)
981 return_ACPI_STATUS (AE_NULL_OBJECT);
984 /* Delete the GPE block (but not the DeviceObject) */
986 Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock);
987 if (ACPI_SUCCESS (Status))
989 ObjDesc->Device.GpeBlock = NULL;
993 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
994 return_ACPI_STATUS (Status);
997 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock)
1000 /*******************************************************************************
1002 * FUNCTION: AcpiGetGpeDevice
1004 * PARAMETERS: Index - System GPE index (0-CurrentGpeCount)
1005 * GpeDevice - Where the parent GPE Device is returned
1009 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
1010 * gpe device indicates that the gpe number is contained in one of
1011 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
1013 ******************************************************************************/
1018 ACPI_HANDLE *GpeDevice)
1020 ACPI_GPE_DEVICE_INFO Info;
1024 ACPI_FUNCTION_TRACE (AcpiGetGpeDevice);
1029 return_ACPI_STATUS (AE_BAD_PARAMETER);
1032 if (Index >= AcpiCurrentGpeCount)
1034 return_ACPI_STATUS (AE_NOT_EXIST);
1037 /* Setup and walk the GPE list */
1040 Info.Status = AE_NOT_EXIST;
1041 Info.GpeDevice = NULL;
1042 Info.NextBlockBaseIndex = 0;
1044 Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info);
1045 if (ACPI_FAILURE (Status))
1047 return_ACPI_STATUS (Status);
1050 *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
1051 return_ACPI_STATUS (Info.Status);
1054 ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice)
1056 #endif /* !ACPI_REDUCED_HARDWARE */