ReactOS 0.4.15-dev-7958-gcd0bb1a
evevent.c
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Module Name: evevent - Fixed Event handling and dispatch
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2022, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44#include "acpi.h"
45#include "accommon.h"
46#include "acevents.h"
47
48#define _COMPONENT ACPI_EVENTS
49 ACPI_MODULE_NAME ("evevent")
50
51#if (!ACPI_REDUCED_HARDWARE) /* Entire module */
52
53/* Local prototypes */
54
55static ACPI_STATUS
57 void);
58
59static UINT32
62
63
64/*******************************************************************************
65 *
66 * FUNCTION: AcpiEvInitializeEvents
67 *
68 * PARAMETERS: None
69 *
70 * RETURN: Status
71 *
72 * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE)
73 *
74 ******************************************************************************/
75
78 void)
79{
81
82
83 ACPI_FUNCTION_TRACE (EvInitializeEvents);
84
85
86 /* If Hardware Reduced flag is set, there are no fixed events */
87
88 if (AcpiGbl_ReducedHardware)
89 {
91 }
92
93 /*
94 * Initialize the Fixed and General Purpose Events. This is done prior to
95 * enabling SCIs to prevent interrupts from occurring before the handlers
96 * are installed.
97 */
99 if (ACPI_FAILURE (Status))
100 {
102 "Unable to initialize fixed events"));
104 }
105
107 if (ACPI_FAILURE (Status))
108 {
110 "Unable to initialize general purpose events"));
112 }
113
115}
116
117
118/*******************************************************************************
119 *
120 * FUNCTION: AcpiEvInstallXruptHandlers
121 *
122 * PARAMETERS: None
123 *
124 * RETURN: Status
125 *
126 * DESCRIPTION: Install interrupt handlers for the SCI and Global Lock
127 *
128 ******************************************************************************/
129
132 void)
133{
135
136
137 ACPI_FUNCTION_TRACE (EvInstallXruptHandlers);
138
139
140 /* If Hardware Reduced flag is set, there is no ACPI h/w */
141
142 if (AcpiGbl_ReducedHardware)
143 {
145 }
146
147 /* Install the SCI handler */
148
150 if (ACPI_FAILURE (Status))
151 {
153 "Unable to install System Control Interrupt handler"));
155 }
156
157 /* Install the handler for the Global Lock */
158
160 if (ACPI_FAILURE (Status))
161 {
163 "Unable to initialize Global Lock handler"));
165 }
166
167 AcpiGbl_EventsInitialized = TRUE;
169}
170
171
172/*******************************************************************************
173 *
174 * FUNCTION: AcpiEvFixedEventInitialize
175 *
176 * PARAMETERS: None
177 *
178 * RETURN: Status
179 *
180 * DESCRIPTION: Install the fixed event handlers and disable all fixed events.
181 *
182 ******************************************************************************/
183
184static ACPI_STATUS
186 void)
187{
188 UINT32 i;
190
191
192 /*
193 * Initialize the structure that keeps track of fixed event handlers and
194 * disable all of the fixed events.
195 */
196 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
197 {
198 AcpiGbl_FixedEventHandlers[i].Handler = NULL;
199 AcpiGbl_FixedEventHandlers[i].Context = NULL;
200
201 /* Disable the fixed event */
202
203 if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF)
204 {
206 AcpiGbl_FixedEventInfo[i].EnableRegisterId,
209 if (ACPI_FAILURE (Status))
210 {
211 return (Status);
212 }
213 }
214 }
215
216 return (AE_OK);
217}
218
219
220/*******************************************************************************
221 *
222 * FUNCTION: AcpiEvFixedEventDetect
223 *
224 * PARAMETERS: None
225 *
226 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
227 *
228 * DESCRIPTION: Checks the PM status register for active fixed events
229 *
230 ******************************************************************************/
231
232UINT32
234 void)
235{
237 UINT32 FixedStatus;
238 UINT32 FixedEnable;
239 UINT32 i;
241
242
243 ACPI_FUNCTION_NAME (EvFixedEventDetect);
244
245
246 /*
247 * Read the fixed feature status and enable registers, as all the cases
248 * depend on their values. Ignore errors here.
249 */
252 if (ACPI_FAILURE (Status))
253 {
254 return (IntStatus);
255 }
256
257 if (FixedEnable & ACPI_BITMASK_PCIEXP_WAKE_DISABLE)
258 FixedEnable &= ~ACPI_BITMASK_PCIEXP_WAKE_DISABLE;
259 else
261
263 "Fixed Event Block: Enable %08X Status %08X\n",
264 FixedEnable, FixedStatus));
265
266 /*
267 * Check for all possible Fixed Events and dispatch those that are active
268 */
269 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
270 {
271 /* Both the status and enable bits must be on for this event */
272
273 if ((FixedStatus & AcpiGbl_FixedEventInfo[i].StatusBitMask) &&
274 (FixedEnable & AcpiGbl_FixedEventInfo[i].EnableBitMask))
275 {
276 /*
277 * Found an active (signalled) event. Invoke global event
278 * handler if present.
279 */
280 AcpiFixedEventCount[i]++;
281 if (AcpiGbl_GlobalEventHandler)
282 {
283 AcpiGbl_GlobalEventHandler (ACPI_EVENT_TYPE_FIXED, NULL,
284 i, AcpiGbl_GlobalEventHandlerContext);
285 }
286
287 IntStatus |= AcpiEvFixedEventDispatch (i);
288 }
289 }
290
291 return (IntStatus);
292}
293
294
295/*******************************************************************************
296 *
297 * FUNCTION: AcpiEvFixedEventDispatch
298 *
299 * PARAMETERS: Event - Event type
300 *
301 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED
302 *
303 * DESCRIPTION: Clears the status bit for the requested event, calls the
304 * handler that previously registered for the event.
305 * NOTE: If there is no handler for the event, the event is
306 * disabled to prevent further interrupts.
307 *
308 ******************************************************************************/
309
310static UINT32
313{
314
316
317
318 /* Clear the status bit */
319
321 AcpiGbl_FixedEventInfo[Event].StatusRegisterId,
323
324 /*
325 * Make sure that a handler exists. If not, report an error
326 * and disable the event to prevent further interrupts.
327 */
328 if (!AcpiGbl_FixedEventHandlers[Event].Handler)
329 {
331 AcpiGbl_FixedEventInfo[Event].EnableRegisterId,
334
336 "No installed handler for fixed event - %s (%u), disabling",
338
340 }
341
342 /* Invoke the Fixed Event handler */
343
344 return ((AcpiGbl_FixedEventHandlers[Event].Handler)(
345 AcpiGbl_FixedEventHandlers[Event].Context));
346}
347
348#endif /* !ACPI_REDUCED_HARDWARE */
unsigned int UINT32
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_OK
Definition: acexcep.h:97
ACPI_FIXED_EVENT_INFO AcpiGbl_FixedEventInfo[ACPI_NUM_FIXED_EVENTS]
Definition: utglobal.c:175
#define ACPI_REGISTER_PM1_ENABLE
Definition: aclocal.h:1185
#define ACPI_REGISTER_PM1_STATUS
Definition: aclocal.h:1184
#define ACPI_BITMASK_PCIEXP_WAKE_DISABLE
Definition: aclocal.h:1219
#define ACPI_DEBUG_PRINT(pl)
Definition: acoutput.h:475
#define ACPI_EXCEPTION(plist)
Definition: acoutput.h:239
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define return_ACPI_STATUS(s)
Definition: acoutput.h:496
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define ACPI_DB_INTERRUPTS
Definition: acoutput.h:178
#define AE_INFO
Definition: acoutput.h:230
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:672
#define ACPI_DISABLE_EVENT
Definition: actypes.h:944
#define ACPI_CLEAR_STATUS
Definition: actypes.h:939
#define ACPI_EVENT_PCIE_WAKE
Definition: actypes.h:768
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_ENABLE_EVENT
Definition: actypes.h:943
#define ACPI_NUM_FIXED_EVENTS
Definition: actypes.h:770
#define ACPI_EVENT_TYPE_FIXED
Definition: actypes.h:1144
#define ACPI_INTERRUPT_NOT_HANDLED
Definition: actypes.h:1263
const char * AcpiUtGetEventName(UINT32 EventId)
Definition: utdecode.c:175
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
static ACPI_STATUS AcpiEvFixedEventInitialize(void)
Definition: evevent.c:185
ACPI_STATUS AcpiEvInitializeEvents(void)
Definition: evevent.c:77
ACPI_STATUS AcpiEvInstallXruptHandlers(void)
Definition: evevent.c:131
UINT32 AcpiEvFixedEventDetect(void)
Definition: evevent.c:233
static UINT32 AcpiEvFixedEventDispatch(UINT32 Event)
Definition: evevent.c:311
ACPI_STATUS AcpiEvInitGlobalLockHandler(void)
Definition: evglock.c:74
ACPI_STATUS AcpiEvGpeInitialize(void)
Definition: evgpeinit.c:84
UINT32 AcpiEvInstallSciHandler(void)
Definition: evsci.c:211
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
ACPI_STATUS AcpiHwRegisterRead(UINT32 RegisterId, UINT32 *ReturnValue)
Definition: hwregs.c:574
ACPI_STATUS AcpiWriteBitRegister(UINT32 RegisterId, UINT32 Value)
Definition: hwxface.c:282