2 * Copyright (c) 2018 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
35 #ifndef PLATFORM_DriverKit
37 #include <mach/message.h>
39 #else /* !PLATFORM_DriverKit */
41 #ifndef _MACH_MESSAGE_H_
42 #define _MACH_MESSAGE_H_
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 */
55 #define MACH_MSG_TYPE_PORT_NONE 0
57 #define MACH_MSG_PORT_DESCRIPTOR 0
58 #define MACH_MSG_OOL_DESCRIPTOR 1
60 typedef unsigned int mach_msg_copy_options_t
;
62 #define MACH_MSG_PHYSICAL_COPY 0
63 #define MACH_MSG_VIRTUAL_COPY 1
64 #define MACH_MSG_ALLOCATE 2
66 typedef uint32_t natural_t
;
67 typedef int32_t integer_t
;
69 typedef unsigned int mach_msg_type_name_t
;
70 typedef unsigned int mach_msg_descriptor_type_t
;
73 typedef void * mach_port_t
;
74 #define MACH_PORT_NULL NULL
76 typedef natural_t mach_port_t
;
77 #define MACH_PORT_NULL 0
80 typedef natural_t mach_port_name_t
;
82 typedef unsigned int mach_msg_bits_t
;
83 typedef natural_t mach_msg_size_t
;
84 typedef integer_t mach_msg_id_t
;
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
;
98 mach_msg_size_t msgh_descriptor_count
;
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
;
107 unsigned int pad2
: 16;
108 mach_msg_type_name_t disposition
: 8;
109 mach_msg_descriptor_type_t type
: 8;
113 } mach_msg_port_descriptor_t
;
117 #if !defined(__LP64__)
118 mach_msg_size_t size
;
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
;
127 #if defined(KERNEL) && !defined(__LP64__)
130 } mach_msg_ool_descriptor_t
;
133 unsigned int val
[80 / sizeof(int)];
134 } mach_msg_max_trailer_t
;
138 #endif /* _MACH_MESSAGE_H_ */
140 #endif /* PLATFORM_DriverKit */
146 typedef uint64_t OSObjectRef
;
149 kIORPCVersion190615
= (mach_msg_id_t
) 0x4da2b68c,
150 kIORPCVersion190615Reply
= (mach_msg_id_t
) 0x4da2b68d,
152 #if DRIVERKIT_PRIVATE
153 kIORPCVersion190501
= (mach_msg_id_t
) 0xfe316a7a,
154 kIORPCVersion190501Reply
= (mach_msg_id_t
) 0xfe316a7b,
156 kIORPCVersionCurrent
= kIORPCVersion190615
,
157 kIORPCVersionCurrentReply
= kIORPCVersion190615Reply
158 #endif /* DRIVERKIT_PRIVATE */
162 kIORPCMessageRemote
= 0x00000001,
163 kIORPCMessageLocalHost
= 0x00000002,
164 kIORPCMessageKernel
= 0x00000004,
165 kIORPCMessageOneway
= 0x00000008,
166 kIORPCMessageObjectRefs
= 0x00000010,
167 kIORPCMessageOnqueue
= 0x00000020,
168 kIORPCMessageError
= 0x00000040,
169 kIORPCMessageSimpleReply
= 0x00000080,
173 kIORPCMessageIDKernel
= (1ULL << 63),
176 struct IORPCMessageMach
{
177 mach_msg_header_t msgh
;
178 mach_msg_body_t msgh_body
;
179 mach_msg_port_descriptor_t objects
[0];
181 typedef struct IORPCMessageMach IORPCMessageMach
;
183 struct IORPCMessage
{
187 OSObjectRef objects
[0];
189 typedef struct IORPCMessage IORPCMessage
;
191 extern "C" IORPCMessage
*
192 IORPCMessageFromMach(IORPCMessageMach
* msg
, bool reply
);
194 struct IORPCMessageErrorReturnContent
{
196 kern_return_t result
;
201 struct IORPCMessageErrorReturn
{
202 IORPCMessageMach mach
;
203 IORPCMessageErrorReturnContent content
;
208 class OSMetaClassBase
;
210 typedef kern_return_t (*OSDispatchMethod
)(OSMetaClassBase
* self
, const IORPC rpc
);
213 IORPCMessageMach
* message
;
214 IORPCMessageMach
* reply
;
218 typedef struct IORPC IORPC
;
221 kOSClassCanRemote
= 0x00000001,
224 struct OSClassDescription
{
225 uint32_t descriptionSize
;
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
;
245 uint64_t methodOptions
[0];
246 uint64_t metaMethodOptions
[0];
248 char dispatchNames
[0];
250 char metaMethodNames
[0];
253 #endif /* _IORPC_H */