]> git.saurik.com Git - apple/xnu.git/blame - osfmk/mach/message.h
xnu-4903.270.47.tar.gz
[apple/xnu.git] / osfmk / mach / message.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 */
0a7de745 31/*
1c79356b
A
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34 * All Rights Reserved.
0a7de745 35 *
1c79356b
A
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
0a7de745 41 *
1c79356b
A
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
0a7de745 45 *
1c79356b 46 * Carnegie Mellon requests users of this software to return to
0a7de745 47 *
1c79356b
A
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
0a7de745 52 *
1c79356b
A
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
2d21ac55
A
56/*
57 * NOTICE: This file was modified by McAfee Research in 2004 to introduce
58 * support for mandatory and extensible security protections. This notice
59 * is included in support of clause 2.2 (b) of the Apple Public License,
60 * Version 2.0.
61 * Copyright (c) 2005 SPARTA, Inc.
62 */
1c79356b
A
63/*
64 */
65/*
66 * File: mach/message.h
67 *
68 * Mach IPC message and primitive function definitions.
69 */
70
0a7de745 71#ifndef _MACH_MESSAGE_H_
1c79356b
A
72#define _MACH_MESSAGE_H_
73
9bccf70c
A
74#include <stdint.h>
75#include <mach/port.h>
76#include <mach/boolean.h>
77#include <mach/kern_return.h>
78#include <mach/machine/vm_types.h>
1c79356b 79
91447636 80#include <sys/cdefs.h>
316670eb 81#include <sys/appleapiopts.h>
3e170ce0 82#include <Availability.h>
91447636 83
1c79356b
A
84/*
85 * The timeout mechanism uses mach_msg_timeout_t values,
86 * passed by value. The timeout units are milliseconds.
87 * It is controlled with the MACH_SEND_TIMEOUT
88 * and MACH_RCV_TIMEOUT options.
89 */
90
91typedef natural_t mach_msg_timeout_t;
92
93/*
94 * The value to be used when there is no timeout.
95 * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.)
96 */
97
0a7de745 98#define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0)
1c79356b
A
99
100/*
b0d623f7 101 * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. If it isn't on, it
1c79356b
A
102 * assumes the body of the message doesn't contain port rights or OOL
103 * data. The field is set in received messages. A user task must
104 * use caution in interpreting the body of a message if the bit isn't
105 * on, because the mach_msg_type's in the body might "lie" about the
106 * contents. If the bit isn't on, but the mach_msg_types
107 * in the body specify rights or OOL data, the behavior is undefined.
108 * (Ie, an error may or may not be produced.)
109 *
110 * The value of MACH_MSGH_BITS_REMOTE determines the interpretation
fe8ab488
A
111 * of the msgh_remote_port field. It is handled like a msgt_name,
112 * but must result in a send or send-once type right.
1c79356b
A
113 *
114 * The value of MACH_MSGH_BITS_LOCAL determines the interpretation
fe8ab488
A
115 * of the msgh_local_port field. It is handled like a msgt_name,
116 * and also must result in a send or send-once type right.
117 *
118 * The value of MACH_MSGH_BITS_VOUCHER determines the interpretation
119 * of the msgh_voucher_port field. It is handled like a msgt_name,
120 * but must result in a send right (and the msgh_voucher_port field
121 * must be the name of a send right to a Mach voucher kernel object.
1c79356b
A
122 *
123 * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote
124 * and local fields, into a single value suitable for msgh_bits.
125 *
126 * MACH_MSGH_BITS_CIRCULAR should be zero; is is used internally.
127 *
128 * The unused bits should be zero and are reserved for the kernel
129 * or for future interface expansion.
130 */
131
0a7de745 132#define MACH_MSGH_BITS_ZERO 0x00000000
1c79356b 133
0a7de745
A
134#define MACH_MSGH_BITS_REMOTE_MASK 0x0000001f
135#define MACH_MSGH_BITS_LOCAL_MASK 0x00001f00
136#define MACH_MSGH_BITS_VOUCHER_MASK 0x001f0000
fe8ab488 137
0a7de745
A
138#define MACH_MSGH_BITS_PORTS_MASK \
139 (MACH_MSGH_BITS_REMOTE_MASK | \
140 MACH_MSGH_BITS_LOCAL_MASK | \
141 MACH_MSGH_BITS_VOUCHER_MASK)
fe8ab488 142
0a7de745 143#define MACH_MSGH_BITS_COMPLEX 0x80000000U /* message is complex */
fe8ab488 144
0a7de745 145#define MACH_MSGH_BITS_USER 0x801f1f1fU /* allowed bits user->kernel */
fe8ab488 146
0a7de745
A
147#define MACH_MSGH_BITS_RAISEIMP 0x20000000U /* importance raised due to msg */
148#define MACH_MSGH_BITS_DENAP MACH_MSGH_BITS_RAISEIMP
1c79356b 149
0a7de745
A
150#define MACH_MSGH_BITS_IMPHOLDASRT 0x10000000U /* assertion help, userland private */
151#define MACH_MSGH_BITS_DENAPHOLDASRT MACH_MSGH_BITS_IMPHOLDASRT
1c79356b 152
0a7de745 153#define MACH_MSGH_BITS_CIRCULAR 0x10000000U /* message circular, kernel private */
fe8ab488 154
0a7de745 155#define MACH_MSGH_BITS_USED 0xb01f1f1fU
fe8ab488
A
156
157/* setter macros for the bits */
0a7de745
A
158#define MACH_MSGH_BITS(remote, local) /* legacy */ \
159 ((remote) | ((local) << 8))
160#define MACH_MSGH_BITS_SET_PORTS(remote, local, voucher) \
161 (((remote) & MACH_MSGH_BITS_REMOTE_MASK) | \
162 (((local) << 8) & MACH_MSGH_BITS_LOCAL_MASK) | \
fe8ab488 163 (((voucher) << 16) & MACH_MSGH_BITS_VOUCHER_MASK))
0a7de745 164#define MACH_MSGH_BITS_SET(remote, local, voucher, other) \
fe8ab488
A
165 (MACH_MSGH_BITS_SET_PORTS((remote), (local), (voucher)) \
166 | ((other) &~ MACH_MSGH_BITS_PORTS_MASK))
167
168/* getter macros for pulling values out of the bits field */
0a7de745
A
169#define MACH_MSGH_BITS_REMOTE(bits) \
170 ((bits) & MACH_MSGH_BITS_REMOTE_MASK)
171#define MACH_MSGH_BITS_LOCAL(bits) \
172 (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8)
173#define MACH_MSGH_BITS_VOUCHER(bits) \
174 (((bits) & MACH_MSGH_BITS_VOUCHER_MASK) >> 16)
175#define MACH_MSGH_BITS_PORTS(bits) \
fe8ab488 176 ((bits) & MACH_MSGH_BITS_PORTS_MASK)
0a7de745
A
177#define MACH_MSGH_BITS_OTHER(bits) \
178 ((bits) &~ MACH_MSGH_BITS_PORTS_MASK)
1c79356b 179
fe8ab488 180/* checking macros */
0a7de745 181#define MACH_MSGH_BITS_HAS_REMOTE(bits) \
fe8ab488 182 (MACH_MSGH_BITS_REMOTE(bits) != MACH_MSGH_BITS_ZERO)
0a7de745 183#define MACH_MSGH_BITS_HAS_LOCAL(bits) \
fe8ab488 184 (MACH_MSGH_BITS_LOCAL(bits) != MACH_MSGH_BITS_ZERO)
0a7de745 185#define MACH_MSGH_BITS_HAS_VOUCHER(bits) \
fe8ab488 186 (MACH_MSGH_BITS_VOUCHER(bits) != MACH_MSGH_BITS_ZERO)
0a7de745 187#define MACH_MSGH_BITS_IS_COMPLEX(bits) \
fe8ab488
A
188 (((bits) & MACH_MSGH_BITS_COMPLEX) != MACH_MSGH_BITS_ZERO)
189
190/* importance checking macros */
0a7de745 191#define MACH_MSGH_BITS_RAISED_IMPORTANCE(bits) \
fe8ab488 192 (((bits) & MACH_MSGH_BITS_RAISEIMP) != MACH_MSGH_BITS_ZERO)
0a7de745 193#define MACH_MSGH_BITS_HOLDS_IMPORTANCE_ASSERTION(bits) \
fe8ab488
A
194 (((bits) & MACH_MSGH_BITS_IMPHOLDASRT) != MACH_MSGH_BITS_ZERO)
195
1c79356b
A
196/*
197 * Every message starts with a message header.
b0d623f7 198 * Following the message header, if the message is complex, are a count
0a7de745
A
199 * of type descriptors and the type descriptors themselves
200 * (mach_msg_descriptor_t). The size of the message must be specified in
201 * bytes, and includes the message header, descriptor count, descriptors,
b0d623f7 202 * and inline data.
1c79356b
A
203 *
204 * The msgh_remote_port field specifies the destination of the message.
205 * It must specify a valid send or send-once right for a port.
206 *
207 * The msgh_local_port field specifies a "reply port". Normally,
208 * This field carries a send-once right that the receiver will use
209 * to reply to the message. It may carry the values MACH_PORT_NULL,
210 * MACH_PORT_DEAD, a send-once right, or a send right.
211 *
fe8ab488
A
212 * The msgh_voucher_port field specifies a Mach voucher port. Only
213 * send rights to kernel-implemented Mach Voucher kernel objects in
214 * addition to MACH_PORT_NULL or MACH_PORT_DEAD may be passed.
1c79356b
A
215 *
216 * The msgh_id field is uninterpreted by the message primitives.
217 * It normally carries information specifying the format
218 * or meaning of the message.
219 */
220
221typedef unsigned int mach_msg_bits_t;
0a7de745 222typedef natural_t mach_msg_size_t;
1c79356b
A
223typedef integer_t mach_msg_id_t;
224
1c79356b
A
225#define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0
226
39037602
A
227typedef unsigned int mach_msg_priority_t;
228
229#define MACH_MSG_PRIORITY_UNSPECIFIED (mach_msg_priority_t) 0
230
1c79356b
A
231typedef unsigned int mach_msg_type_name_t;
232
0a7de745
A
233#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */
234#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send right(s) */
235#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce right */
236#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send right(s) */
237#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */
238#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive right */
239#define MACH_MSG_TYPE_COPY_RECEIVE 22 /* NOT VALID */
240#define MACH_MSG_TYPE_DISPOSE_RECEIVE 24 /* must hold receive right */
241#define MACH_MSG_TYPE_DISPOSE_SEND 25 /* must hold send right(s) */
242#define MACH_MSG_TYPE_DISPOSE_SEND_ONCE 26 /* must hold sendonce right */
1c79356b
A
243
244typedef unsigned int mach_msg_copy_options_t;
245
0a7de745
A
246#define MACH_MSG_PHYSICAL_COPY 0
247#define MACH_MSG_VIRTUAL_COPY 1
248#define MACH_MSG_ALLOCATE 2
249#define MACH_MSG_OVERWRITE 3 /* deprecated */
1c79356b 250#ifdef MACH_KERNEL
0a7de745 251#define MACH_MSG_KALLOC_COPY_T 4
1c79356b
A
252#endif /* MACH_KERNEL */
253
b0d623f7 254/*
0a7de745
A
255 * In a complex mach message, the mach_msg_header_t is followed by
256 * a descriptor count, then an array of that number of descriptors
b0d623f7
A
257 * (mach_msg_*_descriptor_t). The type field of mach_msg_type_descriptor_t
258 * (which any descriptor can be cast to) indicates the flavor of the
259 * descriptor.
260 *
261 * Note that in LP64, the various types of descriptors are no longer all
0a7de745 262 * the same size as mach_msg_descriptor_t, so the array cannot be indexed
b0d623f7
A
263 * as expected.
264 */
265
1c79356b
A
266typedef unsigned int mach_msg_descriptor_type_t;
267
0a7de745
A
268#define MACH_MSG_PORT_DESCRIPTOR 0
269#define MACH_MSG_OOL_DESCRIPTOR 1
270#define MACH_MSG_OOL_PORTS_DESCRIPTOR 2
271#define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3
1c79356b 272
91447636 273#pragma pack(4)
1c79356b 274
0a7de745
A
275typedef struct{
276 natural_t pad1;
277 mach_msg_size_t pad2;
278 unsigned int pad3 : 24;
279 mach_msg_descriptor_type_t type : 8;
1c79356b
A
280} mach_msg_type_descriptor_t;
281
0a7de745
A
282typedef struct{
283 mach_port_t name;
b0d623f7
A
284#if !(defined(KERNEL) && defined(__LP64__))
285// Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes
0a7de745 286 mach_msg_size_t pad1;
b0d623f7 287#endif
0a7de745
A
288 unsigned int pad2 : 16;
289 mach_msg_type_name_t disposition : 8;
290 mach_msg_descriptor_type_t type : 8;
b0d623f7 291#if defined(KERNEL)
0a7de745 292 uint32_t pad_end;
b0d623f7 293#endif
1c79356b
A
294} mach_msg_port_descriptor_t;
295
0a7de745
A
296typedef struct{
297 uint32_t address;
298 mach_msg_size_t size;
299 boolean_t deallocate: 8;
300 mach_msg_copy_options_t copy: 8;
301 unsigned int pad1: 8;
302 mach_msg_descriptor_type_t type: 8;
91447636
A
303} mach_msg_ool_descriptor32_t;
304
0a7de745
A
305typedef struct{
306 uint64_t address;
307 boolean_t deallocate: 8;
308 mach_msg_copy_options_t copy: 8;
309 unsigned int pad1: 8;
310 mach_msg_descriptor_type_t type: 8;
311 mach_msg_size_t size;
91447636
A
312} mach_msg_ool_descriptor64_t;
313
0a7de745
A
314typedef struct{
315 void* address;
91447636 316#if !defined(__LP64__)
0a7de745 317 mach_msg_size_t size;
91447636 318#endif
0a7de745
A
319 boolean_t deallocate: 8;
320 mach_msg_copy_options_t copy: 8;
321 unsigned int pad1: 8;
322 mach_msg_descriptor_type_t type: 8;
91447636 323#if defined(__LP64__)
0a7de745 324 mach_msg_size_t size;
91447636 325#endif
b0d623f7 326#if defined(KERNEL) && !defined(__LP64__)
0a7de745 327 uint32_t pad_end;
b0d623f7 328#endif
1c79356b
A
329} mach_msg_ool_descriptor_t;
330
0a7de745
A
331typedef struct{
332 uint32_t address;
333 mach_msg_size_t count;
334 boolean_t deallocate: 8;
335 mach_msg_copy_options_t copy: 8;
336 mach_msg_type_name_t disposition : 8;
337 mach_msg_descriptor_type_t type : 8;
91447636
A
338} mach_msg_ool_ports_descriptor32_t;
339
0a7de745
A
340typedef struct{
341 uint64_t address;
342 boolean_t deallocate: 8;
343 mach_msg_copy_options_t copy: 8;
344 mach_msg_type_name_t disposition : 8;
345 mach_msg_descriptor_type_t type : 8;
346 mach_msg_size_t count;
91447636
A
347} mach_msg_ool_ports_descriptor64_t;
348
0a7de745
A
349typedef struct{
350 void* address;
91447636 351#if !defined(__LP64__)
0a7de745 352 mach_msg_size_t count;
91447636 353#endif
0a7de745
A
354 boolean_t deallocate: 8;
355 mach_msg_copy_options_t copy: 8;
356 mach_msg_type_name_t disposition : 8;
357 mach_msg_descriptor_type_t type : 8;
91447636 358#if defined(__LP64__)
0a7de745 359 mach_msg_size_t count;
91447636 360#endif
b0d623f7 361#if defined(KERNEL) && !defined(__LP64__)
0a7de745 362 uint32_t pad_end;
b0d623f7 363#endif
1c79356b
A
364} mach_msg_ool_ports_descriptor_t;
365
91447636
A
366/*
367 * LP64support - This union definition is not really
368 * appropriate in LP64 mode because not all descriptors
369 * are of the same size in that environment.
370 */
b0d623f7 371#if defined(__LP64__) && defined(KERNEL)
0a7de745
A
372typedef union{
373 mach_msg_port_descriptor_t port;
374 mach_msg_ool_descriptor32_t out_of_line;
375 mach_msg_ool_ports_descriptor32_t ool_ports;
376 mach_msg_type_descriptor_t type;
b0d623f7
A
377} mach_msg_descriptor_t;
378#else
0a7de745
A
379typedef union{
380 mach_msg_port_descriptor_t port;
381 mach_msg_ool_descriptor_t out_of_line;
382 mach_msg_ool_ports_descriptor_t ool_ports;
383 mach_msg_type_descriptor_t type;
1c79356b 384} mach_msg_descriptor_t;
b0d623f7 385#endif
1c79356b 386
0a7de745
A
387typedef struct{
388 mach_msg_size_t msgh_descriptor_count;
1c79356b
A
389} mach_msg_body_t;
390
391#define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0
392#define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0
393
0a7de745
A
394typedef struct{
395 mach_msg_bits_t msgh_bits;
396 mach_msg_size_t msgh_size;
397 mach_port_t msgh_remote_port;
398 mach_port_t msgh_local_port;
399 mach_port_name_t msgh_voucher_port;
400 mach_msg_id_t msgh_id;
1c79356b
A
401} mach_msg_header_t;
402
0a7de745
A
403#define msgh_reserved msgh_voucher_port
404#define MACH_MSG_NULL (mach_msg_header_t *) 0
1c79356b 405
0a7de745
A
406typedef struct{
407 mach_msg_header_t header;
408 mach_msg_body_t body;
1c79356b
A
409} mach_msg_base_t;
410
0a7de745 411typedef unsigned int mach_msg_trailer_type_t;
1c79356b 412
0a7de745 413#define MACH_MSG_TRAILER_FORMAT_0 0
1c79356b 414
0a7de745 415typedef unsigned int mach_msg_trailer_size_t;
39236c6e 416typedef char *mach_msg_trailer_info_t;
1c79356b 417
0a7de745
A
418typedef struct{
419 mach_msg_trailer_type_t msgh_trailer_type;
420 mach_msg_trailer_size_t msgh_trailer_size;
1c79356b
A
421} mach_msg_trailer_t;
422
fe8ab488
A
423/*
424 * The msgh_seqno field carries a sequence number
425 * associated with the received-from port. A port's
426 * sequence number is incremented every time a message
427 * is received from it and included in the received
428 * trailer to help put messages back in sequence if
429 * multiple threads receive and/or process received
430 * messages.
431 */
0a7de745
A
432typedef struct{
433 mach_msg_trailer_type_t msgh_trailer_type;
434 mach_msg_trailer_size_t msgh_trailer_size;
435 mach_port_seqno_t msgh_seqno;
1c79356b
A
436} mach_msg_seqno_trailer_t;
437
0a7de745
A
438typedef struct{
439 unsigned int val[2];
1c79356b
A
440} security_token_t;
441
0a7de745
A
442typedef struct{
443 mach_msg_trailer_type_t msgh_trailer_type;
444 mach_msg_trailer_size_t msgh_trailer_size;
445 mach_port_seqno_t msgh_seqno;
446 security_token_t msgh_sender;
1c79356b
A
447} mach_msg_security_trailer_t;
448
e5568f75
A
449/*
450 * The audit token is an opaque token which identifies
451 * Mach tasks and senders of Mach messages as subjects
452 * to the BSM audit system. Only the appropriate BSM
453 * library routines should be used to interpret the
454 * contents of the audit token as the representation
455 * of the subject identity within the token may change
456 * over time.
457 */
0a7de745
A
458typedef struct{
459 unsigned int val[8];
55e303ae
A
460} audit_token_t;
461
0a7de745
A
462typedef struct{
463 mach_msg_trailer_type_t msgh_trailer_type;
464 mach_msg_trailer_size_t msgh_trailer_size;
465 mach_port_seqno_t msgh_seqno;
466 security_token_t msgh_sender;
467 audit_token_t msgh_audit;
55e303ae 468} mach_msg_audit_trailer_t;
1c79356b 469
0a7de745
A
470typedef struct{
471 mach_msg_trailer_type_t msgh_trailer_type;
472 mach_msg_trailer_size_t msgh_trailer_size;
473 mach_port_seqno_t msgh_seqno;
474 security_token_t msgh_sender;
475 audit_token_t msgh_audit;
476 mach_port_context_t msgh_context;
b0d623f7
A
477} mach_msg_context_trailer_t;
478
5ba3f43e 479#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
0a7de745
A
480typedef struct{
481 mach_msg_trailer_type_t msgh_trailer_type;
482 mach_msg_trailer_size_t msgh_trailer_size;
483 mach_port_seqno_t msgh_seqno;
484 security_token_t msgh_sender;
485 audit_token_t msgh_audit;
486 mach_port_context32_t msgh_context;
5ba3f43e
A
487} mach_msg_context_trailer32_t;
488
0a7de745
A
489typedef struct{
490 mach_msg_trailer_type_t msgh_trailer_type;
491 mach_msg_trailer_size_t msgh_trailer_size;
492 mach_port_seqno_t msgh_seqno;
493 security_token_t msgh_sender;
494 audit_token_t msgh_audit;
495 mach_port_context64_t msgh_context;
5ba3f43e
A
496} mach_msg_context_trailer64_t;
497#endif
fe8ab488
A
498
499
0a7de745
A
500typedef struct{
501 mach_port_name_t sender;
2d21ac55
A
502} msg_labels_t;
503
0a7de745
A
504/*
505 * Trailer type to pass MAC policy label info as a mach message trailer.
506 *
507 */
508
509typedef struct{
510 mach_msg_trailer_type_t msgh_trailer_type;
511 mach_msg_trailer_size_t msgh_trailer_size;
512 mach_port_seqno_t msgh_seqno;
513 security_token_t msgh_sender;
514 audit_token_t msgh_audit;
515 mach_port_context_t msgh_context;
516 int msgh_ad;
517 msg_labels_t msgh_labels;
2d21ac55
A
518} mach_msg_mac_trailer_t;
519
5ba3f43e 520#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
0a7de745
A
521typedef struct{
522 mach_msg_trailer_type_t msgh_trailer_type;
523 mach_msg_trailer_size_t msgh_trailer_size;
524 mach_port_seqno_t msgh_seqno;
525 security_token_t msgh_sender;
526 audit_token_t msgh_audit;
527 mach_port_context32_t msgh_context;
528 int msgh_ad;
529 msg_labels_t msgh_labels;
5ba3f43e
A
530} mach_msg_mac_trailer32_t;
531
0a7de745
A
532typedef struct{
533 mach_msg_trailer_type_t msgh_trailer_type;
534 mach_msg_trailer_size_t msgh_trailer_size;
535 mach_port_seqno_t msgh_seqno;
536 security_token_t msgh_sender;
537 audit_token_t msgh_audit;
538 mach_port_context64_t msgh_context;
539 int msgh_ad;
540 msg_labels_t msgh_labels;
5ba3f43e
A
541} mach_msg_mac_trailer64_t;
542
543#endif
fe8ab488 544
1c79356b 545#define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t)
55e303ae
A
546
547/*
548 * These values can change from release to release - but clearly
549 * code cannot request additional trailer elements one was not
550 * compiled to understand. Therefore, it is safe to use this
551 * constant when the same module specified the receive options.
552 * Otherwise, you run the risk that the options requested by
553 * another module may exceed the local modules notion of
554 * MAX_TRAILER_SIZE.
555 */
5ba3f43e
A
556#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
557typedef mach_msg_mac_trailer64_t mach_msg_max_trailer64_t;
558typedef mach_msg_mac_trailer32_t mach_msg_max_trailer32_t;
559#endif
39236c6e 560
2d21ac55 561typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t;
b0d623f7 562#define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t))
55e303ae
A
563
564/*
565 * Legacy requirements keep us from ever updating these defines (even
566 * when the format_0 trailers gain new option data fields in the future).
567 * Therefore, they shouldn't be used going forward. Instead, the sizes
568 * should be compared against the specific element size requested using
569 * REQUESTED_TRAILER_SIZE.
570 */
571typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t;
2d21ac55
A
572
573/*typedef mach_msg_mac_trailer_t mach_msg_format_0_trailer_t;
0a7de745 574 */
2d21ac55 575
55e303ae 576#define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t)
1c79356b
A
577
578#define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} }
579extern security_token_t KERNEL_SECURITY_TOKEN;
580
55e303ae
A
581#define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} }
582extern audit_token_t KERNEL_AUDIT_TOKEN;
583
0a7de745 584typedef integer_t mach_msg_options_t;
1c79356b 585
0a7de745
A
586typedef struct{
587 mach_msg_header_t header;
1c79356b
A
588} mach_msg_empty_send_t;
589
0a7de745
A
590typedef struct{
591 mach_msg_header_t header;
592 mach_msg_trailer_t trailer;
1c79356b
A
593} mach_msg_empty_rcv_t;
594
0a7de745
A
595typedef union{
596 mach_msg_empty_send_t send;
597 mach_msg_empty_rcv_t rcv;
1c79356b
A
598} mach_msg_empty_t;
599
91447636
A
600#pragma pack()
601
1c79356b 602/* utility to round the message size - will become machine dependent */
0a7de745
A
603#define round_msg(x) (((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \
604 ~(sizeof (natural_t) - 1))
1c79356b
A
605
606/*
607 * There is no fixed upper bound to the size of Mach messages.
608 */
0a7de745 609#define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0)
1c79356b 610
316670eb
A
611#if defined(__APPLE_API_PRIVATE)
612/*
613 * But architectural limits of a given implementation, or
614 * temporal conditions may cause unpredictable send failures
615 * for messages larger than MACH_MSG_SIZE_RELIABLE.
616 *
617 * In either case, waiting for memory is [currently] outside
618 * the scope of send timeout values provided to IPC.
619 */
0a7de745 620#define MACH_MSG_SIZE_RELIABLE ((mach_msg_size_t) 256 * 1024)
316670eb 621#endif
1c79356b
A
622/*
623 * Compatibility definitions, for code written
624 * when there was a msgh_kind instead of msgh_seqno.
625 */
0a7de745
A
626#define MACH_MSGH_KIND_NORMAL 0x00000000
627#define MACH_MSGH_KIND_NOTIFICATION 0x00000001
628#define msgh_kind msgh_seqno
629#define mach_msg_kind_t mach_port_seqno_t
1c79356b 630
1c79356b
A
631typedef natural_t mach_msg_type_size_t;
632typedef natural_t mach_msg_type_number_t;
633
634/*
635 * Values received/carried in messages. Tells the receiver what
636 * sort of port right he now has.
637 *
638 * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name
639 * which should remain uninterpreted by the kernel. (Port rights
640 * are not transferred, just the port name.)
641 */
642
0a7de745 643#define MACH_MSG_TYPE_PORT_NONE 0
1c79356b 644
0a7de745
A
645#define MACH_MSG_TYPE_PORT_NAME 15
646#define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE
647#define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND
648#define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE
1c79356b 649
0a7de745 650#define MACH_MSG_TYPE_LAST 22 /* Last assigned */
1c79356b
A
651
652/*
653 * A dummy value. Mostly used to indicate that the actual value
654 * will be filled in later, dynamically.
655 */
656
0a7de745 657#define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1)
1c79356b
A
658
659/*
660 * Is a given item a port type?
661 */
662
0a7de745
A
663#define MACH_MSG_TYPE_PORT_ANY(x) \
664 (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
1c79356b
A
665 ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
666
0a7de745
A
667#define MACH_MSG_TYPE_PORT_ANY_SEND(x) \
668 (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \
1c79356b
A
669 ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
670
0a7de745
A
671#define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \
672 (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
1c79356b
A
673 ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE))
674
675typedef integer_t mach_msg_option_t;
676
0a7de745 677#define MACH_MSG_OPTION_NONE 0x00000000
1c79356b 678
0a7de745
A
679#define MACH_SEND_MSG 0x00000001
680#define MACH_RCV_MSG 0x00000002
1c79356b 681
0a7de745
A
682#define MACH_RCV_LARGE 0x00000004 /* report large message sizes */
683#define MACH_RCV_LARGE_IDENTITY 0x00000008 /* identify source of large messages */
39236c6e 684
0a7de745 685#define MACH_SEND_TIMEOUT 0x00000010 /* timeout value applies to send */
39037602 686#define MACH_SEND_OVERRIDE 0x00000020 /* priority override for send */
0a7de745
A
687#define MACH_SEND_INTERRUPT 0x00000040 /* don't restart interrupted sends */
688#define MACH_SEND_NOTIFY 0x00000080 /* arm send-possible notify */
689#define MACH_SEND_ALWAYS 0x00010000 /* ignore qlimits - kernel only */
690#define MACH_SEND_TRAILER 0x00020000 /* sender-provided trailer */
39236c6e 691#define MACH_SEND_NOIMPORTANCE 0x00040000 /* msg won't carry importance */
0a7de745
A
692#define MACH_SEND_NODENAP MACH_SEND_NOIMPORTANCE
693#define MACH_SEND_IMPORTANCE 0x00080000 /* msg carries importance - kernel only */
694#define MACH_SEND_SYNC_OVERRIDE 0x00100000 /* msg should do sync ipc override */
695#define MACH_SEND_PROPAGATE_QOS 0x00200000 /* IPC should propagate the caller's QoS */
696#define MACH_SEND_SYNC_USE_THRPRI MACH_SEND_PROPAGATE_QOS /* obsolete name */
d9a64523 697#define MACH_SEND_KERNEL 0x00400000 /* full send from kernel space - kernel only */
39236c6e 698
0a7de745
A
699#define MACH_RCV_TIMEOUT 0x00000100 /* timeout value applies to receive */
700#define MACH_RCV_NOTIFY 0x00000200 /* reserved - legacy */
701#define MACH_RCV_INTERRUPT 0x00000400 /* don't restart interrupted receive */
702#define MACH_RCV_VOUCHER 0x00000800 /* willing to receive voucher port */
703#define MACH_RCV_OVERWRITE 0x00001000 /* scatter receive (deprecated) */
704#define MACH_RCV_SYNC_WAIT 0x00004000 /* sync waiter waiting for rcv */
1c79356b 705
39037602
A
706#ifdef XNU_KERNEL_PRIVATE
707
0a7de745 708#define MACH_RCV_STACK 0x00002000 /* receive into highest addr of buffer */
39037602
A
709
710/*
711 * NOTE:
712 * This internal-only flag is intended for use by a single thread per-port/set!
713 * If more than one thread attempts to MACH_PEEK_MSG on a port or set, one of
714 * the threads may miss messages (in fact, it may never wake up).
715 */
0a7de745 716#define MACH_PEEK_MSG 0x80000000 /* receive, but leave msgs queued */
39037602
A
717
718#endif
719
0a7de745 720/*
1c79356b 721 * NOTE: a 0x00------ RCV mask implies to ask for
0a7de745 722 * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements,
1c79356b 723 * which is equivalent to a mach_msg_trailer_t.
2d21ac55
A
724 *
725 * XXXMAC: unlike the rest of the MACH_RCV_* flags, MACH_RCV_TRAILER_LABELS
0a7de745 726 * needs its own private bit since we only calculate its fields when absolutely
b0d623f7 727 * required.
1c79356b
A
728 */
729#define MACH_RCV_TRAILER_NULL 0
730#define MACH_RCV_TRAILER_SEQNO 1
731#define MACH_RCV_TRAILER_SENDER 2
55e303ae 732#define MACH_RCV_TRAILER_AUDIT 3
b0d623f7
A
733#define MACH_RCV_TRAILER_CTX 4
734#define MACH_RCV_TRAILER_AV 7
735#define MACH_RCV_TRAILER_LABELS 8
1c79356b 736
0a7de745
A
737#define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28)
738#define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24)
739#define MACH_RCV_TRAILER_MASK ((0xf << 24))
1c79356b 740
1c79356b 741#define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf)
2d21ac55 742
39236c6e
A
743#ifdef MACH_KERNEL_PRIVATE
744/* The options that the kernel honors when passed from user space */
39037602 745#define MACH_SEND_USER (MACH_SEND_MSG | MACH_SEND_TIMEOUT | \
0a7de745
A
746 MACH_SEND_NOTIFY | MACH_SEND_OVERRIDE | \
747 MACH_SEND_TRAILER | MACH_SEND_NOIMPORTANCE | \
748 MACH_SEND_SYNC_OVERRIDE | MACH_SEND_PROPAGATE_QOS)
39236c6e 749
39037602 750#define MACH_RCV_USER (MACH_RCV_MSG | MACH_RCV_TIMEOUT | \
0a7de745
A
751 MACH_RCV_LARGE | MACH_RCV_LARGE_IDENTITY | \
752 MACH_RCV_VOUCHER | MACH_RCV_TRAILER_MASK | \
753 MACH_RCV_SYNC_WAIT)
39236c6e 754
0a7de745 755#define MACH_MSG_OPTION_USER (MACH_SEND_USER | MACH_RCV_USER)
39236c6e
A
756
757/* The options implemented by the library interface to mach_msg et. al. */
0a7de745 758#define MACH_MSG_OPTION_LIB (MACH_SEND_INTERRUPT | MACH_RCV_INTERRUPT)
39236c6e 759
490019cf
A
760/*
761 * Default options to use when sending from the kernel.
762 *
763 * Until we are sure of its effects, we are disabling
764 * importance donation from the kernel-side of user
765 * threads in importance-donating tasks.
766 * (11938665 & 23925818)
767 */
39236c6e 768#define MACH_SEND_KERNEL_DEFAULT (MACH_SEND_MSG | \
0a7de745 769 MACH_SEND_ALWAYS | MACH_SEND_NOIMPORTANCE)
39236c6e
A
770
771#endif /* MACH_KERNEL_PRIVATE */
772
0a7de745
A
773/*
774 * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS,
b0d623f7 775 * we just fall through to mach_msg_max_trailer_t.
2d21ac55 776 * This is correct behavior since mach_msg_max_trailer_t is defined as
b0d623f7 777 * mac_msg_mac_trailer_t which is used for the LABELS trailer.
0a7de745 778 * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed
b0d623f7 779 * with one of the other options.
2d21ac55 780 */
316670eb 781
0a7de745
A
782#define REQUESTED_TRAILER_SIZE_NATIVE(y) \
783 ((mach_msg_trailer_size_t) \
784 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \
785 sizeof(mach_msg_trailer_t) : \
786 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \
787 sizeof(mach_msg_seqno_trailer_t) : \
788 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \
789 sizeof(mach_msg_security_trailer_t) : \
790 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \
791 sizeof(mach_msg_audit_trailer_t) : \
792 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \
793 sizeof(mach_msg_context_trailer_t) : \
794 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \
795 sizeof(mach_msg_mac_trailer_t) : \
b0d623f7 796 sizeof(mach_msg_max_trailer_t))))))))
2d21ac55 797
316670eb
A
798
799#ifdef XNU_KERNEL_PRIVATE
800
5ba3f43e 801#if defined(__arm64__)
0a7de745
A
802#define REQUESTED_TRAILER_SIZE(is64, y) \
803 ((mach_msg_trailer_size_t) \
804 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \
805 sizeof(mach_msg_trailer_t) : \
806 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \
807 sizeof(mach_msg_seqno_trailer_t) : \
808 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \
809 sizeof(mach_msg_security_trailer_t) : \
810 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \
811 sizeof(mach_msg_audit_trailer_t) : \
812 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \
5ba3f43e 813 ((is64) ? sizeof(mach_msg_context_trailer64_t) : sizeof(mach_msg_context_trailer32_t)) : \
0a7de745 814 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \
5ba3f43e
A
815 ((is64) ? sizeof(mach_msg_mac_trailer64_t) : sizeof(mach_msg_mac_trailer32_t)) : \
816 sizeof(mach_msg_max_trailer_t))))))))
817#else
316670eb 818#define REQUESTED_TRAILER_SIZE(is64, y) REQUESTED_TRAILER_SIZE_NATIVE(y)
5ba3f43e 819#endif
316670eb
A
820
821#else /* XNU_KERNEL_PRIVATE */
822#define REQUESTED_TRAILER_SIZE(y) REQUESTED_TRAILER_SIZE_NATIVE(y)
823#endif /* XNU_KERNEL_PRIVATE */
824
1c79356b
A
825/*
826 * Much code assumes that mach_msg_return_t == kern_return_t.
827 * This definition is useful for descriptive purposes.
828 *
829 * See <mach/error.h> for the format of error codes.
830 * IPC errors are system 4. Send errors are subsystem 0;
831 * receive errors are subsystem 1. The code field is always non-zero.
832 * The high bits of the code field communicate extra information
833 * for some error codes. MACH_MSG_MASK masks off these special bits.
834 */
835
836typedef kern_return_t mach_msg_return_t;
837
0a7de745
A
838#define MACH_MSG_SUCCESS 0x00000000
839
840
841#define MACH_MSG_MASK 0x00003e00
842/* All special error code bits defined below. */
843#define MACH_MSG_IPC_SPACE 0x00002000
844/* No room in IPC name space for another capability name. */
845#define MACH_MSG_VM_SPACE 0x00001000
846/* No room in VM address space for out-of-line memory. */
847#define MACH_MSG_IPC_KERNEL 0x00000800
848/* Kernel resource shortage handling an IPC capability. */
849#define MACH_MSG_VM_KERNEL 0x00000400
850/* Kernel resource shortage handling out-of-line memory. */
851
852#define MACH_SEND_IN_PROGRESS 0x10000001
853/* Thread is waiting to send. (Internal use only.) */
854#define MACH_SEND_INVALID_DATA 0x10000002
855/* Bogus in-line data. */
856#define MACH_SEND_INVALID_DEST 0x10000003
857/* Bogus destination port. */
858#define MACH_SEND_TIMED_OUT 0x10000004
859/* Message not sent before timeout expired. */
860#define MACH_SEND_INVALID_VOUCHER 0x10000005
861/* Bogus voucher port. */
862#define MACH_SEND_INTERRUPTED 0x10000007
863/* Software interrupt. */
864#define MACH_SEND_MSG_TOO_SMALL 0x10000008
865/* Data doesn't contain a complete message. */
866#define MACH_SEND_INVALID_REPLY 0x10000009
867/* Bogus reply port. */
868#define MACH_SEND_INVALID_RIGHT 0x1000000a
869/* Bogus port rights in the message body. */
870#define MACH_SEND_INVALID_NOTIFY 0x1000000b
871/* Bogus notify port argument. */
872#define MACH_SEND_INVALID_MEMORY 0x1000000c
873/* Invalid out-of-line memory pointer. */
874#define MACH_SEND_NO_BUFFER 0x1000000d
875/* No message buffer is available. */
876#define MACH_SEND_TOO_LARGE 0x1000000e
877/* Send is too large for port */
878#define MACH_SEND_INVALID_TYPE 0x1000000f
879/* Invalid msg-type specification. */
880#define MACH_SEND_INVALID_HEADER 0x10000010
881/* A field in the header had a bad value. */
882#define MACH_SEND_INVALID_TRAILER 0x10000011
883/* The trailer to be sent does not match kernel format. */
884#define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015
885/* compatibility: no longer a returned error */
886
887#define MACH_RCV_IN_PROGRESS 0x10004001
888/* Thread is waiting for receive. (Internal use only.) */
889#define MACH_RCV_INVALID_NAME 0x10004002
890/* Bogus name for receive port/port-set. */
891#define MACH_RCV_TIMED_OUT 0x10004003
892/* Didn't get a message within the timeout value. */
893#define MACH_RCV_TOO_LARGE 0x10004004
894/* Message buffer is not large enough for inline data. */
895#define MACH_RCV_INTERRUPTED 0x10004005
896/* Software interrupt. */
897#define MACH_RCV_PORT_CHANGED 0x10004006
898/* compatibility: no longer a returned error */
899#define MACH_RCV_INVALID_NOTIFY 0x10004007
900/* Bogus notify port argument. */
901#define MACH_RCV_INVALID_DATA 0x10004008
902/* Bogus message buffer for inline data. */
903#define MACH_RCV_PORT_DIED 0x10004009
904/* Port/set was sent away/died during receive. */
905#define MACH_RCV_IN_SET 0x1000400a
906/* compatibility: no longer a returned error */
907#define MACH_RCV_HEADER_ERROR 0x1000400b
908/* Error receiving message header. See special bits. */
909#define MACH_RCV_BODY_ERROR 0x1000400c
910/* Error receiving message body. See special bits. */
911#define MACH_RCV_INVALID_TYPE 0x1000400d
912/* Invalid msg-type specification in scatter list. */
913#define MACH_RCV_SCATTER_SMALL 0x1000400e
914/* Out-of-line overwrite region is not large enough */
915#define MACH_RCV_INVALID_TRAILER 0x1000400f
916/* trailer type or number of trailer elements not supported */
1c79356b 917#define MACH_RCV_IN_PROGRESS_TIMED 0x10004011
0a7de745 918/* Waiting for receive with timeout. (Internal use only.) */
1c79356b 919
39037602 920#ifdef XNU_KERNEL_PRIVATE
0a7de745
A
921#define MACH_PEEK_IN_PROGRESS 0x10008001
922/* Waiting for a peek. (Internal use only.) */
923#define MACH_PEEK_READY 0x10008002
924/* Waiting for a peek. (Internal use only.) */
39037602
A
925#endif
926
91447636
A
927
928__BEGIN_DECLS
929
9bccf70c
A
930/*
931 * Routine: mach_msg_overwrite
932 * Purpose:
933 * Send and/or receive a message. If the message operation
934 * is interrupted, and the user did not request an indication
935 * of that fact, then restart the appropriate parts of the
936 * operation silently (trap version does not restart).
937 *
938 * Distinct send and receive buffers may be specified. If
939 * no separate receive buffer is specified, the msg parameter
940 * will be used for both send and receive operations.
941 *
942 * In addition to a distinct receive buffer, that buffer may
943 * already contain scatter control information to direct the
944 * receiving of the message.
945 */
3e170ce0 946__WATCHOS_PROHIBITED __TVOS_PROHIBITED
0a7de745
A
947extern mach_msg_return_t mach_msg_overwrite(
948 mach_msg_header_t *msg,
949 mach_msg_option_t option,
950 mach_msg_size_t send_size,
951 mach_msg_size_t rcv_size,
952 mach_port_name_t rcv_name,
953 mach_msg_timeout_t timeout,
954 mach_port_name_t notify,
955 mach_msg_header_t *rcv_msg,
956 mach_msg_size_t rcv_limit);
957
958#ifndef KERNEL
91447636 959
9bccf70c
A
960/*
961 * Routine: mach_msg
962 * Purpose:
963 * Send and/or receive a message. If the message operation
964 * is interrupted, and the user did not request an indication
965 * of that fact, then restart the appropriate parts of the
966 * operation silently (trap version does not restart).
967 */
3e170ce0 968__WATCHOS_PROHIBITED __TVOS_PROHIBITED
0a7de745
A
969extern mach_msg_return_t mach_msg(
970 mach_msg_header_t *msg,
971 mach_msg_option_t option,
972 mach_msg_size_t send_size,
973 mach_msg_size_t rcv_size,
974 mach_port_name_t rcv_name,
975 mach_msg_timeout_t timeout,
976 mach_port_name_t notify);
1c79356b 977
fe8ab488
A
978/*
979 * Routine: mach_voucher_deallocate
980 * Purpose:
981 * Deallocate a mach voucher created or received in a message. Drops
982 * one (send right) reference to the voucher.
983 */
3e170ce0 984__WATCHOS_PROHIBITED __TVOS_PROHIBITED
0a7de745
A
985extern kern_return_t mach_voucher_deallocate(
986 mach_port_name_t voucher);
fe8ab488 987
b0d623f7
A
988#elif defined(MACH_KERNEL_PRIVATE)
989
0a7de745 990extern mach_msg_return_t mach_msg_receive_results(mach_msg_size_t *size);
b0d623f7 991
0a7de745 992#endif /* KERNEL */
91447636
A
993
994__END_DECLS
995
0a7de745 996#endif /* _MACH_MESSAGE_H_ */