1/* iig(DriverKit-286 Mar 29 2024 10:27:09) generated from IODMACommand.iig */
2
3#undef IIG_IMPLEMENTATION
4#define IIG_IMPLEMENTATION IODMACommand.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/IODMACommand.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 IODMACommand_Create_Msg_Content
23{
24 IORPCMessage __hdr;
25 OSObjectRef __object;
26 OSObjectRef device;
27 uint64_t options;
28 IODMACommandSpecification specification;
29};
30#pragma pack(4)
31struct IODMACommand_Create_Msg
32{
33 IORPCMessageMach mach;
34 mach_msg_port_descriptor_t __object__descriptor;
35 mach_msg_port_descriptor_t device__descriptor;
36 IODMACommand_Create_Msg_Content content;
37};
38#pragma pack()
39#define IODMACommand_Create_Msg_ObjRefs (2)
40
41struct IODMACommand_Create_Rpl_Content
42{
43 IORPCMessage __hdr;
44 OSObjectRef command;
45};
46#pragma pack(4)
47struct IODMACommand_Create_Rpl
48{
49 IORPCMessageMach mach;
50 mach_msg_port_descriptor_t command__descriptor;
51 IODMACommand_Create_Rpl_Content content;
52};
53#pragma pack()
54#define IODMACommand_Create_Rpl_ObjRefs (1)
55
56
57typedef union
58{
59 const IORPC rpc;
60 struct
61 {
62 const struct IODMACommand_Create_Msg * message;
63 struct IODMACommand_Create_Rpl * reply;
64 uint32_t sendSize;
65 uint32_t replySize;
66 };
67}
68IODMACommand_Create_Invocation;
69struct IODMACommand_PrepareForDMA_Msg_Content
70{
71 IORPCMessage __hdr;
72 OSObjectRef __object;
73 OSObjectRef memory;
74 uint64_t options;
75 uint64_t offset;
76 uint64_t length;
77 unsigned int segmentsCount;
78};
79#pragma pack(4)
80struct IODMACommand_PrepareForDMA_Msg
81{
82 IORPCMessageMach mach;
83 mach_msg_port_descriptor_t __object__descriptor;
84 mach_msg_port_descriptor_t memory__descriptor;
85 IODMACommand_PrepareForDMA_Msg_Content content;
86};
87#pragma pack()
88#define IODMACommand_PrepareForDMA_Msg_ObjRefs (2)
89
90struct IODMACommand_PrepareForDMA_Rpl_Content
91{
92 IORPCMessage __hdr;
93 unsigned long long flags;
94 unsigned int segmentsCount;
95 IOAddressSegment * segments;
96#if !defined(__LP64__)
97 uint32_t __segmentsPad;
98#endif /* !defined(__LP64__) */
99 IOAddressSegment __segments[32];
100};
101#pragma pack(4)
102struct IODMACommand_PrepareForDMA_Rpl
103{
104 IORPCMessageMach mach;
105 IODMACommand_PrepareForDMA_Rpl_Content content;
106};
107#pragma pack()
108#define IODMACommand_PrepareForDMA_Rpl_ObjRefs (0)
109
110
111typedef union
112{
113 const IORPC rpc;
114 struct
115 {
116 const struct IODMACommand_PrepareForDMA_Msg * message;
117 struct IODMACommand_PrepareForDMA_Rpl * reply;
118 uint32_t sendSize;
119 uint32_t replySize;
120 };
121}
122IODMACommand_PrepareForDMA_Invocation;
123struct IODMACommand_CompleteDMA_Msg_Content
124{
125 IORPCMessage __hdr;
126 OSObjectRef __object;
127 uint64_t options;
128};
129#pragma pack(4)
130struct IODMACommand_CompleteDMA_Msg
131{
132 IORPCMessageMach mach;
133 mach_msg_port_descriptor_t __object__descriptor;
134 IODMACommand_CompleteDMA_Msg_Content content;
135};
136#pragma pack()
137#define IODMACommand_CompleteDMA_Msg_ObjRefs (1)
138
139struct IODMACommand_CompleteDMA_Rpl_Content
140{
141 IORPCMessage __hdr;
142};
143#pragma pack(4)
144struct IODMACommand_CompleteDMA_Rpl
145{
146 IORPCMessageMach mach;
147 IODMACommand_CompleteDMA_Rpl_Content content;
148};
149#pragma pack()
150#define IODMACommand_CompleteDMA_Rpl_ObjRefs (0)
151
152
153typedef union
154{
155 const IORPC rpc;
156 struct
157 {
158 const struct IODMACommand_CompleteDMA_Msg * message;
159 struct IODMACommand_CompleteDMA_Rpl * reply;
160 uint32_t sendSize;
161 uint32_t replySize;
162 };
163}
164IODMACommand_CompleteDMA_Invocation;
165struct IODMACommand_GetPreparation_Msg_Content
166{
167 IORPCMessage __hdr;
168 OSObjectRef __object;
169};
170#pragma pack(4)
171struct IODMACommand_GetPreparation_Msg
172{
173 IORPCMessageMach mach;
174 mach_msg_port_descriptor_t __object__descriptor;
175 IODMACommand_GetPreparation_Msg_Content content;
176};
177#pragma pack()
178#define IODMACommand_GetPreparation_Msg_ObjRefs (1)
179
180struct IODMACommand_GetPreparation_Rpl_Content
181{
182 IORPCMessage __hdr;
183 OSObjectRef memory;
184 unsigned long long offset;
185 unsigned long long length;
186};
187#pragma pack(4)
188struct IODMACommand_GetPreparation_Rpl
189{
190 IORPCMessageMach mach;
191 mach_msg_port_descriptor_t memory__descriptor;
192 IODMACommand_GetPreparation_Rpl_Content content;
193};
194#pragma pack()
195#define IODMACommand_GetPreparation_Rpl_ObjRefs (1)
196
197
198typedef union
199{
200 const IORPC rpc;
201 struct
202 {
203 const struct IODMACommand_GetPreparation_Msg * message;
204 struct IODMACommand_GetPreparation_Rpl * reply;
205 uint32_t sendSize;
206 uint32_t replySize;
207 };
208}
209IODMACommand_GetPreparation_Invocation;
210struct IODMACommand_PerformOperation_Msg_Content
211{
212 IORPCMessage __hdr;
213 OSObjectRef __object;
214 OSObjectRef data;
215 uint64_t options;
216 uint64_t dmaOffset;
217 uint64_t length;
218 uint64_t dataOffset;
219};
220#pragma pack(4)
221struct IODMACommand_PerformOperation_Msg
222{
223 IORPCMessageMach mach;
224 mach_msg_port_descriptor_t __object__descriptor;
225 mach_msg_port_descriptor_t data__descriptor;
226 IODMACommand_PerformOperation_Msg_Content content;
227};
228#pragma pack()
229#define IODMACommand_PerformOperation_Msg_ObjRefs (2)
230
231struct IODMACommand_PerformOperation_Rpl_Content
232{
233 IORPCMessage __hdr;
234};
235#pragma pack(4)
236struct IODMACommand_PerformOperation_Rpl
237{
238 IORPCMessageMach mach;
239 IODMACommand_PerformOperation_Rpl_Content content;
240};
241#pragma pack()
242#define IODMACommand_PerformOperation_Rpl_ObjRefs (0)
243
244
245typedef union
246{
247 const IORPC rpc;
248 struct
249 {
250 const struct IODMACommand_PerformOperation_Msg * message;
251 struct IODMACommand_PerformOperation_Rpl * reply;
252 uint32_t sendSize;
253 uint32_t replySize;
254 };
255}
256IODMACommand_PerformOperation_Invocation;
257#if !KERNEL
258extern OSMetaClass * gOSContainerMetaClass;
259extern OSMetaClass * gOSDataMetaClass;
260extern OSMetaClass * gOSNumberMetaClass;
261extern OSMetaClass * gOSStringMetaClass;
262extern OSMetaClass * gOSBooleanMetaClass;
263extern OSMetaClass * gOSDictionaryMetaClass;
264extern OSMetaClass * gOSArrayMetaClass;
265extern OSMetaClass * gOSSetMetaClass;
266extern OSMetaClass * gOSOrderedSetMetaClass;
267extern OSMetaClass * gIODispatchQueueMetaClass;
268extern OSMetaClass * gIOMemoryMapMetaClass;
269extern OSMetaClass * gIOBufferMemoryDescriptorMetaClass;
270extern OSMetaClass * gIOUserClientMetaClass;
271extern OSMetaClass * gOSActionMetaClass;
272extern OSMetaClass * gIOServiceStateNotificationDispatchSourceMetaClass;
273#endif /* !KERNEL */
274
275#if !KERNEL
276
277#define IODMACommand_QueueNames ""
278
279#define IODMACommand_MethodNames ""
280
281#define IODMACommandMetaClass_MethodNames ""
282
283struct OSClassDescription_IODMACommand_t
284{
285 OSClassDescription base;
286 uint64_t methodOptions[2 * 0];
287 uint64_t metaMethodOptions[2 * 0];
288 char queueNames[sizeof(IODMACommand_QueueNames)];
289 char methodNames[sizeof(IODMACommand_MethodNames)];
290 char metaMethodNames[sizeof(IODMACommandMetaClass_MethodNames)];
291};
292
293const struct OSClassDescription_IODMACommand_t
294OSClassDescription_IODMACommand =
295{
296 .base =
297 {
298 .descriptionSize = sizeof(OSClassDescription_IODMACommand_t),
299 .name = "IODMACommand",
300 .superName = "OSObject",
301 .methodOptionsSize = 2 * sizeof(uint64_t) * 0,
302 .methodOptionsOffset = __builtin_offsetof(struct OSClassDescription_IODMACommand_t, methodOptions),
303 .metaMethodOptionsSize = 2 * sizeof(uint64_t) * 0,
304 .metaMethodOptionsOffset = __builtin_offsetof(struct OSClassDescription_IODMACommand_t, metaMethodOptions),
305 .queueNamesSize = sizeof(IODMACommand_QueueNames),
306 .queueNamesOffset = __builtin_offsetof(struct OSClassDescription_IODMACommand_t, queueNames),
307 .methodNamesSize = sizeof(IODMACommand_MethodNames),
308 .methodNamesOffset = __builtin_offsetof(struct OSClassDescription_IODMACommand_t, methodNames),
309 .metaMethodNamesSize = sizeof(IODMACommandMetaClass_MethodNames),
310 .metaMethodNamesOffset = __builtin_offsetof(struct OSClassDescription_IODMACommand_t, metaMethodNames),
311 .flags = 1*kOSClassCanRemote,
312 },
313 .methodOptions =
314 {
315 },
316 .metaMethodOptions =
317 {
318 },
319 .queueNames = IODMACommand_QueueNames,
320 .methodNames = IODMACommand_MethodNames,
321 .metaMethodNames = IODMACommandMetaClass_MethodNames,
322};
323
324OSMetaClass * gIODMACommandMetaClass;
325
326static kern_return_t
327IODMACommand_New(OSMetaClass * instance);
328
329const OSClassLoadInformation
330IODMACommand_Class =
331{
332 .description = &OSClassDescription_IODMACommand.base,
333 .metaPointer = &gIODMACommandMetaClass,
334 .version = 1,
335 .instanceSize = sizeof(IODMACommand),
336
337 .New = &IODMACommand_New,
338};
339
340extern const void * const
341gIODMACommand_Declaration;
342const void * const
343gIODMACommand_Declaration
344__attribute__((visibility("hidden"),section("__DATA_CONST,__osclassinfo,regular,no_dead_strip"),no_sanitize("address")))
345 = &IODMACommand_Class;
346
347static kern_return_t
348IODMACommand_New(OSMetaClass * instance)
349{
350 if (!new(instance) IODMACommandMetaClass) return (kIOReturnNoMemory);
351 return (kIOReturnSuccess);
352}
353
354kern_return_t
355IODMACommandMetaClass::New(OSObject * instance)
356{
357 if (!new(instance) IODMACommand) return (kIOReturnNoMemory);
358 return (kIOReturnSuccess);
359}
360
361#endif /* !KERNEL */
362
363kern_return_t
364IODMACommand::Dispatch(const IORPC rpc)
365{
366 return _Dispatch(self: this, rpc);
367}
368
369kern_return_t
370IODMACommand::_Dispatch(IODMACommand * self, const IORPC rpc)
371{
372 kern_return_t ret = kIOReturnUnsupported;
373 IORPCMessage * msg = IORPCMessageFromMach(msg: rpc.message, reply: false);
374
375 switch (msg->msgid)
376 {
377#if KERNEL
378 case IODMACommand_PrepareForDMA_ID:
379 {
380 ret = IODMACommand::PrepareForDMA_Invoke(rpc, target: self, SimpleMemberFunctionCast(IODMACommand::PrepareForDMA_Handler, *self, &IODMACommand::PrepareForDMA_Impl));
381 break;
382 }
383#endif /* !KERNEL */
384#if KERNEL
385 case IODMACommand_CompleteDMA_ID:
386 {
387 ret = IODMACommand::CompleteDMA_Invoke(rpc, target: self, SimpleMemberFunctionCast(IODMACommand::CompleteDMA_Handler, *self, &IODMACommand::CompleteDMA_Impl));
388 break;
389 }
390#endif /* !KERNEL */
391#if KERNEL
392 case IODMACommand_GetPreparation_ID:
393 {
394 ret = IODMACommand::GetPreparation_Invoke(rpc, target: self, SimpleMemberFunctionCast(IODMACommand::GetPreparation_Handler, *self, &IODMACommand::GetPreparation_Impl));
395 break;
396 }
397#endif /* !KERNEL */
398#if KERNEL
399 case IODMACommand_PerformOperation_ID:
400 {
401 ret = IODMACommand::PerformOperation_Invoke(rpc, target: self, SimpleMemberFunctionCast(IODMACommand::PerformOperation_Handler, *self, &IODMACommand::PerformOperation_Impl));
402 break;
403 }
404#endif /* !KERNEL */
405
406 default:
407 ret = OSObject::_Dispatch(self, rpc);
408 break;
409 }
410
411 return (ret);
412}
413
414#if KERNEL
415kern_return_t
416IODMACommand::MetaClass::Dispatch(const IORPC rpc)
417{
418#else /* KERNEL */
419kern_return_t
420IODMACommandMetaClass::Dispatch(const IORPC rpc)
421{
422#endif /* !KERNEL */
423
424 kern_return_t ret = kIOReturnUnsupported;
425 IORPCMessage * msg = IORPCMessageFromMach(msg: rpc.message, reply: false);
426
427 switch (msg->msgid)
428 {
429#if KERNEL
430 case IODMACommand_Create_ID:
431 ret = IODMACommand::Create_Invoke(rpc, func: &IODMACommand::Create_Impl);
432 break;
433#endif /* !KERNEL */
434
435 default:
436 ret = OSMetaClassBase::Dispatch(rpc);
437 break;
438 }
439
440 return (ret);
441}
442
443kern_return_t
444IODMACommand::Create(
445 IOService * device,
446 uint64_t options,
447 const IODMACommandSpecification * specification,
448 IODMACommand ** command)
449{
450 kern_return_t ret;
451 union
452 {
453 IODMACommand_Create_Msg msg;
454 struct
455 {
456 IODMACommand_Create_Rpl rpl;
457 mach_msg_max_trailer_t trailer;
458 } rpl;
459 } buf;
460 struct IODMACommand_Create_Msg * msg = &buf.msg;
461 struct IODMACommand_Create_Rpl * rpl = &buf.rpl.rpl;
462
463 memset(s: msg, c: 0, n: sizeof(struct IODMACommand_Create_Msg));
464 msg->mach.msgh.msgh_id = kIORPCVersion190615;
465 msg->mach.msgh.msgh_size = sizeof(*msg);
466 msg->content.__hdr.flags = 0*kIORPCMessageOneway
467 | 0*kIORPCMessageSimpleReply
468 | 0*kIORPCMessageLocalHost
469 | 0*kIORPCMessageOnqueue;
470 msg->content.__hdr.msgid = IODMACommand_Create_ID;
471 msg->content.__object = (OSObjectRef) OSTypeID(IODMACommand);
472 msg->content.__hdr.objectRefs = IODMACommand_Create_Msg_ObjRefs;
473 msg->mach.msgh_body.msgh_descriptor_count = 2;
474
475 msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
476
477 msg->device__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
478 msg->content.device = (OSObjectRef) device;
479
480 msg->content.options = options;
481
482 msg->content.specification = *specification;
483
484 IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) };
485 ret = OSMTypeID(IODMACommand)->Invoke(rpc);
486
487 if (kIOReturnSuccess == ret)
488 do {
489 {
490 if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; };
491 if (rpl->content.__hdr.msgid != IODMACommand_Create_ID) { ret = kIOReturnIPCError; break; };
492 if (rpl->mach.msgh_body.msgh_descriptor_count != 1) { ret = kIOReturnIPCError; break; };
493 if (IODMACommand_Create_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; };
494 }
495 }
496 while (false);
497 if (kIOReturnSuccess == ret)
498 {
499 *command = OSDynamicCast(IODMACommand, (OSObject *) rpl->content.command);
500 if (rpl->content.command && !*command) ret = kIOReturnBadArgument;
501 }
502
503
504 return (ret);
505}
506
507kern_return_t
508IODMACommand::PrepareForDMA(
509 uint64_t options,
510 IOMemoryDescriptor * memory,
511 uint64_t offset,
512 uint64_t length,
513 uint64_t * flags,
514 uint32_t * segmentsCount,
515 IOAddressSegment * segments,
516 OSDispatchMethod supermethod)
517{
518 kern_return_t ret;
519 union
520 {
521 IODMACommand_PrepareForDMA_Msg msg;
522 struct
523 {
524 IODMACommand_PrepareForDMA_Rpl rpl;
525 mach_msg_max_trailer_t trailer;
526 } rpl;
527 } buf;
528 struct IODMACommand_PrepareForDMA_Msg * msg = &buf.msg;
529 struct IODMACommand_PrepareForDMA_Rpl * rpl = &buf.rpl.rpl;
530
531 memset(s: msg, c: 0, n: sizeof(struct IODMACommand_PrepareForDMA_Msg));
532 msg->mach.msgh.msgh_id = kIORPCVersion190615;
533 msg->mach.msgh.msgh_size = sizeof(*msg);
534 msg->content.__hdr.flags = 0*kIORPCMessageOneway
535 | 1*kIORPCMessageSimpleReply
536 | 0*kIORPCMessageLocalHost
537 | 0*kIORPCMessageOnqueue;
538 msg->content.__hdr.msgid = IODMACommand_PrepareForDMA_ID;
539 msg->content.__object = (OSObjectRef) this;
540 msg->content.__hdr.objectRefs = IODMACommand_PrepareForDMA_Msg_ObjRefs;
541 msg->mach.msgh_body.msgh_descriptor_count = 2;
542
543 msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
544
545 msg->content.options = options;
546
547 msg->memory__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
548 msg->content.memory = (OSObjectRef) memory;
549
550 msg->content.offset = offset;
551
552 msg->content.length = length;
553
554 if (*segmentsCount > (sizeof(rpl->content.__segments) / sizeof(rpl->content.__segments[0]))) return kIOReturnOverrun;
555 msg->content.segmentsCount = *segmentsCount;
556
557 IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) };
558 if (supermethod) ret = supermethod((OSObject *)this, rpc);
559 else ret = ((OSObject *)this)->Invoke(rpc);
560
561 if (kIOReturnSuccess == ret)
562 do {
563 {
564 if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; };
565 if (rpl->content.__hdr.msgid != IODMACommand_PrepareForDMA_ID) { ret = kIOReturnIPCError; break; };
566 if (rpl->mach.msgh_body.msgh_descriptor_count != 0) { ret = kIOReturnIPCError; break; };
567 if (IODMACommand_PrepareForDMA_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; };
568 }
569 }
570 while (false);
571 if (kIOReturnSuccess == ret)
572 {
573 if (flags) *flags = rpl->content.flags;
574 if (rpl->content.segmentsCount < *segmentsCount) *segmentsCount = rpl->content.segmentsCount;
575 bcopy(src: &rpl->content.__segments[0], dst: segments, n: *segmentsCount * sizeof(rpl->content.__segments[0]));
576 }
577
578
579 return (ret);
580}
581
582kern_return_t
583IODMACommand::CompleteDMA(
584 uint64_t options,
585 OSDispatchMethod supermethod)
586{
587 kern_return_t ret;
588 union
589 {
590 IODMACommand_CompleteDMA_Msg msg;
591 struct
592 {
593 IODMACommand_CompleteDMA_Rpl rpl;
594 mach_msg_max_trailer_t trailer;
595 } rpl;
596 } buf;
597 struct IODMACommand_CompleteDMA_Msg * msg = &buf.msg;
598 struct IODMACommand_CompleteDMA_Rpl * rpl = &buf.rpl.rpl;
599
600 memset(s: msg, c: 0, n: sizeof(struct IODMACommand_CompleteDMA_Msg));
601 msg->mach.msgh.msgh_id = kIORPCVersion190615;
602 msg->mach.msgh.msgh_size = sizeof(*msg);
603 msg->content.__hdr.flags = 0*kIORPCMessageOneway
604 | 1*kIORPCMessageSimpleReply
605 | 0*kIORPCMessageLocalHost
606 | 0*kIORPCMessageOnqueue;
607 msg->content.__hdr.msgid = IODMACommand_CompleteDMA_ID;
608 msg->content.__object = (OSObjectRef) this;
609 msg->content.__hdr.objectRefs = IODMACommand_CompleteDMA_Msg_ObjRefs;
610 msg->mach.msgh_body.msgh_descriptor_count = 1;
611
612 msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
613
614 msg->content.options = options;
615
616 IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) };
617 if (supermethod) ret = supermethod((OSObject *)this, rpc);
618 else ret = ((OSObject *)this)->Invoke(rpc);
619
620 if (kIOReturnSuccess == ret)
621 do {
622 {
623 if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; };
624 if (rpl->content.__hdr.msgid != IODMACommand_CompleteDMA_ID) { ret = kIOReturnIPCError; break; };
625 if (rpl->mach.msgh_body.msgh_descriptor_count != 0) { ret = kIOReturnIPCError; break; };
626 if (IODMACommand_CompleteDMA_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; };
627 }
628 }
629 while (false);
630 if (kIOReturnSuccess == ret)
631 {
632 }
633
634
635 return (ret);
636}
637
638kern_return_t
639IODMACommand::GetPreparation(
640 uint64_t * offset,
641 uint64_t * length,
642 IOMemoryDescriptor ** memory,
643 OSDispatchMethod supermethod)
644{
645 kern_return_t ret;
646 union
647 {
648 IODMACommand_GetPreparation_Msg msg;
649 struct
650 {
651 IODMACommand_GetPreparation_Rpl rpl;
652 mach_msg_max_trailer_t trailer;
653 } rpl;
654 } buf;
655 struct IODMACommand_GetPreparation_Msg * msg = &buf.msg;
656 struct IODMACommand_GetPreparation_Rpl * rpl = &buf.rpl.rpl;
657
658 memset(s: msg, c: 0, n: sizeof(struct IODMACommand_GetPreparation_Msg));
659 msg->mach.msgh.msgh_id = kIORPCVersion190615;
660 msg->mach.msgh.msgh_size = sizeof(*msg);
661 msg->content.__hdr.flags = 0*kIORPCMessageOneway
662 | 0*kIORPCMessageSimpleReply
663 | 0*kIORPCMessageLocalHost
664 | 0*kIORPCMessageOnqueue;
665 msg->content.__hdr.msgid = IODMACommand_GetPreparation_ID;
666 msg->content.__object = (OSObjectRef) this;
667 msg->content.__hdr.objectRefs = IODMACommand_GetPreparation_Msg_ObjRefs;
668 msg->mach.msgh_body.msgh_descriptor_count = 1;
669
670 msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
671
672 IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) };
673 if (supermethod) ret = supermethod((OSObject *)this, rpc);
674 else ret = ((OSObject *)this)->Invoke(rpc);
675
676 if (kIOReturnSuccess == ret)
677 do {
678 {
679 if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; };
680 if (rpl->content.__hdr.msgid != IODMACommand_GetPreparation_ID) { ret = kIOReturnIPCError; break; };
681 if (rpl->mach.msgh_body.msgh_descriptor_count != 1) { ret = kIOReturnIPCError; break; };
682 if (IODMACommand_GetPreparation_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; };
683 }
684 }
685 while (false);
686 if (kIOReturnSuccess == ret)
687 {
688 if (offset) *offset = rpl->content.offset;
689 if (length) *length = rpl->content.length;
690 *memory = OSDynamicCast(IOMemoryDescriptor, (OSObject *) rpl->content.memory);
691 if (rpl->content.memory && !*memory) ret = kIOReturnBadArgument;
692 }
693
694
695 return (ret);
696}
697
698kern_return_t
699IODMACommand::PerformOperation(
700 uint64_t options,
701 uint64_t dmaOffset,
702 uint64_t length,
703 uint64_t dataOffset,
704 IOMemoryDescriptor * data,
705 OSDispatchMethod supermethod)
706{
707 kern_return_t ret;
708 union
709 {
710 IODMACommand_PerformOperation_Msg msg;
711 struct
712 {
713 IODMACommand_PerformOperation_Rpl rpl;
714 mach_msg_max_trailer_t trailer;
715 } rpl;
716 } buf;
717 struct IODMACommand_PerformOperation_Msg * msg = &buf.msg;
718 struct IODMACommand_PerformOperation_Rpl * rpl = &buf.rpl.rpl;
719
720 memset(s: msg, c: 0, n: sizeof(struct IODMACommand_PerformOperation_Msg));
721 msg->mach.msgh.msgh_id = kIORPCVersion190615;
722 msg->mach.msgh.msgh_size = sizeof(*msg);
723 msg->content.__hdr.flags = 0*kIORPCMessageOneway
724 | 1*kIORPCMessageSimpleReply
725 | 0*kIORPCMessageLocalHost
726 | 0*kIORPCMessageOnqueue;
727 msg->content.__hdr.msgid = IODMACommand_PerformOperation_ID;
728 msg->content.__object = (OSObjectRef) this;
729 msg->content.__hdr.objectRefs = IODMACommand_PerformOperation_Msg_ObjRefs;
730 msg->mach.msgh_body.msgh_descriptor_count = 2;
731
732 msg->__object__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
733
734 msg->content.options = options;
735
736 msg->content.dmaOffset = dmaOffset;
737
738 msg->content.length = length;
739
740 msg->content.dataOffset = dataOffset;
741
742 msg->data__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
743 msg->content.data = (OSObjectRef) data;
744
745 IORPC rpc = { .message = &buf.msg.mach, .reply = &buf.rpl.rpl.mach, .sendSize = sizeof(buf.msg), .replySize = sizeof(buf.rpl) };
746 if (supermethod) ret = supermethod((OSObject *)this, rpc);
747 else ret = ((OSObject *)this)->Invoke(rpc);
748
749 if (kIOReturnSuccess == ret)
750 do {
751 {
752 if (rpl->mach.msgh.msgh_size != sizeof(*rpl)) { ret = kIOReturnIPCError; break; };
753 if (rpl->content.__hdr.msgid != IODMACommand_PerformOperation_ID) { ret = kIOReturnIPCError; break; };
754 if (rpl->mach.msgh_body.msgh_descriptor_count != 0) { ret = kIOReturnIPCError; break; };
755 if (IODMACommand_PerformOperation_Rpl_ObjRefs != rpl->content.__hdr.objectRefs) { ret = kIOReturnIPCError; break; };
756 }
757 }
758 while (false);
759 if (kIOReturnSuccess == ret)
760 {
761 }
762
763
764 return (ret);
765}
766
767kern_return_t
768IODMACommand::Create_Invoke(const IORPC _rpc,
769 Create_Handler func)
770{
771 IODMACommand_Create_Invocation rpc = { .rpc: _rpc };
772 kern_return_t ret;
773 IOService * device;
774
775 if (2 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError);
776 if (IODMACommand_Create_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError);
777 if (rpc.message != NULL && rpc.sendSize < sizeof(IODMACommand_Create_Msg)) return (kIOReturnIPCError);
778 if (rpc.reply != NULL && rpc.replySize < sizeof(IODMACommand_Create_Rpl)) return (kIOReturnIPCError);
779 device = OSDynamicCast(IOService, (OSObject *) rpc.message->content.device);
780 if (!device && rpc.message->content.device) return (kIOReturnBadArgument);
781
782 ret = (*func)( device,
783 rpc.message->content.options,
784 &rpc.message->content.specification,
785 (IODMACommand **)&rpc.reply->content.command);
786
787 if (kIOReturnSuccess != ret) return (ret);
788
789 rpc.reply->content.__hdr.msgid = IODMACommand_Create_ID;
790 rpc.reply->content.__hdr.flags = kIORPCMessageOneway;
791 rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply;
792 rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply);
793 rpc.reply->mach.msgh_body.msgh_descriptor_count = 1;
794 rpc.reply->content.__hdr.objectRefs = IODMACommand_Create_Rpl_ObjRefs;
795 rpc.reply->command__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
796
797 return (ret);
798}
799
800kern_return_t
801IODMACommand::PrepareForDMA_Invoke(const IORPC _rpc,
802 OSMetaClassBase * target,
803 PrepareForDMA_Handler func)
804{
805 IODMACommand_PrepareForDMA_Invocation rpc = { .rpc: _rpc };
806 kern_return_t ret;
807 IOMemoryDescriptor * memory;
808 unsigned int segmentsCount = (sizeof(rpc.reply->content.__segments) / sizeof(rpc.reply->content.__segments[0]));
809 if (segmentsCount > rpc.message->content.segmentsCount) segmentsCount = rpc.message->content.segmentsCount;
810
811 if (2 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError);
812 if (IODMACommand_PrepareForDMA_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError);
813 if (rpc.message != NULL && rpc.sendSize < sizeof(IODMACommand_PrepareForDMA_Msg)) return (kIOReturnIPCError);
814 if (rpc.reply != NULL && rpc.replySize < sizeof(IODMACommand_PrepareForDMA_Rpl)) return (kIOReturnIPCError);
815 memory = OSDynamicCast(IOMemoryDescriptor, (OSObject *) rpc.message->content.memory);
816 if (!memory && rpc.message->content.memory) return (kIOReturnBadArgument);
817
818 ret = (*func)(target,
819 rpc.message->content.options,
820 memory,
821 rpc.message->content.offset,
822 rpc.message->content.length,
823 &rpc.reply->content.flags,
824 &segmentsCount,
825 &rpc.reply->content.__segments[0]);
826
827 if (kIOReturnSuccess != ret) return (ret);
828
829 rpc.reply->content.__hdr.msgid = IODMACommand_PrepareForDMA_ID;
830 rpc.reply->content.__hdr.flags = kIORPCMessageOneway;
831 rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply;
832 rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply);
833 rpc.reply->mach.msgh_body.msgh_descriptor_count = 0;
834 rpc.reply->content.__hdr.objectRefs = IODMACommand_PrepareForDMA_Rpl_ObjRefs;
835 rpc.reply->content.segmentsCount = segmentsCount;
836
837 return (ret);
838}
839
840kern_return_t
841IODMACommand::CompleteDMA_Invoke(const IORPC _rpc,
842 OSMetaClassBase * target,
843 CompleteDMA_Handler func)
844{
845 IODMACommand_CompleteDMA_Invocation rpc = { .rpc: _rpc };
846 kern_return_t ret;
847
848 if (1 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError);
849 if (IODMACommand_CompleteDMA_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError);
850 if (rpc.message != NULL && rpc.sendSize < sizeof(IODMACommand_CompleteDMA_Msg)) return (kIOReturnIPCError);
851 if (rpc.reply != NULL && rpc.replySize < sizeof(IODMACommand_CompleteDMA_Rpl)) return (kIOReturnIPCError);
852
853 ret = (*func)(target,
854 rpc.message->content.options);
855
856 if (kIOReturnSuccess != ret) return (ret);
857
858 rpc.reply->content.__hdr.msgid = IODMACommand_CompleteDMA_ID;
859 rpc.reply->content.__hdr.flags = kIORPCMessageOneway;
860 rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply;
861 rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply);
862 rpc.reply->mach.msgh_body.msgh_descriptor_count = 0;
863 rpc.reply->content.__hdr.objectRefs = IODMACommand_CompleteDMA_Rpl_ObjRefs;
864
865 return (ret);
866}
867
868kern_return_t
869IODMACommand::GetPreparation_Invoke(const IORPC _rpc,
870 OSMetaClassBase * target,
871 GetPreparation_Handler func)
872{
873 IODMACommand_GetPreparation_Invocation rpc = { .rpc: _rpc };
874 kern_return_t ret;
875
876 if (1 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError);
877 if (IODMACommand_GetPreparation_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError);
878 if (rpc.message != NULL && rpc.sendSize < sizeof(IODMACommand_GetPreparation_Msg)) return (kIOReturnIPCError);
879 if (rpc.reply != NULL && rpc.replySize < sizeof(IODMACommand_GetPreparation_Rpl)) return (kIOReturnIPCError);
880
881 ret = (*func)(target,
882 &rpc.reply->content.offset,
883 &rpc.reply->content.length,
884 (IOMemoryDescriptor **)&rpc.reply->content.memory);
885
886 if (kIOReturnSuccess != ret) return (ret);
887
888 rpc.reply->content.__hdr.msgid = IODMACommand_GetPreparation_ID;
889 rpc.reply->content.__hdr.flags = kIORPCMessageOneway;
890 rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply;
891 rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply);
892 rpc.reply->mach.msgh_body.msgh_descriptor_count = 1;
893 rpc.reply->content.__hdr.objectRefs = IODMACommand_GetPreparation_Rpl_ObjRefs;
894 rpc.reply->memory__descriptor.type = MACH_MSG_PORT_DESCRIPTOR;
895
896 return (ret);
897}
898
899kern_return_t
900IODMACommand::PerformOperation_Invoke(const IORPC _rpc,
901 OSMetaClassBase * target,
902 PerformOperation_Handler func)
903{
904 IODMACommand_PerformOperation_Invocation rpc = { .rpc: _rpc };
905 kern_return_t ret;
906 IOMemoryDescriptor * data;
907
908 if (2 != rpc.message->mach.msgh_body.msgh_descriptor_count) return (kIOReturnIPCError);
909 if (IODMACommand_PerformOperation_Msg_ObjRefs != rpc.message->content.__hdr.objectRefs) return (kIOReturnIPCError);
910 if (rpc.message != NULL && rpc.sendSize < sizeof(IODMACommand_PerformOperation_Msg)) return (kIOReturnIPCError);
911 if (rpc.reply != NULL && rpc.replySize < sizeof(IODMACommand_PerformOperation_Rpl)) return (kIOReturnIPCError);
912 data = OSDynamicCast(IOMemoryDescriptor, (OSObject *) rpc.message->content.data);
913 if (!data && rpc.message->content.data) return (kIOReturnBadArgument);
914
915 ret = (*func)(target,
916 rpc.message->content.options,
917 rpc.message->content.dmaOffset,
918 rpc.message->content.length,
919 rpc.message->content.dataOffset,
920 data);
921
922 if (kIOReturnSuccess != ret) return (ret);
923
924 rpc.reply->content.__hdr.msgid = IODMACommand_PerformOperation_ID;
925 rpc.reply->content.__hdr.flags = kIORPCMessageOneway;
926 rpc.reply->mach.msgh.msgh_id = kIORPCVersion190615Reply;
927 rpc.reply->mach.msgh.msgh_size = sizeof(*rpc.reply);
928 rpc.reply->mach.msgh_body.msgh_descriptor_count = 0;
929 rpc.reply->content.__hdr.objectRefs = IODMACommand_PerformOperation_Rpl_ObjRefs;
930
931 return (ret);
932}
933
934
935
936