1 /* 2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_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. 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. 14 * 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 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 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. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 /* 29 * @OSF_COPYRIGHT@ 30 */ 31 32 #ifndef _KERN_IPC_MIG_H_ 33 #define _KERN_IPC_MIG_H_ 34 35 #include <mach/mig.h> 36 #include <mach/mach_types.h> 37 #include <mach/message.h> 38 #include <kern/kern_types.h> 39 40 #include <sys/cdefs.h> 41 42 #ifdef XNU_KERNEL_PRIVATE 43 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_IST(KDEBUG_TRACE, \ 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) \ 62 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \ 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) \ 71 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \ 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) \ 80 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \ 81 KDBG_MIGCODE(msgid) | DBG_FUNC_END, \ 82 (unsigned int)(arg1), \ 83 (unsigned int)(arg2), \ 84 (unsigned int)(arg3), \ 85 (unsigned int)(arg4), \ 86 (unsigned int)(0)); 87 88 #else /* !_MIG_TRACE_PARAMETERS_ */ 89 90 #define __BeforeRcvRpc(msgid, _NAME_) \ 91 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \ 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_) \ 100 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \ 101 KDBG_MIGCODE(msgid) | DBG_FUNC_END, \ 102 (unsigned int)(0), \ 103 (unsigned int)(0), \ 104 (unsigned int)(0), \ 105 (unsigned int)(0), \ 106 (unsigned int)(0)); 107 108 109 #define __BeforeRcvSimple(msgid, _NAME_) \ 110 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \ 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_) \ 119 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \ 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)); 126 127 #endif /* !_MIG_TRACE_PARAMETERS_ */ 128 129 #define _MIG_MSGID_INVALID(msgid) \ 130 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE, \ 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)) 137 138 #endif /* XNU_KERNEL_PRIVATE */ 139 140 __BEGIN_DECLS 141 142 /* Send a message from the kernel */ 143 144 extern mach_msg_return_t mach_msg_send_from_kernel_proper( 145 mach_msg_header_t *msg, 146 mach_msg_size_t send_size); 147 148 #define mach_msg_send_from_kernel mach_msg_send_from_kernel_proper 149 150 extern mach_msg_return_t mach_msg_rpc_from_kernel_proper( 151 mach_msg_header_t *msg, 152 mach_msg_size_t send_size, 153 mach_msg_size_t rcv_size); 154 155 #define mach_msg_rpc_from_kernel mach_msg_rpc_from_kernel_proper 156 157 extern void mach_msg_destroy_from_kernel_proper( 158 mach_msg_header_t *msg); 159 160 #define mach_msg_destroy_from_kernel mach_msg_destroy_from_kernel_proper 161 162 #ifdef XNU_KERNEL_PRIVATE 163 164 mach_msg_return_t kernel_mach_msg_rpc( 165 mach_msg_header_t *msg, 166 mach_msg_size_t send_size, 167 mach_msg_size_t rcv_size, 168 boolean_t interruptible, 169 boolean_t *message_moved); 170 171 extern mach_msg_return_t kernel_mach_msg_send( 172 mach_msg_header_t *msg, 173 mach_msg_size_t send_size, 174 mach_msg_option_t option, 175 mach_msg_timeout_t timeout_val, 176 boolean_t *message_moved); 177 178 extern mach_msg_return_t kernel_mach_msg_send_with_builder( 179 mach_msg_size_t send_size, 180 mach_msg_option_t option, 181 mach_msg_timeout_t timeout_val, 182 boolean_t *message_moved, 183 void (^builder)(mach_msg_header_t *, mach_msg_size_t)); 184 185 extern mach_msg_return_t mach_msg_send_from_kernel_with_options( 186 mach_msg_header_t *msg, 187 mach_msg_size_t send_size, 188 mach_msg_option_t option, 189 mach_msg_timeout_t timeout_val); 190 191 #endif /* XNU_KERNEL_PRIVATE */ 192 #ifdef MACH_KERNEL_PRIVATE 193 194 extern void mach_msg_receive_continue(void); 195 196 #endif /* MACH_KERNEL_PRIVATE */ 197 198 __END_DECLS 199 200 #endif /* _KERN_IPC_MIG_H_ */ 201