2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
34 #ifndef _KERN_IPC_MIG_H_
35 #define _KERN_IPC_MIG_H_
38 #include <mach/mach_types.h>
39 #include <mach/message.h>
40 #include <kern/kern_types.h>
42 #include <sys/cdefs.h>
44 #ifdef XNU_KERNEL_PRIVATE
46 #include <sys/kdebug.h>
49 * Define the trace points for MIG-generated calls. One traces the input parameters
50 * to MIG called things, another traces the outputs, and one traces bad message IDs.
52 #ifdef _MIG_TRACE_PARAMETERS_
54 #define __BeforeRcvCallTrace(msgid,arg1,arg2,arg3,arg4) \
55 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
56 (unsigned int)(arg1), \
57 (unsigned int)(arg2), \
58 (unsigned int)(arg3), \
59 (unsigned int)(arg4), \
62 #define __AfterRcvCallTrace(msgid,arg1,arg2,arg3,arg4) \
63 KERNEL_DEBUG_CONSTANT(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(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
72 (unsigned int)(arg1), \
73 (unsigned int)(arg2), \
74 (unsigned int)(arg3), \
75 (unsigned int)(arg4), \
78 #define __AfterSimpleCallTrace(msgid,arg1,arg2,arg3,arg4) \
79 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
80 (unsigned int)(arg1), \
81 (unsigned int)(arg2), \
82 (unsigned int)(arg3), \
83 (unsigned int)(arg4), \
86 #else /* !_MIG_TRACE_PARAMETERS_ */
88 #define __BeforeRcvRpc(msgid, _NAME_) \
89 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
96 #define __AfterRcvRpc(msgid, _NAME_) \
97 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
105 #define __BeforeRcvSimple(msgid, _NAME_) \
106 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
113 #define __AfterRcvSimple(msgid, _NAME_) \
114 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
121 #endif /* !_MIG_TRACE_PARAMETERS_ */
123 #define _MIG_MSGID_INVALID(msgid) \
124 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_MSGID_INVALID, (msgid)), \
131 #endif /* XNU_KERNEL_PRIVATE */
135 /* Send a message from the kernel */
136 extern mach_msg_return_t
mach_msg_send_from_kernel(
137 mach_msg_header_t
*msg
,
138 mach_msg_size_t send_size
);
141 extern mach_msg_return_t
mach_msg_rpc_from_kernel(
142 mach_msg_header_t
*msg
,
143 mach_msg_size_t send_size
,
144 mach_msg_size_t rcv_size
);
148 #ifdef MACH_KERNEL_PRIVATE
150 extern void mach_msg_receive_continue(void);
152 /* Initialize kernel server dispatch table */
153 extern void mig_init(void);
156 * Kernel implementation of the MIG object base class
158 * Conforms to the MIGObjectInterface defined in <mach/mig.h>
159 * Ports are automatically allocated for the duration of outstanding
160 * cross-task references and then released.
163 typedef struct mig_object
{
164 const IMIGObjectVtbl
*pVtbl
; /* our interface def */
165 mach_port_t port
; /* our port pointer */
170 * MIG notify base class definition
171 * These are chained off the mig object to which the are registered.
172 * When that object triggers a notification delivery, we walk this
173 * chain and deliver the appropriate notification.
175 typedef struct mig_notify_object
{
176 const IMIGNotifyObjectVtbl
*pVtbl
; /* our interface def */
177 mach_port_t port
; /* our port pointer */
178 } mig_notify_object_data_t
;
180 extern kern_return_t
mig_object_init(
181 mig_object_t mig_object
,
182 const IMIGObject
*interface
);
184 extern void mig_object_destroy(
185 mig_object_t mig_object
);
187 extern void mig_object_reference(
188 mig_object_t mig_object
);
190 extern void mig_object_deallocate(
191 mig_object_t mig_object
);
193 extern ipc_port_t
convert_mig_object_to_port(
194 mig_object_t mig_object
);
196 extern mig_object_t
convert_port_to_mig_object(
200 boolean_t
mig_object_no_senders(
202 mach_port_mscount_t mscount
);
204 #endif /* MACH_KERNEL_PRIVATE */
206 #endif /* _KERN_IPC_MIG_H_ */