2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
27 #ifndef _KERN_IPC_MIG_H_
28 #define _KERN_IPC_MIG_H_
31 #include <mach/mach_types.h>
32 #include <mach/message.h>
33 #include <kern/kern_types.h>
35 #include <sys/cdefs.h>
37 #ifdef XNU_KERNEL_PRIVATE
39 #include <sys/kdebug.h>
42 * Define the trace points for MIG-generated calls. One traces the input parameters
43 * to MIG called things, another traces the outputs, and one traces bad message IDs.
45 #ifdef _MIG_TRACE_PARAMETERS_
47 #define __BeforeRcvCallTrace(msgid,arg1,arg2,arg3,arg4) \
48 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
49 (unsigned int)(arg1), \
50 (unsigned int)(arg2), \
51 (unsigned int)(arg3), \
52 (unsigned int)(arg4), \
55 #define __AfterRcvCallTrace(msgid,arg1,arg2,arg3,arg4) \
56 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
57 (unsigned int)(arg1), \
58 (unsigned int)(arg2), \
59 (unsigned int)(arg3), \
60 (unsigned int)(arg4), \
63 #define __BeforeSimpleCallTrace(msgid,arg1,arg2,arg3,arg4) \
64 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
65 (unsigned int)(arg1), \
66 (unsigned int)(arg2), \
67 (unsigned int)(arg3), \
68 (unsigned int)(arg4), \
71 #define __AfterSimpleCallTrace(msgid,arg1,arg2,arg3,arg4) \
72 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
73 (unsigned int)(arg1), \
74 (unsigned int)(arg2), \
75 (unsigned int)(arg3), \
76 (unsigned int)(arg4), \
79 #else /* !_MIG_TRACE_PARAMETERS_ */
81 #define __BeforeRcvRpc(msgid, _NAME_) \
82 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
89 #define __AfterRcvRpc(msgid, _NAME_) \
90 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
98 #define __BeforeRcvSimple(msgid, _NAME_) \
99 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
106 #define __AfterRcvSimple(msgid, _NAME_) \
107 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
114 #endif /* !_MIG_TRACE_PARAMETERS_ */
116 #define _MIG_MSGID_INVALID(msgid) \
117 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_MSGID_INVALID, (msgid)), \
124 #endif /* XNU_KERNEL_PRIVATE */
128 /* Send a message from the kernel */
129 extern mach_msg_return_t
mach_msg_send_from_kernel(
130 mach_msg_header_t
*msg
,
131 mach_msg_size_t send_size
);
134 extern mach_msg_return_t
mach_msg_rpc_from_kernel(
135 mach_msg_header_t
*msg
,
136 mach_msg_size_t send_size
,
137 mach_msg_size_t rcv_size
);
141 #ifdef MACH_KERNEL_PRIVATE
143 extern void mach_msg_receive_continue(void);
145 /* Initialize kernel server dispatch table */
146 extern void mig_init(void);
149 * Kernel implementation of the MIG object base class
151 * Conforms to the MIGObjectInterface defined in <mach/mig.h>
152 * Ports are automatically allocated for the duration of outstanding
153 * cross-task references and then released.
156 typedef struct mig_object
{
157 const IMIGObjectVtbl
*pVtbl
; /* our interface def */
158 mach_port_t port
; /* our port pointer */
163 * MIG notify base class definition
164 * These are chained off the mig object to which the are registered.
165 * When that object triggers a notification delivery, we walk this
166 * chain and deliver the appropriate notification.
168 typedef struct mig_notify_object
{
169 const IMIGNotifyObjectVtbl
*pVtbl
; /* our interface def */
170 mach_port_t port
; /* our port pointer */
171 } mig_notify_object_data_t
;
173 extern kern_return_t
mig_object_init(
174 mig_object_t mig_object
,
175 const IMIGObject
*interface
);
177 extern void mig_object_destroy(
178 mig_object_t mig_object
);
180 extern void mig_object_reference(
181 mig_object_t mig_object
);
183 extern void mig_object_deallocate(
184 mig_object_t mig_object
);
186 extern ipc_port_t
convert_mig_object_to_port(
187 mig_object_t mig_object
);
189 extern mig_object_t
convert_port_to_mig_object(
193 boolean_t
mig_object_no_senders(
195 mach_port_mscount_t mscount
);
197 #endif /* MACH_KERNEL_PRIVATE */
199 #endif /* _KERN_IPC_MIG_H_ */