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: AcpiGpeWakeup
312 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
313 * GpeNumber - GPE level within the GPE block
314 * Action - Enable or Disable
318 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit.
320 ******************************************************************************/
324 ACPI_HANDLE GpeDevice,
328 ACPI_STATUS Status = AE_OK;
329 ACPI_GPE_EVENT_INFO *GpeEventInfo;
330 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo;
331 ACPI_CPU_FLAGS Flags;
335 ACPI_FUNCTION_TRACE (AcpiGpeWakeup);
338 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
340 /* Ensure that we have a valid GPE number */
342 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
345 Status = AE_BAD_PARAMETER;
349 GpeRegisterInfo = GpeEventInfo->RegisterInfo;
350 if (!GpeRegisterInfo)
352 Status = AE_NOT_EXIST;
356 RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo);
358 /* Perform the action */
362 case ACPI_GPE_ENABLE:
363 ACPI_SET_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
366 case ACPI_GPE_DISABLE:
367 ACPI_CLEAR_BIT (GpeRegisterInfo->EnableForWake, (UINT8) RegisterBit);
371 ACPI_ERROR ((AE_INFO, "%u, Invalid action", Action));
372 Status = AE_BAD_PARAMETER;
377 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
378 return_ACPI_STATUS (Status);
381 ACPI_EXPORT_SYMBOL (AcpiGpeWakeup)
384 /*******************************************************************************
386 * FUNCTION: AcpiEnableGpe
388 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
389 * GpeNumber - GPE level within the GPE block
393 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
396 ******************************************************************************/
400 ACPI_HANDLE GpeDevice,
403 ACPI_STATUS Status = AE_OK;
404 ACPI_GPE_EVENT_INFO *GpeEventInfo;
405 ACPI_CPU_FLAGS Flags;
408 ACPI_FUNCTION_TRACE (AcpiEnableGpe);
411 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
413 /* Ensure that we have a valid GPE number */
415 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
418 Status = AE_BAD_PARAMETER;
422 if (GpeEventInfo->RuntimeCount == ACPI_UINT8_MAX)
424 Status = AE_LIMIT; /* Too many references */
428 GpeEventInfo->RuntimeCount++;
429 if (GpeEventInfo->RuntimeCount == 1)
431 Status = AcpiEvUpdateGpeEnableMask (GpeEventInfo);
432 if (ACPI_SUCCESS (Status))
434 Status = AcpiEvEnableGpe (GpeEventInfo);
436 if (ACPI_FAILURE (Status))
438 GpeEventInfo->RuntimeCount--;
443 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
444 return_ACPI_STATUS (Status);
447 ACPI_EXPORT_SYMBOL (AcpiEnableGpe)
450 /*******************************************************************************
452 * FUNCTION: AcpiDisableGpe
454 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
455 * GpeNumber - GPE level within the GPE block
459 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
460 * removed, only then is the GPE disabled (for runtime GPEs), or
461 * the GPE mask bit disabled (for wake GPEs)
463 ******************************************************************************/
467 ACPI_HANDLE GpeDevice,
470 ACPI_STATUS Status = AE_OK;
471 ACPI_GPE_EVENT_INFO *GpeEventInfo;
472 ACPI_CPU_FLAGS Flags;
475 ACPI_FUNCTION_TRACE (AcpiDisableGpe);
478 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
480 /* Ensure that we have a valid GPE number */
482 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
485 Status = AE_BAD_PARAMETER;
489 /* Hardware-disable a runtime GPE on removal of the last reference */
491 if (!GpeEventInfo->RuntimeCount)
493 Status = AE_LIMIT; /* There are no references to remove */
497 GpeEventInfo->RuntimeCount--;
498 if (!GpeEventInfo->RuntimeCount)
500 Status = AcpiEvUpdateGpeEnableMask (GpeEventInfo);
501 if (ACPI_SUCCESS (Status))
503 Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
505 if (ACPI_FAILURE (Status))
507 GpeEventInfo->RuntimeCount++;
512 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
513 return_ACPI_STATUS (Status);
516 ACPI_EXPORT_SYMBOL (AcpiDisableGpe)
519 /*******************************************************************************
521 * FUNCTION: AcpiSetGpe
523 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
524 * GpeNumber - GPE level within the GPE block
525 * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
529 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
530 * the reference count mechanism used in the AcpiEnableGpe and
531 * AcpiDisableGpe interfaces -- and should be used with care.
533 * Note: Typically used to disable a runtime GPE for short period of time,
534 * then re-enable it, without disturbing the existing reference counts. This
535 * is useful, for example, in the Embedded Controller (EC) driver.
537 ******************************************************************************/
541 ACPI_HANDLE GpeDevice,
545 ACPI_GPE_EVENT_INFO *GpeEventInfo;
547 ACPI_CPU_FLAGS Flags;
550 ACPI_FUNCTION_TRACE (AcpiSetGpe);
553 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
555 /* Ensure that we have a valid GPE number */
557 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
560 Status = AE_BAD_PARAMETER;
564 /* Perform the action */
568 case ACPI_GPE_ENABLE:
569 Status = AcpiEvEnableGpe (GpeEventInfo);
572 case ACPI_GPE_DISABLE:
573 Status = AcpiHwLowSetGpe (GpeEventInfo, ACPI_GPE_DISABLE);
577 Status = AE_BAD_PARAMETER;
582 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
583 return_ACPI_STATUS (Status);
586 ACPI_EXPORT_SYMBOL (AcpiSetGpe)
589 /*******************************************************************************
591 * FUNCTION: AcpiDisableEvent
593 * PARAMETERS: Event - The fixed eventto be enabled
598 * DESCRIPTION: Disable an ACPI event (fixed)
600 ******************************************************************************/
607 ACPI_STATUS Status = AE_OK;
611 ACPI_FUNCTION_TRACE (AcpiDisableEvent);
614 /* Decode the Fixed Event */
616 if (Event > ACPI_EVENT_MAX)
618 return_ACPI_STATUS (AE_BAD_PARAMETER);
622 * Disable the requested fixed event (by writing a zero to the enable
625 Status = AcpiWriteBitRegister (
626 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
628 if (ACPI_FAILURE (Status))
630 return_ACPI_STATUS (Status);
633 Status = AcpiReadBitRegister (
634 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
635 if (ACPI_FAILURE (Status))
637 return_ACPI_STATUS (Status);
642 ACPI_ERROR ((AE_INFO,
643 "Could not disable %s events", AcpiUtGetEventName (Event)));
644 return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
647 return_ACPI_STATUS (Status);
650 ACPI_EXPORT_SYMBOL (AcpiDisableEvent)
653 /*******************************************************************************
655 * FUNCTION: AcpiClearEvent
657 * PARAMETERS: Event - The fixed event to be cleared
661 * DESCRIPTION: Clear an ACPI event (fixed)
663 ******************************************************************************/
669 ACPI_STATUS Status = AE_OK;
672 ACPI_FUNCTION_TRACE (AcpiClearEvent);
675 /* Decode the Fixed Event */
677 if (Event > ACPI_EVENT_MAX)
679 return_ACPI_STATUS (AE_BAD_PARAMETER);
683 * Clear the requested fixed event (By writing a one to the status
686 Status = AcpiWriteBitRegister (
687 AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
690 return_ACPI_STATUS (Status);
693 ACPI_EXPORT_SYMBOL (AcpiClearEvent)
696 /*******************************************************************************
698 * FUNCTION: AcpiClearGpe
700 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
701 * GpeNumber - GPE level within the GPE block
705 * DESCRIPTION: Clear an ACPI event (general purpose)
707 ******************************************************************************/
711 ACPI_HANDLE GpeDevice,
714 ACPI_STATUS Status = AE_OK;
715 ACPI_GPE_EVENT_INFO *GpeEventInfo;
716 ACPI_CPU_FLAGS Flags;
719 ACPI_FUNCTION_TRACE (AcpiClearGpe);
722 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
724 /* Ensure that we have a valid GPE number */
726 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
729 Status = AE_BAD_PARAMETER;
733 Status = AcpiHwClearGpe (GpeEventInfo);
736 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
737 return_ACPI_STATUS (Status);
740 ACPI_EXPORT_SYMBOL (AcpiClearGpe)
743 /*******************************************************************************
745 * FUNCTION: AcpiGetEventStatus
747 * PARAMETERS: Event - The fixed event
748 * EventStatus - Where the current status of the event will
753 * DESCRIPTION: Obtains and returns the current status of the event
755 ******************************************************************************/
760 ACPI_EVENT_STATUS *EventStatus)
762 ACPI_STATUS Status = AE_OK;
765 ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
770 return_ACPI_STATUS (AE_BAD_PARAMETER);
773 /* Decode the Fixed Event */
775 if (Event > ACPI_EVENT_MAX)
777 return_ACPI_STATUS (AE_BAD_PARAMETER);
780 /* Get the status of the requested fixed event */
782 Status = AcpiReadBitRegister (
783 AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus);
785 return_ACPI_STATUS (Status);
788 ACPI_EXPORT_SYMBOL (AcpiGetEventStatus)
791 /*******************************************************************************
793 * FUNCTION: AcpiGetGpeStatus
795 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
796 * GpeNumber - GPE level within the GPE block
797 * EventStatus - Where the current status of the event will
802 * DESCRIPTION: Get status of an event (general purpose)
804 ******************************************************************************/
808 ACPI_HANDLE GpeDevice,
810 ACPI_EVENT_STATUS *EventStatus)
812 ACPI_STATUS Status = AE_OK;
813 ACPI_GPE_EVENT_INFO *GpeEventInfo;
814 ACPI_CPU_FLAGS Flags;
817 ACPI_FUNCTION_TRACE (AcpiGetGpeStatus);
820 Flags = AcpiOsAcquireLock (AcpiGbl_GpeLock);
822 /* Ensure that we have a valid GPE number */
824 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
827 Status = AE_BAD_PARAMETER;
831 /* Obtain status on the requested GPE number */
833 Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
836 AcpiOsReleaseLock (AcpiGbl_GpeLock, Flags);
837 return_ACPI_STATUS (Status);
840 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus)
843 /*******************************************************************************
845 * FUNCTION: AcpiInstallGpeBlock
847 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
848 * GpeBlockAddress - Address and SpaceID
849 * RegisterCount - Number of GPE register pairs in the block
850 * InterruptNumber - H/W interrupt for the block
854 * DESCRIPTION: Create and Install a block of GPE registers
856 ******************************************************************************/
859 AcpiInstallGpeBlock (
860 ACPI_HANDLE GpeDevice,
861 ACPI_GENERIC_ADDRESS *GpeBlockAddress,
862 UINT32 RegisterCount,
863 UINT32 InterruptNumber)
866 ACPI_OPERAND_OBJECT *ObjDesc;
867 ACPI_NAMESPACE_NODE *Node;
868 ACPI_GPE_BLOCK_INFO *GpeBlock;
871 ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock);
875 (!GpeBlockAddress) ||
878 return_ACPI_STATUS (AE_BAD_PARAMETER);
881 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
882 if (ACPI_FAILURE (Status))
887 Node = AcpiNsValidateHandle (GpeDevice);
890 Status = AE_BAD_PARAMETER;
895 * For user-installed GPE Block Devices, the GpeBlockBaseNumber
898 Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount,
899 0, InterruptNumber, &GpeBlock);
900 if (ACPI_FAILURE (Status))
905 /* Install block in the DeviceObject attached to the node */
907 ObjDesc = AcpiNsGetAttachedObject (Node);
911 * No object, create a new one (Device nodes do not always have
912 * an attached object)
914 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE);
917 Status = AE_NO_MEMORY;
921 Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE);
923 /* Remove local reference to the object */
925 AcpiUtRemoveReference (ObjDesc);
926 if (ACPI_FAILURE (Status))
932 /* Now install the GPE block in the DeviceObject */
934 ObjDesc->Device.GpeBlock = GpeBlock;
936 /* Run the _PRW methods and enable the runtime GPEs in the new block */
938 Status = AcpiEvInitializeGpeBlock (Node, GpeBlock);
942 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
943 return_ACPI_STATUS (Status);
946 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock)
949 /*******************************************************************************
951 * FUNCTION: AcpiRemoveGpeBlock
953 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
957 * DESCRIPTION: Remove a previously installed block of GPE registers
959 ******************************************************************************/
963 ACPI_HANDLE GpeDevice)
965 ACPI_OPERAND_OBJECT *ObjDesc;
967 ACPI_NAMESPACE_NODE *Node;
970 ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock);
975 return_ACPI_STATUS (AE_BAD_PARAMETER);
978 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
979 if (ACPI_FAILURE (Status))
984 Node = AcpiNsValidateHandle (GpeDevice);
987 Status = AE_BAD_PARAMETER;
991 /* Get the DeviceObject attached to the node */
993 ObjDesc = AcpiNsGetAttachedObject (Node);
995 !ObjDesc->Device.GpeBlock)
997 return_ACPI_STATUS (AE_NULL_OBJECT);
1000 /* Delete the GPE block (but not the DeviceObject) */
1002 Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock);
1003 if (ACPI_SUCCESS (Status))
1005 ObjDesc->Device.GpeBlock = NULL;
1009 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
1010 return_ACPI_STATUS (Status);
1013 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock)
1016 /*******************************************************************************
1018 * FUNCTION: AcpiGetGpeDevice
1020 * PARAMETERS: Index - System GPE index (0-CurrentGpeCount)
1021 * GpeDevice - Where the parent GPE Device is returned
1025 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
1026 * gpe device indicates that the gpe number is contained in one of
1027 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
1029 ******************************************************************************/
1034 ACPI_HANDLE *GpeDevice)
1036 ACPI_GPE_DEVICE_INFO Info;
1040 ACPI_FUNCTION_TRACE (AcpiGetGpeDevice);
1045 return_ACPI_STATUS (AE_BAD_PARAMETER);
1048 if (Index >= AcpiCurrentGpeCount)
1050 return_ACPI_STATUS (AE_NOT_EXIST);
1053 /* Setup and walk the GPE list */
1056 Info.Status = AE_NOT_EXIST;
1057 Info.GpeDevice = NULL;
1058 Info.NextBlockBaseIndex = 0;
1060 Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info);
1061 if (ACPI_FAILURE (Status))
1063 return_ACPI_STATUS (Status);
1066 *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
1067 return_ACPI_STATUS (Info.Status);
1070 ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice)
1073 /*******************************************************************************
1075 * FUNCTION: AcpiEvGetGpeDevice
1077 * PARAMETERS: GPE_WALK_CALLBACK
1081 * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE
1082 * block device. NULL if the GPE is one of the FADT-defined GPEs.
1084 ******************************************************************************/
1087 AcpiEvGetGpeDevice (
1088 ACPI_GPE_XRUPT_INFO *GpeXruptInfo,
1089 ACPI_GPE_BLOCK_INFO *GpeBlock,
1092 ACPI_GPE_DEVICE_INFO *Info = Context;
1095 /* Increment Index by the number of GPEs in this block */
1097 Info->NextBlockBaseIndex += GpeBlock->GpeCount;
1099 if (Info->Index < Info->NextBlockBaseIndex)
1102 * The GPE index is within this block, get the node. Leave the node
1103 * NULL for the FADT-defined GPEs
1105 if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE)
1107 Info->GpeDevice = GpeBlock->Node;
1110 Info->Status = AE_OK;
1111 return (AE_CTRL_END);
1118 /******************************************************************************
1120 * FUNCTION: AcpiDisableAllGpes
1126 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
1128 ******************************************************************************/
1131 AcpiDisableAllGpes (
1137 ACPI_FUNCTION_TRACE (AcpiDisableAllGpes);
1140 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
1141 if (ACPI_FAILURE (Status))
1143 return_ACPI_STATUS (Status);
1146 Status = AcpiHwDisableAllGpes ();
1147 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
1149 return_ACPI_STATUS (Status);
1153 /******************************************************************************
1155 * FUNCTION: AcpiEnableAllRuntimeGpes
1161 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
1163 ******************************************************************************/
1166 AcpiEnableAllRuntimeGpes (
1172 ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes);
1175 Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
1176 if (ACPI_FAILURE (Status))
1178 return_ACPI_STATUS (Status);
1181 Status = AcpiHwEnableAllRuntimeGpes ();
1182 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
1184 return_ACPI_STATUS (Status);