]> git.saurik.com Git - apple/xnu.git/blob - osfmk/kern/ipc_mig.h
51d85242ce471debdaadddc88dced8604ffedef3
[apple/xnu.git] / osfmk / kern / ipc_mig.h
1 /*
2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * @OSF_COPYRIGHT@
25 */
26
27 #ifndef _KERN_IPC_MIG_H_
28 #define _KERN_IPC_MIG_H_
29
30 #include <mach/mig.h>
31 #include <mach/mach_types.h>
32 #include <mach/message.h>
33 #include <kern/kern_types.h>
34
35 #include <sys/cdefs.h>
36
37 #ifdef XNU_KERNEL_PRIVATE
38
39 #include <sys/kdebug.h>
40
41 /*
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.
44 */
45 #ifdef _MIG_TRACE_PARAMETERS_
46
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), \
53 (unsigned int)(0));
54
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), \
61 (unsigned int)(0));
62
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), \
69 (unsigned int)(0));
70
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), \
77 (unsigned int)(0));
78
79 #else /* !_MIG_TRACE_PARAMETERS_ */
80
81 #define __BeforeRcvRpc(msgid, _NAME_) \
82 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
83 (unsigned int)(0), \
84 (unsigned int)(0), \
85 (unsigned int)(0), \
86 (unsigned int)(0), \
87 (unsigned int)(0));
88
89 #define __AfterRcvRpc(msgid, _NAME_) \
90 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
91 (unsigned int)(0), \
92 (unsigned int)(0), \
93 (unsigned int)(0), \
94 (unsigned int)(0), \
95 (unsigned int)(0));
96
97
98 #define __BeforeRcvSimple(msgid, _NAME_) \
99 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
100 (unsigned int)(0), \
101 (unsigned int)(0), \
102 (unsigned int)(0), \
103 (unsigned int)(0), \
104 (unsigned int)(0));
105
106 #define __AfterRcvSimple(msgid, _NAME_) \
107 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
108 (unsigned int)(0), \
109 (unsigned int)(0), \
110 (unsigned int)(0), \
111 (unsigned int)(0), \
112 (unsigned int)(0));
113
114 #endif /* !_MIG_TRACE_PARAMETERS_ */
115
116 #define _MIG_MSGID_INVALID(msgid) \
117 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_MSGID_INVALID, (msgid)), \
118 (unsigned int)(0), \
119 (unsigned int)(0), \
120 (unsigned int)(0), \
121 (unsigned int)(0), \
122 (unsigned int)(0))
123
124 #endif /* XNU_KERNEL_PRIVATE */
125
126 __BEGIN_DECLS
127
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);
132
133
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);
138
139 __END_DECLS
140
141 #ifdef MACH_KERNEL_PRIVATE
142
143 extern void mach_msg_receive_continue(void);
144
145 /* Initialize kernel server dispatch table */
146 extern void mig_init(void);
147
148 /*
149 * Kernel implementation of the MIG object base class
150 *
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.
154 */
155
156 typedef struct mig_object {
157 const IMIGObjectVtbl *pVtbl; /* our interface def */
158 mach_port_t port; /* our port pointer */
159 } mig_object_data_t;
160
161
162 /*
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.
167 */
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;
172
173 extern kern_return_t mig_object_init(
174 mig_object_t mig_object,
175 const IMIGObject *interface);
176
177 extern void mig_object_destroy(
178 mig_object_t mig_object);
179
180 extern void mig_object_reference(
181 mig_object_t mig_object);
182
183 extern void mig_object_deallocate(
184 mig_object_t mig_object);
185
186 extern ipc_port_t convert_mig_object_to_port(
187 mig_object_t mig_object);
188
189 extern mig_object_t convert_port_to_mig_object(
190 ipc_port_t port,
191 const MIGIID *iid);
192
193 boolean_t mig_object_no_senders(
194 ipc_port_t port,
195 mach_port_mscount_t mscount);
196
197 #endif /* MACH_KERNEL_PRIVATE */
198
199 #endif /* _KERN_IPC_MIG_H_ */