1 /******************************************************************************
2  *
3  * Name: acevents.h - Event subcomponent prototypes and defines
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2019, 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 MERCHANTIBILITY 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 #ifndef __ACEVENTS_H__
45 #define __ACEVENTS_H__
46 
47 
48 /*
49  * Conditions to trigger post enabling GPE polling:
50  * It is not sufficient to trigger edge-triggered GPE with specific GPE
51  * chips, software need to poll once after enabling.
52  */
53 #ifdef ACPI_USE_GPE_POLLING
54 #define ACPI_GPE_IS_POLLING_NEEDED(__gpe__)             \
55     ((__gpe__)->RuntimeCount == 1 &&                    \
56      (__gpe__)->Flags & ACPI_GPE_INITIALIZED &&         \
57      ((__gpe__)->Flags & ACPI_GPE_XRUPT_TYPE_MASK) == ACPI_GPE_EDGE_TRIGGERED)
58 #else
59 #define ACPI_GPE_IS_POLLING_NEEDED(__gpe__)             FALSE
60 #endif
61 
62 
63 /*
64  * evevent
65  */
66 ACPI_STATUS
67 AcpiEvInitializeEvents (
68     void);
69 
70 ACPI_STATUS
71 AcpiEvInstallXruptHandlers (
72     void);
73 
74 UINT32
75 AcpiEvFixedEventDetect (
76     void);
77 
78 
79 /*
80  * evmisc
81  */
82 BOOLEAN
83 AcpiEvIsNotifyObject (
84     ACPI_NAMESPACE_NODE     *Node);
85 
86 UINT32
87 AcpiEvGetGpeNumberIndex (
88     UINT32                  GpeNumber);
89 
90 ACPI_STATUS
91 AcpiEvQueueNotifyRequest (
92     ACPI_NAMESPACE_NODE     *Node,
93     UINT32                  NotifyValue);
94 
95 
96 /*
97  * evglock - Global Lock support
98  */
99 ACPI_STATUS
100 AcpiEvInitGlobalLockHandler (
101     void);
102 
103 ACPI_HW_DEPENDENT_RETURN_OK (
104 ACPI_STATUS
105 AcpiEvAcquireGlobalLock(
106     UINT16                  Timeout))
107 
108 ACPI_HW_DEPENDENT_RETURN_OK (
109 ACPI_STATUS
110 AcpiEvReleaseGlobalLock(
111     void))
112 
113 ACPI_STATUS
114 AcpiEvRemoveGlobalLockHandler (
115     void);
116 
117 
118 /*
119  * evgpe - Low-level GPE support
120  */
121 UINT32
122 AcpiEvGpeDetect (
123     ACPI_GPE_XRUPT_INFO     *GpeXruptList);
124 
125 ACPI_STATUS
126 AcpiEvUpdateGpeEnableMask (
127     ACPI_GPE_EVENT_INFO     *GpeEventInfo);
128 
129 ACPI_STATUS
130 AcpiEvEnableGpe (
131     ACPI_GPE_EVENT_INFO     *GpeEventInfo);
132 
133 ACPI_STATUS
134 AcpiEvMaskGpe (
135     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
136     BOOLEAN                 IsMasked);
137 
138 ACPI_STATUS
139 AcpiEvAddGpeReference (
140     ACPI_GPE_EVENT_INFO     *GpeEventInfo);
141 
142 ACPI_STATUS
143 AcpiEvRemoveGpeReference (
144     ACPI_GPE_EVENT_INFO     *GpeEventInfo);
145 
146 ACPI_GPE_EVENT_INFO *
147 AcpiEvGetGpeEventInfo (
148     ACPI_HANDLE             GpeDevice,
149     UINT32                  GpeNumber);
150 
151 ACPI_GPE_EVENT_INFO *
152 AcpiEvLowGetGpeInfo (
153     UINT32                  GpeNumber,
154     ACPI_GPE_BLOCK_INFO     *GpeBlock);
155 
156 ACPI_STATUS
157 AcpiEvFinishGpe (
158     ACPI_GPE_EVENT_INFO     *GpeEventInfo);
159 
160 UINT32
161 AcpiEvDetectGpe (
162     ACPI_NAMESPACE_NODE     *GpeDevice,
163     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
164     UINT32                  GpeNumber);
165 
166 
167 /*
168  * evgpeblk - Upper-level GPE block support
169  */
170 ACPI_STATUS
171 AcpiEvCreateGpeBlock (
172     ACPI_NAMESPACE_NODE     *GpeDevice,
173     UINT64                  Address,
174     UINT8                   SpaceId,
175     UINT32                  RegisterCount,
176     UINT16                  GpeBlockBaseNumber,
177     UINT32                  InterruptNumber,
178     ACPI_GPE_BLOCK_INFO     **ReturnGpeBlock);
179 
180 ACPI_STATUS
181 AcpiEvInitializeGpeBlock (
182     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
183     ACPI_GPE_BLOCK_INFO     *GpeBlock,
184     void                    *Context);
185 
186 ACPI_HW_DEPENDENT_RETURN_OK (
187 ACPI_STATUS
188 AcpiEvDeleteGpeBlock (
189     ACPI_GPE_BLOCK_INFO     *GpeBlock))
190 
191 UINT32
192 AcpiEvGpeDispatch (
193     ACPI_NAMESPACE_NODE     *GpeDevice,
194     ACPI_GPE_EVENT_INFO     *GpeEventInfo,
195     UINT32                  GpeNumber);
196 
197 
198 /*
199  * evgpeinit - GPE initialization and update
200  */
201 ACPI_STATUS
202 AcpiEvGpeInitialize (
203     void);
204 
205 ACPI_HW_DEPENDENT_RETURN_VOID (
206 void
207 AcpiEvUpdateGpes (
208     ACPI_OWNER_ID           TableOwnerId))
209 
210 ACPI_STATUS
211 AcpiEvMatchGpeMethod (
212     ACPI_HANDLE             ObjHandle,
213     UINT32                  Level,
214     void                    *Context,
215     void                    **ReturnValue);
216 
217 
218 /*
219  * evgpeutil - GPE utilities
220  */
221 ACPI_STATUS
222 AcpiEvWalkGpeList (
223     ACPI_GPE_CALLBACK       GpeWalkCallback,
224     void                    *Context);
225 
226 ACPI_STATUS
227 AcpiEvGetGpeDevice (
228     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
229     ACPI_GPE_BLOCK_INFO     *GpeBlock,
230     void                    *Context);
231 
232 ACPI_STATUS
233 AcpiEvGetGpeXruptBlock (
234     UINT32                  InterruptNumber,
235     ACPI_GPE_XRUPT_INFO     **GpeXruptBlock);
236 
237 ACPI_STATUS
238 AcpiEvDeleteGpeXrupt (
239     ACPI_GPE_XRUPT_INFO     *GpeXrupt);
240 
241 ACPI_STATUS
242 AcpiEvDeleteGpeHandlers (
243     ACPI_GPE_XRUPT_INFO     *GpeXruptInfo,
244     ACPI_GPE_BLOCK_INFO     *GpeBlock,
245     void                    *Context);
246 
247 
248 /*
249  * evhandler - Address space handling
250  */
251 ACPI_OPERAND_OBJECT *
252 AcpiEvFindRegionHandler (
253     ACPI_ADR_SPACE_TYPE     SpaceId,
254     ACPI_OPERAND_OBJECT     *HandlerObj);
255 
256 BOOLEAN
257 AcpiEvHasDefaultHandler (
258     ACPI_NAMESPACE_NODE     *Node,
259     ACPI_ADR_SPACE_TYPE     SpaceId);
260 
261 ACPI_STATUS
262 AcpiEvInstallRegionHandlers (
263     void);
264 
265 ACPI_STATUS
266 AcpiEvInstallSpaceHandler (
267     ACPI_NAMESPACE_NODE     *Node,
268     ACPI_ADR_SPACE_TYPE     SpaceId,
269     ACPI_ADR_SPACE_HANDLER  Handler,
270     ACPI_ADR_SPACE_SETUP    Setup,
271     void                    *Context);
272 
273 
274 /*
275  * evregion - Operation region support
276  */
277 ACPI_STATUS
278 AcpiEvInitializeOpRegions (
279     void);
280 
281 ACPI_STATUS
282 AcpiEvAddressSpaceDispatch (
283     ACPI_OPERAND_OBJECT     *RegionObj,
284     ACPI_OPERAND_OBJECT     *FieldObj,
285     UINT32                  Function,
286     UINT32                  RegionOffset,
287     UINT32                  BitWidth,
288     UINT64                  *Value);
289 
290 ACPI_STATUS
291 AcpiEvAttachRegion (
292     ACPI_OPERAND_OBJECT     *HandlerObj,
293     ACPI_OPERAND_OBJECT     *RegionObj,
294     BOOLEAN                 AcpiNsIsLocked);
295 
296 void
297 AcpiEvDetachRegion (
298     ACPI_OPERAND_OBJECT     *RegionObj,
299     BOOLEAN                 AcpiNsIsLocked);
300 
301 void
302 AcpiEvExecuteRegMethods (
303     ACPI_NAMESPACE_NODE     *Node,
304     ACPI_ADR_SPACE_TYPE     SpaceId,
305     UINT32                  Function);
306 
307 ACPI_STATUS
308 AcpiEvExecuteRegMethod (
309     ACPI_OPERAND_OBJECT     *RegionObj,
310     UINT32                  Function);
311 
312 
313 /*
314  * evregini - Region initialization and setup
315  */
316 ACPI_STATUS
317 AcpiEvSystemMemoryRegionSetup (
318     ACPI_HANDLE             Handle,
319     UINT32                  Function,
320     void                    *HandlerContext,
321     void                    **RegionContext);
322 
323 ACPI_STATUS
324 AcpiEvIoSpaceRegionSetup (
325     ACPI_HANDLE             Handle,
326     UINT32                  Function,
327     void                    *HandlerContext,
328     void                    **RegionContext);
329 
330 ACPI_STATUS
331 AcpiEvPciConfigRegionSetup (
332     ACPI_HANDLE             Handle,
333     UINT32                  Function,
334     void                    *HandlerContext,
335     void                    **RegionContext);
336 
337 ACPI_STATUS
338 AcpiEvCmosRegionSetup (
339     ACPI_HANDLE             Handle,
340     UINT32                  Function,
341     void                    *HandlerContext,
342     void                    **RegionContext);
343 
344 ACPI_STATUS
345 AcpiEvPciBarRegionSetup (
346     ACPI_HANDLE             Handle,
347     UINT32                  Function,
348     void                    *HandlerContext,
349     void                    **RegionContext);
350 
351 ACPI_STATUS
352 AcpiEvDefaultRegionSetup (
353     ACPI_HANDLE             Handle,
354     UINT32                  Function,
355     void                    *HandlerContext,
356     void                    **RegionContext);
357 
358 ACPI_STATUS
359 AcpiEvInitializeRegion (
360     ACPI_OPERAND_OBJECT     *RegionObj);
361 
362 BOOLEAN
363 AcpiEvIsPciRootBridge (
364     ACPI_NAMESPACE_NODE     *Node);
365 
366 
367 /*
368  * evsci - SCI (System Control Interrupt) handling/dispatch
369  */
370 UINT32 ACPI_SYSTEM_XFACE
371 AcpiEvGpeXruptHandler (
372     void                    *Context);
373 
374 UINT32
375 AcpiEvSciDispatch (
376     void);
377 
378 UINT32
379 AcpiEvInstallSciHandler (
380     void);
381 
382 ACPI_STATUS
383 AcpiEvRemoveAllSciHandlers (
384     void);
385 
386 ACPI_HW_DEPENDENT_RETURN_VOID (
387 void
388 AcpiEvTerminate (
389     void))
390 
391 #endif  /* __ACEVENTS_H__  */
392