1/* iig(DriverKit-286) generated from IOServiceNotificationDispatchSource.iig */
2
3/* IOServiceNotificationDispatchSource.iig:1-45 */
4/*
5 * Copyright (c) 2019-2019 Apple Inc. All rights reserved.
6 *
7 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
8 *
9 * This file contains Original Code and/or Modifications of Original Code
10 * as defined in and that are subject to the Apple Public Source License
11 * Version 2.0 (the 'License'). You may not use this file except in
12 * compliance with the License. The rights granted to you under the License
13 * may not be used to create, or enable the creation or redistribution of,
14 * unlawful or unlicensed copies of an Apple operating system, or to
15 * circumvent, violate, or enable the circumvention or violation of, any
16 * terms of an Apple operating system software license agreement.
17 *
18 * Please obtain a copy of the License at
19 * http://www.opensource.apple.com/apsl/ and read it before using this file.
20 *
21 * The Original Code and all software distributed under the License are
22 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
23 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
24 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
26 * Please see the License for the specific language governing rights and
27 * limitations under the License.
28 *
29 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 */
31
32#ifndef _IOKIT_UIOSERVICEDISPATCHSOURCE_H
33#define _IOKIT_UIOSERVICEDISPATCHSOURCE_H
34
35#include <DriverKit/IODispatchQueue.h> /* .iig include */
36#include <DriverKit/OSAction.h> /* .iig include */
37#include <DriverKit/IOService.h> /* .iig include */
38
39
40typedef void (^IOServiceNotificationBlock)(uint64_t type, IOService * service, uint64_t options);
41
42enum {
43 kIOServiceNotificationTypeTerminated = 0x00000000,
44 kIOServiceNotificationTypeMatched = 0x00000001,
45 kIOServiceNotificationTypeLast = kIOServiceNotificationTypeMatched,
46 kIOServiceNotificationTypeNone = 0xFFFFFFFF,
47};
48
49/* source class IOServiceNotificationDispatchSource IOServiceNotificationDispatchSource.iig:46-128 */
50
51#if __DOCUMENTATION__
52#define KERNEL IIG_KERNEL
53
54class NATIVE KERNEL IOServiceNotificationDispatchSource : public IODispatchSource
55{
56public:
57
58 /*!
59 * @brief Create an IOServiceNotificationDispatchSource for IOService matching and termination events.
60 * @param matching An IOService matching dictionary.
61 * @param options None defined, pass zero.
62 * @param queue IODispatchQueue the source is attached to. Note that the ServiceNotificationReady
63 * handler is invoked on the queue set for the target method
64 * of the OSAction, not this queue.
65 * @param source Created source with +1 retain count to be released by the caller.
66 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
67 */
68 static kern_return_t
69 Create(
70 OSDictionary * matching,
71 uint64_t options,
72 IODispatchQueue * queue,
73 IOServiceNotificationDispatchSource ** notification) LOCAL;
74
75 virtual bool
76 init() override;
77
78 virtual void
79 free() override;
80
81 /*!
82 * @brief Control the enable state of the notification.
83 * @param enable Pass true to enable the source or false to disable.
84 * @param handler Optional block to be executed after the interrupt has been disabled and any pending
85 * interrupt handlers completed.
86 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
87 */
88 virtual kern_return_t
89 SetEnableWithCompletion(
90 bool enable,
91 IODispatchSourceCancelHandler handler) override LOCAL;
92
93 /*!
94 * @brief Cancel all callbacks from the event source.
95 * @discussion After cancellation, the source can only be freed. It cannot be reactivated.
96 * @param handler Handler block to be invoked after any callbacks have completed.
97 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
98 */
99 virtual kern_return_t
100 Cancel(IODispatchSourceCancelHandler handler) override LOCAL;
101
102 /*!
103 * @brief Set the handler block to run when the notification has become ready.
104 * @param action OSAction instance specifying the callback method. The OSAction object will be retained
105 * until SetHandler is called again or the event source is cancelled.
106 * The ServiceNotificationReady handler is invoked on the queue set for the target method of the
107 * OSAction.
108 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
109 */
110 virtual kern_return_t
111 SetHandler(
112 OSAction * action TYPE(ServiceNotificationReady));
113
114 /*!
115 * @brief Invoke a block for each notification available in response to ServiceNotificationReady.
116 * @discussion The IOService object passed to the notification is only retained for the duration of the block.
117 * It should be retained by the block code if used beyond the invocation.
118 * @param block to be invoked with each notification
119 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
120 */
121 kern_return_t
122 DeliverNotifications(IOServiceNotificationBlock block) LOCALONLY;
123
124private:
125 virtual kern_return_t
126 CheckForWork(bool synchronous) override LOCAL;
127
128 virtual void
129 ServiceNotificationReady(
130 OSAction * action TARGET) LOCAL = 0;
131
132 virtual kern_return_t
133 CopyNextNotification(
134 uint64_t * type,
135 IOService ** service,
136 uint64_t * options);
137};
138
139#undef KERNEL
140#else /* __DOCUMENTATION__ */
141
142/* generated class IOServiceNotificationDispatchSource IOServiceNotificationDispatchSource.iig:46-128 */
143
144#define IOServiceNotificationDispatchSource_Create_ID 0xb40d274e974e946aULL
145#define IOServiceNotificationDispatchSource_SetHandler_ID 0xca55c48f95fc6f8eULL
146#define IOServiceNotificationDispatchSource_ServiceNotificationReady_ID 0xfbaa85f2cdb990b4ULL
147#define IOServiceNotificationDispatchSource_CopyNextNotification_ID 0xca420abbda782780ULL
148
149#define IOServiceNotificationDispatchSource_Create_Args \
150 OSDictionary * matching, \
151 uint64_t options, \
152 IODispatchQueue * queue, \
153 IOServiceNotificationDispatchSource ** notification
154
155#define IOServiceNotificationDispatchSource_SetEnableWithCompletion_Args \
156 bool enable, \
157 IODispatchSourceCancelHandler handler
158
159#define IOServiceNotificationDispatchSource_Cancel_Args \
160 IODispatchSourceCancelHandler handler
161
162#define IOServiceNotificationDispatchSource_SetHandler_Args \
163 OSAction * action
164
165#define IOServiceNotificationDispatchSource_CheckForWork_Args \
166 const IORPC rpc, \
167 bool synchronous
168
169#define IOServiceNotificationDispatchSource_ServiceNotificationReady_Args \
170 OSAction * action
171
172#define IOServiceNotificationDispatchSource_CopyNextNotification_Args \
173 uint64_t * type, \
174 IOService ** service, \
175 uint64_t * options
176
177#define IOServiceNotificationDispatchSource_Methods \
178\
179public:\
180\
181 virtual kern_return_t\
182 Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\
183\
184 static kern_return_t\
185 _Dispatch(IOServiceNotificationDispatchSource * self, const IORPC rpc);\
186\
187 static kern_return_t\
188 Create(\
189 OSDictionary * matching,\
190 uint64_t options,\
191 IODispatchQueue * queue,\
192 IOServiceNotificationDispatchSource ** notification);\
193\
194 kern_return_t\
195 SetHandler(\
196 OSAction * action,\
197 OSDispatchMethod supermethod = NULL);\
198\
199 kern_return_t\
200 DeliverNotifications(\
201 IOServiceNotificationBlock block);\
202\
203 void\
204 ServiceNotificationReady(\
205 OSAction * action,\
206 OSDispatchMethod supermethod = NULL);\
207\
208 kern_return_t\
209 CopyNextNotification(\
210 uint64_t * type,\
211 IOService ** service,\
212 uint64_t * options,\
213 OSDispatchMethod supermethod = NULL);\
214\
215\
216protected:\
217 /* _Impl methods */\
218\
219 static kern_return_t\
220 Create_Call(IOServiceNotificationDispatchSource_Create_Args);\
221\
222 kern_return_t\
223 SetEnableWithCompletion_Impl(IODispatchSource_SetEnableWithCompletion_Args);\
224\
225 kern_return_t\
226 Cancel_Impl(IODispatchSource_Cancel_Args);\
227\
228 kern_return_t\
229 CheckForWork_Impl(IODispatchSource_CheckForWork_Args);\
230\
231\
232public:\
233 /* _Invoke methods */\
234\
235 typedef kern_return_t (*Create_Handler)(IOServiceNotificationDispatchSource_Create_Args);\
236 static kern_return_t\
237 Create_Invoke(const IORPC rpc,\
238 Create_Handler func);\
239\
240 typedef kern_return_t (*SetHandler_Handler)(OSMetaClassBase * target, IOServiceNotificationDispatchSource_SetHandler_Args);\
241 static kern_return_t\
242 SetHandler_Invoke(const IORPC rpc,\
243 OSMetaClassBase * target,\
244 SetHandler_Handler func);\
245\
246 typedef void (*ServiceNotificationReady_Handler)(OSMetaClassBase * target, IOServiceNotificationDispatchSource_ServiceNotificationReady_Args);\
247 static kern_return_t\
248 ServiceNotificationReady_Invoke(const IORPC rpc,\
249 OSMetaClassBase * target,\
250 ServiceNotificationReady_Handler func,\
251 const OSMetaClass * targetActionClass);\
252\
253 static kern_return_t\
254 ServiceNotificationReady_Invoke(const IORPC rpc,\
255 OSMetaClassBase * target,\
256 ServiceNotificationReady_Handler func);\
257\
258 typedef kern_return_t (*CopyNextNotification_Handler)(OSMetaClassBase * target, IOServiceNotificationDispatchSource_CopyNextNotification_Args);\
259 static kern_return_t\
260 CopyNextNotification_Invoke(const IORPC rpc,\
261 OSMetaClassBase * target,\
262 CopyNextNotification_Handler func);\
263\
264
265
266#define IOServiceNotificationDispatchSource_KernelMethods \
267\
268protected:\
269 /* _Impl methods */\
270\
271 static kern_return_t\
272 Create_Impl(IOServiceNotificationDispatchSource_Create_Args);\
273\
274 kern_return_t\
275 SetHandler_Impl(IOServiceNotificationDispatchSource_SetHandler_Args);\
276\
277 kern_return_t\
278 CopyNextNotification_Impl(IOServiceNotificationDispatchSource_CopyNextNotification_Args);\
279\
280
281
282#define IOServiceNotificationDispatchSource_VirtualMethods \
283\
284public:\
285\
286 virtual bool\
287 init(\
288) APPLE_KEXT_OVERRIDE;\
289\
290 virtual void\
291 free(\
292) APPLE_KEXT_OVERRIDE;\
293\
294
295
296#if !KERNEL
297
298extern OSMetaClass * gIOServiceNotificationDispatchSourceMetaClass;
299extern const OSClassLoadInformation IOServiceNotificationDispatchSource_Class;
300
301class IOServiceNotificationDispatchSourceMetaClass : public OSMetaClass
302{
303public:
304 virtual kern_return_t
305 New(OSObject * instance) override;
306 virtual kern_return_t
307 Dispatch(const IORPC rpc) override;
308};
309
310#endif /* !KERNEL */
311
312class IOServiceNotificationDispatchSourceInterface : public OSInterface
313{
314public:
315};
316
317struct IOServiceNotificationDispatchSource_IVars;
318struct IOServiceNotificationDispatchSource_LocalIVars;
319
320class IOServiceNotificationDispatchSource : public IODispatchSource, public IOServiceNotificationDispatchSourceInterface
321{
322#if KERNEL
323 OSDeclareDefaultStructorsWithDispatch(IOServiceNotificationDispatchSource);
324#endif /* KERNEL */
325
326#if !KERNEL
327 friend class IOServiceNotificationDispatchSourceMetaClass;
328#endif /* !KERNEL */
329
330public:
331#ifdef IOServiceNotificationDispatchSource_DECLARE_IVARS
332IOServiceNotificationDispatchSource_DECLARE_IVARS
333#else /* IOServiceNotificationDispatchSource_DECLARE_IVARS */
334 union
335 {
336 IOServiceNotificationDispatchSource_IVars * ivars;
337 IOServiceNotificationDispatchSource_LocalIVars * lvars;
338 };
339#endif /* IOServiceNotificationDispatchSource_DECLARE_IVARS */
340#if !KERNEL
341 static OSMetaClass *
342 sGetMetaClass() { return gIOServiceNotificationDispatchSourceMetaClass; };
343 virtual const OSMetaClass *
344 getMetaClass() const APPLE_KEXT_OVERRIDE { return gIOServiceNotificationDispatchSourceMetaClass; };
345#endif /* KERNEL */
346
347 using super = IODispatchSource;
348
349#if !KERNEL
350 IOServiceNotificationDispatchSource_Methods
351#endif /* !KERNEL */
352
353 IOServiceNotificationDispatchSource_VirtualMethods
354};
355
356#endif /* !__DOCUMENTATION__ */
357
358/* IOServiceNotificationDispatchSource.iig:130- */
359
360#endif /* ! _IOKIT_UIOSERVICEDISPATCHSOURCE_H */
361