1/* iig(DriverKit-286 Mar 29 2024 10:27:09) generated from IOBufferMemoryDescriptor.iig */
2
3#undef IIG_IMPLEMENTATION
4#define IIG_IMPLEMENTATION IOBufferMemoryDescriptor.iig
5
6#if KERNEL
7#include <libkern/c++/OSString.h>
8#else
9#include <DriverKit/DriverKit.h>
10#endif /* KERNEL */
11#include <DriverKit/IOReturn.h>
12#include <DriverKit/IOBufferMemoryDescriptor.h>
13
14
15#if __has_builtin(__builtin_load_member_function_pointer)
16#define SimpleMemberFunctionCast(cfnty, self, func) (cfnty)__builtin_load_member_function_pointer(self, func)
17#else
18#define SimpleMemberFunctionCast(cfnty, self, func) ({ union { typeof(func) memfun; cfnty cfun; } pair; pair.memfun = func; pair.cfun; })
19#endif
20
21
22struct IOBufferMemoryDescriptor_Create_Msg_Content
23{
24 IORPCMessage __hdr;
25 OSObjectRef __object;
26 uint64_t options;
27 uint64_t capacity;
28 uint64_t alignment;
29};
30#pragma pack(4)
31struct IOBufferMemoryDescriptor_Create_Msg
32{
33 IORPCMessageMach mach;
34 mach_msg_port_descriptor_t __object__descriptor;
35 IOBufferMemoryDescriptor_Create_Msg_Content content;
36};
37#pragma pack()
38#define IOBufferMemoryDescriptor_Create_Msg_ObjRefs (1)
39
40struct IOBufferMemoryDescriptor_Create_Rpl_Content
41{
42 IORPCMessage __hdr;
43 OSObjectRef memory;
44};
45#pragma pack(4)
46struct IOBufferMemoryDescriptor_Create_Rpl
47{
48 IORPCMessageMach mach;
49 mach_msg_port_descriptor_t memory__descriptor;
50 IOBufferMemoryDescriptor_Create_Rpl_Content content;
51};
52#pragma pack()
53#define IOBufferMemoryDescriptor_Create_Rpl_ObjRefs (1)
54
55
56typedef union
57{
58 const IORPC rpc;
59 struct
60 {
61 const struct IOBufferMemoryDescriptor_Create_Msg * message;
62 struct IOBufferMemoryDescriptor_Create_Rpl * reply;
63 uint32_t sendSize;
64 uint32_t replySize;
65 };
66}
67IOBufferMemoryDescriptor_Create_Invocation;
68struct IOBufferMemoryDescriptor_SetLength_Msg_Content
69{
70 IORPCMessage __hdr;
71 OSObjectRef __object;
72 uint64_t length;
73};
74#pragma pack(4)
75struct IOBufferMemoryDescriptor_SetLength_Msg
76{
77 IORPCMessageMach mach;
78 mach_msg_port_descriptor_t __object__descriptor;
79 IOBufferMemoryDescriptor_SetLength_Msg_Content content;
80};
81#pragma pack()
82#define IOBufferMemoryDescriptor_SetLength_Msg_ObjRefs (1)
83
84struct IOBufferMemoryDescriptor_SetLength_Rpl_Content
85{
86 IORPCMessage __hdr;
87};
88#pragma pack(4)
89struct IOBufferMemoryDescriptor_SetLength_Rpl
90{
91 IORPCMessageMach mach;
92 IOBufferMemoryDescriptor_SetLength_Rpl_Content content;
93};
94#pragma pack()
95#define IOBufferMemoryDescriptor_SetLength_Rpl_ObjRefs (0)
96
97
98typedef union
99{
100 const IORPC rpc;
101 struct
102 {
103 const struct IOBufferMemoryDescriptor_SetLength_Msg * message;
104 struct IOBufferMemoryDescriptor_SetLength_Rpl * reply;
105 uint32_t sendSize;
106 uint32_t replySize;
107 };
108}
109IOBufferMemoryDescriptor_SetLength_Invocation;
110#if !KERNEL
111extern OSMetaClass * gOSContainerMetaClass;
112extern OSMetaClass * gOSDataMetaClass;
113extern OSMetaClass * gOSNumberMetaClass;
114extern OSMetaClass * gOSStringMetaClass;
115extern OSMetaClass * gOSBooleanMetaClass;
116extern OSMetaClass * gOSDictionaryMetaClass;
117extern OSMetaClass * gOSArrayMetaClass;
118extern OSMetaClass * gOSSetMetaClass;
119extern OSMetaClass * gOSOrderedSetMetaClass;
120extern OSMetaClass * gIODispatchQueueMetaClass;
121extern OSMetaClass * gIOServiceMetaClass;
122extern OSMetaClass * gIOMemoryMapMetaClass;
123#endif /* !KERNEL */
124
125#if !KERNEL
126
127#define IOBufferMemoryDescriptor_QueueNames ""
128
129#define IOBufferMemoryDescriptor_MethodNames ""
130
131#define IOBufferMemoryDescriptorMetaClass_MethodNames ""
132
133struct OSClassDescription_IOBufferMemoryDescriptor_t
134{
135 OSClassDescription base;
136 uint64_t methodOptions[2 * 0];
137 uint64_t metaMethodOptions[2 * 0];
138 char queueNames[sizeof(IOBufferMemoryDescriptor_QueueNames)];
139 char methodNames[sizeof(IOBufferMemoryDescriptor_MethodNames)];
140 char metaMethodNames[sizeof(IOBufferMemoryDescriptorMetaClass_MethodNames)];
141};
142
143const struct OSClassDescription_IOBufferMemoryDescriptor_t
144OSClassDescription_IOBufferMemoryDescriptor =
145{
146 .base =
147 {
148 .descriptionSize = sizeof(OSClassDescription_IOBufferMemoryDescriptor_t),
149 .name = "IOBufferMemoryDescriptor",
150 .superName = "IOMemoryDescriptor",
151 .methodOptionsSize = 2 * sizeof(uint64_t) * 0,
152 .methodOptionsOffset = __builtin_offsetof(struct OSClassDescription_IOBufferMemoryDescriptor_t, methodOptions),
153 .metaMethodOptionsSize = 2 * sizeof(uint64_t) * 0,
154 .metaMethodOptionsOffset = __builtin_offsetof(struct OSClassDescription_IOBufferMemoryDescriptor_t, metaMethodOptions),
155 .queueNamesSize = sizeof(IOBufferMemoryDescriptor_QueueNames),
156 .queueNamesOffset = __builtin_offsetof(struct OSClassDescription_IOBufferMemoryDescriptor_t, queueNames),
157 .methodNamesSize = sizeof(IOBufferMemoryDescriptor_MethodNames),
158 .methodNamesOffset = __builtin_offsetof(struct OSClassDescription_IOBufferMemoryDescriptor_t, methodNames),
159 .metaMethodNamesSize = sizeof(IOBufferMemoryDescriptorMetaClass_MethodNames),
160 .metaMethodNamesOffset = __builtin_offsetof(struct OSClassDescription_IOBufferMemoryDescriptor_t, metaMethodNames),
161 .flags = 1*kOSClassCanRemote,
162 },
163 .methodOptions =
164 {
165 },
166 .metaMethodOptions =
167 {
168 },
169 .queueNames = IOBufferMemoryDescriptor_QueueNames,
170 .methodNames = IOBufferMemoryDescriptor_MethodNames,
171 .metaMethodNames = IOBufferMemoryDescriptorMetaClass_MethodNames,
172};
173
174OSMetaClass * gIOBufferMemoryDescriptorMetaClass;
175
176static kern_return_t
177IOBufferMemoryDescriptor_New(OSMetaClass * instance);
178
179const OSClassLoadInformation
180IOBufferMemoryDescriptor_Class =
181{
182 .description = &OSClassDescription_IOBufferMemoryDescriptor.base,
183 .metaPointer = &gIOBufferMemoryDescriptorMetaClass,
184 .version = 1,
185 .instanceSize = sizeof(IOBufferMemoryDescriptor),
186
187 .New = &IOBufferMemoryDescriptor_New,
188};
189
190extern const void * const
191gIOBufferMemoryDescriptor_Declaration;
192const void * const
193gIOBufferMemoryDescriptor_Declaration
194__attribute__((visibility("hidden"),section("__DATA_CONST,__osclassinfo,regular,no_dead_strip"),no_sanitize("address")))
195 = &IOBufferMemoryDescriptor_Class;
196
197static kern_return_t
198IOBufferMemoryDescriptor_New(OSMetaClass * instance)
199{
200 if (!new(instance) IOBufferMemoryDescriptorMetaClass) return (kIOReturnNoMemory);
201 return (kIOReturnSuccess);
202}
203
204kern_return_t
205IOBufferMemoryDescriptorMetaClass::New(OSObject * instance)
206{
207 if (!new(instance) IOBufferMemoryDescriptor) return (kIOReturnNoMemory);
208 return (kIOReturnSuccess);
209}
210
211#endif /* !KERNEL */
212
213kern_return_t
214IOBufferMemoryDescriptor::Dispatch(const IORPC rpc)
215{
216 return _Dispatch(self: this, rpc);
217}
218
219kern_return_t
220IOBufferMemoryDescriptor::_Dispatch(IOBufferMemoryDescriptor * self, const IORPC rpc)
221{
222 kern_return_t ret = kIOReturnUnsupported;
223 IORPCMessage * msg = IORPCMessageFromMach(msg: rpc.message, reply: false);
224
225 switch (msg->msgid)
226 {
227#if KERNEL
228 case IOBufferMemoryDescriptor_SetLength_ID:
229 {
230 ret = IOBufferMemoryDescriptor::SetLength_Invoke(rpc, target: self, SimpleMemberFunctionCast(IOBufferMemoryDescriptor::SetLength_Handler, *self, &IOBufferMemoryDescriptor::SetLength_Impl));
231 break;
232 }
233#endif /* !KERNEL */
234
235 default:
236 ret = IOMemoryDescriptor::_Dispatch(self, rpc);
237 break;
238 }
239
240 return (ret);
241}
242
243#if KERNEL
244kern_return_t
245IOBufferMemoryDescriptor::MetaClass::Dispatch(const IORPC rpc)
246{
247#else /* KERNEL */
248kern_return_t
249IOBufferMemoryDescriptorMetaClass::Dispatch(const IORPC rpc)
250{
251#endif /* !KERNEL */
252
253 kern_return_t ret = kIOReturnUnsupported;
254 IORPCMessage * msg = IORPCMessageFromMach(msg: rpc.message, reply: false);
255
256 switch (msg->msgid)
257 {
258#if KERNEL
259 case IOBufferMemoryDescriptor_Create_ID:
260 ret = IOBufferMemoryDescriptor::Create_Invoke(rpc, func: &IOBufferMemoryDescriptor::Create_Impl);
261 break;
262#endif /* !KERNEL */
263
264 default:
265 ret = OSMetaClassBase::Dispatch(rpc);
266 break;
267 }
268
269 return (ret);
270}
271
272kern_return_t
273IOBufferMemoryDescriptor::Create(
274 uint64_t options,
275 uint64_t capacity,
276 uint64_t alignment,
277 IOBufferMemoryDescriptor ** memory)
278{
279 kern_return_t ret;
280 union
281 {
282 IOBufferMemoryDescriptor_Create_Msg msg;
283 struct
284 {
285 IOBufferMemoryDescriptor_Create_Rpl rpl;
286 mach_msg_max_trailer_t trailer;
287 } rpl;
288 } buf;
289 struct IOBufferMemoryDescriptor_Create_Msg * msg = &buf.msg;
290 struct IOBufferMemoryDescriptor_Create_Rpl * rpl = &buf.rpl.rpl;
291
292 memset(s: msg, c: 0, n: sizeof(struct IOBufferMemoryDescriptor_Create_Msg));
293 msg->mach.msgh.msgh_id = kIORPCVersion190615;
294 msg->mach.msgh.msgh_size = sizeof(*msg);
295 msg->content.__hdr.flags = 0*kIORPCMessageOneway
296 | 0*kIORPCMessageSimpleReply
297 | 0*kIORPCMessageLocalHost
298 | 0*kIORPCMessageOnqueue;
299 msg->content.__hdr.msgid = IOBufferMemoryDescriptor_Create_ID;
300 msg->content.__object = (OSObjectRef) OSTypeID(IOBufferMemoryDescriptor);
301 msg->content.__hdr.objectRefs = IOBufferMemoryDescriptor_Create_Msg_ObjRefs;
302 msg->mach.msgh_body.msgh_descriptor_count = 1;
303
304 msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
305
306 msg->content.options = options;
307
308 msg->content.capacity = capacity;
309
310 msg->content.alignment = alignment;
311
312 IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) };
313 ret = OSMTypeID(IOBufferMemoryDescriptor)->Invoke(rpc);
314
315 if (kIOReturnSuccess == ret)
316 do {
317 {
318 if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; };
319 if (rpl->content.__hdr.msgid != IOBufferMemoryDescriptor_Create_ID) { ret = kIOReturnIPCError; break; };
320 if (rpl->mach.msgh_body.msgh_descriptor_count != 1) { ret = kIOReturnIPCError; break; };
321 if (IOBufferMemoryDescriptor_Create_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; };
322 }
323 }
324 while (false);
325 if (kIOReturnSuccess == ret)
326 {
327 *memory = OSDynamicCast(IOBufferMemoryDescriptor, (OSObject *) rpl->content.memory);
328 if (rpl->content.memory && !*memory) ret = kIOReturnBadArgument;
329 }
330
331
332 return (ret);
333}
334
335kern_return_t
336IOBufferMemoryDescriptor::SetLength(
337 uint64_t length,
338 OSDispatchMethod supermethod)
339{
340 kern_return_t ret;
341 union
342 {
343 IOBufferMemoryDescriptor_SetLength_Msg msg;
344 struct
345 {
346 IOBufferMemoryDescriptor_SetLength_Rpl rpl;
347 mach_msg_max_trailer_t trailer;
348 } rpl;
349 } buf;
350 struct IOBufferMemoryDescriptor_SetLength_Msg * msg = &buf.msg;
351 struct IOBufferMemoryDescriptor_SetLength_Rpl * rpl = &buf.rpl.rpl;
352
353 memset(s: msg, c: 0, n: sizeof(struct IOBufferMemoryDescriptor_SetLength_Msg));
354 msg->mach.msgh.msgh_id = kIORPCVersion190615;
355 msg->mach.msgh.msgh_size = sizeof(*msg);
356 msg->content.__hdr.flags = 0*kIORPCMessageOneway
357 | 1*kIORPCMessageSimpleReply
358 | 0*kIORPCMessageLocalHost
359 | 0*kIORPCMessageOnqueue;
360 msg->content.__hdr.msgid = IOBufferMemoryDescriptor_SetLength_ID;
361 msg->content.__object = (OSObjectRef) this;
362 msg->content.__hdr.objectRefs = IOBufferMemoryDescriptor_SetLength_Msg_ObjRefs;
363 msg->mach.msgh_body.msgh_descriptor_count = 1;
364
365 msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
366
367 msg->content.length = length;
368
369 IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) };
370 if (supermethod) ret = supermethod((OSObject *)this, rpc);
371 else ret = ((OSObject *)this)->Invoke(rpc);
372
373 if (kIOReturnSuccess == ret)
374 do {
375 {
376 if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; };
377 if (rpl->content.__hdr.msgid != IOBufferMemoryDescriptor_SetLength_ID) { ret = kIOReturnIPCError; break; };
378 if (rpl->mach.msgh_body.msgh_descriptor_count != 0) { ret = kIOReturnIPCError; break; };
379 if (IOBufferMemoryDescriptor_SetLength_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; };
380 }
381 }
382 while (false);
383 if (kIOReturnSuccess == ret)
384 {
385 }
386
387
388 return (ret);
389}
390
391kern_return_t
392IOBufferMemoryDescriptor::Create_Invoke(const IORPC _rpc,
393 Create_Handler func)
394{
395 IOBufferMemoryDescriptor_Create_Invocation rpc = { .rpc: _rpc };
396 kern_return_t ret;
397
398 if (1 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError);
399 if (IOBufferMemoryDescriptor_Create_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError);
400 if (rpc.message != NULL && rpc.sendSize < sizeof(IOBufferMemoryDescriptor_Create_Msg)) return (kIOReturnIPCError);
401 if (rpc.reply != NULL && rpc.replySize < sizeof(IOBufferMemoryDescriptor_Create_Rpl)) return (kIOReturnIPCError);
402
403 ret = (*func)( rpc.message->content.options,
404 rpc.message->content.capacity,
405 rpc.message->content.alignment,
406 (IOBufferMemoryDescriptor **)&rpc.reply->content.memory);
407
408 if (kIOReturnSuccess != ret) return (ret);
409
410 rpc.reply->content.__hdr.msgid = IOBufferMemoryDescriptor_Create_ID;
411 rpc.reply->content.__hdr.flags = kIORPCMessageOneway;
412 rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply;
413 rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply);
414 rpc.reply->mach.msgh_body.msgh_descriptor_count = 1;
415 rpc.reply->content.__hdr.objectRefs = IOBufferMemoryDescriptor_Create_Rpl_ObjRefs;
416 rpc.reply->memory__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
417
418 return (ret);
419}
420
421kern_return_t
422IOBufferMemoryDescriptor::SetLength_Invoke(const IORPC _rpc,
423 OSMetaClassBase * target,
424 SetLength_Handler func)
425{
426 IOBufferMemoryDescriptor_SetLength_Invocation rpc = { .rpc: _rpc };
427 kern_return_t ret;
428
429 if (1 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError);
430 if (IOBufferMemoryDescriptor_SetLength_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError);
431 if (rpc.message != NULL && rpc.sendSize < sizeof(IOBufferMemoryDescriptor_SetLength_Msg)) return (kIOReturnIPCError);
432 if (rpc.reply != NULL && rpc.replySize < sizeof(IOBufferMemoryDescriptor_SetLength_Rpl)) return (kIOReturnIPCError);
433
434 ret = (*func)(target,
435 rpc.message->content.length);
436
437 if (kIOReturnSuccess != ret) return (ret);
438
439 rpc.reply->content.__hdr.msgid = IOBufferMemoryDescriptor_SetLength_ID;
440 rpc.reply->content.__hdr.flags = kIORPCMessageOneway;
441 rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply;
442 rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply);
443 rpc.reply->mach.msgh_body.msgh_descriptor_count = 0;
444 rpc.reply->content.__hdr.objectRefs = IOBufferMemoryDescriptor_SetLength_Rpl_ObjRefs;
445
446 return (ret);
447}
448
449
450
451