1 | /* iig(DriverKit-286) generated from IOWorkGroup.iig */ |
2 | |
3 | /* IOWorkGroup.iig:1-38 */ |
4 | /* |
5 | * Copyright (c) 2021 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_UIOWORKGROUP_H |
33 | #define _IOKIT_UIOWORKGROUP_H |
34 | |
35 | #include <DriverKit/OSObject.h> /* .iig include */ |
36 | #include <DriverKit/IOUserClient.h> /* .iig include */ |
37 | |
38 | enum { |
39 | kIOWorkGroupMaxNameLength = 64, |
40 | }; |
41 | |
42 | /* source class IOWorkGroup IOWorkGroup.iig:39-141 */ |
43 | |
44 | #if __DOCUMENTATION__ |
45 | #define KERNEL IIG_KERNEL |
46 | |
47 | /*! |
48 | * @class IOWorkGroup |
49 | * |
50 | * @abstract |
51 | * Workgroups allow multiple threads to coordinate activities for realtime operations. |
52 | * |
53 | * @discussion |
54 | * |
55 | * Applications that open user clients to a DriverKit driver can send a workgroup to use in the driver. |
56 | * |
57 | * The application will have to first create an workgroup object. The application then should copy the |
58 | * workgroup port with os_workgroup_copy_port(). To send the workgroup port to the driver, use: |
59 | * |
60 | * const char * name = "Work Group Name"; // This must match the name the driver used in IOWorkGroup::Create(). |
61 | * kern_return_t ret = IOConnectTrap3(connect, // user client connection (io_connect_t) |
62 | * 1, // specifies event link configuration trap |
63 | * (uintptr_t)name, |
64 | * (uintptr_t)strlen(name), |
65 | * (uintptr_t)wgPort // port from os_workgroup_copy_port |
66 | * ); |
67 | * |
68 | * Once the workgroup port has been sent to the driver, the driver should be notified with a user-defined external method |
69 | * or other existing signaling mechanism. |
70 | */ |
71 | class NATIVE KERNEL IOWorkGroup : public OSObject |
72 | { |
73 | public: |
74 | |
75 | virtual bool |
76 | init() override; |
77 | |
78 | virtual void |
79 | free() override; |
80 | |
81 | /*! |
82 | * @brief Create an IOWorkGroup object. This object is not functional until a workgroup port has been set. |
83 | * @param name Name of the workgroup |
84 | * @param userClient Userclient to create the workgroup in. The DriverKit runtime will retain the userclient, and will |
85 | * release it in Invalidate() or when the IOWorkGroup is freed. |
86 | * @param workgroup Created IOWorkGroup with +1 retain count to be released by the caller. |
87 | * @return kIOReturnSuccess on success. See IOReturn.h for error codes. |
88 | */ |
89 | static kern_return_t |
90 | Create(OSString * name, IOUserClient * userClient, IOWorkGroup ** workgroup) LOCAL; |
91 | |
92 | #if DRIVERKIT_PRIVATE |
93 | |
94 | /*! |
95 | * @brief Set the port for this workgroup. This should not be called directly. |
96 | * @param port Workgroup port |
97 | * @return kIOReturnSuccess on success. See IOReturn.h for error codes. |
98 | */ |
99 | virtual kern_return_t |
100 | SetWorkGroupPort(mach_port_t port PORTCOPYSEND) LOCAL; |
101 | |
102 | #endif /* DRIVERKIT_PRIVATE */ |
103 | |
104 | /*! |
105 | * @brief Get the size of the workgroup token. |
106 | * @discussion Join() and Leave() require the caller to pass a token. This token should be allocated by the caller, and freed when |
107 | * no longer needed. Use this method to determine how much memory to allocate for the token. |
108 | * @return Workgroup token size |
109 | */ |
110 | size_t |
111 | GetTokenSize() LOCALONLY; |
112 | |
113 | /*! |
114 | * @brief Join the workgroup. |
115 | * @discussion Before calling this method, the caller must allocate a token. This token must be passed to this method. When leaving |
116 | * a workgroup with Leave(), use the same token that was passed to Join(). |
117 | * @param token The workgroup token. |
118 | * @return kIOReturnSuccess on success. See IOReturn.h for error codes. |
119 | */ |
120 | kern_return_t |
121 | Join(void * token) LOCALONLY; |
122 | |
123 | /*! |
124 | * @brief Leave the workgroup. |
125 | * @discussion The workgroup must have been joined with Join(). Use the same token in Join() for this method. |
126 | * @param token The workgroup token. |
127 | * @return kIOReturnSuccess on success. See IOReturn.h for error codes. |
128 | */ |
129 | kern_return_t |
130 | Leave(void * token) LOCALONLY; |
131 | |
132 | /*! |
133 | * @brief Invalidate the IOWorkGroup. |
134 | * @discussion This releases the kernel reference to the IOWorkGroup, allowing the name to be used for a different |
135 | * IOWorkGroup. This method should be called after the client has configured the eventlink with the IOConnectTrap |
136 | * call. After invalidation, the IOWorkGroup can no longer be configured through the IOConnectTrap call. No other |
137 | * functionality is affected. |
138 | * @return kIOReturnSuccess on success. See IOReturn.h for error codes. |
139 | */ |
140 | kern_return_t |
141 | Invalidate() LOCALONLY; |
142 | |
143 | #if DRIVERKIT_PRIVATE |
144 | |
145 | virtual kern_return_t |
146 | InvalidateKernel(IOUserClient * client); |
147 | |
148 | #endif /* DRIVERKIT_PRIVATE */ |
149 | |
150 | }; |
151 | |
152 | #undef KERNEL |
153 | #else /* __DOCUMENTATION__ */ |
154 | |
155 | /* generated class IOWorkGroup IOWorkGroup.iig:39-141 */ |
156 | |
157 | #define IOWorkGroup_Create_ID 0xff6c673bb6df71e7ULL |
158 | #define IOWorkGroup_SetWorkGroupPort_ID 0x8ffac48189cbd31bULL |
159 | #define IOWorkGroup_InvalidateKernel_ID 0xae2ae4397e9f08a1ULL |
160 | |
161 | #define IOWorkGroup_Create_Args \ |
162 | OSString * name, \ |
163 | IOUserClient * userClient, \ |
164 | IOWorkGroup ** workgroup |
165 | |
166 | #define IOWorkGroup_SetWorkGroupPort_Args \ |
167 | mach_port_t port |
168 | |
169 | #define IOWorkGroup_InvalidateKernel_Args \ |
170 | IOUserClient * client |
171 | |
172 | #define IOWorkGroup_Methods \ |
173 | \ |
174 | public:\ |
175 | \ |
176 | virtual kern_return_t\ |
177 | Dispatch(const IORPC rpc) APPLE_KEXT_OVERRIDE;\ |
178 | \ |
179 | static kern_return_t\ |
180 | _Dispatch(IOWorkGroup * self, const IORPC rpc);\ |
181 | \ |
182 | static kern_return_t\ |
183 | Create(\ |
184 | OSString * name,\ |
185 | IOUserClient * userClient,\ |
186 | IOWorkGroup ** workgroup);\ |
187 | \ |
188 | kern_return_t\ |
189 | SetWorkGroupPort(\ |
190 | mach_port_t port,\ |
191 | OSDispatchMethod supermethod = NULL);\ |
192 | \ |
193 | size_t\ |
194 | GetTokenSize(\ |
195 | );\ |
196 | \ |
197 | kern_return_t\ |
198 | Join(\ |
199 | void * token);\ |
200 | \ |
201 | kern_return_t\ |
202 | Leave(\ |
203 | void * token);\ |
204 | \ |
205 | kern_return_t\ |
206 | Invalidate(\ |
207 | );\ |
208 | \ |
209 | kern_return_t\ |
210 | InvalidateKernel(\ |
211 | IOUserClient * client,\ |
212 | OSDispatchMethod supermethod = NULL);\ |
213 | \ |
214 | \ |
215 | protected:\ |
216 | /* _Impl methods */\ |
217 | \ |
218 | static kern_return_t\ |
219 | Create_Call(IOWorkGroup_Create_Args);\ |
220 | \ |
221 | kern_return_t\ |
222 | SetWorkGroupPort_Impl(IOWorkGroup_SetWorkGroupPort_Args);\ |
223 | \ |
224 | \ |
225 | public:\ |
226 | /* _Invoke methods */\ |
227 | \ |
228 | typedef kern_return_t (*Create_Handler)(IOWorkGroup_Create_Args);\ |
229 | static kern_return_t\ |
230 | Create_Invoke(const IORPC rpc,\ |
231 | Create_Handler func);\ |
232 | \ |
233 | typedef kern_return_t (*SetWorkGroupPort_Handler)(OSMetaClassBase * target, IOWorkGroup_SetWorkGroupPort_Args);\ |
234 | static kern_return_t\ |
235 | SetWorkGroupPort_Invoke(const IORPC rpc,\ |
236 | OSMetaClassBase * target,\ |
237 | SetWorkGroupPort_Handler func);\ |
238 | \ |
239 | typedef kern_return_t (*InvalidateKernel_Handler)(OSMetaClassBase * target, IOWorkGroup_InvalidateKernel_Args);\ |
240 | static kern_return_t\ |
241 | InvalidateKernel_Invoke(const IORPC rpc,\ |
242 | OSMetaClassBase * target,\ |
243 | InvalidateKernel_Handler func);\ |
244 | \ |
245 | |
246 | |
247 | #define IOWorkGroup_KernelMethods \ |
248 | \ |
249 | protected:\ |
250 | /* _Impl methods */\ |
251 | \ |
252 | static kern_return_t\ |
253 | Create_Impl(IOWorkGroup_Create_Args);\ |
254 | \ |
255 | kern_return_t\ |
256 | InvalidateKernel_Impl(IOWorkGroup_InvalidateKernel_Args);\ |
257 | \ |
258 | |
259 | |
260 | #define IOWorkGroup_VirtualMethods \ |
261 | \ |
262 | public:\ |
263 | \ |
264 | virtual bool\ |
265 | init(\ |
266 | ) APPLE_KEXT_OVERRIDE;\ |
267 | \ |
268 | virtual void\ |
269 | free(\ |
270 | ) APPLE_KEXT_OVERRIDE;\ |
271 | \ |
272 | |
273 | |
274 | #if !KERNEL |
275 | |
276 | extern OSMetaClass * gIOWorkGroupMetaClass; |
277 | extern const OSClassLoadInformation IOWorkGroup_Class; |
278 | |
279 | class IOWorkGroupMetaClass : public OSMetaClass |
280 | { |
281 | public: |
282 | virtual kern_return_t |
283 | New(OSObject * instance) override; |
284 | virtual kern_return_t |
285 | Dispatch(const IORPC rpc) override; |
286 | }; |
287 | |
288 | #endif /* !KERNEL */ |
289 | |
290 | class IOWorkGroupInterface : public OSInterface |
291 | { |
292 | public: |
293 | }; |
294 | |
295 | struct IOWorkGroup_IVars; |
296 | struct IOWorkGroup_LocalIVars; |
297 | |
298 | class IOWorkGroup : public OSObject, public IOWorkGroupInterface |
299 | { |
300 | #if KERNEL |
301 | OSDeclareDefaultStructorsWithDispatch(IOWorkGroup); |
302 | #endif /* KERNEL */ |
303 | |
304 | #if !KERNEL |
305 | friend class IOWorkGroupMetaClass; |
306 | #endif /* !KERNEL */ |
307 | |
308 | public: |
309 | #ifdef IOWorkGroup_DECLARE_IVARS |
310 | IOWorkGroup_DECLARE_IVARS |
311 | #else /* IOWorkGroup_DECLARE_IVARS */ |
312 | union |
313 | { |
314 | IOWorkGroup_IVars * ivars; |
315 | IOWorkGroup_LocalIVars * lvars; |
316 | }; |
317 | #endif /* IOWorkGroup_DECLARE_IVARS */ |
318 | #if !KERNEL |
319 | static OSMetaClass * |
320 | sGetMetaClass() { return gIOWorkGroupMetaClass; }; |
321 | virtual const OSMetaClass * |
322 | getMetaClass() const APPLE_KEXT_OVERRIDE { return gIOWorkGroupMetaClass; }; |
323 | #endif /* KERNEL */ |
324 | |
325 | using super = OSObject; |
326 | |
327 | #if !KERNEL |
328 | IOWorkGroup_Methods |
329 | #endif /* !KERNEL */ |
330 | |
331 | IOWorkGroup_VirtualMethods |
332 | }; |
333 | |
334 | #endif /* !__DOCUMENTATION__ */ |
335 | |
336 | /* IOWorkGroup.iig:143- */ |
337 | |
338 | #endif /* ! _IOKIT_UIOWORKGROUP_H */ |
339 | |