xref: /minix3/minix/drivers/power/acpi/events/evxfevnt.c (revision 29492bb71c7148a089a5afafa0c99409161218df)
1433d6423SLionel Sambuc /******************************************************************************
2433d6423SLionel Sambuc  *
3433d6423SLionel Sambuc  * Module Name: evxfevnt - External Interfaces, ACPI event disable/enable
4433d6423SLionel Sambuc  *
5433d6423SLionel Sambuc  *****************************************************************************/
6433d6423SLionel Sambuc 
7*29492bb7SDavid van Moolenbroek /*
8*29492bb7SDavid van Moolenbroek  * Copyright (C) 2000 - 2014, Intel Corp.
9433d6423SLionel Sambuc  * All rights reserved.
10433d6423SLionel Sambuc  *
11*29492bb7SDavid van Moolenbroek  * Redistribution and use in source and binary forms, with or without
12*29492bb7SDavid van Moolenbroek  * modification, are permitted provided that the following conditions
13*29492bb7SDavid van Moolenbroek  * are met:
14*29492bb7SDavid van Moolenbroek  * 1. Redistributions of source code must retain the above copyright
15*29492bb7SDavid van Moolenbroek  *    notice, this list of conditions, and the following disclaimer,
16*29492bb7SDavid van Moolenbroek  *    without modification.
17*29492bb7SDavid van Moolenbroek  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*29492bb7SDavid van Moolenbroek  *    substantially similar to the "NO WARRANTY" disclaimer below
19*29492bb7SDavid van Moolenbroek  *    ("Disclaimer") and any redistribution must be conditioned upon
20*29492bb7SDavid van Moolenbroek  *    including a substantially similar Disclaimer requirement for further
21*29492bb7SDavid van Moolenbroek  *    binary redistribution.
22*29492bb7SDavid van Moolenbroek  * 3. Neither the names of the above-listed copyright holders nor the names
23*29492bb7SDavid van Moolenbroek  *    of any contributors may be used to endorse or promote products derived
24*29492bb7SDavid van Moolenbroek  *    from this software without specific prior written permission.
25433d6423SLionel Sambuc  *
26*29492bb7SDavid van Moolenbroek  * Alternatively, this software may be distributed under the terms of the
27*29492bb7SDavid van Moolenbroek  * GNU General Public License ("GPL") version 2 as published by the Free
28*29492bb7SDavid van Moolenbroek  * Software Foundation.
29433d6423SLionel Sambuc  *
30*29492bb7SDavid van Moolenbroek  * NO WARRANTY
31*29492bb7SDavid van Moolenbroek  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*29492bb7SDavid van Moolenbroek  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*29492bb7SDavid van Moolenbroek  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*29492bb7SDavid van Moolenbroek  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*29492bb7SDavid van Moolenbroek  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*29492bb7SDavid van Moolenbroek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*29492bb7SDavid van Moolenbroek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*29492bb7SDavid van Moolenbroek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*29492bb7SDavid van Moolenbroek  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*29492bb7SDavid van Moolenbroek  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*29492bb7SDavid van Moolenbroek  * POSSIBILITY OF SUCH DAMAGES.
42*29492bb7SDavid van Moolenbroek  */
43433d6423SLionel Sambuc 
44*29492bb7SDavid van Moolenbroek #define EXPORT_ACPI_INTERFACES
45433d6423SLionel Sambuc 
46433d6423SLionel Sambuc #include "acpi.h"
47433d6423SLionel Sambuc #include "accommon.h"
48433d6423SLionel Sambuc #include "actables.h"
49433d6423SLionel Sambuc 
50433d6423SLionel Sambuc #define _COMPONENT          ACPI_EVENTS
51433d6423SLionel Sambuc         ACPI_MODULE_NAME    ("evxfevnt")
52433d6423SLionel Sambuc 
53433d6423SLionel Sambuc 
54*29492bb7SDavid van Moolenbroek #if (!ACPI_REDUCED_HARDWARE) /* Entire module */
55433d6423SLionel Sambuc /*******************************************************************************
56433d6423SLionel Sambuc  *
57433d6423SLionel Sambuc  * FUNCTION:    AcpiEnable
58433d6423SLionel Sambuc  *
59433d6423SLionel Sambuc  * PARAMETERS:  None
60433d6423SLionel Sambuc  *
61433d6423SLionel Sambuc  * RETURN:      Status
62433d6423SLionel Sambuc  *
63433d6423SLionel Sambuc  * DESCRIPTION: Transfers the system into ACPI mode.
64433d6423SLionel Sambuc  *
65433d6423SLionel Sambuc  ******************************************************************************/
66433d6423SLionel Sambuc 
67433d6423SLionel Sambuc ACPI_STATUS
AcpiEnable(void)68433d6423SLionel Sambuc AcpiEnable (
69433d6423SLionel Sambuc     void)
70433d6423SLionel Sambuc {
71433d6423SLionel Sambuc     ACPI_STATUS             Status = AE_OK;
72433d6423SLionel Sambuc 
73433d6423SLionel Sambuc 
74433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (AcpiEnable);
75433d6423SLionel Sambuc 
76433d6423SLionel Sambuc 
77433d6423SLionel Sambuc     /* ACPI tables must be present */
78433d6423SLionel Sambuc 
79433d6423SLionel Sambuc     if (!AcpiTbTablesLoaded ())
80433d6423SLionel Sambuc     {
81433d6423SLionel Sambuc         return_ACPI_STATUS (AE_NO_ACPI_TABLES);
82433d6423SLionel Sambuc     }
83433d6423SLionel Sambuc 
84*29492bb7SDavid van Moolenbroek     /* If the Hardware Reduced flag is set, machine is always in acpi mode */
85*29492bb7SDavid van Moolenbroek 
86*29492bb7SDavid van Moolenbroek     if (AcpiGbl_ReducedHardware)
87*29492bb7SDavid van Moolenbroek     {
88*29492bb7SDavid van Moolenbroek         return_ACPI_STATUS (AE_OK);
89*29492bb7SDavid van Moolenbroek     }
90*29492bb7SDavid van Moolenbroek 
91433d6423SLionel Sambuc     /* Check current mode */
92433d6423SLionel Sambuc 
93433d6423SLionel Sambuc     if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI)
94433d6423SLionel Sambuc     {
95433d6423SLionel Sambuc         ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "System is already in ACPI mode\n"));
96433d6423SLionel Sambuc     }
97433d6423SLionel Sambuc     else
98433d6423SLionel Sambuc     {
99433d6423SLionel Sambuc         /* Transition to ACPI mode */
100433d6423SLionel Sambuc 
101433d6423SLionel Sambuc         Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI);
102433d6423SLionel Sambuc         if (ACPI_FAILURE (Status))
103433d6423SLionel Sambuc         {
104433d6423SLionel Sambuc             ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode"));
105433d6423SLionel Sambuc             return_ACPI_STATUS (Status);
106433d6423SLionel Sambuc         }
107433d6423SLionel Sambuc 
108433d6423SLionel Sambuc         ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
109433d6423SLionel Sambuc             "Transition to ACPI mode successful\n"));
110433d6423SLionel Sambuc     }
111433d6423SLionel Sambuc 
112433d6423SLionel Sambuc     return_ACPI_STATUS (Status);
113433d6423SLionel Sambuc }
114433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiEnable)115433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiEnable)
116433d6423SLionel Sambuc 
117433d6423SLionel Sambuc 
118433d6423SLionel Sambuc /*******************************************************************************
119433d6423SLionel Sambuc  *
120433d6423SLionel Sambuc  * FUNCTION:    AcpiDisable
121433d6423SLionel Sambuc  *
122433d6423SLionel Sambuc  * PARAMETERS:  None
123433d6423SLionel Sambuc  *
124433d6423SLionel Sambuc  * RETURN:      Status
125433d6423SLionel Sambuc  *
126433d6423SLionel Sambuc  * DESCRIPTION: Transfers the system into LEGACY (non-ACPI) mode.
127433d6423SLionel Sambuc  *
128433d6423SLionel Sambuc  ******************************************************************************/
129433d6423SLionel Sambuc 
130433d6423SLionel Sambuc ACPI_STATUS
131433d6423SLionel Sambuc AcpiDisable (
132433d6423SLionel Sambuc     void)
133433d6423SLionel Sambuc {
134433d6423SLionel Sambuc     ACPI_STATUS             Status = AE_OK;
135433d6423SLionel Sambuc 
136433d6423SLionel Sambuc 
137433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (AcpiDisable);
138433d6423SLionel Sambuc 
139433d6423SLionel Sambuc 
140*29492bb7SDavid van Moolenbroek     /* If the Hardware Reduced flag is set, machine is always in acpi mode */
141*29492bb7SDavid van Moolenbroek 
142*29492bb7SDavid van Moolenbroek     if (AcpiGbl_ReducedHardware)
143*29492bb7SDavid van Moolenbroek     {
144*29492bb7SDavid van Moolenbroek         return_ACPI_STATUS (AE_OK);
145*29492bb7SDavid van Moolenbroek     }
146*29492bb7SDavid van Moolenbroek 
147433d6423SLionel Sambuc     if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY)
148433d6423SLionel Sambuc     {
149433d6423SLionel Sambuc         ACPI_DEBUG_PRINT ((ACPI_DB_INIT,
150433d6423SLionel Sambuc             "System is already in legacy (non-ACPI) mode\n"));
151433d6423SLionel Sambuc     }
152433d6423SLionel Sambuc     else
153433d6423SLionel Sambuc     {
154433d6423SLionel Sambuc         /* Transition to LEGACY mode */
155433d6423SLionel Sambuc 
156433d6423SLionel Sambuc         Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY);
157433d6423SLionel Sambuc 
158433d6423SLionel Sambuc         if (ACPI_FAILURE (Status))
159433d6423SLionel Sambuc         {
160433d6423SLionel Sambuc             ACPI_ERROR ((AE_INFO,
161433d6423SLionel Sambuc                 "Could not exit ACPI mode to legacy mode"));
162433d6423SLionel Sambuc             return_ACPI_STATUS (Status);
163433d6423SLionel Sambuc         }
164433d6423SLionel Sambuc 
165433d6423SLionel Sambuc         ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI mode disabled\n"));
166433d6423SLionel Sambuc     }
167433d6423SLionel Sambuc 
168433d6423SLionel Sambuc     return_ACPI_STATUS (Status);
169433d6423SLionel Sambuc }
170433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiDisable)171433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiDisable)
172433d6423SLionel Sambuc 
173433d6423SLionel Sambuc 
174433d6423SLionel Sambuc /*******************************************************************************
175433d6423SLionel Sambuc  *
176433d6423SLionel Sambuc  * FUNCTION:    AcpiEnableEvent
177433d6423SLionel Sambuc  *
178433d6423SLionel Sambuc  * PARAMETERS:  Event           - The fixed eventto be enabled
179433d6423SLionel Sambuc  *              Flags           - Reserved
180433d6423SLionel Sambuc  *
181433d6423SLionel Sambuc  * RETURN:      Status
182433d6423SLionel Sambuc  *
183433d6423SLionel Sambuc  * DESCRIPTION: Enable an ACPI event (fixed)
184433d6423SLionel Sambuc  *
185433d6423SLionel Sambuc  ******************************************************************************/
186433d6423SLionel Sambuc 
187433d6423SLionel Sambuc ACPI_STATUS
188433d6423SLionel Sambuc AcpiEnableEvent (
189433d6423SLionel Sambuc     UINT32                  Event,
190433d6423SLionel Sambuc     UINT32                  Flags)
191433d6423SLionel Sambuc {
192433d6423SLionel Sambuc     ACPI_STATUS             Status = AE_OK;
193433d6423SLionel Sambuc     UINT32                  Value;
194433d6423SLionel Sambuc 
195433d6423SLionel Sambuc 
196433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (AcpiEnableEvent);
197433d6423SLionel Sambuc 
198433d6423SLionel Sambuc 
199433d6423SLionel Sambuc     /* Decode the Fixed Event */
200433d6423SLionel Sambuc 
201433d6423SLionel Sambuc     if (Event > ACPI_EVENT_MAX)
202433d6423SLionel Sambuc     {
203433d6423SLionel Sambuc         return_ACPI_STATUS (AE_BAD_PARAMETER);
204433d6423SLionel Sambuc     }
205433d6423SLionel Sambuc 
206433d6423SLionel Sambuc     /*
207433d6423SLionel Sambuc      * Enable the requested fixed event (by writing a one to the enable
208433d6423SLionel Sambuc      * register bit)
209433d6423SLionel Sambuc      */
210433d6423SLionel Sambuc     Status = AcpiWriteBitRegister (
211433d6423SLionel Sambuc                 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
212433d6423SLionel Sambuc                 ACPI_ENABLE_EVENT);
213433d6423SLionel Sambuc     if (ACPI_FAILURE (Status))
214433d6423SLionel Sambuc     {
215433d6423SLionel Sambuc         return_ACPI_STATUS (Status);
216433d6423SLionel Sambuc     }
217433d6423SLionel Sambuc 
218433d6423SLionel Sambuc     /* Make sure that the hardware responded */
219433d6423SLionel Sambuc 
220433d6423SLionel Sambuc     Status = AcpiReadBitRegister (
221433d6423SLionel Sambuc                 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
222433d6423SLionel Sambuc     if (ACPI_FAILURE (Status))
223433d6423SLionel Sambuc     {
224433d6423SLionel Sambuc         return_ACPI_STATUS (Status);
225433d6423SLionel Sambuc     }
226433d6423SLionel Sambuc 
227433d6423SLionel Sambuc     if (Value != 1)
228433d6423SLionel Sambuc     {
229433d6423SLionel Sambuc         ACPI_ERROR ((AE_INFO,
230433d6423SLionel Sambuc             "Could not enable %s event", AcpiUtGetEventName (Event)));
231433d6423SLionel Sambuc         return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
232433d6423SLionel Sambuc     }
233433d6423SLionel Sambuc 
234433d6423SLionel Sambuc     return_ACPI_STATUS (Status);
235433d6423SLionel Sambuc }
236433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiEnableEvent)237433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiEnableEvent)
238433d6423SLionel Sambuc 
239433d6423SLionel Sambuc 
240433d6423SLionel Sambuc /*******************************************************************************
241433d6423SLionel Sambuc  *
242433d6423SLionel Sambuc  * FUNCTION:    AcpiDisableEvent
243433d6423SLionel Sambuc  *
244*29492bb7SDavid van Moolenbroek  * PARAMETERS:  Event           - The fixed event to be disabled
245433d6423SLionel Sambuc  *              Flags           - Reserved
246433d6423SLionel Sambuc  *
247433d6423SLionel Sambuc  * RETURN:      Status
248433d6423SLionel Sambuc  *
249433d6423SLionel Sambuc  * DESCRIPTION: Disable an ACPI event (fixed)
250433d6423SLionel Sambuc  *
251433d6423SLionel Sambuc  ******************************************************************************/
252433d6423SLionel Sambuc 
253433d6423SLionel Sambuc ACPI_STATUS
254433d6423SLionel Sambuc AcpiDisableEvent (
255433d6423SLionel Sambuc     UINT32                  Event,
256433d6423SLionel Sambuc     UINT32                  Flags)
257433d6423SLionel Sambuc {
258433d6423SLionel Sambuc     ACPI_STATUS             Status = AE_OK;
259433d6423SLionel Sambuc     UINT32                  Value;
260433d6423SLionel Sambuc 
261433d6423SLionel Sambuc 
262433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (AcpiDisableEvent);
263433d6423SLionel Sambuc 
264433d6423SLionel Sambuc 
265433d6423SLionel Sambuc     /* Decode the Fixed Event */
266433d6423SLionel Sambuc 
267433d6423SLionel Sambuc     if (Event > ACPI_EVENT_MAX)
268433d6423SLionel Sambuc     {
269433d6423SLionel Sambuc         return_ACPI_STATUS (AE_BAD_PARAMETER);
270433d6423SLionel Sambuc     }
271433d6423SLionel Sambuc 
272433d6423SLionel Sambuc     /*
273433d6423SLionel Sambuc      * Disable the requested fixed event (by writing a zero to the enable
274433d6423SLionel Sambuc      * register bit)
275433d6423SLionel Sambuc      */
276433d6423SLionel Sambuc     Status = AcpiWriteBitRegister (
277433d6423SLionel Sambuc                 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
278433d6423SLionel Sambuc                 ACPI_DISABLE_EVENT);
279433d6423SLionel Sambuc     if (ACPI_FAILURE (Status))
280433d6423SLionel Sambuc     {
281433d6423SLionel Sambuc         return_ACPI_STATUS (Status);
282433d6423SLionel Sambuc     }
283433d6423SLionel Sambuc 
284433d6423SLionel Sambuc     Status = AcpiReadBitRegister (
285433d6423SLionel Sambuc                 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value);
286433d6423SLionel Sambuc     if (ACPI_FAILURE (Status))
287433d6423SLionel Sambuc     {
288433d6423SLionel Sambuc         return_ACPI_STATUS (Status);
289433d6423SLionel Sambuc     }
290433d6423SLionel Sambuc 
291433d6423SLionel Sambuc     if (Value != 0)
292433d6423SLionel Sambuc     {
293433d6423SLionel Sambuc         ACPI_ERROR ((AE_INFO,
294433d6423SLionel Sambuc             "Could not disable %s events", AcpiUtGetEventName (Event)));
295433d6423SLionel Sambuc         return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE);
296433d6423SLionel Sambuc     }
297433d6423SLionel Sambuc 
298433d6423SLionel Sambuc     return_ACPI_STATUS (Status);
299433d6423SLionel Sambuc }
300433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiDisableEvent)301433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiDisableEvent)
302433d6423SLionel Sambuc 
303433d6423SLionel Sambuc 
304433d6423SLionel Sambuc /*******************************************************************************
305433d6423SLionel Sambuc  *
306433d6423SLionel Sambuc  * FUNCTION:    AcpiClearEvent
307433d6423SLionel Sambuc  *
308433d6423SLionel Sambuc  * PARAMETERS:  Event           - The fixed event to be cleared
309433d6423SLionel Sambuc  *
310433d6423SLionel Sambuc  * RETURN:      Status
311433d6423SLionel Sambuc  *
312433d6423SLionel Sambuc  * DESCRIPTION: Clear an ACPI event (fixed)
313433d6423SLionel Sambuc  *
314433d6423SLionel Sambuc  ******************************************************************************/
315433d6423SLionel Sambuc 
316433d6423SLionel Sambuc ACPI_STATUS
317433d6423SLionel Sambuc AcpiClearEvent (
318433d6423SLionel Sambuc     UINT32                  Event)
319433d6423SLionel Sambuc {
320433d6423SLionel Sambuc     ACPI_STATUS             Status = AE_OK;
321433d6423SLionel Sambuc 
322433d6423SLionel Sambuc 
323433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (AcpiClearEvent);
324433d6423SLionel Sambuc 
325433d6423SLionel Sambuc 
326433d6423SLionel Sambuc     /* Decode the Fixed Event */
327433d6423SLionel Sambuc 
328433d6423SLionel Sambuc     if (Event > ACPI_EVENT_MAX)
329433d6423SLionel Sambuc     {
330433d6423SLionel Sambuc         return_ACPI_STATUS (AE_BAD_PARAMETER);
331433d6423SLionel Sambuc     }
332433d6423SLionel Sambuc 
333433d6423SLionel Sambuc     /*
334433d6423SLionel Sambuc      * Clear the requested fixed event (By writing a one to the status
335433d6423SLionel Sambuc      * register bit)
336433d6423SLionel Sambuc      */
337433d6423SLionel Sambuc     Status = AcpiWriteBitRegister (
338433d6423SLionel Sambuc                 AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
339433d6423SLionel Sambuc                 ACPI_CLEAR_STATUS);
340433d6423SLionel Sambuc 
341433d6423SLionel Sambuc     return_ACPI_STATUS (Status);
342433d6423SLionel Sambuc }
343433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiClearEvent)344433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiClearEvent)
345433d6423SLionel Sambuc 
346433d6423SLionel Sambuc 
347433d6423SLionel Sambuc /*******************************************************************************
348433d6423SLionel Sambuc  *
349433d6423SLionel Sambuc  * FUNCTION:    AcpiGetEventStatus
350433d6423SLionel Sambuc  *
351433d6423SLionel Sambuc  * PARAMETERS:  Event           - The fixed event
352433d6423SLionel Sambuc  *              EventStatus     - Where the current status of the event will
353433d6423SLionel Sambuc  *                                be returned
354433d6423SLionel Sambuc  *
355433d6423SLionel Sambuc  * RETURN:      Status
356433d6423SLionel Sambuc  *
357433d6423SLionel Sambuc  * DESCRIPTION: Obtains and returns the current status of the event
358433d6423SLionel Sambuc  *
359433d6423SLionel Sambuc  ******************************************************************************/
360433d6423SLionel Sambuc 
361433d6423SLionel Sambuc ACPI_STATUS
362433d6423SLionel Sambuc AcpiGetEventStatus (
363433d6423SLionel Sambuc     UINT32                  Event,
364433d6423SLionel Sambuc     ACPI_EVENT_STATUS       *EventStatus)
365433d6423SLionel Sambuc {
366*29492bb7SDavid van Moolenbroek     ACPI_STATUS             Status;
367*29492bb7SDavid van Moolenbroek     ACPI_EVENT_STATUS       LocalEventStatus = 0;
368*29492bb7SDavid van Moolenbroek     UINT32                  InByte;
369433d6423SLionel Sambuc 
370433d6423SLionel Sambuc 
371433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (AcpiGetEventStatus);
372433d6423SLionel Sambuc 
373433d6423SLionel Sambuc 
374433d6423SLionel Sambuc     if (!EventStatus)
375433d6423SLionel Sambuc     {
376433d6423SLionel Sambuc         return_ACPI_STATUS (AE_BAD_PARAMETER);
377433d6423SLionel Sambuc     }
378433d6423SLionel Sambuc 
379433d6423SLionel Sambuc     /* Decode the Fixed Event */
380433d6423SLionel Sambuc 
381433d6423SLionel Sambuc     if (Event > ACPI_EVENT_MAX)
382433d6423SLionel Sambuc     {
383433d6423SLionel Sambuc         return_ACPI_STATUS (AE_BAD_PARAMETER);
384433d6423SLionel Sambuc     }
385433d6423SLionel Sambuc 
386*29492bb7SDavid van Moolenbroek     /* Fixed event currently can be dispatched? */
387*29492bb7SDavid van Moolenbroek 
388*29492bb7SDavid van Moolenbroek     if (AcpiGbl_FixedEventHandlers[Event].Handler)
389*29492bb7SDavid van Moolenbroek     {
390*29492bb7SDavid van Moolenbroek         LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER;
391*29492bb7SDavid van Moolenbroek     }
392*29492bb7SDavid van Moolenbroek 
393*29492bb7SDavid van Moolenbroek     /* Fixed event currently enabled? */
394433d6423SLionel Sambuc 
395433d6423SLionel Sambuc     Status = AcpiReadBitRegister (
396*29492bb7SDavid van Moolenbroek                 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &InByte);
397*29492bb7SDavid van Moolenbroek     if (ACPI_FAILURE (Status))
398*29492bb7SDavid van Moolenbroek     {
399433d6423SLionel Sambuc         return_ACPI_STATUS (Status);
400433d6423SLionel Sambuc     }
401433d6423SLionel Sambuc 
402*29492bb7SDavid van Moolenbroek     if (InByte)
403*29492bb7SDavid van Moolenbroek     {
404*29492bb7SDavid van Moolenbroek         LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED;
405*29492bb7SDavid van Moolenbroek     }
406*29492bb7SDavid van Moolenbroek 
407*29492bb7SDavid van Moolenbroek     /* Fixed event currently active? */
408*29492bb7SDavid van Moolenbroek 
409*29492bb7SDavid van Moolenbroek     Status = AcpiReadBitRegister (
410*29492bb7SDavid van Moolenbroek                 AcpiGbl_FixedEventInfo[Event].StatusRegisterId, &InByte);
411*29492bb7SDavid van Moolenbroek     if (ACPI_FAILURE (Status))
412*29492bb7SDavid van Moolenbroek     {
413*29492bb7SDavid van Moolenbroek         return_ACPI_STATUS (Status);
414*29492bb7SDavid van Moolenbroek     }
415*29492bb7SDavid van Moolenbroek 
416*29492bb7SDavid van Moolenbroek     if (InByte)
417*29492bb7SDavid van Moolenbroek     {
418*29492bb7SDavid van Moolenbroek         LocalEventStatus |= ACPI_EVENT_FLAG_SET;
419*29492bb7SDavid van Moolenbroek     }
420*29492bb7SDavid van Moolenbroek 
421*29492bb7SDavid van Moolenbroek     (*EventStatus) = LocalEventStatus;
422*29492bb7SDavid van Moolenbroek     return_ACPI_STATUS (AE_OK);
423*29492bb7SDavid van Moolenbroek }
424*29492bb7SDavid van Moolenbroek 
425433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiGetEventStatus)
426433d6423SLionel Sambuc 
427*29492bb7SDavid van Moolenbroek #endif /* !ACPI_REDUCED_HARDWARE */
428