1 /******************************************************************************
3 * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2011, 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 __EVXFGPE_C__
120 #include "accommon.h"
121 #include "acevents.h"
122 #include "acnamesp.h"
124 #define _COMPONENT ACPI_EVENTS
125 ACPI_MODULE_NAME ("evxfgpe")
128 /*******************************************************************************
130 * FUNCTION: AcpiUpdateAllGpes
136 * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
137 * associated _Lxx or _Exx methods and are not pointed to by any
138 * device _PRW methods (this indicates that these GPEs are
139 * generally intended for system or device wakeup. Such GPEs
140 * have to be enabled directly when the devices whose _PRW
141 * methods point to them are set up for wakeup signaling.)
143 * NOTE: Should be called after any GPEs are added to the system. Primarily,
144 * after the system _PRW methods have been run, but also after a GPE Block
145 * Device has been added or if any new GPE methods have been added via a
146 * dynamic table load.
148 ******************************************************************************/
157 ACPI_FUNCTION_TRACE (AcpiUpdateGpes
);
160 Status
= AcpiUtAcquireMutex (ACPI_MTX_EVENTS
);
161 if (ACPI_FAILURE (Status
))
163 return_ACPI_STATUS (Status
);
166 if (AcpiGbl_AllGpesInitialized
)
171 Status
= AcpiEvWalkGpeList (AcpiEvInitializeGpeBlock
, NULL
);
172 if (ACPI_SUCCESS (Status
))
174 AcpiGbl_AllGpesInitialized
= TRUE
;
178 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS
);
179 return_ACPI_STATUS (Status
);
182 ACPI_EXPORT_SYMBOL (AcpiUpdateAllGpes
)
185 /*******************************************************************************
187 * FUNCTION: AcpiEnableGpe
189 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
190 * GpeNumber - GPE level within the GPE block
194 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
197 ******************************************************************************/
201 ACPI_HANDLE GpeDevice
,
204 ACPI_STATUS Status
= AE_BAD_PARAMETER
;
205 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
206 ACPI_CPU_FLAGS Flags
;
209 ACPI_FUNCTION_TRACE (AcpiEnableGpe
);
212 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
214 /* Ensure that we have a valid GPE number */
216 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
219 Status
= AcpiEvAddGpeReference (GpeEventInfo
);
222 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
223 return_ACPI_STATUS (Status
);
226 ACPI_EXPORT_SYMBOL (AcpiEnableGpe
)
229 /*******************************************************************************
231 * FUNCTION: AcpiDisableGpe
233 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
234 * GpeNumber - GPE level within the GPE block
238 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
239 * removed, only then is the GPE disabled (for runtime GPEs), or
240 * the GPE mask bit disabled (for wake GPEs)
242 ******************************************************************************/
246 ACPI_HANDLE GpeDevice
,
249 ACPI_STATUS Status
= AE_BAD_PARAMETER
;
250 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
251 ACPI_CPU_FLAGS Flags
;
254 ACPI_FUNCTION_TRACE (AcpiDisableGpe
);
257 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
259 /* Ensure that we have a valid GPE number */
261 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
264 Status
= AcpiEvRemoveGpeReference (GpeEventInfo
);
267 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
268 return_ACPI_STATUS (Status
);
271 ACPI_EXPORT_SYMBOL (AcpiDisableGpe
)
274 /*******************************************************************************
276 * FUNCTION: AcpiSetGpe
278 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
279 * GpeNumber - GPE level within the GPE block
280 * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
284 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
285 * the reference count mechanism used in the AcpiEnableGpe and
286 * AcpiDisableGpe interfaces -- and should be used with care.
288 * Note: Typically used to disable a runtime GPE for short period of time,
289 * then re-enable it, without disturbing the existing reference counts. This
290 * is useful, for example, in the Embedded Controller (EC) driver.
292 ******************************************************************************/
296 ACPI_HANDLE GpeDevice
,
300 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
302 ACPI_CPU_FLAGS Flags
;
305 ACPI_FUNCTION_TRACE (AcpiSetGpe
);
308 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
310 /* Ensure that we have a valid GPE number */
312 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
315 Status
= AE_BAD_PARAMETER
;
319 /* Perform the action */
323 case ACPI_GPE_ENABLE
:
324 Status
= AcpiEvEnableGpe (GpeEventInfo
);
327 case ACPI_GPE_DISABLE
:
328 Status
= AcpiHwLowSetGpe (GpeEventInfo
, ACPI_GPE_DISABLE
);
332 Status
= AE_BAD_PARAMETER
;
337 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
338 return_ACPI_STATUS (Status
);
341 ACPI_EXPORT_SYMBOL (AcpiSetGpe
)
344 /*******************************************************************************
346 * FUNCTION: AcpiSetupGpeForWake
348 * PARAMETERS: WakeDevice - Device associated with the GPE (via _PRW)
349 * GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
350 * GpeNumber - GPE level within the GPE block
354 * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
355 * interface is intended to be used as the host executes the
356 * _PRW methods (Power Resources for Wake) in the system tables.
357 * Each _PRW appears under a Device Object (The WakeDevice), and
358 * contains the info for the wake GPE associated with the
361 ******************************************************************************/
364 AcpiSetupGpeForWake (
365 ACPI_HANDLE WakeDevice
,
366 ACPI_HANDLE GpeDevice
,
369 ACPI_STATUS Status
= AE_BAD_PARAMETER
;
370 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
371 ACPI_NAMESPACE_NODE
*DeviceNode
;
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
);
407 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
409 /* Ensure that we have a valid GPE number */
411 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
415 * If there is no method or handler for this GPE, then the
416 * WakeDevice will be notified whenever this GPE fires (aka
417 * "implicit notify") Note: The GPE is assumed to be
418 * level-triggered (for windows compatibility).
420 if ((GpeEventInfo
->Flags
& ACPI_GPE_DISPATCH_MASK
) ==
421 ACPI_GPE_DISPATCH_NONE
)
423 GpeEventInfo
->Flags
=
424 (ACPI_GPE_DISPATCH_NOTIFY
| ACPI_GPE_LEVEL_TRIGGERED
);
425 GpeEventInfo
->Dispatch
.DeviceNode
= DeviceNode
;
428 GpeEventInfo
->Flags
|= ACPI_GPE_CAN_WAKE
;
432 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
433 return_ACPI_STATUS (Status
);
436 ACPI_EXPORT_SYMBOL (AcpiSetupGpeForWake
)
439 /*******************************************************************************
441 * FUNCTION: AcpiSetGpeWakeMask
443 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
444 * GpeNumber - GPE level within the GPE block
445 * Action - Enable or Disable
449 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
450 * already be marked as a WAKE GPE.
452 ******************************************************************************/
456 ACPI_HANDLE GpeDevice
,
460 ACPI_STATUS Status
= AE_OK
;
461 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
462 ACPI_GPE_REGISTER_INFO
*GpeRegisterInfo
;
463 ACPI_CPU_FLAGS Flags
;
467 ACPI_FUNCTION_TRACE (AcpiSetGpeWakeMask
);
470 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
473 * Ensure that we have a valid GPE number and that this GPE is in
476 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
479 Status
= AE_BAD_PARAMETER
;
483 if (!(GpeEventInfo
->Flags
& ACPI_GPE_CAN_WAKE
))
489 GpeRegisterInfo
= GpeEventInfo
->RegisterInfo
;
490 if (!GpeRegisterInfo
)
492 Status
= AE_NOT_EXIST
;
496 RegisterBit
= AcpiHwGetGpeRegisterBit (GpeEventInfo
, GpeRegisterInfo
);
498 /* Perform the action */
502 case ACPI_GPE_ENABLE
:
503 ACPI_SET_BIT (GpeRegisterInfo
->EnableForWake
, (UINT8
) RegisterBit
);
506 case ACPI_GPE_DISABLE
:
507 ACPI_CLEAR_BIT (GpeRegisterInfo
->EnableForWake
, (UINT8
) RegisterBit
);
511 ACPI_ERROR ((AE_INFO
, "%u, Invalid action", Action
));
512 Status
= AE_BAD_PARAMETER
;
517 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
518 return_ACPI_STATUS (Status
);
521 ACPI_EXPORT_SYMBOL (AcpiSetGpeWakeMask
)
524 /*******************************************************************************
526 * FUNCTION: AcpiClearGpe
528 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
529 * GpeNumber - GPE level within the GPE block
533 * DESCRIPTION: Clear an ACPI event (general purpose)
535 ******************************************************************************/
539 ACPI_HANDLE GpeDevice
,
542 ACPI_STATUS Status
= AE_OK
;
543 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
544 ACPI_CPU_FLAGS Flags
;
547 ACPI_FUNCTION_TRACE (AcpiClearGpe
);
550 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
552 /* Ensure that we have a valid GPE number */
554 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
557 Status
= AE_BAD_PARAMETER
;
561 Status
= AcpiHwClearGpe (GpeEventInfo
);
564 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
565 return_ACPI_STATUS (Status
);
568 ACPI_EXPORT_SYMBOL (AcpiClearGpe
)
571 /*******************************************************************************
573 * FUNCTION: AcpiGetGpeStatus
575 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
576 * GpeNumber - GPE level within the GPE block
577 * EventStatus - Where the current status of the event
582 * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
584 ******************************************************************************/
588 ACPI_HANDLE GpeDevice
,
590 ACPI_EVENT_STATUS
*EventStatus
)
592 ACPI_STATUS Status
= AE_OK
;
593 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
594 ACPI_CPU_FLAGS Flags
;
597 ACPI_FUNCTION_TRACE (AcpiGetGpeStatus
);
600 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
602 /* Ensure that we have a valid GPE number */
604 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
607 Status
= AE_BAD_PARAMETER
;
611 /* Obtain status on the requested GPE number */
613 Status
= AcpiHwGetGpeStatus (GpeEventInfo
, EventStatus
);
616 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
617 return_ACPI_STATUS (Status
);
620 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus
)
623 /*******************************************************************************
625 * FUNCTION: AcpiFinishGpe
627 * PARAMETERS: GpeDevice - Namespace node for the GPE Block
628 * (NULL for FADT defined GPEs)
629 * GpeNumber - GPE level within the GPE block
633 * DESCRIPTION: Clear and conditionally reenable a GPE. This completes the GPE
634 * processing. Intended for use by asynchronous host-installed
635 * GPE handlers. The GPE is only reenabled if the EnableForRun bit
636 * is set in the GPE info.
638 ******************************************************************************/
642 ACPI_HANDLE GpeDevice
,
645 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
647 ACPI_CPU_FLAGS Flags
;
650 ACPI_FUNCTION_TRACE (AcpiFinishGpe
);
653 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
655 /* Ensure that we have a valid GPE number */
657 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
660 Status
= AE_BAD_PARAMETER
;
664 Status
= AcpiEvFinishGpe (GpeEventInfo
);
667 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
668 return_ACPI_STATUS (Status
);
671 ACPI_EXPORT_SYMBOL (AcpiFinishGpe
)
674 /******************************************************************************
676 * FUNCTION: AcpiDisableAllGpes
682 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
684 ******************************************************************************/
693 ACPI_FUNCTION_TRACE (AcpiDisableAllGpes
);
696 Status
= AcpiUtAcquireMutex (ACPI_MTX_EVENTS
);
697 if (ACPI_FAILURE (Status
))
699 return_ACPI_STATUS (Status
);
702 Status
= AcpiHwDisableAllGpes ();
703 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS
);
705 return_ACPI_STATUS (Status
);
708 ACPI_EXPORT_SYMBOL (AcpiDisableAllGpes
)
711 /******************************************************************************
713 * FUNCTION: AcpiEnableAllRuntimeGpes
719 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
721 ******************************************************************************/
724 AcpiEnableAllRuntimeGpes (
730 ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes
);
733 Status
= AcpiUtAcquireMutex (ACPI_MTX_EVENTS
);
734 if (ACPI_FAILURE (Status
))
736 return_ACPI_STATUS (Status
);
739 Status
= AcpiHwEnableAllRuntimeGpes ();
740 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS
);
742 return_ACPI_STATUS (Status
);
745 ACPI_EXPORT_SYMBOL (AcpiEnableAllRuntimeGpes
)
748 /*******************************************************************************
750 * FUNCTION: AcpiInstallGpeBlock
752 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
753 * GpeBlockAddress - Address and SpaceID
754 * RegisterCount - Number of GPE register pairs in the block
755 * InterruptNumber - H/W interrupt for the block
759 * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
762 ******************************************************************************/
765 AcpiInstallGpeBlock (
766 ACPI_HANDLE GpeDevice
,
767 ACPI_GENERIC_ADDRESS
*GpeBlockAddress
,
768 UINT32 RegisterCount
,
769 UINT32 InterruptNumber
)
772 ACPI_OPERAND_OBJECT
*ObjDesc
;
773 ACPI_NAMESPACE_NODE
*Node
;
774 ACPI_GPE_BLOCK_INFO
*GpeBlock
;
777 ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock
);
781 (!GpeBlockAddress
) ||
784 return_ACPI_STATUS (AE_BAD_PARAMETER
);
787 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
788 if (ACPI_FAILURE (Status
))
793 Node
= AcpiNsValidateHandle (GpeDevice
);
796 Status
= AE_BAD_PARAMETER
;
801 * For user-installed GPE Block Devices, the GpeBlockBaseNumber
804 Status
= AcpiEvCreateGpeBlock (Node
, GpeBlockAddress
, RegisterCount
,
805 0, InterruptNumber
, &GpeBlock
);
806 if (ACPI_FAILURE (Status
))
811 /* Install block in the DeviceObject attached to the node */
813 ObjDesc
= AcpiNsGetAttachedObject (Node
);
817 * No object, create a new one (Device nodes do not always have
818 * an attached object)
820 ObjDesc
= AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE
);
823 Status
= AE_NO_MEMORY
;
827 Status
= AcpiNsAttachObject (Node
, ObjDesc
, ACPI_TYPE_DEVICE
);
829 /* Remove local reference to the object */
831 AcpiUtRemoveReference (ObjDesc
);
832 if (ACPI_FAILURE (Status
))
838 /* Now install the GPE block in the DeviceObject */
840 ObjDesc
->Device
.GpeBlock
= GpeBlock
;
844 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
845 return_ACPI_STATUS (Status
);
848 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock
)
851 /*******************************************************************************
853 * FUNCTION: AcpiRemoveGpeBlock
855 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
859 * DESCRIPTION: Remove a previously installed block of GPE registers
861 ******************************************************************************/
865 ACPI_HANDLE GpeDevice
)
867 ACPI_OPERAND_OBJECT
*ObjDesc
;
869 ACPI_NAMESPACE_NODE
*Node
;
872 ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock
);
877 return_ACPI_STATUS (AE_BAD_PARAMETER
);
880 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
881 if (ACPI_FAILURE (Status
))
886 Node
= AcpiNsValidateHandle (GpeDevice
);
889 Status
= AE_BAD_PARAMETER
;
893 /* Get the DeviceObject attached to the node */
895 ObjDesc
= AcpiNsGetAttachedObject (Node
);
897 !ObjDesc
->Device
.GpeBlock
)
899 return_ACPI_STATUS (AE_NULL_OBJECT
);
902 /* Delete the GPE block (but not the DeviceObject) */
904 Status
= AcpiEvDeleteGpeBlock (ObjDesc
->Device
.GpeBlock
);
905 if (ACPI_SUCCESS (Status
))
907 ObjDesc
->Device
.GpeBlock
= NULL
;
911 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
912 return_ACPI_STATUS (Status
);
915 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock
)
918 /*******************************************************************************
920 * FUNCTION: AcpiGetGpeDevice
922 * PARAMETERS: Index - System GPE index (0-CurrentGpeCount)
923 * GpeDevice - Where the parent GPE Device is returned
927 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
928 * gpe device indicates that the gpe number is contained in one of
929 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
931 ******************************************************************************/
936 ACPI_HANDLE
*GpeDevice
)
938 ACPI_GPE_DEVICE_INFO Info
;
942 ACPI_FUNCTION_TRACE (AcpiGetGpeDevice
);
947 return_ACPI_STATUS (AE_BAD_PARAMETER
);
950 if (Index
>= AcpiCurrentGpeCount
)
952 return_ACPI_STATUS (AE_NOT_EXIST
);
955 /* Setup and walk the GPE list */
958 Info
.Status
= AE_NOT_EXIST
;
959 Info
.GpeDevice
= NULL
;
960 Info
.NextBlockBaseIndex
= 0;
962 Status
= AcpiEvWalkGpeList (AcpiEvGetGpeDevice
, &Info
);
963 if (ACPI_FAILURE (Status
))
965 return_ACPI_STATUS (Status
);
968 *GpeDevice
= ACPI_CAST_PTR (ACPI_HANDLE
, Info
.GpeDevice
);
969 return_ACPI_STATUS (Info
.Status
);
972 ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice
)