1 /******************************************************************************
3 * Module Name: evxfgpe - External Interfaces for General Purpose Events (GPEs)
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2014, 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__
118 #define EXPORT_ACPI_INTERFACES
121 #include "accommon.h"
122 #include "acevents.h"
123 #include "acnamesp.h"
125 #define _COMPONENT ACPI_EVENTS
126 ACPI_MODULE_NAME ("evxfgpe")
129 #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
130 /*******************************************************************************
132 * FUNCTION: AcpiUpdateAllGpes
138 * DESCRIPTION: Complete GPE initialization and enable all GPEs that have
139 * associated _Lxx or _Exx methods and are not pointed to by any
140 * device _PRW methods (this indicates that these GPEs are
141 * generally intended for system or device wakeup. Such GPEs
142 * have to be enabled directly when the devices whose _PRW
143 * methods point to them are set up for wakeup signaling.)
145 * NOTE: Should be called after any GPEs are added to the system. Primarily,
146 * after the system _PRW methods have been run, but also after a GPE Block
147 * Device has been added or if any new GPE methods have been added via a
148 * dynamic table load.
150 ******************************************************************************/
159 ACPI_FUNCTION_TRACE (AcpiUpdateAllGpes
);
162 Status
= AcpiUtAcquireMutex (ACPI_MTX_EVENTS
);
163 if (ACPI_FAILURE (Status
))
165 return_ACPI_STATUS (Status
);
168 if (AcpiGbl_AllGpesInitialized
)
173 Status
= AcpiEvWalkGpeList (AcpiEvInitializeGpeBlock
, NULL
);
174 if (ACPI_SUCCESS (Status
))
176 AcpiGbl_AllGpesInitialized
= TRUE
;
180 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS
);
181 return_ACPI_STATUS (Status
);
184 ACPI_EXPORT_SYMBOL (AcpiUpdateAllGpes
)
187 /*******************************************************************************
189 * FUNCTION: AcpiEnableGpe
191 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
192 * GpeNumber - GPE level within the GPE block
196 * DESCRIPTION: Add a reference to a GPE. On the first reference, the GPE is
199 ******************************************************************************/
203 ACPI_HANDLE GpeDevice
,
206 ACPI_STATUS Status
= AE_BAD_PARAMETER
;
207 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
208 ACPI_CPU_FLAGS Flags
;
211 ACPI_FUNCTION_TRACE (AcpiEnableGpe
);
214 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
216 /* Ensure that we have a valid GPE number */
218 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
221 Status
= AcpiEvAddGpeReference (GpeEventInfo
);
224 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
225 return_ACPI_STATUS (Status
);
228 ACPI_EXPORT_SYMBOL (AcpiEnableGpe
)
231 /*******************************************************************************
233 * FUNCTION: AcpiDisableGpe
235 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
236 * GpeNumber - GPE level within the GPE block
240 * DESCRIPTION: Remove a reference to a GPE. When the last reference is
241 * removed, only then is the GPE disabled (for runtime GPEs), or
242 * the GPE mask bit disabled (for wake GPEs)
244 ******************************************************************************/
248 ACPI_HANDLE GpeDevice
,
251 ACPI_STATUS Status
= AE_BAD_PARAMETER
;
252 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
253 ACPI_CPU_FLAGS Flags
;
256 ACPI_FUNCTION_TRACE (AcpiDisableGpe
);
259 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
261 /* Ensure that we have a valid GPE number */
263 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
266 Status
= AcpiEvRemoveGpeReference (GpeEventInfo
);
269 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
270 return_ACPI_STATUS (Status
);
273 ACPI_EXPORT_SYMBOL (AcpiDisableGpe
)
276 /*******************************************************************************
278 * FUNCTION: AcpiSetGpe
280 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
281 * GpeNumber - GPE level within the GPE block
282 * Action - ACPI_GPE_ENABLE or ACPI_GPE_DISABLE
286 * DESCRIPTION: Enable or disable an individual GPE. This function bypasses
287 * the reference count mechanism used in the AcpiEnableGpe and
288 * AcpiDisableGpe interfaces -- and should be used with care.
290 * Note: Typically used to disable a runtime GPE for short period of time,
291 * then re-enable it, without disturbing the existing reference counts. This
292 * is useful, for example, in the Embedded Controller (EC) driver.
294 ******************************************************************************/
298 ACPI_HANDLE GpeDevice
,
302 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
304 ACPI_CPU_FLAGS Flags
;
307 ACPI_FUNCTION_TRACE (AcpiSetGpe
);
310 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
312 /* Ensure that we have a valid GPE number */
314 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
317 Status
= AE_BAD_PARAMETER
;
321 /* Perform the action */
325 case ACPI_GPE_ENABLE
:
327 Status
= AcpiEvEnableGpe (GpeEventInfo
);
330 case ACPI_GPE_DISABLE
:
332 Status
= AcpiHwLowSetGpe (GpeEventInfo
, ACPI_GPE_DISABLE
);
337 Status
= AE_BAD_PARAMETER
;
342 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
343 return_ACPI_STATUS (Status
);
346 ACPI_EXPORT_SYMBOL (AcpiSetGpe
)
349 /*******************************************************************************
351 * FUNCTION: AcpiSetupGpeForWake
353 * PARAMETERS: WakeDevice - Device associated with the GPE (via _PRW)
354 * GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
355 * GpeNumber - GPE level within the GPE block
359 * DESCRIPTION: Mark a GPE as having the ability to wake the system. This
360 * interface is intended to be used as the host executes the
361 * _PRW methods (Power Resources for Wake) in the system tables.
362 * Each _PRW appears under a Device Object (The WakeDevice), and
363 * contains the info for the wake GPE associated with the
366 ******************************************************************************/
369 AcpiSetupGpeForWake (
370 ACPI_HANDLE WakeDevice
,
371 ACPI_HANDLE GpeDevice
,
375 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
376 ACPI_NAMESPACE_NODE
*DeviceNode
;
377 ACPI_GPE_NOTIFY_INFO
*Notify
;
378 ACPI_GPE_NOTIFY_INFO
*NewNotify
;
379 ACPI_CPU_FLAGS Flags
;
382 ACPI_FUNCTION_TRACE (AcpiSetupGpeForWake
);
385 /* Parameter Validation */
390 * By forcing WakeDevice to be valid, we automatically enable the
391 * implicit notify feature on all hosts.
393 return_ACPI_STATUS (AE_BAD_PARAMETER
);
396 /* Handle root object case */
398 if (WakeDevice
== ACPI_ROOT_OBJECT
)
400 DeviceNode
= AcpiGbl_RootNode
;
404 DeviceNode
= ACPI_CAST_PTR (ACPI_NAMESPACE_NODE
, WakeDevice
);
407 /* Validate WakeDevice is of type Device */
409 if (DeviceNode
->Type
!= ACPI_TYPE_DEVICE
)
411 return_ACPI_STATUS (AE_BAD_PARAMETER
);
415 * Allocate a new notify object up front, in case it is needed.
416 * Memory allocation while holding a spinlock is a big no-no
419 NewNotify
= ACPI_ALLOCATE_ZEROED (sizeof (ACPI_GPE_NOTIFY_INFO
));
422 return_ACPI_STATUS (AE_NO_MEMORY
);
425 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
427 /* Ensure that we have a valid GPE number */
429 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
432 Status
= AE_BAD_PARAMETER
;
437 * If there is no method or handler for this GPE, then the
438 * WakeDevice will be notified whenever this GPE fires. This is
439 * known as an "implicit notify". Note: The GPE is assumed to be
440 * level-triggered (for windows compatibility).
442 if ((GpeEventInfo
->Flags
& ACPI_GPE_DISPATCH_MASK
) ==
443 ACPI_GPE_DISPATCH_NONE
)
446 * This is the first device for implicit notify on this GPE.
447 * Just set the flags here, and enter the NOTIFY block below.
449 GpeEventInfo
->Flags
=
450 (ACPI_GPE_DISPATCH_NOTIFY
| ACPI_GPE_LEVEL_TRIGGERED
);
454 * If we already have an implicit notify on this GPE, add
455 * this device to the notify list.
457 if ((GpeEventInfo
->Flags
& ACPI_GPE_DISPATCH_MASK
) ==
458 ACPI_GPE_DISPATCH_NOTIFY
)
460 /* Ensure that the device is not already in the list */
462 Notify
= GpeEventInfo
->Dispatch
.NotifyList
;
465 if (Notify
->DeviceNode
== DeviceNode
)
467 Status
= AE_ALREADY_EXISTS
;
470 Notify
= Notify
->Next
;
473 /* Add this device to the notify list for this GPE */
475 NewNotify
->DeviceNode
= DeviceNode
;
476 NewNotify
->Next
= GpeEventInfo
->Dispatch
.NotifyList
;
477 GpeEventInfo
->Dispatch
.NotifyList
= NewNotify
;
481 /* Mark the GPE as a possible wake event */
483 GpeEventInfo
->Flags
|= ACPI_GPE_CAN_WAKE
;
488 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
490 /* Delete the notify object if it was not used above */
494 ACPI_FREE (NewNotify
);
496 return_ACPI_STATUS (Status
);
499 ACPI_EXPORT_SYMBOL (AcpiSetupGpeForWake
)
502 /*******************************************************************************
504 * FUNCTION: AcpiSetGpeWakeMask
506 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
507 * GpeNumber - GPE level within the GPE block
508 * Action - Enable or Disable
512 * DESCRIPTION: Set or clear the GPE's wakeup enable mask bit. The GPE must
513 * already be marked as a WAKE GPE.
515 ******************************************************************************/
519 ACPI_HANDLE GpeDevice
,
523 ACPI_STATUS Status
= AE_OK
;
524 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
525 ACPI_GPE_REGISTER_INFO
*GpeRegisterInfo
;
526 ACPI_CPU_FLAGS Flags
;
530 ACPI_FUNCTION_TRACE (AcpiSetGpeWakeMask
);
533 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
536 * Ensure that we have a valid GPE number and that this GPE is in
539 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
542 Status
= AE_BAD_PARAMETER
;
546 if (!(GpeEventInfo
->Flags
& ACPI_GPE_CAN_WAKE
))
552 GpeRegisterInfo
= GpeEventInfo
->RegisterInfo
;
553 if (!GpeRegisterInfo
)
555 Status
= AE_NOT_EXIST
;
559 RegisterBit
= AcpiHwGetGpeRegisterBit (GpeEventInfo
);
561 /* Perform the action */
565 case ACPI_GPE_ENABLE
:
567 ACPI_SET_BIT (GpeRegisterInfo
->EnableForWake
, (UINT8
) RegisterBit
);
570 case ACPI_GPE_DISABLE
:
572 ACPI_CLEAR_BIT (GpeRegisterInfo
->EnableForWake
, (UINT8
) RegisterBit
);
577 ACPI_ERROR ((AE_INFO
, "%u, Invalid action", Action
));
578 Status
= AE_BAD_PARAMETER
;
583 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
584 return_ACPI_STATUS (Status
);
587 ACPI_EXPORT_SYMBOL (AcpiSetGpeWakeMask
)
590 /*******************************************************************************
592 * FUNCTION: AcpiClearGpe
594 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
595 * GpeNumber - GPE level within the GPE block
599 * DESCRIPTION: Clear an ACPI event (general purpose)
601 ******************************************************************************/
605 ACPI_HANDLE GpeDevice
,
608 ACPI_STATUS Status
= AE_OK
;
609 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
610 ACPI_CPU_FLAGS Flags
;
613 ACPI_FUNCTION_TRACE (AcpiClearGpe
);
616 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
618 /* Ensure that we have a valid GPE number */
620 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
623 Status
= AE_BAD_PARAMETER
;
627 Status
= AcpiHwClearGpe (GpeEventInfo
);
630 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
631 return_ACPI_STATUS (Status
);
634 ACPI_EXPORT_SYMBOL (AcpiClearGpe
)
637 /*******************************************************************************
639 * FUNCTION: AcpiGetGpeStatus
641 * PARAMETERS: GpeDevice - Parent GPE Device. NULL for GPE0/GPE1
642 * GpeNumber - GPE level within the GPE block
643 * EventStatus - Where the current status of the event
648 * DESCRIPTION: Get the current status of a GPE (signalled/not_signalled)
650 ******************************************************************************/
654 ACPI_HANDLE GpeDevice
,
656 ACPI_EVENT_STATUS
*EventStatus
)
658 ACPI_STATUS Status
= AE_OK
;
659 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
660 ACPI_CPU_FLAGS Flags
;
663 ACPI_FUNCTION_TRACE (AcpiGetGpeStatus
);
666 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
668 /* Ensure that we have a valid GPE number */
670 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
673 Status
= AE_BAD_PARAMETER
;
677 /* Obtain status on the requested GPE number */
679 Status
= AcpiHwGetGpeStatus (GpeEventInfo
, EventStatus
);
682 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
683 return_ACPI_STATUS (Status
);
686 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus
)
689 /*******************************************************************************
691 * FUNCTION: AcpiFinishGpe
693 * PARAMETERS: GpeDevice - Namespace node for the GPE Block
694 * (NULL for FADT defined GPEs)
695 * GpeNumber - GPE level within the GPE block
699 * DESCRIPTION: Clear and conditionally reenable a GPE. This completes the GPE
700 * processing. Intended for use by asynchronous host-installed
701 * GPE handlers. The GPE is only reenabled if the EnableForRun bit
702 * is set in the GPE info.
704 ******************************************************************************/
708 ACPI_HANDLE GpeDevice
,
711 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
713 ACPI_CPU_FLAGS Flags
;
716 ACPI_FUNCTION_TRACE (AcpiFinishGpe
);
719 Flags
= AcpiOsAcquireLock (AcpiGbl_GpeLock
);
721 /* Ensure that we have a valid GPE number */
723 GpeEventInfo
= AcpiEvGetGpeEventInfo (GpeDevice
, GpeNumber
);
726 Status
= AE_BAD_PARAMETER
;
730 Status
= AcpiEvFinishGpe (GpeEventInfo
);
733 AcpiOsReleaseLock (AcpiGbl_GpeLock
, Flags
);
734 return_ACPI_STATUS (Status
);
737 ACPI_EXPORT_SYMBOL (AcpiFinishGpe
)
740 /******************************************************************************
742 * FUNCTION: AcpiDisableAllGpes
748 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
750 ******************************************************************************/
759 ACPI_FUNCTION_TRACE (AcpiDisableAllGpes
);
762 Status
= AcpiUtAcquireMutex (ACPI_MTX_EVENTS
);
763 if (ACPI_FAILURE (Status
))
765 return_ACPI_STATUS (Status
);
768 Status
= AcpiHwDisableAllGpes ();
769 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS
);
771 return_ACPI_STATUS (Status
);
774 ACPI_EXPORT_SYMBOL (AcpiDisableAllGpes
)
777 /******************************************************************************
779 * FUNCTION: AcpiEnableAllRuntimeGpes
785 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
787 ******************************************************************************/
790 AcpiEnableAllRuntimeGpes (
796 ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes
);
799 Status
= AcpiUtAcquireMutex (ACPI_MTX_EVENTS
);
800 if (ACPI_FAILURE (Status
))
802 return_ACPI_STATUS (Status
);
805 Status
= AcpiHwEnableAllRuntimeGpes ();
806 (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS
);
808 return_ACPI_STATUS (Status
);
811 ACPI_EXPORT_SYMBOL (AcpiEnableAllRuntimeGpes
)
814 /*******************************************************************************
816 * FUNCTION: AcpiInstallGpeBlock
818 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
819 * GpeBlockAddress - Address and SpaceID
820 * RegisterCount - Number of GPE register pairs in the block
821 * InterruptNumber - H/W interrupt for the block
825 * DESCRIPTION: Create and Install a block of GPE registers. The GPEs are not
828 ******************************************************************************/
831 AcpiInstallGpeBlock (
832 ACPI_HANDLE GpeDevice
,
833 ACPI_GENERIC_ADDRESS
*GpeBlockAddress
,
834 UINT32 RegisterCount
,
835 UINT32 InterruptNumber
)
838 ACPI_OPERAND_OBJECT
*ObjDesc
;
839 ACPI_NAMESPACE_NODE
*Node
;
840 ACPI_GPE_BLOCK_INFO
*GpeBlock
;
843 ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock
);
847 (!GpeBlockAddress
) ||
850 return_ACPI_STATUS (AE_BAD_PARAMETER
);
853 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
854 if (ACPI_FAILURE (Status
))
856 return_ACPI_STATUS (Status
);
859 Node
= AcpiNsValidateHandle (GpeDevice
);
862 Status
= AE_BAD_PARAMETER
;
866 /* Validate the parent device */
868 if (Node
->Type
!= ACPI_TYPE_DEVICE
)
876 Status
= AE_ALREADY_EXISTS
;
881 * For user-installed GPE Block Devices, the GpeBlockBaseNumber
884 Status
= AcpiEvCreateGpeBlock (Node
, GpeBlockAddress
, RegisterCount
,
885 0, InterruptNumber
, &GpeBlock
);
886 if (ACPI_FAILURE (Status
))
891 /* Install block in the DeviceObject attached to the node */
893 ObjDesc
= AcpiNsGetAttachedObject (Node
);
897 * No object, create a new one (Device nodes do not always have
898 * an attached object)
900 ObjDesc
= AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE
);
903 Status
= AE_NO_MEMORY
;
907 Status
= AcpiNsAttachObject (Node
, ObjDesc
, ACPI_TYPE_DEVICE
);
909 /* Remove local reference to the object */
911 AcpiUtRemoveReference (ObjDesc
);
912 if (ACPI_FAILURE (Status
))
918 /* Now install the GPE block in the DeviceObject */
920 ObjDesc
->Device
.GpeBlock
= GpeBlock
;
924 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
925 return_ACPI_STATUS (Status
);
928 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock
)
931 /*******************************************************************************
933 * FUNCTION: AcpiRemoveGpeBlock
935 * PARAMETERS: GpeDevice - Handle to the parent GPE Block Device
939 * DESCRIPTION: Remove a previously installed block of GPE registers
941 ******************************************************************************/
945 ACPI_HANDLE GpeDevice
)
947 ACPI_OPERAND_OBJECT
*ObjDesc
;
949 ACPI_NAMESPACE_NODE
*Node
;
952 ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock
);
957 return_ACPI_STATUS (AE_BAD_PARAMETER
);
960 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
961 if (ACPI_FAILURE (Status
))
963 return_ACPI_STATUS (Status
);
966 Node
= AcpiNsValidateHandle (GpeDevice
);
969 Status
= AE_BAD_PARAMETER
;
973 /* Validate the parent device */
975 if (Node
->Type
!= ACPI_TYPE_DEVICE
)
981 /* Get the DeviceObject attached to the node */
983 ObjDesc
= AcpiNsGetAttachedObject (Node
);
985 !ObjDesc
->Device
.GpeBlock
)
987 return_ACPI_STATUS (AE_NULL_OBJECT
);
990 /* Delete the GPE block (but not the DeviceObject) */
992 Status
= AcpiEvDeleteGpeBlock (ObjDesc
->Device
.GpeBlock
);
993 if (ACPI_SUCCESS (Status
))
995 ObjDesc
->Device
.GpeBlock
= NULL
;
999 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
1000 return_ACPI_STATUS (Status
);
1003 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock
)
1006 /*******************************************************************************
1008 * FUNCTION: AcpiGetGpeDevice
1010 * PARAMETERS: Index - System GPE index (0-CurrentGpeCount)
1011 * GpeDevice - Where the parent GPE Device is returned
1015 * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
1016 * gpe device indicates that the gpe number is contained in one of
1017 * the FADT-defined gpe blocks. Otherwise, the GPE block device.
1019 ******************************************************************************/
1024 ACPI_HANDLE
*GpeDevice
)
1026 ACPI_GPE_DEVICE_INFO Info
;
1030 ACPI_FUNCTION_TRACE (AcpiGetGpeDevice
);
1035 return_ACPI_STATUS (AE_BAD_PARAMETER
);
1038 if (Index
>= AcpiCurrentGpeCount
)
1040 return_ACPI_STATUS (AE_NOT_EXIST
);
1043 /* Setup and walk the GPE list */
1046 Info
.Status
= AE_NOT_EXIST
;
1047 Info
.GpeDevice
= NULL
;
1048 Info
.NextBlockBaseIndex
= 0;
1050 Status
= AcpiEvWalkGpeList (AcpiEvGetGpeDevice
, &Info
);
1051 if (ACPI_FAILURE (Status
))
1053 return_ACPI_STATUS (Status
);
1056 *GpeDevice
= ACPI_CAST_PTR (ACPI_HANDLE
, Info
.GpeDevice
);
1057 return_ACPI_STATUS (Info
.Status
);
1060 ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice
)
1062 #endif /* !ACPI_REDUCED_HARDWARE */