]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/ipc_mig.h
xnu-7195.81.3.tar.gz
[apple/xnu.git] / osfmk / kern / ipc_mig.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
1c79356b 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
2d21ac55
A
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.
0a7de745 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
0a7de745 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31
0a7de745
A
32#ifndef _KERN_IPC_MIG_H_
33#define _KERN_IPC_MIG_H_
1c79356b 34
0b4e3aa0 35#include <mach/mig.h>
91447636 36#include <mach/mach_types.h>
1c79356b 37#include <mach/message.h>
91447636
A
38#include <kern/kern_types.h>
39
40#include <sys/cdefs.h>
41
0a7de745 42#ifdef XNU_KERNEL_PRIVATE
91447636 43
1c79356b
A
44#include <sys/kdebug.h>
45
46/*
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.
49 */
50#ifdef _MIG_TRACE_PARAMETERS_
51
0a7de745 52#define __BeforeRcvCallTrace(msgid, arg1, arg2, arg3, arg4) \
316670eb 53 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
0a7de745
A
54 KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
55 (unsigned int)(arg1), \
56 (unsigned int)(arg2), \
57 (unsigned int)(arg3), \
58 (unsigned int)(arg4), \
59 (unsigned int)(0));
60
61#define __AfterRcvCallTrace(msgid, arg1, arg2, arg3, arg4) \
316670eb 62 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
0a7de745
A
63 KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
64 (unsigned int)(arg1), \
65 (unsigned int)(arg2), \
66 (unsigned int)(arg3), \
67 (unsigned int)(arg4), \
68 (unsigned int)(0));
69
70#define __BeforeSimpleCallTrace(msgid, arg1, arg2, arg3, arg4) \
316670eb 71 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
0a7de745
A
72 KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
73 (unsigned int)(arg1), \
74 (unsigned int)(arg2), \
75 (unsigned int)(arg3), \
76 (unsigned int)(arg4), \
77 (unsigned int)(0));
78
79#define __AfterSimpleCallTrace(msgid, arg1, arg2, arg3, arg4) \
316670eb
A
80 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
81 KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
0a7de745
A
82 (unsigned int)(arg1), \
83 (unsigned int)(arg2), \
84 (unsigned int)(arg3), \
85 (unsigned int)(arg4), \
86 (unsigned int)(0));
1c79356b
A
87
88#else /* !_MIG_TRACE_PARAMETERS_ */
89
0a7de745 90#define __BeforeRcvRpc(msgid, _NAME_) \
316670eb 91 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
0a7de745
A
92 KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
93 (unsigned int)(0), \
94 (unsigned int)(0), \
95 (unsigned int)(0), \
96 (unsigned int)(0), \
97 (unsigned int)(0));
98
99#define __AfterRcvRpc(msgid, _NAME_) \
316670eb
A
100 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
101 KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
0a7de745
A
102 (unsigned int)(0), \
103 (unsigned int)(0), \
104 (unsigned int)(0), \
105 (unsigned int)(0), \
106 (unsigned int)(0));
1c79356b
A
107
108
0a7de745 109#define __BeforeRcvSimple(msgid, _NAME_) \
316670eb 110 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
0a7de745
A
111 KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
112 (unsigned int)(0), \
113 (unsigned int)(0), \
114 (unsigned int)(0), \
115 (unsigned int)(0), \
116 (unsigned int)(0));
117
118#define __AfterRcvSimple(msgid, _NAME_) \
316670eb 119 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
0a7de745
A
120 KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
121 (unsigned int)(0), \
122 (unsigned int)(0), \
123 (unsigned int)(0), \
124 (unsigned int)(0), \
125 (unsigned int)(0));
1c79356b
A
126
127#endif /* !_MIG_TRACE_PARAMETERS_ */
128
0a7de745 129#define _MIG_MSGID_INVALID(msgid) \
316670eb 130 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \
0a7de745
A
131 MACHDBG_CODE(DBG_MACH_MSGID_INVALID, (msgid)), \
132 (unsigned int)(0), \
133 (unsigned int)(0), \
134 (unsigned int)(0), \
135 (unsigned int)(0), \
136 (unsigned int)(0))
1c79356b 137
0a7de745 138#endif /* XNU_KERNEL_PRIVATE */
91447636
A
139
140__BEGIN_DECLS
141
1c79356b 142/* Send a message from the kernel */
b0d623f7
A
143
144extern mach_msg_return_t mach_msg_send_from_kernel_proper(
0a7de745
A
145 mach_msg_header_t *msg,
146 mach_msg_size_t send_size);
1c79356b 147
b0d623f7 148#define mach_msg_send_from_kernel mach_msg_send_from_kernel_proper
1c79356b 149
b0d623f7
A
150extern mach_msg_return_t
151mach_msg_rpc_from_kernel_proper(
0a7de745
A
152 mach_msg_header_t *msg,
153 mach_msg_size_t send_size,
154 mach_msg_size_t rcv_size);
1c79356b 155
b0d623f7
A
156#define mach_msg_rpc_from_kernel mach_msg_rpc_from_kernel_proper
157
ea3f0419
A
158#ifdef XNU_KERNEL_PRIVATE
159mach_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,
163 boolean_t legacy,
164 boolean_t *message_moved);
165#endif /* XNU_KERNEL_PRIVATE */
166
e8c3f781
A
167extern void
168mach_msg_destroy_from_kernel_proper(
0a7de745 169 mach_msg_header_t *msg);
e8c3f781
A
170
171#define mach_msg_destroy_from_kernel mach_msg_destroy_from_kernel_proper
172
39236c6e
A
173#ifdef XNU_KERNEL_PRIVATE
174extern mach_msg_return_t mach_msg_send_from_kernel_with_options_legacy(
0a7de745
A
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);
39236c6e 179
ea3f0419
A
180extern 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);
186
cb323159
A
187extern 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);
193#else
2d21ac55 194extern mach_msg_return_t mach_msg_send_from_kernel_with_options(
0a7de745
A
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);
cb323159 199#endif /* XNU_KERNEL_PRIVATE */
2d21ac55 200
91447636
A
201__END_DECLS
202
0a7de745 203#ifdef MACH_KERNEL_PRIVATE
91447636 204
1c79356b
A
205extern void mach_msg_receive_continue(void);
206
0b4e3aa0
A
207/*
208 * Kernel implementation of the MIG object base class
209 *
210 * Conforms to the MIGObjectInterface defined in <mach/mig.h>
211 * Ports are automatically allocated for the duration of outstanding
0a7de745 212 * cross-task references and then released.
0b4e3aa0
A
213 */
214
215typedef struct mig_object {
0a7de745
A
216 const IMIGObjectVtbl *pVtbl; /* our interface def */
217 mach_port_t port; /* our port pointer */
0b4e3aa0
A
218} mig_object_data_t;
219
220
221/*
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.
226 */
227typedef struct mig_notify_object {
0a7de745
A
228 const IMIGNotifyObjectVtbl *pVtbl; /* our interface def */
229 mach_port_t port; /* our port pointer */
0b4e3aa0
A
230} mig_notify_object_data_t;
231
91447636 232extern kern_return_t mig_object_init(
0a7de745
A
233 mig_object_t mig_object,
234 const IMIGObject *interface);
91447636
A
235
236extern void mig_object_destroy(
0a7de745 237 mig_object_t mig_object);
91447636
A
238
239extern void mig_object_reference(
0a7de745 240 mig_object_t mig_object);
91447636
A
241
242extern void mig_object_deallocate(
0a7de745 243 mig_object_t mig_object);
91447636
A
244
245extern ipc_port_t convert_mig_object_to_port(
0a7de745 246 mig_object_t mig_object);
91447636
A
247
248extern mig_object_t convert_port_to_mig_object(
0a7de745
A
249 ipc_port_t port,
250 const MIGIID *iid);
91447636 251
cb323159
A
252extern void mig_object_no_senders(
253 ipc_port_t port);
91447636
A
254
255#endif /* MACH_KERNEL_PRIVATE */
0b4e3aa0 256
0a7de745 257#endif /* _KERN_IPC_MIG_H_ */