1139823Simp/******************************************************************************
21541Srgrimes *
31541Srgrimes * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
41541Srgrimes *
51541Srgrimes *****************************************************************************/
61541Srgrimes
71541Srgrimes/******************************************************************************
81541Srgrimes *
91541Srgrimes * 1. Copyright Notice
101541Srgrimes *
111541Srgrimes * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp.
121541Srgrimes * All rights reserved.
131541Srgrimes *
141541Srgrimes * 2. License
151541Srgrimes *
161541Srgrimes * 2.1. This is your license from Intel Corp. under its intellectual property
171541Srgrimes * rights. You may have additional license terms from the party that provided
181541Srgrimes * you this software, covering your right to use that party's intellectual
191541Srgrimes * property rights.
201541Srgrimes *
211541Srgrimes * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
221541Srgrimes * copy of the source code appearing in this file ("Covered Code") an
231541Srgrimes * irrevocable, perpetual, worldwide license under Intel's copyrights in the
241541Srgrimes * base code distributed originally by Intel ("Original Intel Code") to copy,
251541Srgrimes * make derivatives, distribute, use and display any portion of the Covered
261541Srgrimes * Code in any form, with the right to sublicense such rights; and
271541Srgrimes *
281541Srgrimes * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
2985051Sru * license (with the right to sublicense), under only those claims of Intel
3050477Speter * patents that are infringed by the Original Intel Code, to make, use, sell,
311541Srgrimes * offer to sell, and import the Covered Code and derivative works thereof
321541Srgrimes * solely to the minimum extent necessary to exercise the above copyright
331541Srgrimes * license, and in no event shall the patent license extend to any additions
341541Srgrimes * to or modifications of the Original Intel Code. No other license or right
351541Srgrimes * is granted directly or by implication, estoppel or otherwise;
361541Srgrimes *
3732356Seivind * The above copyright and patent license is granted only if the following
3832350Seivind * conditions are met:
3954263Sshin *
4031742Seivind * 3. Conditions
4131742Seivind *
421541Srgrimes * 3.1. Redistribution of Source with Rights to Further Distribute Source.
431541Srgrimes * Redistribution of source code of any substantial portion of the Covered
441541Srgrimes * Code or modification with rights to further distribute source must include
4571791Speter * the above Copyright Notice, the above License, this list of Conditions,
461541Srgrimes * and the following Disclaimer and Export Compliance provision. In addition,
4771862Speter * Licensee must cause all Covered Code to which Licensee contributes to
4891648Sbrooks * contain a file documenting the changes Licensee made to create that Covered
4991648Sbrooks * Code and the date of any change. Licensee must include in that file the
501541Srgrimes * documentation of any changes made by any predecessor Licensee. Licensee
5124204Sbde * must include a prominent statement that the modification is derived,
5271791Speter * directly or indirectly, from Original Intel Code.
531541Srgrimes *
541541Srgrimes * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55130933Sbrooks * Redistribution of source code of any substantial portion of the Covered
561541Srgrimes * Code or modification without rights to further distribute source must
571541Srgrimes * include the following Disclaimer and Export Compliance provision in the
581541Srgrimes * documentation and/or other materials provided with distribution. In
591541Srgrimes * addition, Licensee may not authorize further sublicense of source of any
601541Srgrimes * portion of the Covered Code, and must include terms to the effect that the
611541Srgrimes * license from Licensee to its licensee is limited to the intellectual
621541Srgrimes * property embodied in the software Licensee provides to its licensee, and
631541Srgrimes * not to intellectual property embodied in modifications its licensee may
641541Srgrimes * make.
651541Srgrimes *
6611819Sjulian * 3.3. Redistribution of Executable. Redistribution in executable form of any
6711819Sjulian * substantial portion of the Covered Code or modification must reproduce the
6811819Sjulian * above Copyright Notice, and the following Disclaimer and Export Compliance
6911819Sjulian * provision in the documentation and/or other materials provided with the
7011819Sjulian * distribution.
7153541Sshin *
7253541Sshin * 3.4. Intel retains all right, title, and interest in and to the Original
7353541Sshin * Intel Code.
7453541Sshin *
7553541Sshin * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7662587Sitojun * Intel shall be used in advertising or otherwise to promote the sale, use or
7753541Sshin * other dealings in products derived from or relating to the Covered Code
7853541Sshin * without prior written authorization from Intel.
7915885Sjulian *
8015885Sjulian * 4. Disclaimer and Export Compliance
8115885Sjulian *
8283268Speter * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8315885Sjulian * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
841622Sdg * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
851541Srgrimes * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
8653541Sshin * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
8753541Sshin * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
881622Sdg * PARTICULAR PURPOSE.
896876Sdg *
901622Sdg * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
911541Srgrimes * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9291648Sbrooks * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
931541Srgrimes * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9471791Speter * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95147256Sbrooks * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
9671791Speter * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9791648Sbrooks * LIMITED REMEDY.
9891648Sbrooks *
9991648Sbrooks * 4.3. Licensee shall not export, either directly or indirectly, any of this
10091648Sbrooks * software or system incorporating such software without first obtaining any
10191648Sbrooks * required license or other approval from the U. S. Department of Commerce or
102160195Ssam * any other agency or department of the United States Government. In the
103128209Sbrooks * event Licensee exports any such software from the United States or
10491648Sbrooks * re-exports any such software from a foreign destination, Licensee shall
10591648Sbrooks * ensure that the distribution and export/re-export of the software is in
10691648Sbrooks * compliance with all laws, regulations, orders, or other restrictions of the
10791648Sbrooks * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10891648Sbrooks * any of its subsidiaries will export/re-export any technical data, process,
109130933Sbrooks * software, or service, directly or indirectly, to any country for which the
11091648Sbrooks * United States government or any agency thereof requires an export license,
111128209Sbrooks * other governmental approval, or letter of assurance, without first obtaining
112177965Srwatson * such license, approval or letter.
11391648Sbrooks *
11491648Sbrooks *****************************************************************************
11591648Sbrooks *
11691648Sbrooks * Alternatively, you may choose to be licensed under the terms of the
11791648Sbrooks * following license:
11897289Sbrooks *
11997289Sbrooks * Redistribution and use in source and binary forms, with or without
12091648Sbrooks * modification, are permitted provided that the following conditions
12191648Sbrooks * are met:
12291648Sbrooks * 1. Redistributions of source code must retain the above copyright
123147256Sbrooks *    notice, this list of conditions, and the following disclaimer,
12493752Sluigi *    without modification.
12591648Sbrooks * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12691648Sbrooks *    substantially similar to the "NO WARRANTY" disclaimer below
127128209Sbrooks *    ("Disclaimer") and any redistribution must be conditioned upon
128177965Srwatson *    including a substantially similar Disclaimer requirement for further
12971791Speter *    binary redistribution.
130147256Sbrooks * 3. Neither the names of the above-listed copyright holders nor the names
13171791Speter *    of any contributors may be used to endorse or promote products derived
13271791Speter *    from this software without specific prior written permission.
133111119Simp *
134147256Sbrooks * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135147256Sbrooks * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136147256Sbrooks * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137147256Sbrooks * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138147256Sbrooks * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
13971791Speter * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140147256Sbrooks * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141147256Sbrooks * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142147256Sbrooks * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143147256Sbrooks * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144147256Sbrooks * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145147256Sbrooks *
146147256Sbrooks * Alternatively, you may choose to be licensed under the terms of the
147147256Sbrooks * GNU General Public License ("GPL") version 2 as published by the Free
148147611Sdwmalone * Software Foundation.
14971791Speter *
150147256Sbrooks *****************************************************************************/
15192081Smux
15292081Smux#define EXPORT_ACPI_INTERFACES
15371791Speter
15471791Speter#include <contrib/dev/acpica/include/acpi.h>
15571791Speter#include <contrib/dev/acpica/include/accommon.h>
15671862Speter#include <contrib/dev/acpica/include/actables.h>
15771862Speter
158177965Srwatson#define _COMPONENT          ACPI_EVENTS
15971862Speter        ACPI_MODULE_NAME    ("evxfevnt")
16071862Speter
16191648Sbrooks
16271862Speter#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
163177965Srwatson/*******************************************************************************
16471862Speter *
16571862Speter * FUNCTION:    AcpiEnable
166177965Srwatson *
167177965Srwatson * PARAMETERS:  None
168132199Sphk *
169177965Srwatson * RETURN:      Status
17071862Speter *
171177965Srwatson * DESCRIPTION: Transfers the system into ACPI mode.
17271862Speter *
1731541Srgrimes ******************************************************************************/
17471862Speter
17571862SpeterACPI_STATUS
17671862SpeterAcpiEnable (
17771862Speter    void)
17871862Speter{
17971862Speter    ACPI_STATUS             Status = AE_OK;
180121596Skan
18171862Speter
18254263Sshin    ACPI_FUNCTION_TRACE (AcpiEnable);
183177965Srwatson
184177965Srwatson
1851541Srgrimes    /* ACPI tables must be present */
186147611Sdwmalone
187147611Sdwmalone    if (AcpiGbl_FadtIndex == ACPI_INVALID_TABLE_INDEX)
188113255Sdes    {
189113255Sdes        return_ACPI_STATUS (AE_NO_ACPI_TABLES);
19036908Sjulian    }
19136908Sjulian
19236908Sjulian    /* If the Hardware Reduced flag is set, machine is always in acpi mode */
19336908Sjulian
19436908Sjulian    if (AcpiGbl_ReducedHardware)
19553541Sshin    {
19636908Sjulian        return_ACPI_STATUS (AE_OK);
19736908Sjulian    }
198147611Sdwmalone
199147611Sdwmalone    /* Check current mode */
200147611Sdwmalone
201147611Sdwmalone    if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI)
202147611Sdwmalone    {
203147611Sdwmalone        ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
204147611Sdwmalone            "System is already in ACPI mode\n"));
20536992Sjulian    }
20636992Sjulian    else
20736992Sjulian    {
20853541Sshin        /* Transition to ACPI mode */
20936992Sjulian
21036992Sjulian        Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI);
21136994Sjulian        if (ACPI_FAILURE (Status))
21236992Sjulian        {
21365454Srwatson            ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode"));
21436992Sjulian            return_ACPI_STATUS (Status);
21536992Sjulian        }
21636992Sjulian
21736992Sjulian        ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
218177965Srwatson            "Transition to ACPI mode successful\n"));
21936908Sjulian    }
22036908Sjulian
22136908Sjulian    return_ACPI_STATUS (Status);
22236908Sjulian}
22336908Sjulian
22436908SjulianACPI_EXPORT_SYMBOL (AcpiEnable)
22536908Sjulian
22636908Sjulian
22736908Sjulian/*******************************************************************************
22836908Sjulian *
22936908Sjulian * FUNCTION:    AcpiDisable
23036908Sjulian *
23136908Sjulian * PARAMETERS:  None
232177965Srwatson *
23336908Sjulian * RETURN:      Status
23469152Sjlemon *
2351541Srgrimes * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
236113255Sdes *
237121645Ssam ******************************************************************************/
23836908Sjulian
23960889SarchieACPI_STATUS
240162539SsuzAcpiDisable (
241162539Ssuz    void)
242162539Ssuz{
243162539Ssuz    ACPI_STATUS             Status = AE_OK;
244162539Ssuz
245162539Ssuz
246162539Ssuz    ACPI_FUNCTION_TRACE (AcpiDisable);
247162539Ssuz
248162539Ssuz
249162539Ssuz    /* If the Hardware Reduced flag is set, machine is always in acpi mode */
250162539Ssuz
251162539Ssuz    if (AcpiGbl_ReducedHardware)
252123922Ssam    {
253162539Ssuz        return_ACPI_STATUS (AE_OK);
254162539Ssuz    }
255162539Ssuz
256162539Ssuz    if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY)
257162539Ssuz    {
258162539Ssuz        ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
259162539Ssuz            "System is already in legacy (non-ACPI) mode\n"));
260162539Ssuz    }
261162539Ssuz    else
262162539Ssuz    {
263162539Ssuz        /* Transition to LEGACY mode */
264162539Ssuz
265162539Ssuz        Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY);
2661541Srgrimes
2671541Srgrimes        if (ACPI_FAILURE (Status))
26836908Sjulian        {
26937600Sdfr            ACPI_ERROR ((AE_INFO,
27060952Sgallatin                "Could not exit ACPI mode to legacy mode"));
271166577Scognet            return_ACPI_STATUS (Status);
272158471Sjhb        }
273158471Sjhb
274158471Sjhb        ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
275158471Sjhb            "ACPI mode disabled\n"));
27660952Sgallatin    }
27761181Smjacob
27860952Sgallatin    return_ACPI_STATUS (Status);
27960952Sgallatin}
28060952Sgallatin
28160952SgallatinACPI_EXPORT_SYMBOL (AcpiDisable)
282132780Skan
28360952Sgallatin
28437600Sdfr/*******************************************************************************
28537600Sdfr *
28636908Sjulian * FUNCTION:    AcpiEnableEvent
28760889Sarchie *
28860889Sarchie * PARAMETERS:  Event           - The fixed eventto be enabled
2891541Srgrimes *              Flags           - Reserved
2901541Srgrimes *
2911541Srgrimes * RETURN:      Status
2921541Srgrimes *
2931541Srgrimes * DESCRIPTION: Enable an ACPI event (fixed)
29453541Sshin *
29553541Sshin ******************************************************************************/
29653541Sshin
29753541SshinACPI_STATUS
29853541SshinAcpiEnableEvent (
29953541Sshin    UINT32                  Event,
30011819Sjulian    UINT32                  Flags)
30111819Sjulian{
30211819Sjulian    ACPI_STATUS             Status = AE_OK;
30311819Sjulian    UINT32                  Value;
30411819Sjulian
30515885Sjulian
30615885Sjulian    ACPI_FUNCTION_TRACE (AcpiEnableEvent);
307111888Sjlemon
30815885Sjulian
30983268Speter    /* If Hardware Reduced flag is set, there are no fixed events */
3101541Srgrimes
31160889Sarchie    if (AcpiGbl_ReducedHardware)
3121541Srgrimes    {
3131541Srgrimes        return_ACPI_STATUS (AE_OK);
3141541Srgrimes    }
3151541Srgrimes
3161541Srgrimes    /* Decode the Fixed Event */
317134391Sandre
3181541Srgrimes    if (Event > ACPI_EVENT_MAX)
3191541Srgrimes    {
3201541Srgrimes        return_ACPI_STATUS (AE_BAD_PARAMETER);
3211541Srgrimes    }
32212706Sphk
323177965Srwatson    /*
3241541Srgrimes     * Enable the requested fixed event (by writing a one to the enable
325177965Srwatson     * register bit)
326120727Ssam     */
327142352Ssam    Status = AcpiWriteBitRegister (
3281541Srgrimes        AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
3291541Srgrimes        ACPI_ENABLE_EVENT);
3301541Srgrimes    if (ACPI_FAILURE (Status))
3311541Srgrimes    {
3321541Srgrimes        return_ACPI_STATUS (Status);
3331541Srgrimes    }
33454263Sshin
335177965Srwatson    /* Make sure that the hardware responded */
3361541Srgrimes
337177965Srwatson    Status = AcpiReadBitRegister (
338177965Srwatson        AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
339177965Srwatson    if (ACPI_FAILURE (Status))
3401541Srgrimes    {
3411541Srgrimes        return_ACPI_STATUS (Status);
3421541Srgrimes    }
343148887Srwatson
344148887Srwatson    if (Value != 1)
3451541Srgrimes    {
34613928Swollman        ACPI_ERROR ((AE_INFO,
3471541Srgrimes            "Could not enable %s event", AcpiUtGetEventName (Event)));
3481541Srgrimes        return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
3491541Srgrimes    }
3501541Srgrimes
3511541Srgrimes    return_ACPI_STATUS (Status);
3521541Srgrimes}
3531541Srgrimes
3541541SrgrimesACPI_EXPORT_SYMBOL (AcpiEnableEvent)
3551541Srgrimes
3561541Srgrimes
3571541Srgrimes/*******************************************************************************
3581541Srgrimes *
3591541Srgrimes * FUNCTION:    AcpiDisableEvent
3601541Srgrimes *
3611541Srgrimes * PARAMETERS:  Event           - The fixed event to be disabled
3621541Srgrimes *              Flags           - Reserved
3631541Srgrimes *
36453541Sshin * RETURN:      Status
36553541Sshin *
36653541Sshin * DESCRIPTION: Disable an ACPI event (fixed)
36753541Sshin *
3681541Srgrimes ******************************************************************************/
3691541Srgrimes
3701541SrgrimesACPI_STATUS
3711541SrgrimesAcpiDisableEvent (
3721541Srgrimes    UINT32                  Event,
3731541Srgrimes    UINT32                  Flags)
3741541Srgrimes{
3751944Sdg    ACPI_STATUS             Status = AE_OK;
37649468Sbrian    UINT32                  Value;
3771944Sdg
3781944Sdg
37935563Sphk    ACPI_FUNCTION_TRACE (AcpiDisableEvent);
38035563Sphk
38135563Sphk
3821541Srgrimes    /* If Hardware Reduced flag is set, there are no fixed events */
3831541Srgrimes
3841541Srgrimes    if (AcpiGbl_ReducedHardware)
3851541Srgrimes    {
3861541Srgrimes        return_ACPI_STATUS (AE_OK);
387    }
388
389    /* Decode the Fixed Event */
390
391    if (Event > ACPI_EVENT_MAX)
392    {
393        return_ACPI_STATUS (AE_BAD_PARAMETER);
394    }
395
396    /*
397     * Disable the requested fixed event (by writing a zero to the enable
398     * register bit)
399     */
400    Status = AcpiWriteBitRegister (
401        AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
402        ACPI_DISABLE_EVENT);
403    if (ACPI_FAILURE (Status))
404    {
405        return_ACPI_STATUS (Status);
406    }
407
408    Status = AcpiReadBitRegister (
409        AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
410    if (ACPI_FAILURE (Status))
411    {
412        return_ACPI_STATUS (Status);
413    }
414
415    if (Value != 0)
416    {
417        ACPI_ERROR ((AE_INFO,
418            "Could not disable %s events", AcpiUtGetEventName (Event)));
419        return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
420    }
421
422    return_ACPI_STATUS (Status);
423}
424
425ACPI_EXPORT_SYMBOL (AcpiDisableEvent)
426
427
428/*******************************************************************************
429 *
430 * FUNCTION:    AcpiClearEvent
431 *
432 * PARAMETERS:  Event           - The fixed event to be cleared
433 *
434 * RETURN:      Status
435 *
436 * DESCRIPTION: Clear an ACPI event (fixed)
437 *
438 ******************************************************************************/
439
440ACPI_STATUS
441AcpiClearEvent (
442    UINT32                  Event)
443{
444    ACPI_STATUS             Status = AE_OK;
445
446
447    ACPI_FUNCTION_TRACE (AcpiClearEvent);
448
449
450    /* If Hardware Reduced flag is set, there are no fixed events */
451
452    if (AcpiGbl_ReducedHardware)
453    {
454        return_ACPI_STATUS (AE_OK);
455    }
456
457    /* Decode the Fixed Event */
458
459    if (Event > ACPI_EVENT_MAX)
460    {
461        return_ACPI_STATUS (AE_BAD_PARAMETER);
462    }
463
464    /*
465     * Clear the requested fixed event (By writing a one to the status
466     * register bit)
467     */
468    Status = AcpiWriteBitRegister (
469        AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
470        ACPI_CLEAR_STATUS);
471
472    return_ACPI_STATUS (Status);
473}
474
475ACPI_EXPORT_SYMBOL (AcpiClearEvent)
476
477
478/*******************************************************************************
479 *
480 * FUNCTION:    AcpiGetEventStatus
481 *
482 * PARAMETERS:  Event           - The fixed event
483 *              EventStatus     - Where the current status of the event will
484 *                                be returned
485 *
486 * RETURN:      Status
487 *
488 * DESCRIPTION: Obtains and returns the current status of the event
489 *
490 ******************************************************************************/
491
492ACPI_STATUS
493AcpiGetEventStatus (
494    UINT32                  Event,
495    ACPI_EVENT_STATUS       *EventStatus)
496{
497    ACPI_STATUS             Status;
498    ACPI_EVENT_STATUS       LocalEventStatus = 0;
499    UINT32                  InByte;
500
501
502    ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
503
504
505    if (!EventStatus)
506    {
507        return_ACPI_STATUS (AE_BAD_PARAMETER);
508    }
509
510    /* Decode the Fixed Event */
511
512    if (Event > ACPI_EVENT_MAX)
513    {
514        return_ACPI_STATUS (AE_BAD_PARAMETER);
515    }
516
517    /* Fixed event currently can be dispatched? */
518
519    if (AcpiGbl_FixedEventHandlers[Event].Handler)
520    {
521        LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER;
522    }
523
524    /* Fixed event currently enabled? */
525
526    Status = AcpiReadBitRegister (
527        AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &InByte);
528    if (ACPI_FAILURE (Status))
529    {
530        return_ACPI_STATUS (Status);
531    }
532
533    if (InByte)
534    {
535        LocalEventStatus |=
536            (ACPI_EVENT_FLAG_ENABLED | ACPI_EVENT_FLAG_ENABLE_SET);
537    }
538
539    /* Fixed event currently active? */
540
541    Status = AcpiReadBitRegister (
542        AcpiGbl_FixedEventInfo[Event].StatusRegisterId, &InByte);
543    if (ACPI_FAILURE (Status))
544    {
545        return_ACPI_STATUS (Status);
546    }
547
548    if (InByte)
549    {
550        LocalEventStatus |= ACPI_EVENT_FLAG_STATUS_SET;
551    }
552
553    (*EventStatus) = LocalEventStatus;
554    return_ACPI_STATUS (AE_OK);
555}
556
557ACPI_EXPORT_SYMBOL (AcpiGetEventStatus)
558
559#endif /* !ACPI_REDUCED_HARDWARE */
560