ReactOS 0.4.15-dev-8428-g6910fa6
evmisc.c
Go to the documentation of this file.
1/******************************************************************************
2 *
3 * Module Name: evmisc - Miscellaneous event manager support functions
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#include "acnamesp.h"
48
49#define _COMPONENT ACPI_EVENTS
50 ACPI_MODULE_NAME ("evmisc")
51
52
53/* Local prototypes */
54
55static void ACPI_SYSTEM_XFACE
57 void *Context);
58
59
60/*******************************************************************************
61 *
62 * FUNCTION: AcpiEvIsNotifyObject
63 *
64 * PARAMETERS: Node - Node to check
65 *
66 * RETURN: TRUE if notifies allowed on this object
67 *
68 * DESCRIPTION: Check type of node for a object that supports notifies.
69 *
70 * TBD: This could be replaced by a flag bit in the node.
71 *
72 ******************************************************************************/
73
77{
78
79 switch (Node->Type)
80 {
84 /*
85 * These are the ONLY objects that can receive ACPI notifications
86 */
87 return (TRUE);
88
89 default:
90
91 return (FALSE);
92 }
93}
94
95
96/*******************************************************************************
97 *
98 * FUNCTION: AcpiEvQueueNotifyRequest
99 *
100 * PARAMETERS: Node - NS node for the notified object
101 * NotifyValue - Value from the Notify() request
102 *
103 * RETURN: Status
104 *
105 * DESCRIPTION: Dispatch a device notification event to a previously
106 * installed handler.
107 *
108 ******************************************************************************/
109
113 UINT32 NotifyValue)
114{
115 ACPI_OPERAND_OBJECT *ObjDesc;
116 ACPI_OPERAND_OBJECT *HandlerListHead = NULL;
118 UINT8 HandlerListId = 0;
120
121
122 ACPI_FUNCTION_NAME (EvQueueNotifyRequest);
123
124
125 /* Are Notifies allowed on this object? */
126
128 {
129 return (AE_TYPE);
130 }
131
132 /* Get the correct notify list type (System or Device) */
133
134 if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
135 {
136 HandlerListId = ACPI_SYSTEM_HANDLER_LIST;
137 }
138 else
139 {
140 HandlerListId = ACPI_DEVICE_HANDLER_LIST;
141 }
142
143 /* Get the notify object attached to the namespace Node */
144
145 ObjDesc = AcpiNsGetAttachedObject (Node);
146 if (ObjDesc)
147 {
148 /* We have an attached object, Get the correct handler list */
149
150 HandlerListHead = ObjDesc->CommonNotify.NotifyList[HandlerListId];
151 }
152
153 /*
154 * If there is no notify handler (Global or Local)
155 * for this object, just ignore the notify
156 */
157 if (!AcpiGbl_GlobalNotify[HandlerListId].Handler && !HandlerListHead)
158 {
160 "No notify handler for Notify, ignoring (%4.4s, %X) node %p\n",
161 AcpiUtGetNodeName (Node), NotifyValue, Node));
162
163 return (AE_OK);
164 }
165
166 /* Setup notify info and schedule the notify dispatcher */
167
169 if (!Info)
170 {
171 return (AE_NO_MEMORY);
172 }
173
174 Info->Common.DescriptorType = ACPI_DESC_TYPE_STATE_NOTIFY;
175
176 Info->Notify.Node = Node;
177 Info->Notify.Value = (UINT16) NotifyValue;
178 Info->Notify.HandlerListId = HandlerListId;
179 Info->Notify.HandlerListHead = HandlerListHead;
180 Info->Notify.Global = &AcpiGbl_GlobalNotify[HandlerListId];
181
183 "Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n",
185 NotifyValue, AcpiUtGetNotifyName (NotifyValue, ACPI_TYPE_ANY), Node));
186
189 if (ACPI_FAILURE (Status))
190 {
192 }
193
194 return (Status);
195}
196
197
198/*******************************************************************************
199 *
200 * FUNCTION: AcpiEvNotifyDispatch
201 *
202 * PARAMETERS: Context - To be passed to the notify handler
203 *
204 * RETURN: None.
205 *
206 * DESCRIPTION: Dispatch a device notification event to a previously
207 * installed handler.
208 *
209 ******************************************************************************/
210
211static void ACPI_SYSTEM_XFACE
213 void *Context)
214{
216 ACPI_OPERAND_OBJECT *HandlerObj;
217
218
220
221
222 /* Invoke a global notify handler if installed */
223
224 if (Info->Notify.Global->Handler)
225 {
226 Info->Notify.Global->Handler (Info->Notify.Node,
227 Info->Notify.Value,
228 Info->Notify.Global->Context);
229 }
230
231 /* Now invoke the local notify handler(s) if any are installed */
232
233 HandlerObj = Info->Notify.HandlerListHead;
234 while (HandlerObj)
235 {
236 HandlerObj->Notify.Handler (Info->Notify.Node,
237 Info->Notify.Value,
238 HandlerObj->Notify.Context);
239
240 HandlerObj = HandlerObj->Notify.Next[Info->Notify.HandlerListId];
241 }
242
243 /* All done with the info object */
244
246}
247
248
249#if (!ACPI_REDUCED_HARDWARE)
250/******************************************************************************
251 *
252 * FUNCTION: AcpiEvTerminate
253 *
254 * PARAMETERS: none
255 *
256 * RETURN: none
257 *
258 * DESCRIPTION: Disable events and free memory allocated for table storage.
259 *
260 ******************************************************************************/
261
262void
264 void)
265{
266 UINT32 i;
268
269
270 ACPI_FUNCTION_TRACE (EvTerminate);
271
272
273 if (AcpiGbl_EventsInitialized)
274 {
275 /*
276 * Disable all event-related functionality. In all cases, on error,
277 * print a message but obviously we don't abort.
278 */
279
280 /* Disable all fixed events */
281
282 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
283 {
285 if (ACPI_FAILURE (Status))
286 {
288 "Could not disable fixed event %u", (UINT32) i));
289 }
290 }
291
292 /* Disable all GPEs in all GPE blocks */
293
295 if (ACPI_FAILURE (Status))
296 {
298 "Could not disable GPEs in GPE block"));
299 }
300
302 if (ACPI_FAILURE (Status))
303 {
305 "Could not remove Global Lock handler"));
306 }
307
308 AcpiGbl_EventsInitialized = FALSE;
309 }
310
311 /* Remove SCI handlers */
312
314 if (ACPI_FAILURE (Status))
315 {
317 "Could not remove SCI handler"));
318 }
319
320 /* Deallocate all handler objects installed within GPE info structs */
321
323 if (ACPI_FAILURE (Status))
324 {
326 "Could not delete GPE handlers"));
327 }
328
329
330 /* Return to original mode if necessary */
331
332 if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY)
333 {
334 Status = AcpiDisable ();
335 if (ACPI_FAILURE (Status))
336 {
337 ACPI_WARNING ((AE_INFO, "AcpiDisable failed"));
338 }
339 }
341}
342
343#endif /* !ACPI_REDUCED_HARDWARE */
unsigned short UINT16
unsigned char BOOLEAN
unsigned char UINT8
unsigned int UINT32
#define ACPI_SYSTEM_XFACE
Definition: acenv.h:326
#define ACPI_FAILURE(a)
Definition: acexcep.h:95
#define AE_NO_MEMORY
Definition: acexcep.h:112
#define AE_TYPE
Definition: acexcep.h:116
#define AE_OK
Definition: acexcep.h:97
ACPI_OPERAND_OBJECT * AcpiNsGetAttachedObject(ACPI_NAMESPACE_NODE *Node)
Definition: nsobject.c:308
#define ACPI_DESC_TYPE_STATE_NOTIFY
Definition: acobject.h:572
#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_WARNING(plist)
Definition: acoutput.h:238
#define ACPI_FUNCTION_ENTRY()
Definition: acoutput.h:484
#define ACPI_FUNCTION_TRACE(a)
Definition: acoutput.h:480
#define ACPI_ERROR(plist)
Definition: acoutput.h:240
#define AE_INFO
Definition: acoutput.h:230
#define return_VOID
Definition: acoutput.h:495
#define ACPI_DB_INFO
Definition: acoutput.h:153
#define ACPI_FUNCTION_NAME(a)
Definition: acoutput.h:479
@ OSL_NOTIFY_HANDLER
Definition: acpiosxf.h:58
ACPI_STATUS AcpiOsExecute(ACPI_EXECUTE_TYPE Type, ACPI_OSD_EXEC_CALLBACK Function, void *Context)
Definition: osl.c:224
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_TYPE_PROCESSOR
Definition: actypes.h:699
#define ACPI_SYSTEM_HANDLER_LIST
Definition: actypes.h:853
#define ACPI_TYPE_ANY
Definition: actypes.h:687
UINT32 ACPI_STATUS
Definition: actypes.h:460
#define ACPI_TYPE_DEVICE
Definition: actypes.h:693
#define ACPI_MAX_SYS_NOTIFY
Definition: actypes.h:850
#define ACPI_NUM_FIXED_EVENTS
Definition: actypes.h:770
#define ACPI_DEVICE_HANDLER_LIST
Definition: actypes.h:854
#define ACPI_TYPE_THERMAL
Definition: actypes.h:700
#define ACPI_SYS_MODE_LEGACY
Definition: actypes.h:1085
const char * AcpiUtGetTypeName(ACPI_OBJECT_TYPE Type)
Definition: utdecode.c:250
ACPI_GENERIC_STATE * AcpiUtCreateGenericState(void)
Definition: utstate.c:130
const char * AcpiUtGetNodeName(void *Object)
Definition: utdecode.c:306
void AcpiUtDeleteGenericState(ACPI_GENERIC_STATE *State)
Definition: utstate.c:340
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
union node Node
Definition: types.h:1255
ACPI_STATUS AcpiEvRemoveGlobalLockHandler(void)
Definition: evglock.c:135
ACPI_STATUS AcpiEvDeleteGpeHandlers(ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
Definition: evgpeutil.c:339
ACPI_STATUS AcpiEvWalkGpeList(ACPI_GPE_CALLBACK GpeWalkCallback, void *Context)
Definition: evgpeutil.c:67
static void ACPI_SYSTEM_XFACE AcpiEvNotifyDispatch(void *Context)
Definition: evmisc.c:212
ACPI_STATUS AcpiEvQueueNotifyRequest(ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue)
Definition: evmisc.c:111
BOOLEAN AcpiEvIsNotifyObject(ACPI_NAMESPACE_NODE *Node)
Definition: evmisc.c:75
void AcpiEvTerminate(void)
Definition: evmisc.c:263
ACPI_STATUS AcpiEvRemoveAllSciHandlers(void)
Definition: evsci.c:246
ACPI_STATUS AcpiDisable(void)
Definition: evxfevnt.c:132
ACPI_STATUS AcpiDisableEvent(UINT32 Event, UINT32 Flags)
Definition: evxfevnt.c:263
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 AcpiHwDisableGpeBlock(ACPI_GPE_XRUPT_INFO *GpeXruptInfo, ACPI_GPE_BLOCK_INFO *GpeBlock, void *Context)
Definition: hwgpe.c:364
ACPI_NOTIFY_HANDLER Handler
Definition: acobject.h:402
union acpi_operand_object * Next[2]
Definition: acobject.h:404
ACPI_OBJECT_NOTIFY_HANDLER Notify
Definition: acobject.h:538
ACPI_OBJECT_NOTIFY_COMMON CommonNotify
Definition: acobject.h:528
Definition: dlist.c:348
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690