1/* iig(DriverKit-286) generated from IOServiceStateNotificationDispatchSource.iig */
2
3/* IOServiceStateNotificationDispatchSource.iig:1-36 */
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_UIOSERVICESTATEDISPATCHSOURCE_H
33#define _IOKIT_UIOSERVICESTATEDISPATCHSOURCE_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
40/* source class IOServiceStateNotificationDispatchSource IOServiceStateNotificationDispatchSource.iig:37-106 */
41
42#if __DOCUMENTATION__
43#define KERNEL IIG_KERNEL
44
45class NATIVE KERNEL IOServiceStateNotificationDispatchSource : public IODispatchSource
46{
47public:
48
49 virtual bool
50 init() override;
51
52 virtual void
53 free() override;
54
55 /*!
56 * @brief Create an IOServiceStateNotificationDispatchSource for notification of IOService state events sent by the StateNotificationSet() api.
57 * @param service The object hosting state, typically returned by IOService::CopySystemStateNotificationService().
58 * @param items Array of state item names to be notified about.
59 * @param queue IODispatchQueue the source is attached to. Note that the StateNotificationReady
60 * handler is invoked on the queue set for the target method
61 * of the OSAction, not this queue.
62 * @param source Created source with +1 retain count to be released by the caller.
63 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
64 */
65 static kern_return_t
66 Create(IOService * service, OSArray * items, IODispatchQueue * queue, IOServiceStateNotificationDispatchSource ** source) LOCAL;
67
68
69 /*!
70 * @brief Control the enable state of the notification.
71 * @param enable Pass true to enable the source or false to disable.
72 * @param handler Optional block to be executed after the interrupt has been disabled and any pending
73 * interrupt handlers completed.
74 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
75 */
76 virtual kern_return_t
77 SetEnableWithCompletion(
78 bool enable,
79 IODispatchSourceCancelHandler handler) override LOCAL;
80
81 /*!
82 * @brief Cancel all callbacks from the event source.
83 * @discussion After cancellation, the source can only be freed. It cannot be reactivated.
84 * @param handler Handler block to be invoked after any callbacks have completed.
85 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
86 */
87 virtual kern_return_t
88 Cancel(IODispatchSourceCancelHandler handler) override LOCAL;
89
90 /*!
91 * @brief Set the handler block to run when the notification has become ready.
92 * @param action OSAction instance specifying the callback method. The OSAction object will be retained
93 * until SetHandler is called again or the event source is cancelled.
94 * The StateNotificationReady handler is invoked on the queue set for the target method of the
95 * OSAction.
96 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
97 */
98 virtual kern_return_t
99 SetHandler(
100 OSAction * action TYPE(StateNotificationReady));
101
102 /*!
103 * @brief Rearm the notification.
104 * @discussion Call this method in the implementation of your StateNotificationReady action
105 * before reading any item values.
106 * @return kIOReturnSuccess on success. See IOReturn.h for error codes.
107 */
108 virtual kern_return_t
109 StateNotificationBegin(void);
110
111private:
112 virtual void
113 StateNotificationReady(
114 OSAction * action TARGET) LOCAL = 0;
115};
116
117#undef KERNEL
118#else /* __DOCUMENTATION__ */
119
120/* generated class IOServiceStateNotificationDispatchSource IOServiceStateNotificationDispatchSource.iig:37-106 */
121
122#define IOServiceStateNotificationDispatchSource_Create_ID 0xddfc03b5eb685059ULL
123#define IOServiceStateNotificationDispatchSource_SetHandler_ID 0x91981670bc7b5188ULL
124#define IOServiceStateNotificationDispatchSource_StateNotificationBegin_ID 0xe0940d907a5fc5dcULL
125#define IOServiceStateNotificationDispatchSource_StateNotificationReady_ID 0xda6f23bbb0b49076ULL
126
127#define IOServiceStateNotificationDispatchSource_Create_Args \
128 IOService * service, \
129 OSArray * items, \
130 IODispatchQueue * queue, \
131 IOServiceStateNotificationDispatchSource ** source
132
133#define IOServiceStateNotificationDispatchSource_SetEnableWithCompletion_Args \
134 bool enable, \
135 IODispatchSourceCancelHandler handler
136
137#define IOServiceStateNotificationDispatchSource_Cancel_Args \
138 IODispatchSourceCancelHandler handler
139
140#define IOServiceStateNotificationDispatchSource_SetHandler_Args \
141 OSAction * action
142
143#define IOServiceStateNotificationDispatchSource_StateNotificationBegin_Args \
144
145
146#define IOServiceStateNotificationDispatchSource_StateNotificationReady_Args \
147 OSAction * action
148
149#define IOServiceStateNotificationDispatchSource_Methods \
150\
151public:\
152\
153 virtual kern_return_t\
154 Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\
155\
156 static kern_return_t\
157 _Dispatch(IOServiceStateNotificationDispatchSource * self, const IORPC rpc);\
158\
159 static kern_return_t\
160 Create(\
161 IOService * service,\
162 OSArray * items,\
163 IODispatchQueue * queue,\
164 IOServiceStateNotificationDispatchSource ** source);\
165\
166 kern_return_t\
167 SetHandler(\
168 OSAction * action,\
169 OSDispatchMethod supermethod = NULL);\
170\
171 kern_return_t\
172 StateNotificationBegin(\
173 OSDispatchMethod supermethod = NULL);\
174\
175 void\
176 StateNotificationReady(\
177 OSAction * action,\
178 OSDispatchMethod supermethod = NULL);\
179\
180\
181protected:\
182 /* _Impl methods */\
183\
184 static kern_return_t\
185 Create_Call(IOServiceStateNotificationDispatchSource_Create_Args);\
186\
187 kern_return_t\
188 SetEnableWithCompletion_Impl(IODispatchSource_SetEnableWithCompletion_Args);\
189\
190 kern_return_t\
191 Cancel_Impl(IODispatchSource_Cancel_Args);\
192\
193\
194public:\
195 /* _Invoke methods */\
196\
197 typedef kern_return_t (*Create_Handler)(IOServiceStateNotificationDispatchSource_Create_Args);\
198 static kern_return_t\
199 Create_Invoke(const IORPC rpc,\
200 Create_Handler func);\
201\
202 typedef kern_return_t (*SetHandler_Handler)(OSMetaClassBase * target, IOServiceStateNotificationDispatchSource_SetHandler_Args);\
203 static kern_return_t\
204 SetHandler_Invoke(const IORPC rpc,\
205 OSMetaClassBase * target,\
206 SetHandler_Handler func);\
207\
208 typedef kern_return_t (*StateNotificationBegin_Handler)(OSMetaClassBase * targetIOServiceStateNotificationDispatchSource_StateNotificationBegin_Args);\
209 static kern_return_t\
210 StateNotificationBegin_Invoke(const IORPC rpc,\
211 OSMetaClassBase * target,\
212 StateNotificationBegin_Handler func);\
213\
214 typedef void (*StateNotificationReady_Handler)(OSMetaClassBase * target, IOServiceStateNotificationDispatchSource_StateNotificationReady_Args);\
215 static kern_return_t\
216 StateNotificationReady_Invoke(const IORPC rpc,\
217 OSMetaClassBase * target,\
218 StateNotificationReady_Handler func,\
219 const OSMetaClass * targetActionClass);\
220\
221 static kern_return_t\
222 StateNotificationReady_Invoke(const IORPC rpc,\
223 OSMetaClassBase * target,\
224 StateNotificationReady_Handler func);\
225\
226
227
228#define IOServiceStateNotificationDispatchSource_KernelMethods \
229\
230protected:\
231 /* _Impl methods */\
232\
233 static kern_return_t\
234 Create_Impl(IOServiceStateNotificationDispatchSource_Create_Args);\
235\
236 kern_return_t\
237 SetHandler_Impl(IOServiceStateNotificationDispatchSource_SetHandler_Args);\
238\
239 kern_return_t\
240 StateNotificationBegin_Impl(IOServiceStateNotificationDispatchSource_StateNotificationBegin_Args);\
241\
242
243
244#define IOServiceStateNotificationDispatchSource_VirtualMethods \
245\
246public:\
247\
248 virtual bool\
249 init(\
250) APPLE_KEXT_OVERRIDE;\
251\
252 virtual void\
253 free(\
254) APPLE_KEXT_OVERRIDE;\
255\
256
257
258#if !KERNEL
259
260extern OSMetaClass * gIOServiceStateNotificationDispatchSourceMetaClass;
261extern const OSClassLoadInformation IOServiceStateNotificationDispatchSource_Class;
262
263class IOServiceStateNotificationDispatchSourceMetaClass : public OSMetaClass
264{
265public:
266 virtual kern_return_t
267 New(OSObject * instance) override;
268 virtual kern_return_t
269 Dispatch(const IORPC rpc) override;
270};
271
272#endif /* !KERNEL */
273
274class IOServiceStateNotificationDispatchSourceInterface : public OSInterface
275{
276public:
277};
278
279struct IOServiceStateNotificationDispatchSource_IVars;
280struct IOServiceStateNotificationDispatchSource_LocalIVars;
281
282class IOServiceStateNotificationDispatchSource : public IODispatchSource, public IOServiceStateNotificationDispatchSourceInterface
283{
284#if KERNEL
285 OSDeclareDefaultStructorsWithDispatch(IOServiceStateNotificationDispatchSource);
286#endif /* KERNEL */
287
288#if !KERNEL
289 friend class IOServiceStateNotificationDispatchSourceMetaClass;
290#endif /* !KERNEL */
291
292public:
293#ifdef IOServiceStateNotificationDispatchSource_DECLARE_IVARS
294IOServiceStateNotificationDispatchSource_DECLARE_IVARS
295#else /* IOServiceStateNotificationDispatchSource_DECLARE_IVARS */
296 union
297 {
298 IOServiceStateNotificationDispatchSource_IVars * ivars;
299 IOServiceStateNotificationDispatchSource_LocalIVars * lvars;
300 };
301#endif /* IOServiceStateNotificationDispatchSource_DECLARE_IVARS */
302#if !KERNEL
303 static OSMetaClass *
304 sGetMetaClass() { return gIOServiceStateNotificationDispatchSourceMetaClass; };
305 virtual const OSMetaClass *
306 getMetaClass() const APPLE_KEXT_OVERRIDE { return gIOServiceStateNotificationDispatchSourceMetaClass; };
307#endif /* KERNEL */
308
309 using super = IODispatchSource;
310
311#if !KERNEL
312 IOServiceStateNotificationDispatchSource_Methods
313#endif /* !KERNEL */
314
315 IOServiceStateNotificationDispatchSource_VirtualMethods
316};
317
318#endif /* !__DOCUMENTATION__ */
319
320/* IOServiceStateNotificationDispatchSource.iig:108- */
321
322#endif /* ! _IOKIT_UIOSERVICESTATEDISPATCHSOURCE_H */
323