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