2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
26 #ifndef _KERN_IPC_MIG_H_
27 #define _KERN_IPC_MIG_H_
30 #include <mach/mach_types.h>
31 #include <mach/message.h>
32 #include <kern/kern_types.h>
34 #include <sys/cdefs.h>
36 #ifdef XNU_KERNEL_PRIVATE
38 #include <sys/kdebug.h>
41 * Define the trace points for MIG-generated calls. One traces the input parameters
42 * to MIG called things, another traces the outputs, and one traces bad message IDs.
44 #ifdef _MIG_TRACE_PARAMETERS_
46 #define __BeforeRcvCallTrace(msgid,arg1,arg2,arg3,arg4) \
47 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
48 (unsigned int)(arg1), \
49 (unsigned int)(arg2), \
50 (unsigned int)(arg3), \
51 (unsigned int)(arg4), \
54 #define __AfterRcvCallTrace(msgid,arg1,arg2,arg3,arg4) \
55 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
56 (unsigned int)(arg1), \
57 (unsigned int)(arg2), \
58 (unsigned int)(arg3), \
59 (unsigned int)(arg4), \
62 #define __BeforeSimpleCallTrace(msgid,arg1,arg2,arg3,arg4) \
63 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
64 (unsigned int)(arg1), \
65 (unsigned int)(arg2), \
66 (unsigned int)(arg3), \
67 (unsigned int)(arg4), \
70 #define __AfterSimpleCallTrace(msgid,arg1,arg2,arg3,arg4) \
71 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
72 (unsigned int)(arg1), \
73 (unsigned int)(arg2), \
74 (unsigned int)(arg3), \
75 (unsigned int)(arg4), \
78 #else /* !_MIG_TRACE_PARAMETERS_ */
80 #define __BeforeRcvRpc(msgid, _NAME_) \
81 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
88 #define __AfterRcvRpc(msgid, _NAME_) \
89 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
97 #define __BeforeRcvSimple(msgid, _NAME_) \
98 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
105 #define __AfterRcvSimple(msgid, _NAME_) \
106 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
113 #endif /* !_MIG_TRACE_PARAMETERS_ */
115 #define _MIG_MSGID_INVALID(msgid) \
116 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_MSGID_INVALID, (msgid)), \
123 #endif /* XNU_KERNEL_PRIVATE */
127 /* Send a message from the kernel */
128 extern mach_msg_return_t
mach_msg_send_from_kernel(
129 mach_msg_header_t
*msg
,
130 mach_msg_size_t send_size
);
133 extern mach_msg_return_t
mach_msg_rpc_from_kernel(
134 mach_msg_header_t
*msg
,
135 mach_msg_size_t send_size
,
136 mach_msg_size_t rcv_size
);
140 #ifdef MACH_KERNEL_PRIVATE
142 extern void mach_msg_receive_continue(void);
144 /* Initialize kernel server dispatch table */
145 extern void mig_init(void);
148 * Kernel implementation of the MIG object base class
150 * Conforms to the MIGObjectInterface defined in <mach/mig.h>
151 * Ports are automatically allocated for the duration of outstanding
152 * cross-task references and then released.
155 typedef struct mig_object
{
156 const IMIGObjectVtbl
*pVtbl
; /* our interface def */
157 mach_port_t port
; /* our port pointer */
162 * MIG notify base class definition
163 * These are chained off the mig object to which the are registered.
164 * When that object triggers a notification delivery, we walk this
165 * chain and deliver the appropriate notification.
167 typedef struct mig_notify_object
{
168 const IMIGNotifyObjectVtbl
*pVtbl
; /* our interface def */
169 mach_port_t port
; /* our port pointer */
170 } mig_notify_object_data_t
;
172 extern kern_return_t
mig_object_init(
173 mig_object_t mig_object
,
174 const IMIGObject
*interface
);
176 extern void mig_object_destroy(
177 mig_object_t mig_object
);
179 extern void mig_object_reference(
180 mig_object_t mig_object
);
182 extern void mig_object_deallocate(
183 mig_object_t mig_object
);
185 extern ipc_port_t
convert_mig_object_to_port(
186 mig_object_t mig_object
);
188 extern mig_object_t
convert_port_to_mig_object(
192 boolean_t
mig_object_no_senders(
194 mach_port_mscount_t mscount
);
196 #endif /* MACH_KERNEL_PRIVATE */
198 #endif /* _KERN_IPC_MIG_H_ */