1 /******************************************************************************
3 * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************/
117 #define __EVXFEVNT_C__
119 #include <contrib/dev/acpica/include/acpi.h>
120 #include <contrib/dev/acpica/include/accommon.h>
121 #include <contrib/dev/acpica/include/acevents.h>
122 #include <contrib/dev/acpica/include/acnamesp.h>
123 #include <contrib/dev/acpica/include/actables.h>
125 #define _COMPONENT ACPI_EVENTS
126 ACPI_MODULE_NAME ("evxfevnt")
128 /* Local prototypes */
132 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
133 ACPI_GPE_BLOCK_INFO *GpeBlock,
137 /*******************************************************************************
139 * FUNCTION: AcpiEnable
145 * DESCRIPTION: Transfers the system into ACPI mode.
147 ******************************************************************************/
153 ACPI_STATUS Status = AE_OK;
156 ACPI_FUNCTION_TRACE (AcpiEnable);
159 /* ACPI tables must be present */
161 if (!AcpiTbTablesLoaded ())
163 return_ACPI_STATUS (AE_NO_ACPI_TABLES);
166 /* Check current mode */
168 if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI)
170 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
174 /* Transition to ACPI mode */
176 Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI);
177 if (ACPI_FAILURE (Status))
179 ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode"));
180 return_ACPI_STATUS (Status);
183 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
184 "Transition to ACPI mode successful\n"));
187 return_ACPI_STATUS (Status);
190 ACPI_EXPORT_SYMBOL (AcpiEnable)
193 /*******************************************************************************
195 * FUNCTION: AcpiDisable
201 * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
203 ******************************************************************************/
209 ACPI_STATUS Status = AE_OK;
212 ACPI_FUNCTION_TRACE (AcpiDisable);
215 if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY)
217 ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
218 "System is already in legacy (non-ACPI) mode\n"));
222 /* Transition to LEGACY mode */
224 Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY);
226 if (ACPI_FAILURE (Status))
228 ACPI_ERROR ((AE_INFO,
229 "Could not exit ACPI mode to legacy mode"));
230 return_ACPI_STATUS (Status);
233 ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
236 return_ACPI_STATUS (Status);
239 ACPI_EXPORT_SYMBOL (AcpiDisable)
242 /*******************************************************************************
244 * FUNCTION: AcpiEnableEvent
246 * PARAMETERS: Event - The fixed eventto be enabled
251 * DESCRIPTION: Enable an ACPI event (fixed)
253 ******************************************************************************/
260 ACPI_STATUS Status = AE_OK;
264 ACPI_FUNCTION_TRACE (AcpiEnableEvent);
267 /* Decode the Fixed Event */
269 if (Event > ACPI_EVENT_MAX)
271 return_ACPI_STATUS (AE_BAD_PARAMETER);
275 * Enable the requested fixed event (by writing a one to the enable
278 Status = AcpiWriteBitRegister (
279 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
281 if (ACPI_FAILURE (Status))
283 return_ACPI_STATUS (Status);
286 /* Make sure that the hardware responded */
288 Status = AcpiReadBitRegister (
289 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
290 if (ACPI_FAILURE (Status))
292 return_ACPI_STATUS (Status);
297 ACPI_ERROR ((AE_INFO,
298 "Could not enable %s event", AcpiUtGetEventName (Event)));
299 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
302 return_ACPI_STATUS (Status);
305 ACPI_EXPORT_SYMBOL (AcpiEnableEvent)
308 /*******************************************************************************
310 * FUNCTION: AcpiEnableGpe
312 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
313 * GpeNumber - GPE level within the GPE block
314 * GpeType - ACPI_GPE_TYPE_RUNTIME or ACPI_GPE_TYPE_WAKE
319 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
320 * hardware-enabled (for runtime GPEs), or the GPE register mask
321 * is updated (for wake GPEs).
323 ******************************************************************************/
327 ACPI_HANDLE GpeDevice,
331 ACPI_STATUS Status = AE_OK;
332 ACPI_GPE_EVENT_INFO *GpeEventInfo;
333 ACPI_CPU_FLAGS Flags;
336 ACPI_FUNCTION_TRACE (AcpiEnableGpe);
339 /* Parameter validation */
341 if (!GpeType || (GpeType & ~ACPI_GPE_TYPE_WAKE_RUN))
343 return_ACPI_STATUS (AE_BAD_PARAMETER);
346 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
348 /* Ensure that we have a valid GPE number */
350 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
353 Status = AE_BAD_PARAMETER;
357 if (GpeType & ACPI_GPE_TYPE_RUNTIME)
359 if (GpeEventInfo->RuntimeCount == ACPI_UINT8_MAX)
361 Status = AE_LIMIT; /* Too many references */
365 GpeEventInfo->RuntimeCount++;
366 if (GpeEventInfo->RuntimeCount == 1)
368 Status = AcpiEvEnableGpe (GpeEventInfo);
369 if (ACPI_FAILURE (Status))
371 GpeEventInfo->RuntimeCount--;
377 if (GpeType & ACPI_GPE_TYPE_WAKE)
379 /* The GPE must have the ability to wake the system */
381 if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE))
387 if (GpeEventInfo->WakeupCount == ACPI_UINT8_MAX)
389 Status = AE_LIMIT; /* Too many references */
394 * Update the enable mask on the first wakeup reference. Wake GPEs
395 * are only hardware-enabled just before sleeping.
397 GpeEventInfo->WakeupCount++;
398 if (GpeEventInfo->WakeupCount == 1)
400 (void) AcpiEvUpdateGpeEnableMasks (GpeEventInfo);
405 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
406 return_ACPI_STATUS (Status);
409 ACPI_EXPORT_SYMBOL (AcpiEnableGpe)
412 /*******************************************************************************
414 * FUNCTION: AcpiDisableGpe
416 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
417 * GpeNumber - GPE level within the GPE block
418 * GpeType - ACPI_GPE_TYPE_RUNTIME or ACPI_GPE_TYPE_WAKE
423 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
424 * removed, only then is the GPE disabled (for runtime GPEs), or
425 * the GPE mask bit disabled (for wake GPEs)
427 ******************************************************************************/
431 ACPI_HANDLE GpeDevice,
435 ACPI_STATUS Status = AE_OK;
436 ACPI_GPE_EVENT_INFO *GpeEventInfo;
437 ACPI_CPU_FLAGS Flags;
440 ACPI_FUNCTION_TRACE (AcpiDisableGpe);
443 /* Parameter validation */
445 if (!GpeType || (GpeType & ~ACPI_GPE_TYPE_WAKE_RUN))
447 return_ACPI_STATUS (AE_BAD_PARAMETER);
450 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
452 /* Ensure that we have a valid GPE number */
454 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
457 Status = AE_BAD_PARAMETER;
461 /* Hardware-disable a runtime GPE on removal of the last reference */
463 if (GpeType & ACPI_GPE_TYPE_RUNTIME)
465 if (!GpeEventInfo->RuntimeCount)
467 Status = AE_LIMIT; /* There are no references to remove */
471 GpeEventInfo->RuntimeCount--;
472 if (!GpeEventInfo->RuntimeCount)
474 Status = AcpiEvDisableGpe (GpeEventInfo);
475 if (ACPI_FAILURE (Status))
477 GpeEventInfo->RuntimeCount++;
484 * Update masks for wake GPE on removal of the last reference.
485 * No need to hardware-disable wake GPEs here, they are not currently
488 if (GpeType & ACPI_GPE_TYPE_WAKE)
490 if (!GpeEventInfo->WakeupCount)
492 Status = AE_LIMIT; /* There are no references to remove */
496 GpeEventInfo->WakeupCount--;
497 if (!GpeEventInfo->WakeupCount)
499 (void) AcpiEvUpdateGpeEnableMasks (GpeEventInfo);
505 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
506 return_ACPI_STATUS (Status);
509 ACPI_EXPORT_SYMBOL (AcpiDisableGpe)
512 /*******************************************************************************
514 * FUNCTION: AcpiSetGpe
516 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
517 * GpeNumber - GPE level within the GPE block
518 * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
522 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
523 * the reference count mechanism used in the AcpiEnableGpe and
524 * AcpiDisableGpe interfaces -- and should be used with care.
526 * Note: Typically used to disable a runtime GPE for short period of time,
527 * then re-enable it, without disturbing the existing reference counts. This
528 * is useful, for example, in the Embedded Controller (EC) driver.
530 ******************************************************************************/
534 ACPI_HANDLE GpeDevice,
538 ACPI_GPE_EVENT_INFO *GpeEventInfo;
540 ACPI_CPU_FLAGS Flags;
543 ACPI_FUNCTION_TRACE (AcpiSetGpe);
546 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
548 /* Ensure that we have a valid GPE number */
550 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
553 Status = AE_BAD_PARAMETER;
557 /* Perform the action */
561 case ACPI_GPE_ENABLE:
562 Status = AcpiEvEnableGpe (GpeEventInfo);
565 case ACPI_GPE_DISABLE:
566 Status = AcpiEvDisableGpe (GpeEventInfo);
570 Status = AE_BAD_PARAMETER;
575 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
576 return_ACPI_STATUS (Status);
579 ACPI_EXPORT_SYMBOL (AcpiSetGpe)
582 /*******************************************************************************
584 * FUNCTION: AcpiDisableEvent
586 * PARAMETERS: Event - The fixed eventto be enabled
591 * DESCRIPTION: Disable an ACPI event (fixed)
593 ******************************************************************************/
600 ACPI_STATUS Status = AE_OK;
604 ACPI_FUNCTION_TRACE (AcpiDisableEvent);
607 /* Decode the Fixed Event */
609 if (Event > ACPI_EVENT_MAX)
611 return_ACPI_STATUS (AE_BAD_PARAMETER);
615 * Disable the requested fixed event (by writing a zero to the enable
618 Status = AcpiWriteBitRegister (
619 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
621 if (ACPI_FAILURE (Status))
623 return_ACPI_STATUS (Status);
626 Status = AcpiReadBitRegister (
627 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
628 if (ACPI_FAILURE (Status))
630 return_ACPI_STATUS (Status);
635 ACPI_ERROR ((AE_INFO,
636 "Could not disable %s events", AcpiUtGetEventName (Event)));
637 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
640 return_ACPI_STATUS (Status);
643 ACPI_EXPORT_SYMBOL (AcpiDisableEvent)
646 /*******************************************************************************
648 * FUNCTION: AcpiClearEvent
650 * PARAMETERS: Event - The fixed event to be cleared
654 * DESCRIPTION: Clear an ACPI event (fixed)
656 ******************************************************************************/
662 ACPI_STATUS Status = AE_OK;
665 ACPI_FUNCTION_TRACE (AcpiClearEvent);
668 /* Decode the Fixed Event */
670 if (Event > ACPI_EVENT_MAX)
672 return_ACPI_STATUS (AE_BAD_PARAMETER);
676 * Clear the requested fixed event (By writing a one to the status
679 Status = AcpiWriteBitRegister (
680 AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
683 return_ACPI_STATUS (Status);
686 ACPI_EXPORT_SYMBOL (AcpiClearEvent)
689 /*******************************************************************************
691 * FUNCTION: AcpiClearGpe
693 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
694 * GpeNumber - GPE level within the GPE block
698 * DESCRIPTION: Clear an ACPI event (general purpose)
700 ******************************************************************************/
704 ACPI_HANDLE GpeDevice,
707 ACPI_STATUS Status = AE_OK;
708 ACPI_GPE_EVENT_INFO *GpeEventInfo;
709 ACPI_CPU_FLAGS Flags;
712 ACPI_FUNCTION_TRACE (AcpiClearGpe);
715 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
717 /* Ensure that we have a valid GPE number */
719 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
722 Status = AE_BAD_PARAMETER;
726 Status = AcpiHwClearGpe (GpeEventInfo);
729 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
730 return_ACPI_STATUS (Status);
733 ACPI_EXPORT_SYMBOL (AcpiClearGpe)
736 /*******************************************************************************
738 * FUNCTION: AcpiGetEventStatus
740 * PARAMETERS: Event - The fixed event
741 * EventStatus - Where the current status of the event will
746 * DESCRIPTION: Obtains and returns the current status of the event
748 ******************************************************************************/
753 ACPI_EVENT_STATUS *EventStatus)
755 ACPI_STATUS Status = AE_OK;
758 ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
763 return_ACPI_STATUS (AE_BAD_PARAMETER);
766 /* Decode the Fixed Event */
768 if (Event > ACPI_EVENT_MAX)
770 return_ACPI_STATUS (AE_BAD_PARAMETER);
773 /* Get the status of the requested fixed event */
775 Status = AcpiReadBitRegister (
776 AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus);
778 return_ACPI_STATUS (Status);
781 ACPI_EXPORT_SYMBOL (AcpiGetEventStatus)
784 /*******************************************************************************
786 * FUNCTION: AcpiGetGpeStatus
788 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
789 * GpeNumber - GPE level within the GPE block
790 * EventStatus - Where the current status of the event will
795 * DESCRIPTION: Get status of an event (general purpose)
797 ******************************************************************************/
801 ACPI_HANDLE GpeDevice,
803 ACPI_EVENT_STATUS *EventStatus)
805 ACPI_STATUS Status = AE_OK;
806 ACPI_GPE_EVENT_INFO *GpeEventInfo;
807 ACPI_CPU_FLAGS Flags;
810 ACPI_FUNCTION_TRACE (AcpiGetGpeStatus);
813 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
815 /* Ensure that we have a valid GPE number */
817 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
820 Status = AE_BAD_PARAMETER;
824 /* Obtain status on the requested GPE number */
826 Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
829 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
830 return_ACPI_STATUS (Status);
833 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus)
836 /*******************************************************************************
838 * FUNCTION: AcpiInstallGpeBlock
840 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
841 * GpeBlockAddress - Address and SpaceID
842 * RegisterCount - Number of GPE register pairs in the block
843 * InterruptNumber - H/W interrupt for the block
847 * DESCRIPTION: Create and Install a block of GPE registers
849 ******************************************************************************/
852 AcpiInstallGpeBlock (
853 ACPI_HANDLE GpeDevice,
854 ACPI_GENERIC_ADDRESS *GpeBlockAddress,
855 UINT32 RegisterCount,
856 UINT32 InterruptNumber)
859 ACPI_OPERAND_OBJECT *ObjDesc;
860 ACPI_NAMESPACE_NODE *Node;
861 ACPI_GPE_BLOCK_INFO *GpeBlock;
864 ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock);
868 (!GpeBlockAddress) ||
871 return_ACPI_STATUS (AE_BAD_PARAMETER);
874 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
875 if (ACPI_FAILURE (Status))
880 Node = AcpiNsValidateHandle (GpeDevice);
883 Status = AE_BAD_PARAMETER;
888 * For user-installed GPE Block Devices, the GpeBlockBaseNumber
891 Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount,
892 0, InterruptNumber, &GpeBlock);
893 if (ACPI_FAILURE (Status))
898 /* Install block in the DeviceObject attached to the node */
900 ObjDesc = AcpiNsGetAttachedObject (Node);
904 * No object, create a new one (Device nodes do not always have
905 * an attached object)
907 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE);
910 Status = AE_NO_MEMORY;
914 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE);
916 /* Remove local reference to the object */
918 AcpiUtRemoveReference (ObjDesc);
919 if (ACPI_FAILURE (Status))
925 /* Now install the GPE block in the DeviceObject */
927 ObjDesc->Device.GpeBlock = GpeBlock;
929 /* Run the _PRW methods and enable the runtime GPEs in the new block */
931 Status = AcpiEvInitializeGpeBlock (Node, GpeBlock);
935 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
936 return_ACPI_STATUS (Status);
939 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock)
942 /*******************************************************************************
944 * FUNCTION: AcpiRemoveGpeBlock
946 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
950 * DESCRIPTION: Remove a previously installed block of GPE registers
952 ******************************************************************************/
956 ACPI_HANDLE GpeDevice)
958 ACPI_OPERAND_OBJECT *ObjDesc;
960 ACPI_NAMESPACE_NODE *Node;
963 ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock);
968 return_ACPI_STATUS (AE_BAD_PARAMETER);
971 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
972 if (ACPI_FAILURE (Status))
977 Node = AcpiNsValidateHandle (GpeDevice);
980 Status = AE_BAD_PARAMETER;
984 /* Get the DeviceObject attached to the node */
986 ObjDesc = AcpiNsGetAttachedObject (Node);
988 !ObjDesc->Device.GpeBlock)
990 return_ACPI_STATUS (AE_NULL_OBJECT);
993 /* Delete the GPE block (but not the DeviceObject) */
995 Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock);
996 if (ACPI_SUCCESS (Status))
998 ObjDesc->Device.GpeBlock = NULL;
1002 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
1003 return_ACPI_STATUS (Status);
1006 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock)
1009 /*******************************************************************************
1011 * FUNCTION: AcpiGetGpeDevice
1013 * PARAMETERS: Index - System GPE index (0-CurrentGpeCount)
1014 * GpeDevice - Where the parent GPE Device is returned
1018 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
1019 * gpe device indicates that the gpe number is contained in one of
1020 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
1022 ******************************************************************************/
1027 ACPI_HANDLE *GpeDevice)
1029 ACPI_GPE_DEVICE_INFO Info;
1033 ACPI_FUNCTION_TRACE (AcpiGetGpeDevice);
1038 return_ACPI_STATUS (AE_BAD_PARAMETER);
1041 if (Index >= AcpiCurrentGpeCount)
1043 return_ACPI_STATUS (AE_NOT_EXIST);
1046 /* Setup and walk the GPE list */
1049 Info.Status = AE_NOT_EXIST;
1050 Info.GpeDevice = NULL;
1051 Info.NextBlockBaseIndex = 0;
1053 Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info);
1054 if (ACPI_FAILURE (Status))
1056 return_ACPI_STATUS (Status);
1059 *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
1060 return_ACPI_STATUS (Info.Status);
1063 ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice)
1066 /*******************************************************************************
1068 * FUNCTION: AcpiEvGetGpeDevice
1070 * PARAMETERS: GPE_WALK_CALLBACK
1074 * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE
1075 * block device. NULL if the GPE is one of the FADT-defined GPEs.
1077 ******************************************************************************/
1080 AcpiEvGetGpeDevice (
1081 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
1082 ACPI_GPE_BLOCK_INFO *GpeBlock,
1085 ACPI_GPE_DEVICE_INFO *Info = Context;
1088 /* Increment Index by the number of GPEs in this block */
1090 Info->NextBlockBaseIndex += GpeBlock->GpeCount;
1092 if (Info->Index < Info->NextBlockBaseIndex)
1095 * The GPE index is within this block, get the node. Leave the node
1096 * NULL for the FADT-defined GPEs
1098 if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE)
1100 Info->GpeDevice = GpeBlock->Node;
1103 Info->Status = AE_OK;
1104 return (AE_CTRL_END);
1111 /******************************************************************************
1113 * FUNCTION: AcpiDisableAllGpes
1119 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
1121 ******************************************************************************/
1124 AcpiDisableAllGpes (
1130 ACPI_FUNCTION_TRACE (AcpiDisableAllGpes);
1133 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
1134 if (ACPI_FAILURE (Status))
1136 return_ACPI_STATUS (Status);
1139 Status = AcpiHwDisableAllGpes ();
1140 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
1142 return_ACPI_STATUS (Status);
1146 /******************************************************************************
1148 * FUNCTION: AcpiEnableAllRuntimeGpes
1154 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
1156 ******************************************************************************/
1159 AcpiEnableAllRuntimeGpes (
1165 ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes);
1168 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
1169 if (ACPI_FAILURE (Status))
1171 return_ACPI_STATUS (Status);
1174 Status = AcpiHwEnableAllRuntimeGpes ();
1175 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
1177 return_ACPI_STATUS (Status);