evxfevnt.c revision 70243
167754Smsmith/******************************************************************************
267754Smsmith *
367754Smsmith * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
470243Smsmith *              $Revision: 27 $
567754Smsmith *
667754Smsmith *****************************************************************************/
767754Smsmith
867754Smsmith/******************************************************************************
967754Smsmith *
1067754Smsmith * 1. Copyright Notice
1167754Smsmith *
1270243Smsmith * Some or all of this work - Copyright (c) 1999, 2000, Intel Corp.
1370243Smsmith * All rights reserved.
1467754Smsmith *
1567754Smsmith * 2. License
1667754Smsmith *
1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1867754Smsmith * rights.  You may have additional license terms from the party that provided
1967754Smsmith * you this software, covering your right to use that party's intellectual
2067754Smsmith * property rights.
2167754Smsmith *
2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2767754Smsmith * Code in any form, with the right to sublicense such rights; and
2867754Smsmith *
2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3067754Smsmith * license (with the right to sublicense), under only those claims of Intel
3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3467754Smsmith * license, and in no event shall the patent license extend to any additions
3567754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3667754Smsmith * is granted directly or by implication, estoppel or otherwise;
3767754Smsmith *
3867754Smsmith * The above copyright and patent license is granted only if the following
3967754Smsmith * conditions are met:
4067754Smsmith *
4167754Smsmith * 3. Conditions
4267754Smsmith *
4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4467754Smsmith * Redistribution of source code of any substantial prton of the Covered
4567754Smsmith * Code or modification with rights to further distribute source must include
4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4767754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered
5067754Smsmith * Code and the date of any change.  Licensee must include in that file the
5167754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5267754Smsmith * must include a prominent statement that the modification is derived,
5367754Smsmith * directly or indirectly, from Original Intel Code.
5467754Smsmith *
5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5667754Smsmith * Redistribution of source code of any substantial portion of the Covered
5767754Smsmith * Code or modification without rights to further distribute source must
5867754Smsmith * include the following Disclaimer and Export Compliance provision in the
5967754Smsmith * documentation and/or other materials provided with distribution.  In
6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6267754Smsmith * license from Licensee to its licensee is limited to the intellectual
6367754Smsmith * property embodied in the software Licensee provides to its licensee, and
6467754Smsmith * not to intellectual property embodied in modifications its licensee may
6567754Smsmith * make.
6667754Smsmith *
6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the
6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
7067754Smsmith * provision in the documentation and/or other materials provided with the
7167754Smsmith * distribution.
7267754Smsmith *
7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7467754Smsmith * Intel Code.
7567754Smsmith *
7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7867754Smsmith * other dealings in products derived from or relating to the Covered Code
7967754Smsmith * without prior written authorization from Intel.
8067754Smsmith *
8167754Smsmith * 4. Disclaimer and Export Compliance
8267754Smsmith *
8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8467754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8967754Smsmith * PARTICULAR PURPOSE.
9067754Smsmith *
9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9867754Smsmith * LIMITED REMEDY.
9967754Smsmith *
10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10167754Smsmith * software or system incorporating such software without first obtaining any
10267754Smsmith * required license or other approval from the U. S. Department of Commerce or
10367754Smsmith * any other agency or department of the United States Government.  In the
10467754Smsmith * event Licensee exports any such software from the United States or
10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10667754Smsmith * ensure that the distribution and export/re-export of the software is in
10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11067754Smsmith * software, or service, directly or indirectly, to any country for which the
11167754Smsmith * United States government or any agency thereof requires an export license,
11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11367754Smsmith * such license, approval or letter.
11467754Smsmith *
11567754Smsmith *****************************************************************************/
11667754Smsmith
11767754Smsmith
11867754Smsmith#define __EVXFEVNT_C__
11967754Smsmith
12067754Smsmith#include "acpi.h"
12167754Smsmith#include "achware.h"
12267754Smsmith#include "acnamesp.h"
12367754Smsmith#include "acevents.h"
12467754Smsmith#include "amlcode.h"
12567754Smsmith#include "acinterp.h"
12667754Smsmith
12767754Smsmith#define _COMPONENT          EVENT_HANDLING
12867754Smsmith        MODULE_NAME         ("evxfevnt")
12967754Smsmith
13067754Smsmith
13167754Smsmith/**************************************************************************
13267754Smsmith *
13367754Smsmith * FUNCTION:    AcpiEnable
13467754Smsmith *
13567754Smsmith * PARAMETERS:  None
13667754Smsmith *
13767754Smsmith * RETURN:      Status
13867754Smsmith *
13967754Smsmith * DESCRIPTION: Transfers the system into ACPI mode.
14067754Smsmith *
14167754Smsmith *************************************************************************/
14267754Smsmith
14367754SmsmithACPI_STATUS
14467754SmsmithAcpiEnable (void)
14567754Smsmith{
14667754Smsmith    ACPI_STATUS             Status;
14767754Smsmith
14867754Smsmith
14967754Smsmith    FUNCTION_TRACE ("AcpiEnable");
15067754Smsmith
15167754Smsmith
15267754Smsmith    /* Make sure we've got ACPI tables */
15367754Smsmith
15467754Smsmith    if (!AcpiGbl_DSDT)
15567754Smsmith    {
15667754Smsmith        DEBUG_PRINT (ACPI_WARN, ("No ACPI tables present!\n"));
15767754Smsmith        return_ACPI_STATUS (AE_NO_ACPI_TABLES);
15867754Smsmith    }
15967754Smsmith
16067754Smsmith    /* Make sure the BIOS supports ACPI mode */
16167754Smsmith
16267754Smsmith    if (SYS_MODE_LEGACY == AcpiHwGetModeCapabilities())
16367754Smsmith    {
16467754Smsmith        DEBUG_PRINT (ACPI_WARN,
16567754Smsmith            ("AcpiEnable: Only legacy mode supported!\n"));
16667754Smsmith        return_ACPI_STATUS (AE_ERROR);
16767754Smsmith    }
16867754Smsmith
16967754Smsmith    /* Transition to ACPI mode */
17067754Smsmith
17167754Smsmith    Status = AcpiHwSetMode (SYS_MODE_ACPI);
17267754Smsmith    if (ACPI_FAILURE (Status))
17367754Smsmith    {
17467754Smsmith        DEBUG_PRINT (ACPI_FATAL, ("Could not transition to ACPI mode.\n"));
17567754Smsmith        return_ACPI_STATUS (Status);
17667754Smsmith    }
17767754Smsmith
17867754Smsmith    DEBUG_PRINT (ACPI_OK, ("Transition to ACPI mode successful\n"));
17967754Smsmith
18067754Smsmith    return_ACPI_STATUS (Status);
18167754Smsmith}
18267754Smsmith
18367754Smsmith
18467754Smsmith/**************************************************************************
18567754Smsmith *
18667754Smsmith * FUNCTION:    AcpiDisable
18767754Smsmith *
18867754Smsmith * PARAMETERS:  None
18967754Smsmith *
19067754Smsmith * RETURN:      Status
19167754Smsmith *
19267754Smsmith * DESCRIPTION: Returns the system to original ACPI/legacy mode, and
19367754Smsmith *              uninstalls the SCI interrupt handler.
19467754Smsmith *
19567754Smsmith *************************************************************************/
19667754Smsmith
19767754SmsmithACPI_STATUS
19867754SmsmithAcpiDisable (void)
19967754Smsmith{
20067754Smsmith    ACPI_STATUS             Status;
20167754Smsmith
20267754Smsmith
20367754Smsmith    FUNCTION_TRACE ("AcpiDisable");
20467754Smsmith
20567754Smsmith
20667754Smsmith    /* Restore original mode  */
20767754Smsmith
20867754Smsmith    Status = AcpiHwSetMode (AcpiGbl_OriginalMode);
20967754Smsmith    if (ACPI_FAILURE (Status))
21067754Smsmith    {
21167754Smsmith        DEBUG_PRINT (ACPI_ERROR, ("Unable to transition to original mode"));
21267754Smsmith        return_ACPI_STATUS (Status);
21367754Smsmith    }
21467754Smsmith
21567754Smsmith    /* Unload the SCI interrupt handler  */
21667754Smsmith
21767754Smsmith    AcpiEvRemoveSciHandler ();
21867754Smsmith    AcpiEvRestoreAcpiState ();
21967754Smsmith
22067754Smsmith    return_ACPI_STATUS (Status);
22167754Smsmith}
22267754Smsmith
22367754Smsmith
22467754Smsmith/******************************************************************************
22567754Smsmith *
22667754Smsmith * FUNCTION:    AcpiEnableEvent
22767754Smsmith *
22867754Smsmith * PARAMETERS:  Event           - The fixed event or GPE to be enabled
22967754Smsmith *              Type            - The type of event
23067754Smsmith *
23167754Smsmith * RETURN:      Status
23267754Smsmith *
23367754Smsmith * DESCRIPTION: Enable an ACPI event (fixed and general purpose)
23467754Smsmith *
23567754Smsmith ******************************************************************************/
23667754Smsmith
23767754SmsmithACPI_STATUS
23867754SmsmithAcpiEnableEvent (
23967754Smsmith    UINT32                  Event,
24067754Smsmith    UINT32                  Type)
24167754Smsmith{
24267754Smsmith    ACPI_STATUS             Status = AE_OK;
24367754Smsmith    UINT32                  RegisterId;
24467754Smsmith
24567754Smsmith
24667754Smsmith    FUNCTION_TRACE ("AcpiEnableEvent");
24767754Smsmith
24867754Smsmith
24967754Smsmith    /* The Type must be either Fixed AcpiEvent or GPE */
25067754Smsmith
25167754Smsmith    switch (Type)
25267754Smsmith    {
25367754Smsmith
25467754Smsmith    case ACPI_EVENT_FIXED:
25567754Smsmith
25667754Smsmith        /* Decode the Fixed AcpiEvent */
25767754Smsmith
25867754Smsmith        switch (Event)
25967754Smsmith        {
26067754Smsmith        case ACPI_EVENT_PMTIMER:
26167754Smsmith            RegisterId = TMR_EN;
26267754Smsmith            break;
26367754Smsmith
26467754Smsmith        case ACPI_EVENT_GLOBAL:
26567754Smsmith            RegisterId = GBL_EN;
26667754Smsmith            break;
26767754Smsmith
26867754Smsmith        case ACPI_EVENT_POWER_BUTTON:
26967754Smsmith            RegisterId = PWRBTN_EN;
27067754Smsmith            break;
27167754Smsmith
27267754Smsmith        case ACPI_EVENT_SLEEP_BUTTON:
27367754Smsmith            RegisterId = SLPBTN_EN;
27467754Smsmith            break;
27567754Smsmith
27667754Smsmith        case ACPI_EVENT_RTC:
27767754Smsmith            RegisterId = RTC_EN;
27867754Smsmith            break;
27967754Smsmith
28067754Smsmith        default:
28167754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
28267754Smsmith            break;
28367754Smsmith        }
28467754Smsmith
28567754Smsmith        /*
28667754Smsmith         * Enable the requested fixed event (by writing a one to the
28767754Smsmith         * enable register bit)
28867754Smsmith         */
28967754Smsmith
29069450Smsmith        AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RegisterId, 1);
29169450Smsmith
29269450Smsmith        if (1 != AcpiHwRegisterBitAccess(ACPI_READ, ACPI_MTX_LOCK, RegisterId))
29369450Smsmith        {
29469450Smsmith            DEBUG_PRINT(ACPI_ERROR, ("Fixed event bit clear when it should be set,\n"));
29569450Smsmith            return_ACPI_STATUS (AE_ERROR);
29669450Smsmith        }
29769450Smsmith
29867754Smsmith        break;
29967754Smsmith
30067754Smsmith
30167754Smsmith    case ACPI_EVENT_GPE:
30267754Smsmith
30367754Smsmith        /* Ensure that we have a valid GPE number */
30467754Smsmith
30567754Smsmith        if ((Event >= NUM_GPE) ||
30667754Smsmith            (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID))
30767754Smsmith        {
30867754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
30967754Smsmith        }
31067754Smsmith
31167754Smsmith
31267754Smsmith        /* Enable the requested GPE number */
31367754Smsmith
31467754Smsmith        AcpiHwEnableGpe (Event);
31567754Smsmith        break;
31667754Smsmith
31767754Smsmith
31867754Smsmith    default:
31967754Smsmith
32067754Smsmith        Status = AE_BAD_PARAMETER;
32167754Smsmith    }
32267754Smsmith
32367754Smsmith
32467754Smsmith    return_ACPI_STATUS (Status);
32567754Smsmith}
32667754Smsmith
32767754Smsmith
32867754Smsmith/******************************************************************************
32967754Smsmith *
33067754Smsmith * FUNCTION:    AcpiDisableEvent
33167754Smsmith *
33267754Smsmith * PARAMETERS:  Event           - The fixed event or GPE to be enabled
33367754Smsmith *              Type            - The type of event
33467754Smsmith *
33567754Smsmith * RETURN:      Status
33667754Smsmith *
33767754Smsmith * DESCRIPTION: Disable an ACPI event (fixed and general purpose)
33867754Smsmith *
33967754Smsmith ******************************************************************************/
34067754Smsmith
34167754SmsmithACPI_STATUS
34267754SmsmithAcpiDisableEvent (
34367754Smsmith    UINT32                  Event,
34467754Smsmith    UINT32                  Type)
34567754Smsmith{
34667754Smsmith    ACPI_STATUS             Status = AE_OK;
34767754Smsmith    UINT32                  RegisterId;
34867754Smsmith
34967754Smsmith
35067754Smsmith    FUNCTION_TRACE ("AcpiDisableEvent");
35167754Smsmith
35267754Smsmith
35367754Smsmith    /* The Type must be either Fixed AcpiEvent or GPE */
35467754Smsmith
35567754Smsmith    switch (Type)
35667754Smsmith    {
35767754Smsmith
35867754Smsmith    case ACPI_EVENT_FIXED:
35967754Smsmith
36067754Smsmith        /* Decode the Fixed AcpiEvent */
36167754Smsmith
36267754Smsmith        switch (Event)
36367754Smsmith        {
36467754Smsmith        case ACPI_EVENT_PMTIMER:
36567754Smsmith            RegisterId = TMR_EN;
36667754Smsmith            break;
36767754Smsmith
36867754Smsmith        case ACPI_EVENT_GLOBAL:
36967754Smsmith            RegisterId = GBL_EN;
37067754Smsmith            break;
37167754Smsmith
37267754Smsmith        case ACPI_EVENT_POWER_BUTTON:
37367754Smsmith            RegisterId = PWRBTN_EN;
37467754Smsmith            break;
37567754Smsmith
37667754Smsmith        case ACPI_EVENT_SLEEP_BUTTON:
37767754Smsmith            RegisterId = SLPBTN_EN;
37867754Smsmith            break;
37967754Smsmith
38067754Smsmith        case ACPI_EVENT_RTC:
38167754Smsmith            RegisterId = RTC_EN;
38267754Smsmith            break;
38367754Smsmith
38467754Smsmith        default:
38567754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
38667754Smsmith            break;
38767754Smsmith        }
38867754Smsmith
38967754Smsmith        /*
39067754Smsmith         * Disable the requested fixed event (by writing a zero to the
39167754Smsmith         * enable register bit)
39267754Smsmith         */
39367754Smsmith
39469450Smsmith        AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RegisterId, 0);
39569450Smsmith
39669450Smsmith        if (0 != AcpiHwRegisterBitAccess(ACPI_READ, ACPI_MTX_LOCK, RegisterId))
39769450Smsmith        {
39869450Smsmith            DEBUG_PRINT(ACPI_ERROR, ("Fixed event bit set when it should be clear,\n"));
39969450Smsmith            return_ACPI_STATUS (AE_ERROR);
40069450Smsmith        }
40169450Smsmith
40267754Smsmith        break;
40367754Smsmith
40467754Smsmith
40567754Smsmith    case ACPI_EVENT_GPE:
40667754Smsmith
40767754Smsmith        /* Ensure that we have a valid GPE number */
40867754Smsmith
40967754Smsmith        if ((Event >= NUM_GPE) ||
41067754Smsmith            (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID))
41167754Smsmith        {
41267754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
41367754Smsmith        }
41467754Smsmith
41567754Smsmith        /* Disable the requested GPE number */
41667754Smsmith
41767754Smsmith        AcpiHwDisableGpe (Event);
41867754Smsmith        break;
41967754Smsmith
42067754Smsmith
42167754Smsmith    default:
42267754Smsmith        Status = AE_BAD_PARAMETER;
42367754Smsmith    }
42467754Smsmith
42567754Smsmith    return_ACPI_STATUS (Status);
42667754Smsmith}
42767754Smsmith
42867754Smsmith
42967754Smsmith/******************************************************************************
43067754Smsmith *
43167754Smsmith * FUNCTION:    AcpiClearEvent
43267754Smsmith *
43367754Smsmith * PARAMETERS:  Event           - The fixed event or GPE to be cleared
43467754Smsmith *              Type            - The type of event
43567754Smsmith *
43667754Smsmith * RETURN:      Status
43767754Smsmith *
43867754Smsmith * DESCRIPTION: Clear an ACPI event (fixed and general purpose)
43967754Smsmith *
44067754Smsmith ******************************************************************************/
44167754Smsmith
44267754SmsmithACPI_STATUS
44367754SmsmithAcpiClearEvent (
44467754Smsmith    UINT32                  Event,
44567754Smsmith    UINT32                  Type)
44667754Smsmith{
44767754Smsmith    ACPI_STATUS             Status = AE_OK;
44867754Smsmith    UINT32                  RegisterId;
44967754Smsmith
45067754Smsmith
45167754Smsmith    FUNCTION_TRACE ("AcpiClearEvent");
45267754Smsmith
45367754Smsmith
45467754Smsmith    /* The Type must be either Fixed AcpiEvent or GPE */
45567754Smsmith
45667754Smsmith    switch (Type)
45767754Smsmith    {
45867754Smsmith
45967754Smsmith    case ACPI_EVENT_FIXED:
46067754Smsmith
46167754Smsmith        /* Decode the Fixed AcpiEvent */
46267754Smsmith
46367754Smsmith        switch (Event)
46467754Smsmith        {
46567754Smsmith        case ACPI_EVENT_PMTIMER:
46667754Smsmith            RegisterId = TMR_STS;
46767754Smsmith            break;
46867754Smsmith
46967754Smsmith        case ACPI_EVENT_GLOBAL:
47067754Smsmith            RegisterId = GBL_STS;
47167754Smsmith            break;
47267754Smsmith
47367754Smsmith        case ACPI_EVENT_POWER_BUTTON:
47467754Smsmith            RegisterId = PWRBTN_STS;
47567754Smsmith            break;
47667754Smsmith
47767754Smsmith        case ACPI_EVENT_SLEEP_BUTTON:
47867754Smsmith            RegisterId = SLPBTN_STS;
47967754Smsmith            break;
48067754Smsmith
48167754Smsmith        case ACPI_EVENT_RTC:
48267754Smsmith            RegisterId = RTC_STS;
48367754Smsmith            break;
48467754Smsmith
48567754Smsmith        default:
48667754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
48767754Smsmith            break;
48867754Smsmith        }
48967754Smsmith
49067754Smsmith        /*
49167754Smsmith         * Clear the requested fixed event (By writing a one to the
49267754Smsmith         * status register bit)
49367754Smsmith         */
49467754Smsmith
49569450Smsmith        AcpiHwRegisterBitAccess (ACPI_WRITE, ACPI_MTX_LOCK, RegisterId, 1);
49667754Smsmith        break;
49767754Smsmith
49867754Smsmith
49967754Smsmith    case ACPI_EVENT_GPE:
50067754Smsmith
50167754Smsmith        /* Ensure that we have a valid GPE number */
50267754Smsmith
50367754Smsmith        if ((Event >= NUM_GPE) ||
50467754Smsmith            (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID))
50567754Smsmith        {
50667754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
50767754Smsmith        }
50867754Smsmith
50967754Smsmith
51067754Smsmith        AcpiHwClearGpe (Event);
51167754Smsmith        break;
51267754Smsmith
51367754Smsmith
51467754Smsmith    default:
51567754Smsmith
51667754Smsmith        Status = AE_BAD_PARAMETER;
51767754Smsmith    }
51867754Smsmith
51967754Smsmith    return_ACPI_STATUS (Status);
52067754Smsmith}
52167754Smsmith
52267754Smsmith
52367754Smsmith/******************************************************************************
52467754Smsmith *
52567754Smsmith * FUNCTION:    AcpiGetEventStatus
52667754Smsmith *
52767754Smsmith * PARAMETERS:  Event           - The fixed event or GPE
52867754Smsmith *              Type            - The type of event
52967754Smsmith *              Status          - Where the current status of the event will
53067754Smsmith *                                be returned
53167754Smsmith *
53267754Smsmith * RETURN:      Status
53367754Smsmith *
53467754Smsmith * DESCRIPTION: Obtains and returns the current status of the event
53567754Smsmith *
53667754Smsmith ******************************************************************************/
53767754Smsmith
53867754Smsmith
53967754SmsmithACPI_STATUS
54067754SmsmithAcpiGetEventStatus (
54167754Smsmith    UINT32                  Event,
54267754Smsmith    UINT32                  Type,
54367754Smsmith    ACPI_EVENT_STATUS       *EventStatus)
54467754Smsmith{
54567754Smsmith    ACPI_STATUS             Status = AE_OK;
54667754Smsmith    UINT32                  RegisterId;
54767754Smsmith
54867754Smsmith
54967754Smsmith    FUNCTION_TRACE ("AcpiGetEventStatus");
55067754Smsmith
55167754Smsmith
55267754Smsmith    if (!EventStatus)
55367754Smsmith    {
55467754Smsmith        return_ACPI_STATUS (AE_BAD_PARAMETER);
55567754Smsmith    }
55667754Smsmith
55767754Smsmith
55867754Smsmith    /* The Type must be either Fixed AcpiEvent or GPE */
55967754Smsmith
56067754Smsmith    switch (Type)
56167754Smsmith    {
56267754Smsmith
56367754Smsmith    case ACPI_EVENT_FIXED:
56467754Smsmith
56567754Smsmith        /* Decode the Fixed AcpiEvent */
56667754Smsmith
56767754Smsmith        switch (Event)
56867754Smsmith        {
56967754Smsmith        case ACPI_EVENT_PMTIMER:
57067754Smsmith            RegisterId = TMR_STS;
57167754Smsmith            break;
57267754Smsmith
57367754Smsmith        case ACPI_EVENT_GLOBAL:
57467754Smsmith            RegisterId = GBL_STS;
57567754Smsmith            break;
57667754Smsmith
57767754Smsmith        case ACPI_EVENT_POWER_BUTTON:
57867754Smsmith            RegisterId = PWRBTN_STS;
57967754Smsmith            break;
58067754Smsmith
58167754Smsmith        case ACPI_EVENT_SLEEP_BUTTON:
58267754Smsmith            RegisterId = SLPBTN_STS;
58367754Smsmith            break;
58467754Smsmith
58567754Smsmith        case ACPI_EVENT_RTC:
58667754Smsmith            RegisterId = RTC_STS;
58767754Smsmith            break;
58867754Smsmith
58967754Smsmith        default:
59067754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
59167754Smsmith            break;
59267754Smsmith        }
59367754Smsmith
59467754Smsmith        /* Get the status of the requested fixed event */
59567754Smsmith
59669450Smsmith        *EventStatus = AcpiHwRegisterBitAccess (ACPI_READ, ACPI_MTX_LOCK, RegisterId);
59767754Smsmith        break;
59867754Smsmith
59967754Smsmith
60067754Smsmith    case ACPI_EVENT_GPE:
60167754Smsmith
60267754Smsmith        /* Ensure that we have a valid GPE number */
60367754Smsmith
60467754Smsmith        if ((Event >= NUM_GPE) ||
60567754Smsmith            (AcpiGbl_GpeValid[Event] == ACPI_GPE_INVALID))
60667754Smsmith        {
60767754Smsmith            return_ACPI_STATUS (AE_BAD_PARAMETER);
60867754Smsmith        }
60967754Smsmith
61067754Smsmith
61167754Smsmith        /* Obtain status on the requested GPE number */
61267754Smsmith
61367754Smsmith        AcpiHwGetGpeStatus (Event, EventStatus);
61467754Smsmith        break;
61567754Smsmith
61667754Smsmith
61767754Smsmith    default:
61867754Smsmith        Status = AE_BAD_PARAMETER;
61967754Smsmith    }
62067754Smsmith
62167754Smsmith
62267754Smsmith    return_ACPI_STATUS (Status);
62367754Smsmith}
62467754Smsmith
625