Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/evxfevnt.c need to be fixed.

0001 /******************************************************************************
0002  *
0003  * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
0004  *
0005  *****************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights.  You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code.  No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision.  In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change.  Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee.  Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution.  In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government.  In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************/
0115 
0116 
0117 #define __EVXFEVNT_C__
0118 
0119 #include "acpi.h"
0120 #include "accommon.h"
0121 #include "acevents.h"
0122 #include "acnamesp.h"
0123 #include "actables.h"
0124 
0125 #define _COMPONENT          ACPI_EVENTS
0126         ACPI_MODULE_NAME    ("evxfevnt")
0127 
0128 /* Local prototypes */
0129 
0130 static ACPI_STATUS
0131 AcpiEvGetGpeDevice (
0132     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
0133     ACPI_GPE_BLOCK_INFO     *GpeBlock,
0134     void                    *Context);
0135 
0136 
0137 /*******************************************************************************
0138  *
0139  * FUNCTION:    AcpiEnable
0140  *
0141  * PARAMETERS:  None
0142  *
0143  * RETURN:      Status
0144  *
0145  * DESCRIPTION: Transfers the system into ACPI mode.
0146  *
0147  ******************************************************************************/
0148 
0149 ACPI_STATUS
0150 AcpiEnable (
0151     void)
0152 {
0153     ACPI_STATUS             Status = AE_OK;
0154 
0155 
0156     ACPI_FUNCTION_TRACE (AcpiEnable);
0157 
0158 
0159     /* ACPI tables must be present */
0160 
0161     if (!AcpiTbTablesLoaded ())
0162     {
0163         return_ACPI_STATUS (AE_NO_ACPI_TABLES);
0164     }
0165 
0166     /* Check current mode */
0167 
0168     if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI)
0169     {
0170         ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
0171     }
0172     else
0173     {
0174         /* Transition to ACPI mode */
0175 
0176         Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI);
0177         if (ACPI_FAILURE (Status))
0178         {
0179             ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode"));
0180             return_ACPI_STATUS (Status);
0181         }
0182 
0183         ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
0184             "Transition to ACPI mode successful\n"));
0185     }
0186 
0187     return_ACPI_STATUS (Status);
0188 }
0189 
0190 ACPI_EXPORT_SYMBOL (AcpiEnable)
0191 
0192 
0193 /*******************************************************************************
0194  *
0195  * FUNCTION:    AcpiDisable
0196  *
0197  * PARAMETERS:  None
0198  *
0199  * RETURN:      Status
0200  *
0201  * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
0202  *
0203  ******************************************************************************/
0204 
0205 ACPI_STATUS
0206 AcpiDisable (
0207     void)
0208 {
0209     ACPI_STATUS             Status = AE_OK;
0210 
0211 
0212     ACPI_FUNCTION_TRACE (AcpiDisable);
0213 
0214 
0215     if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY)
0216     {
0217         ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
0218             "System is already in legacy (non-ACPI) mode\n"));
0219     }
0220     else
0221     {
0222         /* Transition to LEGACY mode */
0223 
0224         Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY);
0225 
0226         if (ACPI_FAILURE (Status))
0227         {
0228             ACPI_ERROR ((AE_INFO,
0229                 "Could not exit ACPI mode to legacy mode"));
0230             return_ACPI_STATUS (Status);
0231         }
0232 
0233         ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
0234     }
0235 
0236     return_ACPI_STATUS (Status);
0237 }
0238 
0239 ACPI_EXPORT_SYMBOL (AcpiDisable)
0240 
0241 
0242 /*******************************************************************************
0243  *
0244  * FUNCTION:    AcpiEnableEvent
0245  *
0246  * PARAMETERS:  Event           - The fixed eventto be enabled
0247  *              Flags           - Reserved
0248  *
0249  * RETURN:      Status
0250  *
0251  * DESCRIPTION: Enable an ACPI event (fixed)
0252  *
0253  ******************************************************************************/
0254 
0255 ACPI_STATUS
0256 AcpiEnableEvent (
0257     UINT32                  Event,
0258     UINT32                  Flags)
0259 {
0260     ACPI_STATUS             Status = AE_OK;
0261     UINT32                  Value;
0262 
0263 
0264     ACPI_FUNCTION_TRACE (AcpiEnableEvent);
0265 
0266 
0267     /* Decode the Fixed Event */
0268 
0269     if (Event > ACPI_EVENT_MAX)
0270     {
0271         return_ACPI_STATUS (AE_BAD_PARAMETER);
0272     }
0273 
0274     /*
0275      * Enable the requested fixed event (by writing a one to the enable
0276      * register bit)
0277      */
0278     Status = AcpiWriteBitRegister (
0279                 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
0280                 ACPI_ENABLE_EVENT);
0281     if (ACPI_FAILURE (Status))
0282     {
0283         return_ACPI_STATUS (Status);
0284     }
0285 
0286     /* Make sure that the hardware responded */
0287 
0288     Status = AcpiReadBitRegister (
0289                 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
0290     if (ACPI_FAILURE (Status))
0291     {
0292         return_ACPI_STATUS (Status);
0293     }
0294 
0295     if (Value != 1)
0296     {
0297         ACPI_ERROR ((AE_INFO,
0298             "Could not enable %s event", AcpiUtGetEventName (Event)));
0299         return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
0300     }
0301 
0302     return_ACPI_STATUS (Status);
0303 }
0304 
0305 ACPI_EXPORT_SYMBOL (AcpiEnableEvent)
0306 
0307 
0308 /*******************************************************************************
0309  *
0310  * FUNCTION:    AcpiSetGpeType
0311  *
0312  * PARAMETERS:  GpeDevice       - Parent GPE Device
0313  *              GpeNumber       - GPE level within the GPE block
0314  *              Type            - New GPE type
0315  *
0316  * RETURN:      Status
0317  *
0318  * DESCRIPTION: Set the type of an individual GPE
0319  *
0320  ******************************************************************************/
0321 
0322 ACPI_STATUS
0323 AcpiSetGpeType (
0324     ACPI_HANDLE             GpeDevice,
0325     UINT32                  GpeNumber,
0326     UINT8                   Type)
0327 {
0328     ACPI_STATUS             Status = AE_OK;
0329     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
0330 
0331 
0332     ACPI_FUNCTION_TRACE (AcpiSetGpeType);
0333 
0334 
0335     /* Ensure that we have a valid GPE number */
0336 
0337     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
0338     if (!GpeEventInfo)
0339     {
0340         Status = AE_BAD_PARAMETER;
0341         goto UnlockAndExit;
0342     }
0343 
0344     if ((GpeEventInfo->Flags & ACPI_GPE_TYPE_MASK) == Type)
0345     {
0346         return_ACPI_STATUS (AE_OK);
0347     }
0348 
0349     /* Set the new type (will disable GPE if currently enabled) */
0350 
0351     Status = AcpiEvSetGpeType (GpeEventInfo, Type);
0352 
0353 UnlockAndExit:
0354     return_ACPI_STATUS (Status);
0355 }
0356 
0357 ACPI_EXPORT_SYMBOL (AcpiSetGpeType)
0358 
0359 
0360 /*******************************************************************************
0361  *
0362  * FUNCTION:    AcpiEnableGpe
0363  *
0364  * PARAMETERS:  GpeDevice       - Parent GPE Device
0365  *              GpeNumber       - GPE level within the GPE block
0366  *              Flags           - Just enable, or also wake enable?
0367  *                                Called from ISR or not
0368  *
0369  * RETURN:      Status
0370  *
0371  * DESCRIPTION: Enable an ACPI event (general purpose)
0372  *
0373  ******************************************************************************/
0374 
0375 ACPI_STATUS
0376 AcpiEnableGpe (
0377     ACPI_HANDLE             GpeDevice,
0378     UINT32                  GpeNumber,
0379     UINT32                  Flags)
0380 {
0381     ACPI_STATUS             Status = AE_OK;
0382     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
0383 
0384 
0385     ACPI_FUNCTION_TRACE (AcpiEnableGpe);
0386 
0387 
0388     /* Use semaphore lock if not executing at interrupt level */
0389 
0390     if (Flags & ACPI_NOT_ISR)
0391     {
0392         Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
0393         if (ACPI_FAILURE (Status))
0394         {
0395             return_ACPI_STATUS (Status);
0396         }
0397     }
0398 
0399     /* Ensure that we have a valid GPE number */
0400 
0401     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
0402     if (!GpeEventInfo)
0403     {
0404         Status = AE_BAD_PARAMETER;
0405         goto UnlockAndExit;
0406     }
0407 
0408     /* Perform the enable */
0409 
0410     Status = AcpiEvEnableGpe (GpeEventInfo, TRUE);
0411 
0412 UnlockAndExit:
0413     if (Flags & ACPI_NOT_ISR)
0414     {
0415         (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
0416     }
0417     return_ACPI_STATUS (Status);
0418 }
0419 
0420 ACPI_EXPORT_SYMBOL (AcpiEnableGpe)
0421 
0422 
0423 /*******************************************************************************
0424  *
0425  * FUNCTION:    AcpiDisableGpe
0426  *
0427  * PARAMETERS:  GpeDevice       - Parent GPE Device
0428  *              GpeNumber       - GPE level within the GPE block
0429  *              Flags           - Just disable, or also wake disable?
0430  *                                Called from ISR or not
0431  *
0432  * RETURN:      Status
0433  *
0434  * DESCRIPTION: Disable an ACPI event (general purpose)
0435  *
0436  ******************************************************************************/
0437 
0438 ACPI_STATUS
0439 AcpiDisableGpe (
0440     ACPI_HANDLE             GpeDevice,
0441     UINT32                  GpeNumber,
0442     UINT32                  Flags)
0443 {
0444     ACPI_STATUS             Status = AE_OK;
0445     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
0446 
0447 
0448     ACPI_FUNCTION_TRACE (AcpiDisableGpe);
0449 
0450 
0451     /* Use semaphore lock if not executing at interrupt level */
0452 
0453     if (Flags & ACPI_NOT_ISR)
0454     {
0455         Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
0456         if (ACPI_FAILURE (Status))
0457         {
0458             return_ACPI_STATUS (Status);
0459         }
0460     }
0461 
0462     /* Ensure that we have a valid GPE number */
0463 
0464     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
0465     if (!GpeEventInfo)
0466     {
0467         Status = AE_BAD_PARAMETER;
0468         goto UnlockAndExit;
0469     }
0470 
0471     Status = AcpiEvDisableGpe (GpeEventInfo);
0472 
0473 UnlockAndExit:
0474     if (Flags & ACPI_NOT_ISR)
0475     {
0476         (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
0477     }
0478     return_ACPI_STATUS (Status);
0479 }
0480 
0481 ACPI_EXPORT_SYMBOL (AcpiDisableGpe)
0482 
0483 
0484 /*******************************************************************************
0485  *
0486  * FUNCTION:    AcpiDisableEvent
0487  *
0488  * PARAMETERS:  Event           - The fixed eventto be enabled
0489  *              Flags           - Reserved
0490  *
0491  * RETURN:      Status
0492  *
0493  * DESCRIPTION: Disable an ACPI event (fixed)
0494  *
0495  ******************************************************************************/
0496 
0497 ACPI_STATUS
0498 AcpiDisableEvent (
0499     UINT32                  Event,
0500     UINT32                  Flags)
0501 {
0502     ACPI_STATUS             Status = AE_OK;
0503     UINT32                  Value;
0504 
0505 
0506     ACPI_FUNCTION_TRACE (AcpiDisableEvent);
0507 
0508 
0509     /* Decode the Fixed Event */
0510 
0511     if (Event > ACPI_EVENT_MAX)
0512     {
0513         return_ACPI_STATUS (AE_BAD_PARAMETER);
0514     }
0515 
0516     /*
0517      * Disable the requested fixed event (by writing a zero to the enable
0518      * register bit)
0519      */
0520     Status = AcpiWriteBitRegister (
0521                 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
0522                 ACPI_DISABLE_EVENT);
0523     if (ACPI_FAILURE (Status))
0524     {
0525         return_ACPI_STATUS (Status);
0526     }
0527 
0528     Status = AcpiReadBitRegister (
0529                 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
0530     if (ACPI_FAILURE (Status))
0531     {
0532         return_ACPI_STATUS (Status);
0533     }
0534 
0535     if (Value != 0)
0536     {
0537         ACPI_ERROR ((AE_INFO,
0538             "Could not disable %s events", AcpiUtGetEventName (Event)));
0539         return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
0540     }
0541 
0542     return_ACPI_STATUS (Status);
0543 }
0544 
0545 ACPI_EXPORT_SYMBOL (AcpiDisableEvent)
0546 
0547 
0548 /*******************************************************************************
0549  *
0550  * FUNCTION:    AcpiClearEvent
0551  *
0552  * PARAMETERS:  Event           - The fixed event to be cleared
0553  *
0554  * RETURN:      Status
0555  *
0556  * DESCRIPTION: Clear an ACPI event (fixed)
0557  *
0558  ******************************************************************************/
0559 
0560 ACPI_STATUS
0561 AcpiClearEvent (
0562     UINT32                  Event)
0563 {
0564     ACPI_STATUS             Status = AE_OK;
0565 
0566 
0567     ACPI_FUNCTION_TRACE (AcpiClearEvent);
0568 
0569 
0570     /* Decode the Fixed Event */
0571 
0572     if (Event > ACPI_EVENT_MAX)
0573     {
0574         return_ACPI_STATUS (AE_BAD_PARAMETER);
0575     }
0576 
0577     /*
0578      * Clear the requested fixed event (By writing a one to the status
0579      * register bit)
0580      */
0581     Status = AcpiWriteBitRegister (
0582                 AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
0583                 ACPI_CLEAR_STATUS);
0584 
0585     return_ACPI_STATUS (Status);
0586 }
0587 
0588 ACPI_EXPORT_SYMBOL (AcpiClearEvent)
0589 
0590 
0591 /*******************************************************************************
0592  *
0593  * FUNCTION:    AcpiClearGpe
0594  *
0595  * PARAMETERS:  GpeDevice       - Parent GPE Device
0596  *              GpeNumber       - GPE level within the GPE block
0597  *              Flags           - Called from an ISR or not
0598  *
0599  * RETURN:      Status
0600  *
0601  * DESCRIPTION: Clear an ACPI event (general purpose)
0602  *
0603  ******************************************************************************/
0604 
0605 ACPI_STATUS
0606 AcpiClearGpe (
0607     ACPI_HANDLE             GpeDevice,
0608     UINT32                  GpeNumber,
0609     UINT32                  Flags)
0610 {
0611     ACPI_STATUS             Status = AE_OK;
0612     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
0613 
0614 
0615     ACPI_FUNCTION_TRACE (AcpiClearGpe);
0616 
0617 
0618     /* Use semaphore lock if not executing at interrupt level */
0619 
0620     if (Flags & ACPI_NOT_ISR)
0621     {
0622         Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
0623         if (ACPI_FAILURE (Status))
0624         {
0625             return_ACPI_STATUS (Status);
0626         }
0627     }
0628 
0629     /* Ensure that we have a valid GPE number */
0630 
0631     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
0632     if (!GpeEventInfo)
0633     {
0634         Status = AE_BAD_PARAMETER;
0635         goto UnlockAndExit;
0636     }
0637 
0638     Status = AcpiHwClearGpe (GpeEventInfo);
0639 
0640 UnlockAndExit:
0641     if (Flags & ACPI_NOT_ISR)
0642     {
0643         (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
0644     }
0645     return_ACPI_STATUS (Status);
0646 }
0647 
0648 ACPI_EXPORT_SYMBOL (AcpiClearGpe)
0649 
0650 
0651 /*******************************************************************************
0652  *
0653  * FUNCTION:    AcpiGetEventStatus
0654  *
0655  * PARAMETERS:  Event           - The fixed event
0656  *              EventStatus     - Where the current status of the event will
0657  *                                be returned
0658  *
0659  * RETURN:      Status
0660  *
0661  * DESCRIPTION: Obtains and returns the current status of the event
0662  *
0663  ******************************************************************************/
0664 
0665 ACPI_STATUS
0666 AcpiGetEventStatus (
0667     UINT32                  Event,
0668     ACPI_EVENT_STATUS       *EventStatus)
0669 {
0670     ACPI_STATUS             Status = AE_OK;
0671 
0672 
0673     ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
0674 
0675 
0676     if (!EventStatus)
0677     {
0678         return_ACPI_STATUS (AE_BAD_PARAMETER);
0679     }
0680 
0681     /* Decode the Fixed Event */
0682 
0683     if (Event > ACPI_EVENT_MAX)
0684     {
0685         return_ACPI_STATUS (AE_BAD_PARAMETER);
0686     }
0687 
0688     /* Get the status of the requested fixed event */
0689 
0690     Status = AcpiReadBitRegister (
0691                 AcpiGbl_FixedEventInfo[Event].StatusRegisterId, EventStatus);
0692 
0693     return_ACPI_STATUS (Status);
0694 }
0695 
0696 ACPI_EXPORT_SYMBOL (AcpiGetEventStatus)
0697 
0698 
0699 /*******************************************************************************
0700  *
0701  * FUNCTION:    AcpiGetGpeStatus
0702  *
0703  * PARAMETERS:  GpeDevice       - Parent GPE Device
0704  *              GpeNumber       - GPE level within the GPE block
0705  *              Flags           - Called from an ISR or not
0706  *              EventStatus     - Where the current status of the event will
0707  *                                be returned
0708  *
0709  * RETURN:      Status
0710  *
0711  * DESCRIPTION: Get status of an event (general purpose)
0712  *
0713  ******************************************************************************/
0714 
0715 ACPI_STATUS
0716 AcpiGetGpeStatus (
0717     ACPI_HANDLE             GpeDevice,
0718     UINT32                  GpeNumber,
0719     UINT32                  Flags,
0720     ACPI_EVENT_STATUS       *EventStatus)
0721 {
0722     ACPI_STATUS             Status = AE_OK;
0723     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
0724 
0725 
0726     ACPI_FUNCTION_TRACE (AcpiGetGpeStatus);
0727 
0728 
0729     /* Use semaphore lock if not executing at interrupt level */
0730 
0731     if (Flags & ACPI_NOT_ISR)
0732     {
0733         Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
0734         if (ACPI_FAILURE (Status))
0735         {
0736             return_ACPI_STATUS (Status);
0737         }
0738     }
0739 
0740     /* Ensure that we have a valid GPE number */
0741 
0742     GpeEventInfo = AcpiEvGetGpeEventInfo (GpeDevice, GpeNumber);
0743     if (!GpeEventInfo)
0744     {
0745         Status = AE_BAD_PARAMETER;
0746         goto UnlockAndExit;
0747     }
0748 
0749     /* Obtain status on the requested GPE number */
0750 
0751     Status = AcpiHwGetGpeStatus (GpeEventInfo, EventStatus);
0752 
0753 UnlockAndExit:
0754     if (Flags & ACPI_NOT_ISR)
0755     {
0756         (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
0757     }
0758     return_ACPI_STATUS (Status);
0759 }
0760 
0761 ACPI_EXPORT_SYMBOL (AcpiGetGpeStatus)
0762 
0763 
0764 /*******************************************************************************
0765  *
0766  * FUNCTION:    AcpiInstallGpeBlock
0767  *
0768  * PARAMETERS:  GpeDevice           - Handle to the parent GPE Block Device
0769  *              GpeBlockAddress     - Address and SpaceID
0770  *              RegisterCount       - Number of GPE register pairs in the block
0771  *              InterruptNumber     - H/W interrupt for the block
0772  *
0773  * RETURN:      Status
0774  *
0775  * DESCRIPTION: Create and Install a block of GPE registers
0776  *
0777  ******************************************************************************/
0778 
0779 ACPI_STATUS
0780 AcpiInstallGpeBlock (
0781     ACPI_HANDLE             GpeDevice,
0782     ACPI_GENERIC_ADDRESS    *GpeBlockAddress,
0783     UINT32                  RegisterCount,
0784     UINT32                  InterruptNumber)
0785 {
0786     ACPI_STATUS             Status;
0787     ACPI_OPERAND_OBJECT     *ObjDesc;
0788     ACPI_NAMESPACE_NODE     *Node;
0789     ACPI_GPE_BLOCK_INFO     *GpeBlock;
0790 
0791 
0792     ACPI_FUNCTION_TRACE (AcpiInstallGpeBlock);
0793 
0794 
0795     if ((!GpeDevice)       ||
0796         (!GpeBlockAddress) ||
0797         (!RegisterCount))
0798     {
0799         return_ACPI_STATUS (AE_BAD_PARAMETER);
0800     }
0801 
0802     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
0803     if (ACPI_FAILURE (Status))
0804     {
0805         return (Status);
0806     }
0807 
0808     Node = AcpiNsMapHandleToNode (GpeDevice);
0809     if (!Node)
0810     {
0811         Status = AE_BAD_PARAMETER;
0812         goto UnlockAndExit;
0813     }
0814 
0815     /*
0816      * For user-installed GPE Block Devices, the GpeBlockBaseNumber
0817      * is always zero
0818      */
0819     Status = AcpiEvCreateGpeBlock (Node, GpeBlockAddress, RegisterCount,
0820                 0, InterruptNumber, &GpeBlock);
0821     if (ACPI_FAILURE (Status))
0822     {
0823         goto UnlockAndExit;
0824     }
0825 
0826     /* Run the _PRW methods and enable the GPEs */
0827 
0828     Status = AcpiEvInitializeGpeBlock (Node, GpeBlock);
0829     if (ACPI_FAILURE (Status))
0830     {
0831         goto UnlockAndExit;
0832     }
0833 
0834     /* Get the DeviceObject attached to the node */
0835 
0836     ObjDesc = AcpiNsGetAttachedObject (Node);
0837     if (!ObjDesc)
0838     {
0839         /* No object, create a new one */
0840 
0841         ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_DEVICE);
0842         if (!ObjDesc)
0843         {
0844             Status = AE_NO_MEMORY;
0845             goto UnlockAndExit;
0846         }
0847 
0848         Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_DEVICE);
0849 
0850         /* Remove local reference to the object */
0851 
0852         AcpiUtRemoveReference (ObjDesc);
0853 
0854         if (ACPI_FAILURE (Status))
0855         {
0856             goto UnlockAndExit;
0857         }
0858     }
0859 
0860     /* Install the GPE block in the DeviceObject */
0861 
0862     ObjDesc->Device.GpeBlock = GpeBlock;
0863 
0864 
0865 UnlockAndExit:
0866     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
0867     return_ACPI_STATUS (Status);
0868 }
0869 
0870 ACPI_EXPORT_SYMBOL (AcpiInstallGpeBlock)
0871 
0872 
0873 /*******************************************************************************
0874  *
0875  * FUNCTION:    AcpiRemoveGpeBlock
0876  *
0877  * PARAMETERS:  GpeDevice           - Handle to the parent GPE Block Device
0878  *
0879  * RETURN:      Status
0880  *
0881  * DESCRIPTION: Remove a previously installed block of GPE registers
0882  *
0883  ******************************************************************************/
0884 
0885 ACPI_STATUS
0886 AcpiRemoveGpeBlock (
0887     ACPI_HANDLE             GpeDevice)
0888 {
0889     ACPI_OPERAND_OBJECT     *ObjDesc;
0890     ACPI_STATUS             Status;
0891     ACPI_NAMESPACE_NODE     *Node;
0892 
0893 
0894     ACPI_FUNCTION_TRACE (AcpiRemoveGpeBlock);
0895 
0896 
0897     if (!GpeDevice)
0898     {
0899         return_ACPI_STATUS (AE_BAD_PARAMETER);
0900     }
0901 
0902     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
0903     if (ACPI_FAILURE (Status))
0904     {
0905         return (Status);
0906     }
0907 
0908     Node = AcpiNsMapHandleToNode (GpeDevice);
0909     if (!Node)
0910     {
0911         Status = AE_BAD_PARAMETER;
0912         goto UnlockAndExit;
0913     }
0914 
0915     /* Get the DeviceObject attached to the node */
0916 
0917     ObjDesc = AcpiNsGetAttachedObject (Node);
0918     if (!ObjDesc ||
0919         !ObjDesc->Device.GpeBlock)
0920     {
0921         return_ACPI_STATUS (AE_NULL_OBJECT);
0922     }
0923 
0924     /* Delete the GPE block (but not the DeviceObject) */
0925 
0926     Status = AcpiEvDeleteGpeBlock (ObjDesc->Device.GpeBlock);
0927     if (ACPI_SUCCESS (Status))
0928     {
0929         ObjDesc->Device.GpeBlock = NULL;
0930     }
0931 
0932 UnlockAndExit:
0933     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
0934     return_ACPI_STATUS (Status);
0935 }
0936 
0937 ACPI_EXPORT_SYMBOL (AcpiRemoveGpeBlock)
0938 
0939 
0940 /*******************************************************************************
0941  *
0942  * FUNCTION:    AcpiGetGpeDevice
0943  *
0944  * PARAMETERS:  Index               - System GPE index (0-CurrentGpeCount)
0945  *              GpeDevice           - Where the parent GPE Device is returned
0946  *
0947  * RETURN:      Status
0948  *
0949  * DESCRIPTION: Obtain the GPE device associated with the input index. A NULL
0950  *              gpe device indicates that the gpe number is contained in one of
0951  *              the FADT-defined gpe blocks. Otherwise, the GPE block device.
0952  *
0953  ******************************************************************************/
0954 
0955 ACPI_STATUS
0956 AcpiGetGpeDevice (
0957     UINT32                  Index,
0958     ACPI_HANDLE             *GpeDevice)
0959 {
0960     ACPI_GPE_DEVICE_INFO    Info;
0961     ACPI_STATUS             Status;
0962 
0963 
0964     ACPI_FUNCTION_TRACE (AcpiGetGpeDevice);
0965 
0966 
0967     if (!GpeDevice)
0968     {
0969         return_ACPI_STATUS (AE_BAD_PARAMETER);
0970     }
0971 
0972     if (Index >= AcpiCurrentGpeCount)
0973     {
0974         return_ACPI_STATUS (AE_NOT_EXIST);
0975     }
0976 
0977     /* Setup and walk the GPE list */
0978 
0979     Info.Index = Index;
0980     Info.Status = AE_NOT_EXIST;
0981     Info.GpeDevice = NULL;
0982     Info.NextBlockBaseIndex = 0;
0983 
0984     Status = AcpiEvWalkGpeList (AcpiEvGetGpeDevice, &Info);
0985     if (ACPI_FAILURE (Status))
0986     {
0987         return_ACPI_STATUS (Status);
0988     }
0989 
0990     *GpeDevice = ACPI_CAST_PTR (ACPI_HANDLE, Info.GpeDevice);
0991     return_ACPI_STATUS (Info.Status);
0992 }
0993 
0994 ACPI_EXPORT_SYMBOL (AcpiGetGpeDevice)
0995 
0996 
0997 /*******************************************************************************
0998  *
0999  * FUNCTION:    AcpiEvGetGpeDevice
1000  *
1001  * PARAMETERS:  GPE_WALK_CALLBACK
1002  *
1003  * RETURN:      Status
1004  *
1005  * DESCRIPTION: Matches the input GPE index (0-CurrentGpeCount) with a GPE
1006  *              block device. NULL if the GPE is one of the FADT-defined GPEs.
1007  *
1008  ******************************************************************************/
1009 
1010 static ACPI_STATUS
1011 AcpiEvGetGpeDevice (
1012     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
1013     ACPI_GPE_BLOCK_INFO     *GpeBlock,
1014     void                    *Context)
1015 {
1016     ACPI_GPE_DEVICE_INFO    *Info = Context;
1017 
1018 
1019     /* Increment Index by the number of GPEs in this block */
1020 
1021     Info->NextBlockBaseIndex +=
1022         (GpeBlock->RegisterCount * ACPI_GPE_REGISTER_WIDTH);
1023 
1024     if (Info->Index < Info->NextBlockBaseIndex)
1025     {
1026         /*
1027          * The GPE index is within this block, get the node. Leave the node
1028          * NULL for the FADT-defined GPEs
1029          */
1030         if ((GpeBlock->Node)->Type == ACPI_TYPE_DEVICE)
1031         {
1032             Info->GpeDevice = GpeBlock->Node;
1033         }
1034 
1035         Info->Status = AE_OK;
1036         return (AE_CTRL_END);
1037     }
1038 
1039     return (AE_OK);
1040 }
1041 
1042 
1043 /******************************************************************************
1044  *
1045  * FUNCTION:    AcpiDisableAllGpes
1046  *
1047  * PARAMETERS:  None
1048  *
1049  * RETURN:      Status
1050  *
1051  * DESCRIPTION: Disable and clear all GPEs in all GPE blocks
1052  *
1053  ******************************************************************************/
1054 
1055 ACPI_STATUS
1056 AcpiDisableAllGpes (
1057     void)
1058 {
1059     ACPI_STATUS             Status;
1060 
1061 
1062     ACPI_FUNCTION_TRACE (AcpiDisableAllGpes);
1063 
1064 
1065     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
1066     if (ACPI_FAILURE (Status))
1067     {
1068         return_ACPI_STATUS (Status);
1069     }
1070 
1071     Status = AcpiHwDisableAllGpes ();
1072     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
1073 
1074     return_ACPI_STATUS (Status);
1075 }
1076 
1077 
1078 /******************************************************************************
1079  *
1080  * FUNCTION:    AcpiEnableAllRuntimeGpes
1081  *
1082  * PARAMETERS:  None
1083  *
1084  * RETURN:      Status
1085  *
1086  * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks
1087  *
1088  ******************************************************************************/
1089 
1090 ACPI_STATUS
1091 AcpiEnableAllRuntimeGpes (
1092     void)
1093 {
1094     ACPI_STATUS             Status;
1095 
1096 
1097     ACPI_FUNCTION_TRACE (AcpiEnableAllRuntimeGpes);
1098 
1099 
1100     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
1101     if (ACPI_FAILURE (Status))
1102     {
1103         return_ACPI_STATUS (Status);
1104     }
1105 
1106     Status = AcpiHwEnableAllRuntimeGpes ();
1107     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
1108 
1109     return_ACPI_STATUS (Status);
1110 }
1111 
1112