2 * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34 * All Rights Reserved.
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.
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.
46 * Carnegie Mellon requests users of this software to return to
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
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,
61 * Copyright (c) 2005 SPARTA, Inc.
66 * File: mach/message.h
68 * Mach IPC message and primitive function definitions.
71 #ifndef _MACH_MESSAGE_H_
72 #define _MACH_MESSAGE_H_
75 #include <mach/port.h>
76 #include <mach/boolean.h>
77 #include <mach/kern_return.h>
78 #include <mach/machine/vm_types.h>
80 #include <sys/cdefs.h>
81 #include <sys/appleapiopts.h>
82 #include <Availability.h>
83 #if !KERNEL && PRIVATE
84 #include <TargetConditionals.h>
88 * The timeout mechanism uses mach_msg_timeout_t values,
89 * passed by value. The timeout units are milliseconds.
90 * It is controlled with the MACH_SEND_TIMEOUT
91 * and MACH_RCV_TIMEOUT options.
94 typedef natural_t mach_msg_timeout_t
;
97 * The value to be used when there is no timeout.
98 * (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.)
101 #define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0)
104 * The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. If it isn't on, it
105 * assumes the body of the message doesn't contain port rights or OOL
106 * data. The field is set in received messages. A user task must
107 * use caution in interpreting the body of a message if the bit isn't
108 * on, because the mach_msg_type's in the body might "lie" about the
109 * contents. If the bit isn't on, but the mach_msg_types
110 * in the body specify rights or OOL data, the behavior is undefined.
111 * (Ie, an error may or may not be produced.)
113 * The value of MACH_MSGH_BITS_REMOTE determines the interpretation
114 * of the msgh_remote_port field. It is handled like a msgt_name,
115 * but must result in a send or send-once type right.
117 * The value of MACH_MSGH_BITS_LOCAL determines the interpretation
118 * of the msgh_local_port field. It is handled like a msgt_name,
119 * and also must result in a send or send-once type right.
121 * The value of MACH_MSGH_BITS_VOUCHER determines the interpretation
122 * of the msgh_voucher_port field. It is handled like a msgt_name,
123 * but must result in a send right (and the msgh_voucher_port field
124 * must be the name of a send right to a Mach voucher kernel object.
126 * MACH_MSGH_BITS() combines two MACH_MSG_TYPE_* values, for the remote
127 * and local fields, into a single value suitable for msgh_bits.
129 * MACH_MSGH_BITS_CIRCULAR should be zero; is is used internally.
131 * The unused bits should be zero and are reserved for the kernel
132 * or for future interface expansion.
135 #define MACH_MSGH_BITS_ZERO 0x00000000
137 #define MACH_MSGH_BITS_REMOTE_MASK 0x0000001f
138 #define MACH_MSGH_BITS_LOCAL_MASK 0x00001f00
139 #define MACH_MSGH_BITS_VOUCHER_MASK 0x001f0000
141 #define MACH_MSGH_BITS_PORTS_MASK \
142 (MACH_MSGH_BITS_REMOTE_MASK | \
143 MACH_MSGH_BITS_LOCAL_MASK | \
144 MACH_MSGH_BITS_VOUCHER_MASK)
146 #define MACH_MSGH_BITS_COMPLEX 0x80000000U /* message is complex */
148 #define MACH_MSGH_BITS_USER 0x801f1f1fU /* allowed bits user->kernel */
150 #define MACH_MSGH_BITS_RAISEIMP 0x20000000U /* importance raised due to msg */
151 #define MACH_MSGH_BITS_DENAP MACH_MSGH_BITS_RAISEIMP
153 #define MACH_MSGH_BITS_IMPHOLDASRT 0x10000000U /* assertion help, userland private */
154 #define MACH_MSGH_BITS_DENAPHOLDASRT MACH_MSGH_BITS_IMPHOLDASRT
156 #define MACH_MSGH_BITS_CIRCULAR 0x10000000U /* message circular, kernel private */
158 #define MACH_MSGH_BITS_USED 0xb01f1f1fU
160 /* setter macros for the bits */
161 #define MACH_MSGH_BITS(remote, local) /* legacy */ \
162 ((remote) | ((local) << 8))
163 #define MACH_MSGH_BITS_SET_PORTS(remote, local, voucher) \
164 (((remote) & MACH_MSGH_BITS_REMOTE_MASK) | \
165 (((local) << 8) & MACH_MSGH_BITS_LOCAL_MASK) | \
166 (((voucher) << 16) & MACH_MSGH_BITS_VOUCHER_MASK))
167 #define MACH_MSGH_BITS_SET(remote, local, voucher, other) \
168 (MACH_MSGH_BITS_SET_PORTS((remote), (local), (voucher)) \
169 | ((other) &~ MACH_MSGH_BITS_PORTS_MASK))
171 /* getter macros for pulling values out of the bits field */
172 #define MACH_MSGH_BITS_REMOTE(bits) \
173 ((bits) & MACH_MSGH_BITS_REMOTE_MASK)
174 #define MACH_MSGH_BITS_LOCAL(bits) \
175 (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8)
176 #define MACH_MSGH_BITS_VOUCHER(bits) \
177 (((bits) & MACH_MSGH_BITS_VOUCHER_MASK) >> 16)
178 #define MACH_MSGH_BITS_PORTS(bits) \
179 ((bits) & MACH_MSGH_BITS_PORTS_MASK)
180 #define MACH_MSGH_BITS_OTHER(bits) \
181 ((bits) &~ MACH_MSGH_BITS_PORTS_MASK)
183 /* checking macros */
184 #define MACH_MSGH_BITS_HAS_REMOTE(bits) \
185 (MACH_MSGH_BITS_REMOTE(bits) != MACH_MSGH_BITS_ZERO)
186 #define MACH_MSGH_BITS_HAS_LOCAL(bits) \
187 (MACH_MSGH_BITS_LOCAL(bits) != MACH_MSGH_BITS_ZERO)
188 #define MACH_MSGH_BITS_HAS_VOUCHER(bits) \
189 (MACH_MSGH_BITS_VOUCHER(bits) != MACH_MSGH_BITS_ZERO)
190 #define MACH_MSGH_BITS_IS_COMPLEX(bits) \
191 (((bits) & MACH_MSGH_BITS_COMPLEX) != MACH_MSGH_BITS_ZERO)
193 /* importance checking macros */
194 #define MACH_MSGH_BITS_RAISED_IMPORTANCE(bits) \
195 (((bits) & MACH_MSGH_BITS_RAISEIMP) != MACH_MSGH_BITS_ZERO)
196 #define MACH_MSGH_BITS_HOLDS_IMPORTANCE_ASSERTION(bits) \
197 (((bits) & MACH_MSGH_BITS_IMPHOLDASRT) != MACH_MSGH_BITS_ZERO)
200 * Every message starts with a message header.
201 * Following the message header, if the message is complex, are a count
202 * of type descriptors and the type descriptors themselves
203 * (mach_msg_descriptor_t). The size of the message must be specified in
204 * bytes, and includes the message header, descriptor count, descriptors,
207 * The msgh_remote_port field specifies the destination of the message.
208 * It must specify a valid send or send-once right for a port.
210 * The msgh_local_port field specifies a "reply port". Normally,
211 * This field carries a send-once right that the receiver will use
212 * to reply to the message. It may carry the values MACH_PORT_NULL,
213 * MACH_PORT_DEAD, a send-once right, or a send right.
215 * The msgh_voucher_port field specifies a Mach voucher port. Only
216 * send rights to kernel-implemented Mach Voucher kernel objects in
217 * addition to MACH_PORT_NULL or MACH_PORT_DEAD may be passed.
219 * The msgh_id field is uninterpreted by the message primitives.
220 * It normally carries information specifying the format
221 * or meaning of the message.
224 typedef unsigned int mach_msg_bits_t
;
225 typedef natural_t mach_msg_size_t
;
226 typedef integer_t mach_msg_id_t
;
228 #define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0
230 typedef unsigned int mach_msg_priority_t
;
232 #define MACH_MSG_PRIORITY_UNSPECIFIED (mach_msg_priority_t) 0
235 typedef uint8_t mach_msg_qos_t
; // same as thread_qos_t
236 #define MACH_MSG_QOS_UNSPECIFIED 0
237 #define MACH_MSG_QOS_MAINTENANCE 1
238 #define MACH_MSG_QOS_BACKGROUND 2
239 #define MACH_MSG_QOS_UTILITY 3
240 #define MACH_MSG_QOS_DEFAULT 4
241 #define MACH_MSG_QOS_USER_INITIATED 5
242 #define MACH_MSG_QOS_USER_INTERACTIVE 6
243 #define MACH_MSG_QOS_LAST 6
245 extern int mach_msg_priority_is_pthread_priority(mach_msg_priority_t pri
);
246 extern mach_msg_priority_t
mach_msg_priority_encode(
247 mach_msg_qos_t override_qos
,
250 extern mach_msg_qos_t
mach_msg_priority_overide_qos(mach_msg_priority_t pri
);
251 extern mach_msg_qos_t
mach_msg_priority_qos(mach_msg_priority_t pri
);
252 extern int mach_msg_priority_relpri(mach_msg_priority_t pri
);
254 #if KERNEL || !TARGET_OS_SIMULATOR
256 mach_msg_priority_is_pthread_priority_inline(mach_msg_priority_t pri
)
258 return (pri
& 0xff) == 0xff;
261 #define MACH_MSG_PRIORITY_RELPRI_SHIFT 8
262 #define MACH_MSG_PRIORITY_RELPRI_MASK (0xff << MACH_MSG_PRIORITY_RELPRI_SHIFT)
263 #define MACH_MSG_PRIORITY_QOS_SHIFT 16
264 #define MACH_MSG_PRIORITY_QOS_MASK (0xf << MACH_MSG_PRIORITY_QOS_SHIFT)
265 #define MACH_MSG_PRIORITY_OVERRIDE_SHIFT 20
266 #define MACH_MSG_PRIORITY_OVERRIDE_MASK (0xf << MACH_MSG_PRIORITY_OVERRIDE_SHIFT)
268 static inline mach_msg_priority_t
269 mach_msg_priority_encode_inline(mach_msg_qos_t override_qos
, mach_msg_qos_t qos
, int relpri
)
271 mach_msg_priority_t pri
= 0;
272 if (qos
> 0 && qos
<= MACH_MSG_QOS_LAST
) {
273 pri
|= (uint32_t)(qos
<< MACH_MSG_PRIORITY_QOS_SHIFT
);
274 pri
|= (uint32_t)((uint8_t)(relpri
- 1) << MACH_MSG_PRIORITY_RELPRI_SHIFT
);
276 if (override_qos
> 0 && override_qos
<= MACH_MSG_QOS_LAST
) {
277 pri
|= (uint32_t)(override_qos
<< MACH_MSG_PRIORITY_OVERRIDE_SHIFT
);
282 static inline mach_msg_qos_t
283 mach_msg_priority_overide_qos_inline(mach_msg_priority_t pri
)
285 pri
&= MACH_MSG_PRIORITY_OVERRIDE_MASK
;
286 pri
>>= MACH_MSG_PRIORITY_OVERRIDE_SHIFT
;
287 return (mach_msg_qos_t
)(pri
<= MACH_MSG_QOS_LAST
? pri
: 0);
290 static inline mach_msg_qos_t
291 mach_msg_priority_qos_inline(mach_msg_priority_t pri
)
293 pri
&= MACH_MSG_PRIORITY_QOS_MASK
;
294 pri
>>= MACH_MSG_PRIORITY_QOS_SHIFT
;
295 return (mach_msg_qos_t
)(pri
<= MACH_MSG_QOS_LAST
? pri
: 0);
299 mach_msg_priority_relpri_inline(mach_msg_priority_t pri
)
301 if (mach_msg_priority_qos_inline(pri
)) {
302 return (int8_t)(pri
>> MACH_MSG_PRIORITY_RELPRI_SHIFT
) + 1;
307 #define mach_msg_priority_is_pthread_priority(...) \
308 mach_msg_priority_is_pthread_priority_inline(__VA_ARGS__)
309 #define mach_msg_priority_encode(...) \
310 mach_msg_priority_encode_inline(__VA_ARGS__)
311 #define mach_msg_priority_overide_qos(...) \
312 mach_msg_priority_overide_qos_inline(__VA_ARGS__)
313 #define mach_msg_priority_qos(...) \
314 mach_msg_priority_qos_inline(__VA_ARGS__)
315 #define mach_msg_priority_relpri(...) \
316 mach_msg_priority_relpri_inline(__VA_ARGS__)
321 typedef unsigned int mach_msg_type_name_t
;
323 #define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */
324 #define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send right(s) */
325 #define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce right */
326 #define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send right(s) */
327 #define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */
328 #define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive right */
329 #define MACH_MSG_TYPE_COPY_RECEIVE 22 /* NOT VALID */
330 #define MACH_MSG_TYPE_DISPOSE_RECEIVE 24 /* must hold receive right */
331 #define MACH_MSG_TYPE_DISPOSE_SEND 25 /* must hold send right(s) */
332 #define MACH_MSG_TYPE_DISPOSE_SEND_ONCE 26 /* must hold sendonce right */
334 typedef unsigned int mach_msg_copy_options_t
;
336 #define MACH_MSG_PHYSICAL_COPY 0
337 #define MACH_MSG_VIRTUAL_COPY 1
338 #define MACH_MSG_ALLOCATE 2
339 #define MACH_MSG_OVERWRITE 3 /* deprecated */
341 #define MACH_MSG_KALLOC_COPY_T 4
342 #endif /* MACH_KERNEL */
344 #define MACH_MSG_GUARD_FLAGS_NONE 0x0000
345 #define MACH_MSG_GUARD_FLAGS_IMMOVABLE_RECEIVE 0x0001 /* Move the receive right and mark it as immovable */
346 #define MACH_MSG_GUARD_FLAGS_UNGUARDED_ON_SEND 0x0002 /* Verify that the port is unguarded */
347 #define MACH_MSG_GUARD_FLAGS_MASK 0x0003 /* Valid flag bits */
348 typedef unsigned int mach_msg_guard_flags_t
;
351 * In a complex mach message, the mach_msg_header_t is followed by
352 * a descriptor count, then an array of that number of descriptors
353 * (mach_msg_*_descriptor_t). The type field of mach_msg_type_descriptor_t
354 * (which any descriptor can be cast to) indicates the flavor of the
357 * Note that in LP64, the various types of descriptors are no longer all
358 * the same size as mach_msg_descriptor_t, so the array cannot be indexed
362 typedef unsigned int mach_msg_descriptor_type_t
;
364 #define MACH_MSG_PORT_DESCRIPTOR 0
365 #define MACH_MSG_OOL_DESCRIPTOR 1
366 #define MACH_MSG_OOL_PORTS_DESCRIPTOR 2
367 #define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3
368 #define MACH_MSG_GUARDED_PORT_DESCRIPTOR 4
370 #pragma pack(push, 4)
374 mach_msg_size_t pad2
;
375 unsigned int pad3
: 24;
376 mach_msg_descriptor_type_t type
: 8;
377 } mach_msg_type_descriptor_t
;
381 #if !(defined(KERNEL) && defined(__LP64__))
382 // Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes
383 mach_msg_size_t pad1
;
385 unsigned int pad2
: 16;
386 mach_msg_type_name_t disposition
: 8;
387 mach_msg_descriptor_type_t type
: 8;
391 } mach_msg_port_descriptor_t
;
395 mach_msg_size_t size
;
396 boolean_t deallocate
: 8;
397 mach_msg_copy_options_t copy
: 8;
398 unsigned int pad1
: 8;
399 mach_msg_descriptor_type_t type
: 8;
400 } mach_msg_ool_descriptor32_t
;
404 boolean_t deallocate
: 8;
405 mach_msg_copy_options_t copy
: 8;
406 unsigned int pad1
: 8;
407 mach_msg_descriptor_type_t type
: 8;
408 mach_msg_size_t size
;
409 } mach_msg_ool_descriptor64_t
;
413 #if !defined(__LP64__)
414 mach_msg_size_t size
;
416 boolean_t deallocate
: 8;
417 mach_msg_copy_options_t copy
: 8;
418 unsigned int pad1
: 8;
419 mach_msg_descriptor_type_t type
: 8;
420 #if defined(__LP64__)
421 mach_msg_size_t size
;
423 #if defined(KERNEL) && !defined(__LP64__)
426 } mach_msg_ool_descriptor_t
;
430 mach_msg_size_t count
;
431 boolean_t deallocate
: 8;
432 mach_msg_copy_options_t copy
: 8;
433 mach_msg_type_name_t disposition
: 8;
434 mach_msg_descriptor_type_t type
: 8;
435 } mach_msg_ool_ports_descriptor32_t
;
439 boolean_t deallocate
: 8;
440 mach_msg_copy_options_t copy
: 8;
441 mach_msg_type_name_t disposition
: 8;
442 mach_msg_descriptor_type_t type
: 8;
443 mach_msg_size_t count
;
444 } mach_msg_ool_ports_descriptor64_t
;
448 #if !defined(__LP64__)
449 mach_msg_size_t count
;
451 boolean_t deallocate
: 8;
452 mach_msg_copy_options_t copy
: 8;
453 mach_msg_type_name_t disposition
: 8;
454 mach_msg_descriptor_type_t type
: 8;
455 #if defined(__LP64__)
456 mach_msg_size_t count
;
458 #if defined(KERNEL) && !defined(__LP64__)
461 } mach_msg_ool_ports_descriptor_t
;
465 mach_port_name_t name
;
466 mach_msg_guard_flags_t flags
: 16;
467 mach_msg_type_name_t disposition
: 8;
468 mach_msg_descriptor_type_t type
: 8;
469 } mach_msg_guarded_port_descriptor32_t
;
473 mach_msg_guard_flags_t flags
: 16;
474 mach_msg_type_name_t disposition
: 8;
475 mach_msg_descriptor_type_t type
: 8;
476 mach_port_name_t name
;
477 } mach_msg_guarded_port_descriptor64_t
;
482 #if !defined(__LP64__)
485 mach_msg_guard_flags_t flags
: 16;
486 mach_msg_type_name_t disposition
: 8;
487 mach_msg_descriptor_type_t type
: 8;
488 #if defined(__LP64__)
490 #endif /* defined(__LP64__) */
492 mach_port_context_t context
;
493 #if !defined(__LP64__)
494 mach_port_name_t name
;
496 mach_msg_guard_flags_t flags
: 16;
497 mach_msg_type_name_t disposition
: 8;
498 mach_msg_descriptor_type_t type
: 8;
499 #if defined(__LP64__)
500 mach_port_name_t name
;
501 #endif /* defined(__LP64__) */
502 #endif /* defined(KERNEL) */
503 } mach_msg_guarded_port_descriptor_t
;
506 * LP64support - This union definition is not really
507 * appropriate in LP64 mode because not all descriptors
508 * are of the same size in that environment.
510 #if defined(__LP64__) && defined(KERNEL)
512 mach_msg_port_descriptor_t port
;
513 mach_msg_ool_descriptor32_t out_of_line
;
514 mach_msg_ool_ports_descriptor32_t ool_ports
;
515 mach_msg_type_descriptor_t type
;
516 mach_msg_guarded_port_descriptor32_t guarded_port
;
517 } mach_msg_descriptor_t
;
520 mach_msg_port_descriptor_t port
;
521 mach_msg_ool_descriptor_t out_of_line
;
522 mach_msg_ool_ports_descriptor_t ool_ports
;
523 mach_msg_type_descriptor_t type
;
524 mach_msg_guarded_port_descriptor_t guarded_port
;
525 } mach_msg_descriptor_t
;
529 mach_msg_size_t msgh_descriptor_count
;
532 #define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0
533 #define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0
536 mach_msg_bits_t msgh_bits
;
537 mach_msg_size_t msgh_size
;
538 mach_port_t msgh_remote_port
;
539 mach_port_t msgh_local_port
;
540 mach_port_name_t msgh_voucher_port
;
541 mach_msg_id_t msgh_id
;
544 #define msgh_reserved msgh_voucher_port
545 #define MACH_MSG_NULL (mach_msg_header_t *) 0
548 mach_msg_header_t header
;
549 mach_msg_body_t body
;
552 typedef unsigned int mach_msg_trailer_type_t
;
554 #define MACH_MSG_TRAILER_FORMAT_0 0
556 typedef unsigned int mach_msg_trailer_size_t
;
557 typedef char *mach_msg_trailer_info_t
;
560 mach_msg_trailer_type_t msgh_trailer_type
;
561 mach_msg_trailer_size_t msgh_trailer_size
;
562 } mach_msg_trailer_t
;
565 * The msgh_seqno field carries a sequence number
566 * associated with the received-from port. A port's
567 * sequence number is incremented every time a message
568 * is received from it and included in the received
569 * trailer to help put messages back in sequence if
570 * multiple threads receive and/or process received
574 mach_msg_trailer_type_t msgh_trailer_type
;
575 mach_msg_trailer_size_t msgh_trailer_size
;
576 mach_port_seqno_t msgh_seqno
;
577 } mach_msg_seqno_trailer_t
;
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 } mach_msg_security_trailer_t
;
591 * The audit token is an opaque token which identifies
592 * Mach tasks and senders of Mach messages as subjects
593 * to the BSM audit system. Only the appropriate BSM
594 * library routines should be used to interpret the
595 * contents of the audit token as the representation
596 * of the subject identity within the token may change
604 mach_msg_trailer_type_t msgh_trailer_type
;
605 mach_msg_trailer_size_t msgh_trailer_size
;
606 mach_port_seqno_t msgh_seqno
;
607 security_token_t msgh_sender
;
608 audit_token_t msgh_audit
;
609 } mach_msg_audit_trailer_t
;
612 mach_msg_trailer_type_t msgh_trailer_type
;
613 mach_msg_trailer_size_t msgh_trailer_size
;
614 mach_port_seqno_t msgh_seqno
;
615 security_token_t msgh_sender
;
616 audit_token_t msgh_audit
;
617 mach_port_context_t msgh_context
;
618 } mach_msg_context_trailer_t
;
620 #if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
622 mach_msg_trailer_type_t msgh_trailer_type
;
623 mach_msg_trailer_size_t msgh_trailer_size
;
624 mach_port_seqno_t msgh_seqno
;
625 security_token_t msgh_sender
;
626 audit_token_t msgh_audit
;
627 mach_port_context32_t msgh_context
;
628 } mach_msg_context_trailer32_t
;
631 mach_msg_trailer_type_t msgh_trailer_type
;
632 mach_msg_trailer_size_t msgh_trailer_size
;
633 mach_port_seqno_t msgh_seqno
;
634 security_token_t msgh_sender
;
635 audit_token_t msgh_audit
;
636 mach_port_context64_t msgh_context
;
637 } mach_msg_context_trailer64_t
;
642 mach_port_name_t sender
;
645 typedef int mach_msg_filter_id
;
646 #define MACH_MSG_FILTER_POLICY_ALLOW (mach_msg_filter_id)0
649 * Trailer type to pass MAC policy label info as a mach message trailer.
654 mach_msg_trailer_type_t msgh_trailer_type
;
655 mach_msg_trailer_size_t msgh_trailer_size
;
656 mach_port_seqno_t msgh_seqno
;
657 security_token_t msgh_sender
;
658 audit_token_t msgh_audit
;
659 mach_port_context_t msgh_context
;
660 mach_msg_filter_id msgh_ad
;
661 msg_labels_t msgh_labels
;
662 } mach_msg_mac_trailer_t
;
664 #if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
666 mach_msg_trailer_type_t msgh_trailer_type
;
667 mach_msg_trailer_size_t msgh_trailer_size
;
668 mach_port_seqno_t msgh_seqno
;
669 security_token_t msgh_sender
;
670 audit_token_t msgh_audit
;
671 mach_port_context32_t msgh_context
;
672 mach_msg_filter_id msgh_ad
;
673 msg_labels_t msgh_labels
;
674 } mach_msg_mac_trailer32_t
;
677 mach_msg_trailer_type_t msgh_trailer_type
;
678 mach_msg_trailer_size_t msgh_trailer_size
;
679 mach_port_seqno_t msgh_seqno
;
680 security_token_t msgh_sender
;
681 audit_token_t msgh_audit
;
682 mach_port_context64_t msgh_context
;
683 mach_msg_filter_id msgh_ad
;
684 msg_labels_t msgh_labels
;
685 } mach_msg_mac_trailer64_t
;
689 #define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t)
692 * These values can change from release to release - but clearly
693 * code cannot request additional trailer elements one was not
694 * compiled to understand. Therefore, it is safe to use this
695 * constant when the same module specified the receive options.
696 * Otherwise, you run the risk that the options requested by
697 * another module may exceed the local modules notion of
700 #if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
701 typedef mach_msg_mac_trailer64_t mach_msg_max_trailer64_t
;
702 typedef mach_msg_mac_trailer32_t mach_msg_max_trailer32_t
;
705 typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t
;
706 #define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t))
709 * Legacy requirements keep us from ever updating these defines (even
710 * when the format_0 trailers gain new option data fields in the future).
711 * Therefore, they shouldn't be used going forward. Instead, the sizes
712 * should be compared against the specific element size requested using
713 * REQUESTED_TRAILER_SIZE.
715 typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t
;
717 /*typedef mach_msg_mac_trailer_t mach_msg_format_0_trailer_t;
720 #define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t)
722 #define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} }
723 extern const security_token_t KERNEL_SECURITY_TOKEN
;
725 #define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} }
726 extern const audit_token_t KERNEL_AUDIT_TOKEN
;
728 typedef integer_t mach_msg_options_t
;
731 mach_msg_header_t header
;
732 } mach_msg_empty_send_t
;
735 mach_msg_header_t header
;
736 mach_msg_trailer_t trailer
;
737 } mach_msg_empty_rcv_t
;
740 mach_msg_empty_send_t send
;
741 mach_msg_empty_rcv_t rcv
;
746 /* utility to round the message size - will become machine dependent */
747 #define round_msg(x) (((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \
748 ~(sizeof (natural_t) - 1))
750 #ifdef XNU_KERNEL_PRIVATE
753 #include <os/overflow.h>
754 #include <kern/debug.h>
756 #define round_msg_overflow(in, out) __os_warn_unused(({ \
757 bool __ovr = os_add_overflow(in, (__typeof__(*out))(sizeof(natural_t) - 1), out); \
758 *out &= ~((__typeof__(*out))(sizeof(natural_t) - 1)); \
762 static inline mach_msg_size_t
763 mach_round_msg(mach_msg_size_t x
)
765 if (round_msg_overflow(x
, &x
)) {
766 panic("round msg overflow");
770 #endif /* XNU_KERNEL_PRIVATE */
773 * There is no fixed upper bound to the size of Mach messages.
775 #define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0)
777 #if defined(__APPLE_API_PRIVATE)
779 * But architectural limits of a given implementation, or
780 * temporal conditions may cause unpredictable send failures
781 * for messages larger than MACH_MSG_SIZE_RELIABLE.
783 * In either case, waiting for memory is [currently] outside
784 * the scope of send timeout values provided to IPC.
786 #define MACH_MSG_SIZE_RELIABLE ((mach_msg_size_t) 256 * 1024)
789 * Compatibility definitions, for code written
790 * when there was a msgh_kind instead of msgh_seqno.
792 #define MACH_MSGH_KIND_NORMAL 0x00000000
793 #define MACH_MSGH_KIND_NOTIFICATION 0x00000001
794 #define msgh_kind msgh_seqno
795 #define mach_msg_kind_t mach_port_seqno_t
797 typedef natural_t mach_msg_type_size_t
;
798 typedef natural_t mach_msg_type_number_t
;
801 * Values received/carried in messages. Tells the receiver what
802 * sort of port right he now has.
804 * MACH_MSG_TYPE_PORT_NAME is used to transfer a port name
805 * which should remain uninterpreted by the kernel. (Port rights
806 * are not transferred, just the port name.)
809 #define MACH_MSG_TYPE_PORT_NONE 0
811 #define MACH_MSG_TYPE_PORT_NAME 15
812 #define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE
813 #define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND
814 #define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE
816 #define MACH_MSG_TYPE_LAST 22 /* Last assigned */
819 * A dummy value. Mostly used to indicate that the actual value
820 * will be filled in later, dynamically.
823 #define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1)
826 * Is a given item a port type?
829 #define MACH_MSG_TYPE_PORT_ANY(x) \
830 (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
831 ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
833 #define MACH_MSG_TYPE_PORT_ANY_SEND(x) \
834 (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \
835 ((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
837 #define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \
838 (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
839 ((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE))
841 typedef integer_t mach_msg_option_t
;
843 #define MACH_MSG_OPTION_NONE 0x00000000
845 #define MACH_SEND_MSG 0x00000001
846 #define MACH_RCV_MSG 0x00000002
848 #define MACH_RCV_LARGE 0x00000004 /* report large message sizes */
849 #define MACH_RCV_LARGE_IDENTITY 0x00000008 /* identify source of large messages */
851 #define MACH_SEND_TIMEOUT 0x00000010 /* timeout value applies to send */
852 #define MACH_SEND_OVERRIDE 0x00000020 /* priority override for send */
853 #define MACH_SEND_INTERRUPT 0x00000040 /* don't restart interrupted sends */
854 #define MACH_SEND_NOTIFY 0x00000080 /* arm send-possible notify */
855 #define MACH_SEND_ALWAYS 0x00010000 /* ignore qlimits - kernel only */
856 #define MACH_SEND_TRAILER 0x00020000 /* sender-provided trailer */
857 #define MACH_SEND_NOIMPORTANCE 0x00040000 /* msg won't carry importance */
858 #define MACH_SEND_NODENAP MACH_SEND_NOIMPORTANCE
859 #define MACH_SEND_IMPORTANCE 0x00080000 /* msg carries importance - kernel only */
860 #define MACH_SEND_SYNC_OVERRIDE 0x00100000 /* msg should do sync ipc override */
861 #define MACH_SEND_PROPAGATE_QOS 0x00200000 /* IPC should propagate the caller's QoS */
862 #define MACH_SEND_SYNC_USE_THRPRI MACH_SEND_PROPAGATE_QOS /* obsolete name */
863 #define MACH_SEND_KERNEL 0x00400000 /* full send from kernel space - kernel only */
864 #define MACH_SEND_SYNC_BOOTSTRAP_CHECKIN 0x00800000 /* special reply port should boost thread doing sync bootstrap checkin */
866 #define MACH_RCV_TIMEOUT 0x00000100 /* timeout value applies to receive */
867 #define MACH_RCV_NOTIFY 0x00000000 /* legacy name (value was: 0x00000200) */
868 #define MACH_RCV_INTERRUPT 0x00000400 /* don't restart interrupted receive */
869 #define MACH_RCV_VOUCHER 0x00000800 /* willing to receive voucher port */
870 #define MACH_RCV_OVERWRITE 0x00000000 /* scatter receive (deprecated) */
871 #define MACH_RCV_GUARDED_DESC 0x00001000 /* Can receive new guarded descriptor */
872 #define MACH_RCV_SYNC_WAIT 0x00004000 /* sync waiter waiting for rcv */
873 #define MACH_RCV_SYNC_PEEK 0x00008000 /* sync waiter waiting to peek */
875 #define MACH_MSG_STRICT_REPLY 0x00000200 /* Enforce specific properties about the reply port, and
876 * the context in which a thread replies to a message.
877 * This flag must be passed on both the SEND and RCV */
879 #ifdef XNU_KERNEL_PRIVATE
881 #define MACH_RCV_STACK 0x00002000 /* receive into highest addr of buffer */
885 * This internal-only flag is intended for use by a single thread per-port/set!
886 * If more than one thread attempts to MACH_PEEK_MSG on a port or set, one of
887 * the threads may miss messages (in fact, it may never wake up).
889 #define MACH_PEEK_MSG 0x80000000 /* receive, but leave msgs queued */
894 * NOTE: a 0x00------ RCV mask implies to ask for
895 * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements,
896 * which is equivalent to a mach_msg_trailer_t.
898 * XXXMAC: unlike the rest of the MACH_RCV_* flags, MACH_RCV_TRAILER_LABELS
899 * needs its own private bit since we only calculate its fields when absolutely
902 #define MACH_RCV_TRAILER_NULL 0
903 #define MACH_RCV_TRAILER_SEQNO 1
904 #define MACH_RCV_TRAILER_SENDER 2
905 #define MACH_RCV_TRAILER_AUDIT 3
906 #define MACH_RCV_TRAILER_CTX 4
907 #define MACH_RCV_TRAILER_AV 7
908 #define MACH_RCV_TRAILER_LABELS 8
910 #define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28)
911 #define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24)
912 #define MACH_RCV_TRAILER_MASK ((0xf << 24))
914 #define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf)
916 #ifdef MACH_KERNEL_PRIVATE
917 /* The options that the kernel honors when passed from user space */
918 #define MACH_SEND_USER (MACH_SEND_MSG | MACH_SEND_TIMEOUT | \
919 MACH_SEND_NOTIFY | MACH_SEND_OVERRIDE | \
920 MACH_SEND_TRAILER | MACH_SEND_NOIMPORTANCE | \
921 MACH_SEND_SYNC_OVERRIDE | MACH_SEND_PROPAGATE_QOS | \
922 MACH_SEND_SYNC_BOOTSTRAP_CHECKIN | \
923 MACH_MSG_STRICT_REPLY | MACH_RCV_GUARDED_DESC)
925 #define MACH_RCV_USER (MACH_RCV_MSG | MACH_RCV_TIMEOUT | \
926 MACH_RCV_LARGE | MACH_RCV_LARGE_IDENTITY | \
927 MACH_RCV_VOUCHER | MACH_RCV_TRAILER_MASK | \
928 MACH_RCV_SYNC_WAIT | MACH_RCV_SYNC_PEEK | \
929 MACH_RCV_GUARDED_DESC | MACH_MSG_STRICT_REPLY)
931 #define MACH_MSG_OPTION_USER (MACH_SEND_USER | MACH_RCV_USER)
933 /* The options implemented by the library interface to mach_msg et. al. */
934 #define MACH_MSG_OPTION_LIB (MACH_SEND_INTERRUPT | MACH_RCV_INTERRUPT)
937 * Default options to use when sending from the kernel.
939 * Until we are sure of its effects, we are disabling
940 * importance donation from the kernel-side of user
941 * threads in importance-donating tasks.
942 * (11938665 & 23925818)
944 #define MACH_SEND_KERNEL_DEFAULT (MACH_SEND_MSG | \
945 MACH_SEND_ALWAYS | MACH_SEND_NOIMPORTANCE)
947 #define MACH_SEND_WITH_STRICT_REPLY(_opts) (((_opts) & (MACH_MSG_STRICT_REPLY | MACH_SEND_MSG)) == \
948 (MACH_MSG_STRICT_REPLY | MACH_SEND_MSG))
950 #define MACH_SEND_REPLY_IS_IMMOVABLE(_opts) (((_opts) & (MACH_MSG_STRICT_REPLY | \
951 MACH_SEND_MSG | MACH_RCV_MSG | \
952 MACH_RCV_GUARDED_DESC)) == \
953 (MACH_MSG_STRICT_REPLY | MACH_SEND_MSG | MACH_RCV_GUARDED_DESC))
955 #define MACH_RCV_WITH_STRICT_REPLY(_opts) (((_opts) & (MACH_MSG_STRICT_REPLY | MACH_RCV_MSG)) == \
956 (MACH_MSG_STRICT_REPLY | MACH_RCV_MSG))
958 #define MACH_RCV_WITH_IMMOVABLE_REPLY(_opts) (((_opts) & (MACH_MSG_STRICT_REPLY | \
959 MACH_RCV_MSG | MACH_RCV_GUARDED_DESC)) == \
960 (MACH_MSG_STRICT_REPLY | MACH_RCV_MSG | MACH_RCV_GUARDED_DESC))
962 #endif /* MACH_KERNEL_PRIVATE */
965 * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS,
966 * we just fall through to mach_msg_max_trailer_t.
967 * This is correct behavior since mach_msg_max_trailer_t is defined as
968 * mac_msg_mac_trailer_t which is used for the LABELS trailer.
969 * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed
970 * with one of the other options.
973 #define REQUESTED_TRAILER_SIZE_NATIVE(y) \
974 ((mach_msg_trailer_size_t) \
975 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \
976 sizeof(mach_msg_trailer_t) : \
977 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \
978 sizeof(mach_msg_seqno_trailer_t) : \
979 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \
980 sizeof(mach_msg_security_trailer_t) : \
981 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \
982 sizeof(mach_msg_audit_trailer_t) : \
983 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \
984 sizeof(mach_msg_context_trailer_t) : \
985 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \
986 sizeof(mach_msg_mac_trailer_t) : \
987 sizeof(mach_msg_max_trailer_t))))))))
990 #ifdef XNU_KERNEL_PRIVATE
992 #if defined(__arm64__)
993 #define REQUESTED_TRAILER_SIZE(is64, y) \
994 ((mach_msg_trailer_size_t) \
995 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \
996 sizeof(mach_msg_trailer_t) : \
997 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \
998 sizeof(mach_msg_seqno_trailer_t) : \
999 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \
1000 sizeof(mach_msg_security_trailer_t) : \
1001 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \
1002 sizeof(mach_msg_audit_trailer_t) : \
1003 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \
1004 ((is64) ? sizeof(mach_msg_context_trailer64_t) : sizeof(mach_msg_context_trailer32_t)) : \
1005 ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \
1006 ((is64) ? sizeof(mach_msg_mac_trailer64_t) : sizeof(mach_msg_mac_trailer32_t)) : \
1007 sizeof(mach_msg_max_trailer_t))))))))
1009 #define REQUESTED_TRAILER_SIZE(is64, y) REQUESTED_TRAILER_SIZE_NATIVE(y)
1012 #else /* XNU_KERNEL_PRIVATE */
1013 #define REQUESTED_TRAILER_SIZE(y) REQUESTED_TRAILER_SIZE_NATIVE(y)
1014 #endif /* XNU_KERNEL_PRIVATE */
1017 * Much code assumes that mach_msg_return_t == kern_return_t.
1018 * This definition is useful for descriptive purposes.
1020 * See <mach/error.h> for the format of error codes.
1021 * IPC errors are system 4. Send errors are subsystem 0;
1022 * receive errors are subsystem 1. The code field is always non-zero.
1023 * The high bits of the code field communicate extra information
1024 * for some error codes. MACH_MSG_MASK masks off these special bits.
1027 typedef kern_return_t mach_msg_return_t
;
1029 #define MACH_MSG_SUCCESS 0x00000000
1032 #define MACH_MSG_MASK 0x00003e00
1033 /* All special error code bits defined below. */
1034 #define MACH_MSG_IPC_SPACE 0x00002000
1035 /* No room in IPC name space for another capability name. */
1036 #define MACH_MSG_VM_SPACE 0x00001000
1037 /* No room in VM address space for out-of-line memory. */
1038 #define MACH_MSG_IPC_KERNEL 0x00000800
1039 /* Kernel resource shortage handling an IPC capability. */
1040 #define MACH_MSG_VM_KERNEL 0x00000400
1041 /* Kernel resource shortage handling out-of-line memory. */
1043 #define MACH_SEND_IN_PROGRESS 0x10000001
1044 /* Thread is waiting to send. (Internal use only.) */
1045 #define MACH_SEND_INVALID_DATA 0x10000002
1046 /* Bogus in-line data. */
1047 #define MACH_SEND_INVALID_DEST 0x10000003
1048 /* Bogus destination port. */
1049 #define MACH_SEND_TIMED_OUT 0x10000004
1050 /* Message not sent before timeout expired. */
1051 #define MACH_SEND_INVALID_VOUCHER 0x10000005
1052 /* Bogus voucher port. */
1053 #define MACH_SEND_INTERRUPTED 0x10000007
1054 /* Software interrupt. */
1055 #define MACH_SEND_MSG_TOO_SMALL 0x10000008
1056 /* Data doesn't contain a complete message. */
1057 #define MACH_SEND_INVALID_REPLY 0x10000009
1058 /* Bogus reply port. */
1059 #define MACH_SEND_INVALID_RIGHT 0x1000000a
1060 /* Bogus port rights in the message body. */
1061 #define MACH_SEND_INVALID_NOTIFY 0x1000000b
1062 /* Bogus notify port argument. */
1063 #define MACH_SEND_INVALID_MEMORY 0x1000000c
1064 /* Invalid out-of-line memory pointer. */
1065 #define MACH_SEND_NO_BUFFER 0x1000000d
1066 /* No message buffer is available. */
1067 #define MACH_SEND_TOO_LARGE 0x1000000e
1068 /* Send is too large for port */
1069 #define MACH_SEND_INVALID_TYPE 0x1000000f
1070 /* Invalid msg-type specification. */
1071 #define MACH_SEND_INVALID_HEADER 0x10000010
1072 /* A field in the header had a bad value. */
1073 #define MACH_SEND_INVALID_TRAILER 0x10000011
1074 /* The trailer to be sent does not match kernel format. */
1075 #define MACH_SEND_INVALID_CONTEXT 0x10000012
1076 /* The sending thread context did not match the context on the dest port */
1077 #define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015
1078 /* compatibility: no longer a returned error */
1079 #define MACH_SEND_NO_GRANT_DEST 0x10000016
1080 /* The destination port doesn't accept ports in body */
1081 #define MACH_SEND_MSG_FILTERED 0x10000017
1082 /* Message send was rejected by message filter */
1084 #define MACH_RCV_IN_PROGRESS 0x10004001
1085 /* Thread is waiting for receive. (Internal use only.) */
1086 #define MACH_RCV_INVALID_NAME 0x10004002
1087 /* Bogus name for receive port/port-set. */
1088 #define MACH_RCV_TIMED_OUT 0x10004003
1089 /* Didn't get a message within the timeout value. */
1090 #define MACH_RCV_TOO_LARGE 0x10004004
1091 /* Message buffer is not large enough for inline data. */
1092 #define MACH_RCV_INTERRUPTED 0x10004005
1093 /* Software interrupt. */
1094 #define MACH_RCV_PORT_CHANGED 0x10004006
1095 /* compatibility: no longer a returned error */
1096 #define MACH_RCV_INVALID_NOTIFY 0x10004007
1097 /* Bogus notify port argument. */
1098 #define MACH_RCV_INVALID_DATA 0x10004008
1099 /* Bogus message buffer for inline data. */
1100 #define MACH_RCV_PORT_DIED 0x10004009
1101 /* Port/set was sent away/died during receive. */
1102 #define MACH_RCV_IN_SET 0x1000400a
1103 /* compatibility: no longer a returned error */
1104 #define MACH_RCV_HEADER_ERROR 0x1000400b
1105 /* Error receiving message header. See special bits. */
1106 #define MACH_RCV_BODY_ERROR 0x1000400c
1107 /* Error receiving message body. See special bits. */
1108 #define MACH_RCV_INVALID_TYPE 0x1000400d
1109 /* Invalid msg-type specification in scatter list. */
1110 #define MACH_RCV_SCATTER_SMALL 0x1000400e
1111 /* Out-of-line overwrite region is not large enough */
1112 #define MACH_RCV_INVALID_TRAILER 0x1000400f
1113 /* trailer type or number of trailer elements not supported */
1114 #define MACH_RCV_IN_PROGRESS_TIMED 0x10004011
1115 /* Waiting for receive with timeout. (Internal use only.) */
1116 #define MACH_RCV_INVALID_REPLY 0x10004012
1117 /* invalid reply port used in a STRICT_REPLY message */
1119 #ifdef XNU_KERNEL_PRIVATE
1120 #define MACH_PEEK_IN_PROGRESS 0x10008001
1121 /* Waiting for a peek. (Internal use only.) */
1122 #define MACH_PEEK_READY 0x10008002
1123 /* Waiting for a peek. (Internal use only.) */
1130 * Routine: mach_msg_overwrite
1132 * Send and/or receive a message. If the message operation
1133 * is interrupted, and the user did not request an indication
1134 * of that fact, then restart the appropriate parts of the
1135 * operation silently (trap version does not restart).
1137 * Distinct send and receive buffers may be specified. If
1138 * no separate receive buffer is specified, the msg parameter
1139 * will be used for both send and receive operations.
1141 * In addition to a distinct receive buffer, that buffer may
1142 * already contain scatter control information to direct the
1143 * receiving of the message.
1145 __WATCHOS_PROHIBITED __TVOS_PROHIBITED
1146 extern mach_msg_return_t
mach_msg_overwrite(
1147 mach_msg_header_t
*msg
,
1148 mach_msg_option_t option
,
1149 mach_msg_size_t send_size
,
1150 mach_msg_size_t rcv_size
,
1151 mach_port_name_t rcv_name
,
1152 mach_msg_timeout_t timeout
,
1153 mach_port_name_t notify
,
1154 mach_msg_header_t
*rcv_msg
,
1155 mach_msg_size_t rcv_limit
);
1162 * Send and/or receive a message. If the message operation
1163 * is interrupted, and the user did not request an indication
1164 * of that fact, then restart the appropriate parts of the
1165 * operation silently (trap version does not restart).
1167 __WATCHOS_PROHIBITED __TVOS_PROHIBITED
1168 extern mach_msg_return_t
mach_msg(
1169 mach_msg_header_t
*msg
,
1170 mach_msg_option_t option
,
1171 mach_msg_size_t send_size
,
1172 mach_msg_size_t rcv_size
,
1173 mach_port_name_t rcv_name
,
1174 mach_msg_timeout_t timeout
,
1175 mach_port_name_t notify
);
1178 * Routine: mach_voucher_deallocate
1180 * Deallocate a mach voucher created or received in a message. Drops
1181 * one (send right) reference to the voucher.
1183 __WATCHOS_PROHIBITED __TVOS_PROHIBITED
1184 extern kern_return_t
mach_voucher_deallocate(
1185 mach_port_name_t voucher
);
1187 #elif defined(MACH_KERNEL_PRIVATE)
1189 extern mach_msg_return_t
mach_msg_receive_results(mach_msg_size_t
*size
);
1195 #endif /* _MACH_MESSAGE_H_ */