2 * Copyright (c) 2000-2005 Apple Computer, 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@
32 #ifndef _KERN_IPC_MIG_H_
33 #define _KERN_IPC_MIG_H_
36 #include <mach/mach_types.h>
37 #include <mach/message.h>
38 #include <kern/kern_types.h>
40 #include <sys/cdefs.h>
42 #ifdef XNU_KERNEL_PRIVATE
44 #include <sys/kdebug.h>
47 * Define the trace points for MIG-generated calls. One traces the input parameters
48 * to MIG called things, another traces the outputs, and one traces bad message IDs.
50 #ifdef _MIG_TRACE_PARAMETERS_
52 #define __BeforeRcvCallTrace(msgid, arg1, arg2, arg3, arg4) \
53 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
54 KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
55 (unsigned int)(arg1), \
56 (unsigned int)(arg2), \
57 (unsigned int)(arg3), \
58 (unsigned int)(arg4), \
61 #define __AfterRcvCallTrace(msgid, arg1, arg2, arg3, arg4) \
62 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
63 KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
64 (unsigned int)(arg1), \
65 (unsigned int)(arg2), \
66 (unsigned int)(arg3), \
67 (unsigned int)(arg4), \
70 #define __BeforeSimpleCallTrace(msgid, arg1, arg2, arg3, arg4) \
71 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
72 KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
73 (unsigned int)(arg1), \
74 (unsigned int)(arg2), \
75 (unsigned int)(arg3), \
76 (unsigned int)(arg4), \
79 #define __AfterSimpleCallTrace(msgid, arg1, arg2, arg3, arg4) \
80 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
81 KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
82 (unsigned int)(arg1), \
83 (unsigned int)(arg2), \
84 (unsigned int)(arg3), \
85 (unsigned int)(arg4), \
88 #else /* !_MIG_TRACE_PARAMETERS_ */
90 #define __BeforeRcvRpc(msgid, _NAME_) \
91 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
92 KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
99 #define __AfterRcvRpc(msgid, _NAME_) \
100 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
101 KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
109 #define __BeforeRcvSimple(msgid, _NAME_) \
110 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
111 KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
118 #define __AfterRcvSimple(msgid, _NAME_) \
119 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
120 KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
127 #endif /* !_MIG_TRACE_PARAMETERS_ */
129 #define _MIG_MSGID_INVALID(msgid) \
130 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
131 MACHDBG_CODE(DBG_MACH_MSGID_INVALID, (msgid)), \
138 #endif /* XNU_KERNEL_PRIVATE */
142 /* Send a message from the kernel */
144 extern mach_msg_return_t
mach_msg_send_from_kernel_proper(
145 mach_msg_header_t
*msg
,
146 mach_msg_size_t send_size
);
148 #define mach_msg_send_from_kernel mach_msg_send_from_kernel_proper
150 extern mach_msg_return_t
151 mach_msg_rpc_from_kernel_proper(
152 mach_msg_header_t
*msg
,
153 mach_msg_size_t send_size
,
154 mach_msg_size_t rcv_size
);
156 #define mach_msg_rpc_from_kernel mach_msg_rpc_from_kernel_proper
158 #ifdef XNU_KERNEL_PRIVATE
159 mach_msg_return_t
kernel_mach_msg_rpc(
160 mach_msg_header_t
*msg
,
161 mach_msg_size_t send_size
,
162 mach_msg_size_t rcv_size
,
164 boolean_t
*message_moved
);
165 #endif /* XNU_KERNEL_PRIVATE */
168 mach_msg_destroy_from_kernel_proper(
169 mach_msg_header_t
*msg
);
171 #define mach_msg_destroy_from_kernel mach_msg_destroy_from_kernel_proper
173 #ifdef XNU_KERNEL_PRIVATE
174 extern mach_msg_return_t
mach_msg_send_from_kernel_with_options_legacy(
175 mach_msg_header_t
*msg
,
176 mach_msg_size_t send_size
,
177 mach_msg_option_t option
,
178 mach_msg_timeout_t timeout_val
);
180 extern mach_msg_return_t
kernel_mach_msg_send(
181 mach_msg_header_t
*msg
,
182 mach_msg_size_t send_size
,
183 mach_msg_option_t option
,
184 mach_msg_timeout_t timeout_val
,
185 boolean_t
*message_moved
);
187 extern mach_msg_return_t
mach_msg_send_from_kernel_with_options(
188 mach_msg_header_t
*msg
,
189 mach_msg_size_t send_size
,
190 mach_msg_option_t option
,
191 mach_msg_timeout_t timeout_val
)
192 __XNU_INTERNAL(mach_msg_send_from_kernel_with_options
);
194 extern mach_msg_return_t
mach_msg_send_from_kernel_with_options(
195 mach_msg_header_t
*msg
,
196 mach_msg_size_t send_size
,
197 mach_msg_option_t option
,
198 mach_msg_timeout_t timeout_val
);
199 #endif /* XNU_KERNEL_PRIVATE */
203 #ifdef MACH_KERNEL_PRIVATE
205 extern void mach_msg_receive_continue(void);
208 * Kernel implementation of the MIG object base class
210 * Conforms to the MIGObjectInterface defined in <mach/mig.h>
211 * Ports are automatically allocated for the duration of outstanding
212 * cross-task references and then released.
215 typedef struct mig_object
{
216 const IMIGObjectVtbl
*pVtbl
; /* our interface def */
217 mach_port_t port
; /* our port pointer */
222 * MIG notify base class definition
223 * These are chained off the mig object to which the are registered.
224 * When that object triggers a notification delivery, we walk this
225 * chain and deliver the appropriate notification.
227 typedef struct mig_notify_object
{
228 const IMIGNotifyObjectVtbl
*pVtbl
; /* our interface def */
229 mach_port_t port
; /* our port pointer */
230 } mig_notify_object_data_t
;
232 extern kern_return_t
mig_object_init(
233 mig_object_t mig_object
,
234 const IMIGObject
*interface
);
236 extern void mig_object_destroy(
237 mig_object_t mig_object
);
239 extern void mig_object_reference(
240 mig_object_t mig_object
);
242 extern void mig_object_deallocate(
243 mig_object_t mig_object
);
245 extern ipc_port_t
convert_mig_object_to_port(
246 mig_object_t mig_object
);
248 extern mig_object_t
convert_port_to_mig_object(
252 extern void mig_object_no_senders(
255 #endif /* MACH_KERNEL_PRIVATE */
257 #endif /* _KERN_IPC_MIG_H_ */