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.
44 #define EXPORT_ACPI_INTERFACES
51 #define _COMPONENT ACPI_EVENTS
52 ACPI_MODULE_NAME ("evxfgpe")
55 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
56 /*******************************************************************************
58 * FUNCTION: AcpiUpdateAllGpes
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.)
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
76 ******************************************************************************/
85 ACPI_FUNCTION_TRACE (AcpiUpdateAllGpes);
88 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
89 if (ACPI_FAILURE (Status))
91 return_ACPI_STATUS (Status);
94 if (AcpiGbl_AllGpesInitialized)
99 Status = AcpiEvWalkGpeList (AcpiEvInitializeGpeBlock, NULL);
100 if (ACPI_SUCCESS (Status))
102 AcpiGbl_AllGpesInitialized = TRUE;
106 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
107 return_ACPI_STATUS (Status);
110 ACPI_EXPORT_SYMBOL (AcpiUpdateAllGpes)
113 /*******************************************************************************
115 * FUNCTION: AcpiEnableGpe
117 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
118 * GpeNumber - GPE level within the GPE block
122 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
125 ******************************************************************************/
129 ACPI_HANDLE GpeDevice,
132 ACPI_STATUS Status = AE_BAD_PARAMETER;
133 ACPI_GPE_EVENT_INFO *GpeEventInfo;
134 ACPI_CPU_FLAGS Flags;
137 ACPI_FUNCTION_TRACE (AcpiEnableGpe);
140 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
143 * Ensure that we have a valid GPE number and that there is some way
144 * of handling the GPE (handler or a GPE method). In other words, we
145 * won't allow a valid GPE to be enabled if there is no way to handle it.
147 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
150 if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) !=
151 ACPI_GPE_DISPATCH_NONE)
153 Status = AcpiEvAddGpeReference (GpeEventInfo);
157 Status = AE_NO_HANDLER;
161 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
162 return_ACPI_STATUS (Status);
165 ACPI_EXPORT_SYMBOL (AcpiEnableGpe)
168 /*******************************************************************************
170 * FUNCTION: AcpiDisableGpe
172 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
173 * GpeNumber - GPE level within the GPE block
177 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
178 * removed, only then is the GPE disabled (for runtime GPEs), or
179 * the GPE mask bit disabled (for wake GPEs)
181 ******************************************************************************/
185 ACPI_HANDLE GpeDevice,
188 ACPI_STATUS Status = AE_BAD_PARAMETER;
189 ACPI_GPE_EVENT_INFO *GpeEventInfo;
190 ACPI_CPU_FLAGS Flags;
193 ACPI_FUNCTION_TRACE (AcpiDisableGpe);
196 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
198 /* Ensure that we have a valid GPE number */
200 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
203 Status = AcpiEvRemoveGpeReference (GpeEventInfo);
206 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
207 return_ACPI_STATUS (Status);
210 ACPI_EXPORT_SYMBOL (AcpiDisableGpe)
213 /*******************************************************************************
215 * FUNCTION: AcpiSetGpe
217 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
218 * GpeNumber - GPE level within the GPE block
219 * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
223 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
224 * the reference count mechanism used in the AcpiEnableGpe and
225 * AcpiDisableGpe interfaces -- and should be used with care.
227 * Note: Typically used to disable a runtime GPE for short period of time,
228 * then re-enable it, without disturbing the existing reference counts. This
229 * is useful, for example, in the Embedded Controller (EC) driver.
231 ******************************************************************************/
235 ACPI_HANDLE GpeDevice,
239 ACPI_GPE_EVENT_INFO *GpeEventInfo;
241 ACPI_CPU_FLAGS Flags;
244 ACPI_FUNCTION_TRACE (AcpiSetGpe);
247 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
249 /* Ensure that we have a valid GPE number */
251 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
254 Status = AE_BAD_PARAMETER;
258 /* Perform the action */
262 case ACPI_GPE_ENABLE:
264 Status = AcpiEvEnableGpe (GpeEventInfo);
267 case ACPI_GPE_DISABLE:
269 Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
274 Status = AE_BAD_PARAMETER;
279 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
280 return_ACPI_STATUS (Status);
283 ACPI_EXPORT_SYMBOL (AcpiSetGpe)
286 /*******************************************************************************
288 * FUNCTION: AcpiMarkGpeForWake
290 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
291 * GpeNumber - GPE level within the GPE block
295 * DESCRIPTION: Mark a GPE as having the ability to wake the system. Simply
296 * sets the ACPI_GPE_CAN_WAKE flag.
298 * Some potential callers of AcpiSetupGpeForWake may know in advance that
299 * there won't be any notify handlers installed for device wake notifications
300 * from the given GPE (one example is a button GPE in Linux). For these cases,
301 * AcpiMarkGpeForWake should be used instead of AcpiSetupGpeForWake.
302 * This will set the ACPI_GPE_CAN_WAKE flag for the GPE without trying to
303 * setup implicit wake notification for it (since there's no handler method).
305 ******************************************************************************/
309 ACPI_HANDLE GpeDevice,
312 ACPI_GPE_EVENT_INFO *GpeEventInfo;
313 ACPI_STATUS Status = AE_BAD_PARAMETER;
314 ACPI_CPU_FLAGS Flags;
317 ACPI_FUNCTION_TRACE (AcpiMarkGpeForWake);
320 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
322 /* Ensure that we have a valid GPE number */
324 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
327 /* Mark the GPE as a possible wake event */
329 GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE;
333 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
334 return_ACPI_STATUS (Status);
337 ACPI_EXPORT_SYMBOL (AcpiMarkGpeForWake)
340 /*******************************************************************************
342 * FUNCTION: AcpiSetupGpeForWake
344 * PARAMETERS: WakeDevice - Device associated with the GPE (via _PRW)
345 * GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
346 * GpeNumber - GPE level within the GPE block
350 * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
351 * interface is intended to be used as the host executes the
352 * _PRW methods (Power Resources for Wake) in the system tables.
353 * Each _PRW appears under a Device Object (The WakeDevice), and
354 * contains the info for the wake GPE associated with the
357 ******************************************************************************/
360 AcpiSetupGpeForWake (
361 ACPI_HANDLE WakeDevice,
362 ACPI_HANDLE GpeDevice,
366 ACPI_GPE_EVENT_INFO *GpeEventInfo;
367 ACPI_NAMESPACE_NODE *DeviceNode;
368 ACPI_GPE_NOTIFY_INFO *Notify;
369 ACPI_GPE_NOTIFY_INFO *NewNotify;
370 ACPI_CPU_FLAGS Flags;
373 ACPI_FUNCTION_TRACE (AcpiSetupGpeForWake);
376 /* Parameter Validation */
381 * By forcing WakeDevice to be valid, we automatically enable the
382 * implicit notify feature on all hosts.
384 return_ACPI_STATUS (AE_BAD_PARAMETER);
387 /* Handle root object case */
389 if (WakeDevice == ACPI_ROOT_OBJECT)
391 DeviceNode = AcpiGbl_RootNode;
395 DeviceNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, WakeDevice);
398 /* Validate WakeDevice is of type Device */
400 if (DeviceNode->Type != ACPI_TYPE_DEVICE)
402 return_ACPI_STATUS (AE_BAD_PARAMETER);
406 * Allocate a new notify object up front, in case it is needed.
407 * Memory allocation while holding a spinlock is a big no-no
410 NewNotify = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_NOTIFY_INFO));
413 return_ACPI_STATUS (AE_NO_MEMORY);
416 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
418 /* Ensure that we have a valid GPE number */
420 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
423 Status = AE_BAD_PARAMETER;
428 * If there is no method or handler for this GPE, then the
429 * WakeDevice will be notified whenever this GPE fires. This is
430 * known as an "implicit notify". Note: The GPE is assumed to be
431 * level-triggered (for windows compatibility).
433 if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
434 ACPI_GPE_DISPATCH_NONE)
437 * This is the first device for implicit notify on this GPE.
438 * Just set the flags here, and enter the NOTIFY block below.
440 GpeEventInfo->Flags =
441 (ACPI_GPE_DISPATCH_NOTIFY | ACPI_GPE_LEVEL_TRIGGERED);
445 * If we already have an implicit notify on this GPE, add
446 * this device to the notify list.
448 if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) ==
449 ACPI_GPE_DISPATCH_NOTIFY)
451 /* Ensure that the device is not already in the list */
453 Notify = GpeEventInfo->Dispatch.NotifyList;
456 if (Notify->DeviceNode == DeviceNode)
458 Status = AE_ALREADY_EXISTS;
461 Notify = Notify->Next;
464 /* Add this device to the notify list for this GPE */
466 NewNotify->DeviceNode = DeviceNode;
467 NewNotify->Next = GpeEventInfo->Dispatch.NotifyList;
468 GpeEventInfo->Dispatch.NotifyList = NewNotify;
472 /* Mark the GPE as a possible wake event */
474 GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE;
479 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
481 /* Delete the notify object if it was not used above */
485 ACPI_FREE (NewNotify);
487 return_ACPI_STATUS (Status);
490 ACPI_EXPORT_SYMBOL (AcpiSetupGpeForWake)
493 /*******************************************************************************
495 * FUNCTION: AcpiSetGpeWakeMask
497 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
498 * GpeNumber - GPE level within the GPE block
499 * Action - Enable or Disable
503 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
504 * already be marked as a WAKE GPE.
506 ******************************************************************************/
510 ACPI_HANDLE GpeDevice,
514 ACPI_STATUS Status = AE_OK;
515 ACPI_GPE_EVENT_INFO *GpeEventInfo;
516 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
517 ACPI_CPU_FLAGS Flags;
521 ACPI_FUNCTION_TRACE (AcpiSetGpeWakeMask);
524 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
527 * Ensure that we have a valid GPE number and that this GPE is in
530 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
533 Status = AE_BAD_PARAMETER;
537 if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE))
543 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
544 if (!GpeRegisterInfo)
546 Status = AE_NOT_EXIST;
550 RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo);
552 /* Perform the action */
556 case ACPI_GPE_ENABLE:
558 ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
561 case ACPI_GPE_DISABLE:
563 ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
568 ACPI_ERROR ((AE_INFO, "%u, Invalid action", Action));
569 Status = AE_BAD_PARAMETER;
574 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
575 return_ACPI_STATUS (Status);
578 ACPI_EXPORT_SYMBOL (AcpiSetGpeWakeMask)
581 /*******************************************************************************
583 * FUNCTION: AcpiClearGpe
585 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
586 * GpeNumber - GPE level within the GPE block
590 * DESCRIPTION: Clear an ACPI event (general purpose)
592 ******************************************************************************/
596 ACPI_HANDLE GpeDevice,
599 ACPI_STATUS Status = AE_OK;
600 ACPI_GPE_EVENT_INFO *GpeEventInfo;
601 ACPI_CPU_FLAGS Flags;
604 ACPI_FUNCTION_TRACE (AcpiClearGpe);
607 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
609 /* Ensure that we have a valid GPE number */
611 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
614 Status = AE_BAD_PARAMETER;
618 Status = AcpiHwClearGpe (GpeEventInfo);
621 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
622 return_ACPI_STATUS (Status);
625 ACPI_EXPORT_SYMBOL (AcpiClearGpe)
628 /*******************************************************************************
630 * FUNCTION: AcpiGetGpeStatus
632 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
633 * GpeNumber - GPE level within the GPE block
634 * EventStatus - Where the current status of the event
639 * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
641 ******************************************************************************/
645 ACPI_HANDLE GpeDevice,
647 ACPI_EVENT_STATUS *EventStatus)
649 ACPI_STATUS Status = AE_OK;
650 ACPI_GPE_EVENT_INFO *GpeEventInfo;
651 ACPI_CPU_FLAGS Flags;
654 ACPI_FUNCTION_TRACE (AcpiGetGpeStatus);
657 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
659 /* Ensure that we have a valid GPE number */
661 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
664 Status = AE_BAD_PARAMETER;
668 /* Obtain status on the requested GPE number */
670 Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
673 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
674 return_ACPI_STATUS (Status);
677 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus)
680 /*******************************************************************************
682 * FUNCTION: AcpiFinishGpe
684 * PARAMETERS: GpeDevice - Namespace node for the GPE Block
685 * (NULL for FADT defined GPEs)
686 * GpeNumber - GPE level within the GPE block
690 * DESCRIPTION: Clear and conditionally reenable a GPE. This completes the GPE
691 * processing. Intended for use by asynchronous host-installed
692 * GPE handlers. The GPE is only reenabled if the EnableForRun bit
693 * is set in the GPE info.
695 ******************************************************************************/
699 ACPI_HANDLE GpeDevice,
702 ACPI_GPE_EVENT_INFO *GpeEventInfo;
704 ACPI_CPU_FLAGS Flags;
707 ACPI_FUNCTION_TRACE (AcpiFinishGpe);
710 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
712 /* Ensure that we have a valid GPE number */
714 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
717 Status = AE_BAD_PARAMETER;
721 Status = AcpiEvFinishGpe (GpeEventInfo);
724 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
725 return_ACPI_STATUS (Status);
728 ACPI_EXPORT_SYMBOL (AcpiFinishGpe)
731 /******************************************************************************
733 * FUNCTION: AcpiDisableAllGpes
739 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
741 ******************************************************************************/
750 ACPI_FUNCTION_TRACE (AcpiDisableAllGpes);
753 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
754 if (ACPI_FAILURE (Status))
756 return_ACPI_STATUS (Status);
759 Status = AcpiHwDisableAllGpes ();
760 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
762 return_ACPI_STATUS (Status);
765 ACPI_EXPORT_SYMBOL (AcpiDisableAllGpes)
768 /******************************************************************************
770 * FUNCTION: AcpiEnableAllRuntimeGpes
776 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
778 ******************************************************************************/
781 AcpiEnableAllRuntimeGpes (
787 ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes);
790 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
791 if (ACPI_FAILURE (Status))
793 return_ACPI_STATUS (Status);
796 Status = AcpiHwEnableAllRuntimeGpes ();
797 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
799 return_ACPI_STATUS (Status);
802 ACPI_EXPORT_SYMBOL (AcpiEnableAllRuntimeGpes)
805 /*******************************************************************************
807 * FUNCTION: AcpiInstallGpeBlock
809 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
810 * GpeBlockAddress - Address and SpaceID
811 * RegisterCount - Number of GPE register pairs in the block
812 * InterruptNumber - H/W interrupt for the block
816 * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
819 ******************************************************************************/
822 AcpiInstallGpeBlock (
823 ACPI_HANDLE GpeDevice,
824 ACPI_GENERIC_ADDRESS *GpeBlockAddress,
825 UINT32 RegisterCount,
826 UINT32 InterruptNumber)
829 ACPI_OPERAND_OBJECT *ObjDesc;
830 ACPI_NAMESPACE_NODE *Node;
831 ACPI_GPE_BLOCK_INFO *GpeBlock;
834 ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock);
838 (!GpeBlockAddress) ||
841 return_ACPI_STATUS (AE_BAD_PARAMETER);
844 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
845 if (ACPI_FAILURE (Status))
847 return_ACPI_STATUS (Status);
850 Node = AcpiNsValidateHandle (GpeDevice);
853 Status = AE_BAD_PARAMETER;
857 /* Validate the parent device */
859 if (Node->Type != ACPI_TYPE_DEVICE)
867 Status = AE_ALREADY_EXISTS;
872 * For user-installed GPE Block Devices, the GpeBlockBaseNumber
875 Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress->Address,
876 GpeBlockAddress->SpaceId, RegisterCount,
877 0, InterruptNumber, &GpeBlock);
878 if (ACPI_FAILURE (Status))
883 /* Install block in the DeviceObject attached to the node */
885 ObjDesc = AcpiNsGetAttachedObject (Node);
889 * No object, create a new one (Device nodes do not always have
890 * an attached object)
892 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE);
895 Status = AE_NO_MEMORY;
899 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE);
901 /* Remove local reference to the object */
903 AcpiUtRemoveReference (ObjDesc);
904 if (ACPI_FAILURE (Status))
910 /* Now install the GPE block in the DeviceObject */
912 ObjDesc->Device.GpeBlock = GpeBlock;
916 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
917 return_ACPI_STATUS (Status);
920 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock)
923 /*******************************************************************************
925 * FUNCTION: AcpiRemoveGpeBlock
927 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
931 * DESCRIPTION: Remove a previously installed block of GPE registers
933 ******************************************************************************/
937 ACPI_HANDLE GpeDevice)
939 ACPI_OPERAND_OBJECT *ObjDesc;
941 ACPI_NAMESPACE_NODE *Node;
944 ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock);
949 return_ACPI_STATUS (AE_BAD_PARAMETER);
952 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
953 if (ACPI_FAILURE (Status))
955 return_ACPI_STATUS (Status);
958 Node = AcpiNsValidateHandle (GpeDevice);
961 Status = AE_BAD_PARAMETER;
965 /* Validate the parent device */
967 if (Node->Type != ACPI_TYPE_DEVICE)
973 /* Get the DeviceObject attached to the node */
975 ObjDesc = AcpiNsGetAttachedObject (Node);
977 !ObjDesc->Device.GpeBlock)
979 return_ACPI_STATUS (AE_NULL_OBJECT);
982 /* Delete the GPE block (but not the DeviceObject) */
984 Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock);
985 if (ACPI_SUCCESS (Status))
987 ObjDesc->Device.GpeBlock = NULL;
991 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
992 return_ACPI_STATUS (Status);
995 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock)
998 /*******************************************************************************
1000 * FUNCTION: AcpiGetGpeDevice
1002 * PARAMETERS: Index - System GPE index (0-CurrentGpeCount)
1003 * GpeDevice - Where the parent GPE Device is returned
1007 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
1008 * gpe device indicates that the gpe number is contained in one of
1009 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
1011 ******************************************************************************/
1016 ACPI_HANDLE *GpeDevice)
1018 ACPI_GPE_DEVICE_INFO Info;
1022 ACPI_FUNCTION_TRACE (AcpiGetGpeDevice);
1027 return_ACPI_STATUS (AE_BAD_PARAMETER);
1030 if (Index >= AcpiCurrentGpeCount)
1032 return_ACPI_STATUS (AE_NOT_EXIST);
1035 /* Setup and walk the GPE list */
1038 Info.Status = AE_NOT_EXIST;
1039 Info.GpeDevice = NULL;
1040 Info.NextBlockBaseIndex = 0;
1042 Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info);
1043 if (ACPI_FAILURE (Status))
1045 return_ACPI_STATUS (Status);
1048 *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
1049 return_ACPI_STATUS (Info.Status);
1052 ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice)
1054 #endif /* !ACPI_REDUCED_HARDWARE */