]> git.saurik.com Git - apple/xnu.git/blob - iokit/DriverKit/IORPC.h
xnu-6153.11.26.tar.gz
[apple/xnu.git] / iokit / DriverKit / IORPC.h
1 /*
2 * Copyright (c) 2018 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28
29
30 #ifndef _IORPC_H
31 #define _IORPC_H
32
33 #include <stdint.h>
34
35 #ifndef PLATFORM_DriverKit
36
37 #include <mach/message.h>
38
39 #else /* !PLATFORM_DriverKit */
40
41 #ifndef _MACH_MESSAGE_H_
42 #define _MACH_MESSAGE_H_
43
44 #define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */
45 #define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send right(s) */
46 #define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce right */
47 #define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send right(s) */
48 #define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */
49 #define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive right */
50 #define MACH_MSG_TYPE_COPY_RECEIVE 22 /* NOT VALID */
51 #define MACH_MSG_TYPE_DISPOSE_RECEIVE 24 /* must hold receive right */
52 #define MACH_MSG_TYPE_DISPOSE_SEND 25 /* must hold send right(s) */
53 #define MACH_MSG_TYPE_DISPOSE_SEND_ONCE 26 /* must hold sendonce right */
54
55 #define MACH_MSG_TYPE_PORT_NONE 0
56
57 #define MACH_MSG_PORT_DESCRIPTOR 0
58 #define MACH_MSG_OOL_DESCRIPTOR 1
59
60 typedef unsigned int mach_msg_copy_options_t;
61
62 #define MACH_MSG_PHYSICAL_COPY 0
63 #define MACH_MSG_VIRTUAL_COPY 1
64 #define MACH_MSG_ALLOCATE 2
65
66 typedef uint32_t natural_t;
67 typedef int32_t integer_t;
68
69 typedef unsigned int mach_msg_type_name_t;
70 typedef unsigned int mach_msg_descriptor_type_t;
71
72 #if KERNEL
73 typedef void * mach_port_t;
74 #define MACH_PORT_NULL NULL
75 #else /* !KERNEL */
76 typedef natural_t mach_port_t;
77 #define MACH_PORT_NULL 0
78 #endif /* !KERNEL */
79
80 typedef natural_t mach_port_name_t;
81
82 typedef unsigned int mach_msg_bits_t;
83 typedef natural_t mach_msg_size_t;
84 typedef integer_t mach_msg_id_t;
85
86 #pragma pack(push, 4)
87
88 typedef struct{
89 mach_msg_bits_t msgh_bits;
90 mach_msg_size_t msgh_size;
91 mach_port_t msgh_remote_port;
92 mach_port_t msgh_local_port;
93 mach_port_name_t msgh_voucher_port;
94 mach_msg_id_t msgh_id;
95 } mach_msg_header_t;
96
97 typedef struct{
98 mach_msg_size_t msgh_descriptor_count;
99 } mach_msg_body_t;
100
101 typedef struct{
102 mach_port_t name;
103 #if !(defined(KERNEL) && defined(__LP64__))
104 // Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes
105 mach_msg_size_t pad1;
106 #endif
107 unsigned int pad2 : 16;
108 mach_msg_type_name_t disposition : 8;
109 mach_msg_descriptor_type_t type : 8;
110 #if defined(KERNEL)
111 uint32_t pad_end;
112 #endif
113 } mach_msg_port_descriptor_t;
114
115 typedef struct{
116 void * address;
117 #if !defined(__LP64__)
118 mach_msg_size_t size;
119 #endif
120 int deallocate: 8;
121 mach_msg_copy_options_t copy: 8;
122 unsigned int pad1: 8;
123 mach_msg_descriptor_type_t type: 8;
124 #if defined(__LP64__)
125 mach_msg_size_t size;
126 #endif
127 #if defined(KERNEL) && !defined(__LP64__)
128 uint32_t pad_end;
129 #endif
130 } mach_msg_ool_descriptor_t;
131
132 typedef struct{
133 unsigned int val[80 / sizeof(int)];
134 } mach_msg_max_trailer_t;
135
136 #pragma pack(pop)
137
138 #endif /* _MACH_MESSAGE_H_ */
139
140 #endif /* PLATFORM_DriverKit */
141
142 #if KERNEL
143 class IOUserServer;
144 #endif /* KERNEL */
145
146 typedef uint64_t OSObjectRef;
147
148 enum {
149 kIORPCVersion190615 = (mach_msg_id_t) 0x4da2b68c,
150 kIORPCVersion190615Reply = (mach_msg_id_t) 0x4da2b68d,
151
152 #if DRIVERKIT_PRIVATE
153 kIORPCVersion190501 = (mach_msg_id_t) 0xfe316a7a,
154 kIORPCVersion190501Reply = (mach_msg_id_t) 0xfe316a7b,
155
156 kIORPCVersionCurrent = kIORPCVersion190615,
157 kIORPCVersionCurrentReply = kIORPCVersion190615Reply
158 #endif /* DRIVERKIT_PRIVATE */
159 };
160
161 enum{
162 kIORPCMessageRemote = 0x00000001,
163 kIORPCMessageLocalHost = 0x00000002,
164 kIORPCMessageKernel = 0x00000004,
165 kIORPCMessageOneway = 0x00000008,
166 kIORPCMessageObjectRefs = 0x00000010,
167 kIORPCMessageOnqueue = 0x00000020,
168 kIORPCMessageError = 0x00000040,
169 kIORPCMessageSimpleReply = 0x00000080,
170 };
171
172 enum{
173 kIORPCMessageIDKernel = (1ULL << 63),
174 };
175
176 struct IORPCMessageMach {
177 mach_msg_header_t msgh;
178 mach_msg_body_t msgh_body;
179 mach_msg_port_descriptor_t objects[0];
180 };
181 typedef struct IORPCMessageMach IORPCMessageMach;
182
183 struct IORPCMessage {
184 uint64_t msgid;
185 uint64_t flags;
186 uint64_t objectRefs;
187 OSObjectRef objects[0];
188 };
189 typedef struct IORPCMessage IORPCMessage;
190
191 extern "C" IORPCMessage *
192 IORPCMessageFromMach(IORPCMessageMach * msg, bool reply);
193
194 struct IORPCMessageErrorReturnContent {
195 IORPCMessage hdr;
196 kern_return_t result;
197 uint32_t pad;
198 };
199
200 #pragma pack(4)
201 struct IORPCMessageErrorReturn {
202 IORPCMessageMach mach;
203 IORPCMessageErrorReturnContent content;
204 };
205 #pragma pack()
206
207
208 class OSMetaClassBase;
209 struct IORPC;
210 typedef kern_return_t (*OSDispatchMethod)(OSMetaClassBase * self, const IORPC rpc);
211
212 struct IORPC {
213 IORPCMessageMach * message;
214 IORPCMessageMach * reply;
215 uint32_t sendSize;
216 uint32_t replySize;
217 };
218 typedef struct IORPC IORPC;
219
220 enum {
221 kOSClassCanRemote = 0x00000001,
222 };
223
224 struct OSClassDescription {
225 uint32_t descriptionSize;
226
227 char name[96];
228 char superName[96];
229
230 uint32_t methodOptionsSize;
231 uint32_t methodOptionsOffset;
232 uint32_t metaMethodOptionsSize;
233 uint32_t metaMethodOptionsOffset;
234 uint32_t queueNamesSize;
235 uint32_t queueNamesOffset;
236 uint32_t methodNamesSize;
237 uint32_t methodNamesOffset;
238 uint32_t metaMethodNamesSize;
239 uint32_t metaMethodNamesOffset;
240
241 uint64_t flags;
242
243 uint64_t resv1[8];
244
245 uint64_t methodOptions[0];
246 uint64_t metaMethodOptions[0];
247
248 char dispatchNames[0];
249 char methodNames[0];
250 char metaMethodNames[0];
251 };
252
253 #endif /* _IORPC_H */