]> git.saurik.com Git - apple/xnu.git/blame - osfmk/kern/ipc_mig.h
xnu-1699.22.81.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@
1c79356b 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.
8f6c56a5 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.
17 *
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31
91447636
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
42#ifdef XNU_KERNEL_PRIVATE
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
52#define __BeforeRcvCallTrace(msgid,arg1,arg2,arg3,arg4) \
53 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
54 (unsigned int)(arg1), \
55 (unsigned int)(arg2), \
56 (unsigned int)(arg3), \
57 (unsigned int)(arg4), \
58 (unsigned int)(0));
59
60#define __AfterRcvCallTrace(msgid,arg1,arg2,arg3,arg4) \
61 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
62 (unsigned int)(arg1), \
63 (unsigned int)(arg2), \
64 (unsigned int)(arg3), \
65 (unsigned int)(arg4), \
66 (unsigned int)(0));
67
68#define __BeforeSimpleCallTrace(msgid,arg1,arg2,arg3,arg4) \
69 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
70 (unsigned int)(arg1), \
71 (unsigned int)(arg2), \
72 (unsigned int)(arg3), \
73 (unsigned int)(arg4), \
74 (unsigned int)(0));
75
76#define __AfterSimpleCallTrace(msgid,arg1,arg2,arg3,arg4) \
77 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
78 (unsigned int)(arg1), \
79 (unsigned int)(arg2), \
80 (unsigned int)(arg3), \
81 (unsigned int)(arg4), \
82 (unsigned int)(0));
83
84#else /* !_MIG_TRACE_PARAMETERS_ */
85
86#define __BeforeRcvRpc(msgid, _NAME_) \
87 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
88 (unsigned int)(0), \
89 (unsigned int)(0), \
90 (unsigned int)(0), \
91 (unsigned int)(0), \
92 (unsigned int)(0));
93
94#define __AfterRcvRpc(msgid, _NAME_) \
95 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
96 (unsigned int)(0), \
97 (unsigned int)(0), \
98 (unsigned int)(0), \
99 (unsigned int)(0), \
100 (unsigned int)(0));
101
102
103#define __BeforeRcvSimple(msgid, _NAME_) \
104 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_START, \
105 (unsigned int)(0), \
106 (unsigned int)(0), \
107 (unsigned int)(0), \
108 (unsigned int)(0), \
109 (unsigned int)(0));
110
111#define __AfterRcvSimple(msgid, _NAME_) \
112 KERNEL_DEBUG_CONSTANT(KDBG_MIGCODE(msgid) | DBG_FUNC_END, \
113 (unsigned int)(0), \
114 (unsigned int)(0), \
115 (unsigned int)(0), \
116 (unsigned int)(0), \
117 (unsigned int)(0));
118
119#endif /* !_MIG_TRACE_PARAMETERS_ */
120
121#define _MIG_MSGID_INVALID(msgid) \
122 KERNEL_DEBUG_CONSTANT(MACHDBG_CODE(DBG_MACH_MSGID_INVALID, (msgid)), \
123 (unsigned int)(0), \
124 (unsigned int)(0), \
125 (unsigned int)(0), \
126 (unsigned int)(0), \
127 (unsigned int)(0))
128
91447636
A
129#endif /* XNU_KERNEL_PRIVATE */
130
131__BEGIN_DECLS
132
1c79356b 133/* Send a message from the kernel */
b0d623f7
A
134
135extern mach_msg_return_t mach_msg_send_from_kernel_proper(
1c79356b
A
136 mach_msg_header_t *msg,
137 mach_msg_size_t send_size);
138
b0d623f7 139#define mach_msg_send_from_kernel mach_msg_send_from_kernel_proper
1c79356b 140
b0d623f7
A
141extern mach_msg_return_t
142mach_msg_rpc_from_kernel_proper(
1c79356b
A
143 mach_msg_header_t *msg,
144 mach_msg_size_t send_size,
145 mach_msg_size_t rcv_size);
146
b0d623f7
A
147#define mach_msg_rpc_from_kernel mach_msg_rpc_from_kernel_proper
148
2d21ac55
A
149extern mach_msg_return_t mach_msg_send_from_kernel_with_options(
150 mach_msg_header_t *msg,
151 mach_msg_size_t send_size,
152 mach_msg_option_t option,
153 mach_msg_timeout_t timeout_val);
154
91447636
A
155__END_DECLS
156
157#ifdef MACH_KERNEL_PRIVATE
158
1c79356b
A
159extern void mach_msg_receive_continue(void);
160
91447636 161/* Initialize kernel server dispatch table */
2d21ac55 162extern void mig_init(void) __attribute__((section("__TEXT, initcode")));
9bccf70c 163
0b4e3aa0
A
164/*
165 * Kernel implementation of the MIG object base class
166 *
167 * Conforms to the MIGObjectInterface defined in <mach/mig.h>
168 * Ports are automatically allocated for the duration of outstanding
169 * cross-task references and then released.
170 */
171
172typedef struct mig_object {
91447636 173 const IMIGObjectVtbl *pVtbl; /* our interface def */
0b4e3aa0
A
174 mach_port_t port; /* our port pointer */
175} mig_object_data_t;
176
177
178/*
179 * MIG notify base class definition
180 * These are chained off the mig object to which the are registered.
181 * When that object triggers a notification delivery, we walk this
182 * chain and deliver the appropriate notification.
183 */
184typedef struct mig_notify_object {
91447636 185 const IMIGNotifyObjectVtbl *pVtbl; /* our interface def */
0b4e3aa0
A
186 mach_port_t port; /* our port pointer */
187} mig_notify_object_data_t;
188
91447636
A
189extern kern_return_t mig_object_init(
190 mig_object_t mig_object,
191 const IMIGObject *interface);
192
193extern void mig_object_destroy(
194 mig_object_t mig_object);
195
196extern void mig_object_reference(
197 mig_object_t mig_object);
198
199extern void mig_object_deallocate(
200 mig_object_t mig_object);
201
202extern ipc_port_t convert_mig_object_to_port(
203 mig_object_t mig_object);
204
205extern mig_object_t convert_port_to_mig_object(
206 ipc_port_t port,
207 const MIGIID *iid);
208
209boolean_t mig_object_no_senders(
210 ipc_port_t port,
211 mach_port_mscount_t mscount);
212
213#endif /* MACH_KERNEL_PRIVATE */
0b4e3aa0 214
91447636 215#endif /* _KERN_IPC_MIG_H_ */