* Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
- *
+ *
* This file contains Original Code and/or Modifications of Original Code
* as defined in and that are subject to the Apple Public Source License
* Version 2.0 (the 'License'). You may not use this file except in
* unlawful or unlicensed copies of an Apple operating system, or to
* circumvent, violate, or enable the circumvention or violation of, any
* terms of an Apple operating system software license agreement.
- *
+ *
* Please obtain a copy of the License at
* http://www.opensource.apple.com/apsl/ and read it before using this file.
- *
+ *
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
* Please see the License for the specific language governing rights and
* limitations under the License.
- *
+ *
* @APPLE_OSREFERENCE_LICENSE_HEADER_END@
*/
/*
* @OSF_COPYRIGHT@
*/
-/*
+/*
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
- *
+ *
* Permission to use, copy, modify and distribute this software and its
* documentation is hereby granted, provided that both the copyright
* notice and this permission notice appear in all copies of the
* software, derivative works or modified versions, and any portions
* thereof, and that both notices appear in supporting documentation.
- *
+ *
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
* ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
+ *
* Carnegie Mellon requests users of this software to return to
- *
+ *
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
- *
+ *
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
* Mach IPC message and primitive function definitions.
*/
-#ifndef _MACH_MESSAGE_H_
+#ifndef _MACH_MESSAGE_H_
#define _MACH_MESSAGE_H_
#include <stdint.h>
#include <sys/cdefs.h>
#include <sys/appleapiopts.h>
+#include <Availability.h>
/*
* The timeout mechanism uses mach_msg_timeout_t values,
* (No MACH_SEND_TIMEOUT/MACH_RCV_TIMEOUT option.)
*/
-#define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0)
+#define MACH_MSG_TIMEOUT_NONE ((mach_msg_timeout_t) 0)
/*
* The kernel uses MACH_MSGH_BITS_COMPLEX as a hint. If it isn't on, it
* or for future interface expansion.
*/
-#define MACH_MSGH_BITS_ZERO 0x00000000
+#define MACH_MSGH_BITS_ZERO 0x00000000
-#define MACH_MSGH_BITS_REMOTE_MASK 0x0000001f
-#define MACH_MSGH_BITS_LOCAL_MASK 0x00001f00
-#define MACH_MSGH_BITS_VOUCHER_MASK 0x001f0000
+#define MACH_MSGH_BITS_REMOTE_MASK 0x0000001f
+#define MACH_MSGH_BITS_LOCAL_MASK 0x00001f00
+#define MACH_MSGH_BITS_VOUCHER_MASK 0x001f0000
-#define MACH_MSGH_BITS_PORTS_MASK \
- (MACH_MSGH_BITS_REMOTE_MASK | \
- MACH_MSGH_BITS_LOCAL_MASK | \
- MACH_MSGH_BITS_VOUCHER_MASK)
+#define MACH_MSGH_BITS_PORTS_MASK \
+ (MACH_MSGH_BITS_REMOTE_MASK | \
+ MACH_MSGH_BITS_LOCAL_MASK | \
+ MACH_MSGH_BITS_VOUCHER_MASK)
-#define MACH_MSGH_BITS_COMPLEX 0x80000000U /* message is complex */
+#define MACH_MSGH_BITS_COMPLEX 0x80000000U /* message is complex */
-#define MACH_MSGH_BITS_USER 0x801f1f1fU /* allowed bits user->kernel */
+#define MACH_MSGH_BITS_USER 0x801f1f1fU /* allowed bits user->kernel */
-#define MACH_MSGH_BITS_RAISEIMP 0x20000000U /* importance raised due to msg */
-#define MACH_MSGH_BITS_DENAP MACH_MSGH_BITS_RAISEIMP
+#define MACH_MSGH_BITS_RAISEIMP 0x20000000U /* importance raised due to msg */
+#define MACH_MSGH_BITS_DENAP MACH_MSGH_BITS_RAISEIMP
-#define MACH_MSGH_BITS_IMPHOLDASRT 0x10000000U /* assertion help, userland private */
-#define MACH_MSGH_BITS_DENAPHOLDASRT MACH_MSGH_BITS_IMPHOLDASRT
+#define MACH_MSGH_BITS_IMPHOLDASRT 0x10000000U /* assertion help, userland private */
+#define MACH_MSGH_BITS_DENAPHOLDASRT MACH_MSGH_BITS_IMPHOLDASRT
-#define MACH_MSGH_BITS_CIRCULAR 0x10000000U /* message circular, kernel private */
+#define MACH_MSGH_BITS_CIRCULAR 0x10000000U /* message circular, kernel private */
-#define MACH_MSGH_BITS_USED 0xb01f1f1fU
+#define MACH_MSGH_BITS_USED 0xb01f1f1fU
/* setter macros for the bits */
-#define MACH_MSGH_BITS(remote, local) /* legacy */ \
- ((remote) | ((local) << 8))
-#define MACH_MSGH_BITS_SET_PORTS(remote, local, voucher) \
- (((remote) & MACH_MSGH_BITS_REMOTE_MASK) | \
- (((local) << 8) & MACH_MSGH_BITS_LOCAL_MASK) | \
+#define MACH_MSGH_BITS(remote, local) /* legacy */ \
+ ((remote) | ((local) << 8))
+#define MACH_MSGH_BITS_SET_PORTS(remote, local, voucher) \
+ (((remote) & MACH_MSGH_BITS_REMOTE_MASK) | \
+ (((local) << 8) & MACH_MSGH_BITS_LOCAL_MASK) | \
(((voucher) << 16) & MACH_MSGH_BITS_VOUCHER_MASK))
-#define MACH_MSGH_BITS_SET(remote, local, voucher, other) \
+#define MACH_MSGH_BITS_SET(remote, local, voucher, other) \
(MACH_MSGH_BITS_SET_PORTS((remote), (local), (voucher)) \
| ((other) &~ MACH_MSGH_BITS_PORTS_MASK))
/* getter macros for pulling values out of the bits field */
-#define MACH_MSGH_BITS_REMOTE(bits) \
- ((bits) & MACH_MSGH_BITS_REMOTE_MASK)
-#define MACH_MSGH_BITS_LOCAL(bits) \
- (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8)
-#define MACH_MSGH_BITS_VOUCHER(bits) \
- (((bits) & MACH_MSGH_BITS_VOUCHER_MASK) >> 16)
-#define MACH_MSGH_BITS_PORTS(bits) \
+#define MACH_MSGH_BITS_REMOTE(bits) \
+ ((bits) & MACH_MSGH_BITS_REMOTE_MASK)
+#define MACH_MSGH_BITS_LOCAL(bits) \
+ (((bits) & MACH_MSGH_BITS_LOCAL_MASK) >> 8)
+#define MACH_MSGH_BITS_VOUCHER(bits) \
+ (((bits) & MACH_MSGH_BITS_VOUCHER_MASK) >> 16)
+#define MACH_MSGH_BITS_PORTS(bits) \
((bits) & MACH_MSGH_BITS_PORTS_MASK)
-#define MACH_MSGH_BITS_OTHER(bits) \
- ((bits) &~ MACH_MSGH_BITS_PORTS_MASK)
+#define MACH_MSGH_BITS_OTHER(bits) \
+ ((bits) &~ MACH_MSGH_BITS_PORTS_MASK)
/* checking macros */
-#define MACH_MSGH_BITS_HAS_REMOTE(bits) \
+#define MACH_MSGH_BITS_HAS_REMOTE(bits) \
(MACH_MSGH_BITS_REMOTE(bits) != MACH_MSGH_BITS_ZERO)
-#define MACH_MSGH_BITS_HAS_LOCAL(bits) \
+#define MACH_MSGH_BITS_HAS_LOCAL(bits) \
(MACH_MSGH_BITS_LOCAL(bits) != MACH_MSGH_BITS_ZERO)
-#define MACH_MSGH_BITS_HAS_VOUCHER(bits) \
+#define MACH_MSGH_BITS_HAS_VOUCHER(bits) \
(MACH_MSGH_BITS_VOUCHER(bits) != MACH_MSGH_BITS_ZERO)
-#define MACH_MSGH_BITS_IS_COMPLEX(bits) \
+#define MACH_MSGH_BITS_IS_COMPLEX(bits) \
(((bits) & MACH_MSGH_BITS_COMPLEX) != MACH_MSGH_BITS_ZERO)
/* importance checking macros */
-#define MACH_MSGH_BITS_RAISED_IMPORTANCE(bits) \
+#define MACH_MSGH_BITS_RAISED_IMPORTANCE(bits) \
(((bits) & MACH_MSGH_BITS_RAISEIMP) != MACH_MSGH_BITS_ZERO)
-#define MACH_MSGH_BITS_HOLDS_IMPORTANCE_ASSERTION(bits) \
+#define MACH_MSGH_BITS_HOLDS_IMPORTANCE_ASSERTION(bits) \
(((bits) & MACH_MSGH_BITS_IMPHOLDASRT) != MACH_MSGH_BITS_ZERO)
/*
* Every message starts with a message header.
* Following the message header, if the message is complex, are a count
- * of type descriptors and the type descriptors themselves
- * (mach_msg_descriptor_t). The size of the message must be specified in
- * bytes, and includes the message header, descriptor count, descriptors,
+ * of type descriptors and the type descriptors themselves
+ * (mach_msg_descriptor_t). The size of the message must be specified in
+ * bytes, and includes the message header, descriptor count, descriptors,
* and inline data.
*
* The msgh_remote_port field specifies the destination of the message.
*/
typedef unsigned int mach_msg_bits_t;
-typedef natural_t mach_msg_size_t;
+typedef natural_t mach_msg_size_t;
typedef integer_t mach_msg_id_t;
-
#define MACH_MSG_SIZE_NULL (mach_msg_size_t *) 0
+typedef unsigned int mach_msg_priority_t;
+
+#define MACH_MSG_PRIORITY_UNSPECIFIED (mach_msg_priority_t) 0
+
typedef unsigned int mach_msg_type_name_t;
-#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */
-#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send right(s) */
-#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce right */
-#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send right(s) */
-#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */
-#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive right */
-#define MACH_MSG_TYPE_COPY_RECEIVE 22 /* NOT VALID */
-#define MACH_MSG_TYPE_DISPOSE_RECEIVE 24 /* must hold receive right */
-#define MACH_MSG_TYPE_DISPOSE_SEND 25 /* must hold send right(s) */
-#define MACH_MSG_TYPE_DISPOSE_SEND_ONCE 26 /* must hold sendonce right */
+#define MACH_MSG_TYPE_MOVE_RECEIVE 16 /* Must hold receive right */
+#define MACH_MSG_TYPE_MOVE_SEND 17 /* Must hold send right(s) */
+#define MACH_MSG_TYPE_MOVE_SEND_ONCE 18 /* Must hold sendonce right */
+#define MACH_MSG_TYPE_COPY_SEND 19 /* Must hold send right(s) */
+#define MACH_MSG_TYPE_MAKE_SEND 20 /* Must hold receive right */
+#define MACH_MSG_TYPE_MAKE_SEND_ONCE 21 /* Must hold receive right */
+#define MACH_MSG_TYPE_COPY_RECEIVE 22 /* NOT VALID */
+#define MACH_MSG_TYPE_DISPOSE_RECEIVE 24 /* must hold receive right */
+#define MACH_MSG_TYPE_DISPOSE_SEND 25 /* must hold send right(s) */
+#define MACH_MSG_TYPE_DISPOSE_SEND_ONCE 26 /* must hold sendonce right */
typedef unsigned int mach_msg_copy_options_t;
-#define MACH_MSG_PHYSICAL_COPY 0
-#define MACH_MSG_VIRTUAL_COPY 1
-#define MACH_MSG_ALLOCATE 2
-#define MACH_MSG_OVERWRITE 3
+#define MACH_MSG_PHYSICAL_COPY 0
+#define MACH_MSG_VIRTUAL_COPY 1
+#define MACH_MSG_ALLOCATE 2
+#define MACH_MSG_OVERWRITE 3 /* deprecated */
#ifdef MACH_KERNEL
-#define MACH_MSG_KALLOC_COPY_T 4
+#define MACH_MSG_KALLOC_COPY_T 4
#endif /* MACH_KERNEL */
+#define MACH_MSG_GUARD_FLAGS_NONE 0x0000
+#define MACH_MSG_GUARD_FLAGS_IMMOVABLE_RECEIVE 0x0001 /* Move the receive right and mark it as immovable */
+#define MACH_MSG_GUARD_FLAGS_UNGUARDED_ON_SEND 0x0002 /* Verify that the port is unguarded */
+#define MACH_MSG_GUARD_FLAGS_MASK 0x0003 /* Valid flag bits */
+typedef unsigned int mach_msg_guard_flags_t;
+
/*
- * In a complex mach message, the mach_msg_header_t is followed by
- * a descriptor count, then an array of that number of descriptors
+ * In a complex mach message, the mach_msg_header_t is followed by
+ * a descriptor count, then an array of that number of descriptors
* (mach_msg_*_descriptor_t). The type field of mach_msg_type_descriptor_t
* (which any descriptor can be cast to) indicates the flavor of the
* descriptor.
*
* Note that in LP64, the various types of descriptors are no longer all
- * the same size as mach_msg_descriptor_t, so the array cannot be indexed
+ * the same size as mach_msg_descriptor_t, so the array cannot be indexed
* as expected.
*/
typedef unsigned int mach_msg_descriptor_type_t;
-#define MACH_MSG_PORT_DESCRIPTOR 0
-#define MACH_MSG_OOL_DESCRIPTOR 1
-#define MACH_MSG_OOL_PORTS_DESCRIPTOR 2
-#define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3
+#define MACH_MSG_PORT_DESCRIPTOR 0
+#define MACH_MSG_OOL_DESCRIPTOR 1
+#define MACH_MSG_OOL_PORTS_DESCRIPTOR 2
+#define MACH_MSG_OOL_VOLATILE_DESCRIPTOR 3
+#define MACH_MSG_GUARDED_PORT_DESCRIPTOR 4
-#pragma pack(4)
+#pragma pack(push, 4)
-typedef struct
-{
- natural_t pad1;
- mach_msg_size_t pad2;
- unsigned int pad3 : 24;
- mach_msg_descriptor_type_t type : 8;
+typedef struct{
+ natural_t pad1;
+ mach_msg_size_t pad2;
+ unsigned int pad3 : 24;
+ mach_msg_descriptor_type_t type : 8;
} mach_msg_type_descriptor_t;
-typedef struct
-{
- mach_port_t name;
+typedef struct{
+ mach_port_t name;
#if !(defined(KERNEL) && defined(__LP64__))
// Pad to 8 bytes everywhere except the K64 kernel where mach_port_t is 8 bytes
- mach_msg_size_t pad1;
+ mach_msg_size_t pad1;
#endif
- unsigned int pad2 : 16;
- mach_msg_type_name_t disposition : 8;
- mach_msg_descriptor_type_t type : 8;
+ unsigned int pad2 : 16;
+ mach_msg_type_name_t disposition : 8;
+ mach_msg_descriptor_type_t type : 8;
#if defined(KERNEL)
- uint32_t pad_end;
+ uint32_t pad_end;
#endif
} mach_msg_port_descriptor_t;
-typedef struct
-{
- uint32_t address;
- mach_msg_size_t size;
- boolean_t deallocate: 8;
- mach_msg_copy_options_t copy: 8;
- unsigned int pad1: 8;
- mach_msg_descriptor_type_t type: 8;
+typedef struct{
+ uint32_t address;
+ mach_msg_size_t size;
+ boolean_t deallocate: 8;
+ mach_msg_copy_options_t copy: 8;
+ unsigned int pad1: 8;
+ mach_msg_descriptor_type_t type: 8;
} mach_msg_ool_descriptor32_t;
-typedef struct
-{
- uint64_t address;
- boolean_t deallocate: 8;
- mach_msg_copy_options_t copy: 8;
- unsigned int pad1: 8;
- mach_msg_descriptor_type_t type: 8;
- mach_msg_size_t size;
+typedef struct{
+ uint64_t address;
+ boolean_t deallocate: 8;
+ mach_msg_copy_options_t copy: 8;
+ unsigned int pad1: 8;
+ mach_msg_descriptor_type_t type: 8;
+ mach_msg_size_t size;
} mach_msg_ool_descriptor64_t;
-typedef struct
-{
- void* address;
+typedef struct{
+ void* address;
#if !defined(__LP64__)
- mach_msg_size_t size;
+ mach_msg_size_t size;
#endif
- boolean_t deallocate: 8;
- mach_msg_copy_options_t copy: 8;
- unsigned int pad1: 8;
- mach_msg_descriptor_type_t type: 8;
+ boolean_t deallocate: 8;
+ mach_msg_copy_options_t copy: 8;
+ unsigned int pad1: 8;
+ mach_msg_descriptor_type_t type: 8;
#if defined(__LP64__)
- mach_msg_size_t size;
+ mach_msg_size_t size;
#endif
#if defined(KERNEL) && !defined(__LP64__)
- uint32_t pad_end;
+ uint32_t pad_end;
#endif
} mach_msg_ool_descriptor_t;
-typedef struct
-{
- uint32_t address;
- mach_msg_size_t count;
- boolean_t deallocate: 8;
- mach_msg_copy_options_t copy: 8;
- mach_msg_type_name_t disposition : 8;
- mach_msg_descriptor_type_t type : 8;
+typedef struct{
+ uint32_t address;
+ mach_msg_size_t count;
+ boolean_t deallocate: 8;
+ mach_msg_copy_options_t copy: 8;
+ mach_msg_type_name_t disposition : 8;
+ mach_msg_descriptor_type_t type : 8;
} mach_msg_ool_ports_descriptor32_t;
-typedef struct
-{
- uint64_t address;
- boolean_t deallocate: 8;
- mach_msg_copy_options_t copy: 8;
- mach_msg_type_name_t disposition : 8;
- mach_msg_descriptor_type_t type : 8;
- mach_msg_size_t count;
+typedef struct{
+ uint64_t address;
+ boolean_t deallocate: 8;
+ mach_msg_copy_options_t copy: 8;
+ mach_msg_type_name_t disposition : 8;
+ mach_msg_descriptor_type_t type : 8;
+ mach_msg_size_t count;
} mach_msg_ool_ports_descriptor64_t;
-typedef struct
-{
- void* address;
+typedef struct{
+ void* address;
#if !defined(__LP64__)
- mach_msg_size_t count;
+ mach_msg_size_t count;
#endif
- boolean_t deallocate: 8;
- mach_msg_copy_options_t copy: 8;
- mach_msg_type_name_t disposition : 8;
- mach_msg_descriptor_type_t type : 8;
+ boolean_t deallocate: 8;
+ mach_msg_copy_options_t copy: 8;
+ mach_msg_type_name_t disposition : 8;
+ mach_msg_descriptor_type_t type : 8;
#if defined(__LP64__)
- mach_msg_size_t count;
+ mach_msg_size_t count;
#endif
#if defined(KERNEL) && !defined(__LP64__)
- uint32_t pad_end;
+ uint32_t pad_end;
#endif
} mach_msg_ool_ports_descriptor_t;
+typedef struct{
+ uint32_t context;
+ mach_port_name_t name;
+ mach_msg_guard_flags_t flags : 16;
+ mach_msg_type_name_t disposition : 8;
+ mach_msg_descriptor_type_t type : 8;
+} mach_msg_guarded_port_descriptor32_t;
+
+typedef struct{
+ uint64_t context;
+ mach_msg_guard_flags_t flags : 16;
+ mach_msg_type_name_t disposition : 8;
+ mach_msg_descriptor_type_t type : 8;
+ mach_port_name_t name;
+} mach_msg_guarded_port_descriptor64_t;
+
+typedef struct{
+#if defined(KERNEL)
+ mach_port_t name;
+#if !defined(__LP64__)
+ uint32_t pad1;
+#endif
+ mach_msg_guard_flags_t flags : 16;
+ mach_msg_type_name_t disposition : 8;
+ mach_msg_descriptor_type_t type : 8;
+#if defined(__LP64__)
+ uint32_t pad_end;
+#endif /* defined(__LP64__) */
+#else
+ mach_port_context_t context;
+#if !defined(__LP64__)
+ mach_port_name_t name;
+#endif
+ mach_msg_guard_flags_t flags : 16;
+ mach_msg_type_name_t disposition : 8;
+ mach_msg_descriptor_type_t type : 8;
+#if defined(__LP64__)
+ mach_port_name_t name;
+#endif /* defined(__LP64__) */
+#endif /* defined(KERNEL) */
+} mach_msg_guarded_port_descriptor_t;
+
/*
* LP64support - This union definition is not really
* appropriate in LP64 mode because not all descriptors
* are of the same size in that environment.
*/
#if defined(__LP64__) && defined(KERNEL)
-typedef union
-{
- mach_msg_port_descriptor_t port;
- mach_msg_ool_descriptor32_t out_of_line;
- mach_msg_ool_ports_descriptor32_t ool_ports;
- mach_msg_type_descriptor_t type;
+typedef union{
+ mach_msg_port_descriptor_t port;
+ mach_msg_ool_descriptor32_t out_of_line;
+ mach_msg_ool_ports_descriptor32_t ool_ports;
+ mach_msg_type_descriptor_t type;
+ mach_msg_guarded_port_descriptor32_t guarded_port;
} mach_msg_descriptor_t;
#else
-typedef union
-{
- mach_msg_port_descriptor_t port;
- mach_msg_ool_descriptor_t out_of_line;
- mach_msg_ool_ports_descriptor_t ool_ports;
- mach_msg_type_descriptor_t type;
+typedef union{
+ mach_msg_port_descriptor_t port;
+ mach_msg_ool_descriptor_t out_of_line;
+ mach_msg_ool_ports_descriptor_t ool_ports;
+ mach_msg_type_descriptor_t type;
+ mach_msg_guarded_port_descriptor_t guarded_port;
} mach_msg_descriptor_t;
#endif
-typedef struct
-{
- mach_msg_size_t msgh_descriptor_count;
+typedef struct{
+ mach_msg_size_t msgh_descriptor_count;
} mach_msg_body_t;
#define MACH_MSG_BODY_NULL (mach_msg_body_t *) 0
#define MACH_MSG_DESCRIPTOR_NULL (mach_msg_descriptor_t *) 0
-typedef struct
-{
- mach_msg_bits_t msgh_bits;
- mach_msg_size_t msgh_size;
- mach_port_t msgh_remote_port;
- mach_port_t msgh_local_port;
- mach_port_name_t msgh_voucher_port;
- mach_msg_id_t msgh_id;
+typedef struct{
+ mach_msg_bits_t msgh_bits;
+ mach_msg_size_t msgh_size;
+ mach_port_t msgh_remote_port;
+ mach_port_t msgh_local_port;
+ mach_port_name_t msgh_voucher_port;
+ mach_msg_id_t msgh_id;
} mach_msg_header_t;
-#define msgh_reserved msgh_voucher_port
-#define MACH_MSG_NULL (mach_msg_header_t *) 0
+#define msgh_reserved msgh_voucher_port
+#define MACH_MSG_NULL (mach_msg_header_t *) 0
-typedef struct
-{
- mach_msg_header_t header;
- mach_msg_body_t body;
+typedef struct{
+ mach_msg_header_t header;
+ mach_msg_body_t body;
} mach_msg_base_t;
-typedef unsigned int mach_msg_trailer_type_t;
+typedef unsigned int mach_msg_trailer_type_t;
-#define MACH_MSG_TRAILER_FORMAT_0 0
+#define MACH_MSG_TRAILER_FORMAT_0 0
-typedef unsigned int mach_msg_trailer_size_t;
+typedef unsigned int mach_msg_trailer_size_t;
typedef char *mach_msg_trailer_info_t;
-typedef struct
-{
- mach_msg_trailer_type_t msgh_trailer_type;
- mach_msg_trailer_size_t msgh_trailer_size;
+typedef struct{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
} mach_msg_trailer_t;
/*
* multiple threads receive and/or process received
* messages.
*/
-typedef struct
-{
- mach_msg_trailer_type_t msgh_trailer_type;
- mach_msg_trailer_size_t msgh_trailer_size;
- mach_port_seqno_t msgh_seqno;
+typedef struct{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
} mach_msg_seqno_trailer_t;
-typedef struct
-{
- unsigned int val[2];
+typedef struct{
+ unsigned int val[2];
} security_token_t;
-typedef struct
-{
- mach_msg_trailer_type_t msgh_trailer_type;
- mach_msg_trailer_size_t msgh_trailer_size;
- mach_port_seqno_t msgh_seqno;
- security_token_t msgh_sender;
+typedef struct{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
} mach_msg_security_trailer_t;
/*
* of the subject identity within the token may change
* over time.
*/
-typedef struct
-{
- unsigned int val[8];
+typedef struct{
+ unsigned int val[8];
} audit_token_t;
-typedef struct
-{
- mach_msg_trailer_type_t msgh_trailer_type;
- mach_msg_trailer_size_t msgh_trailer_size;
- mach_port_seqno_t msgh_seqno;
- security_token_t msgh_sender;
- audit_token_t msgh_audit;
+typedef struct{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
} mach_msg_audit_trailer_t;
-typedef struct
-{
- mach_msg_trailer_type_t msgh_trailer_type;
- mach_msg_trailer_size_t msgh_trailer_size;
- mach_port_seqno_t msgh_seqno;
- security_token_t msgh_sender;
- audit_token_t msgh_audit;
- mach_port_context_t msgh_context;
+typedef struct{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context_t msgh_context;
} mach_msg_context_trailer_t;
+#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
+typedef struct{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context32_t msgh_context;
+} mach_msg_context_trailer32_t;
+
+typedef struct{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context64_t msgh_context;
+} mach_msg_context_trailer64_t;
+#endif
-typedef struct
-{
- mach_port_name_t sender;
+typedef struct{
+ mach_port_name_t sender;
} msg_labels_t;
-/*
- Trailer type to pass MAC policy label info as a mach message trailer.
-
-*/
-
-typedef struct
-{
- mach_msg_trailer_type_t msgh_trailer_type;
- mach_msg_trailer_size_t msgh_trailer_size;
- mach_port_seqno_t msgh_seqno;
- security_token_t msgh_sender;
- audit_token_t msgh_audit;
- mach_port_context_t msgh_context;
- int msgh_ad;
- msg_labels_t msgh_labels;
+/*
+ * Trailer type to pass MAC policy label info as a mach message trailer.
+ *
+ */
+
+typedef struct{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context_t msgh_context;
+ int msgh_ad;
+ msg_labels_t msgh_labels;
} mach_msg_mac_trailer_t;
+#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
+typedef struct{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context32_t msgh_context;
+ int msgh_ad;
+ msg_labels_t msgh_labels;
+} mach_msg_mac_trailer32_t;
+
+typedef struct{
+ mach_msg_trailer_type_t msgh_trailer_type;
+ mach_msg_trailer_size_t msgh_trailer_size;
+ mach_port_seqno_t msgh_seqno;
+ security_token_t msgh_sender;
+ audit_token_t msgh_audit;
+ mach_port_context64_t msgh_context;
+ int msgh_ad;
+ msg_labels_t msgh_labels;
+} mach_msg_mac_trailer64_t;
+
+#endif
#define MACH_MSG_TRAILER_MINIMUM_SIZE sizeof(mach_msg_trailer_t)
* another module may exceed the local modules notion of
* MAX_TRAILER_SIZE.
*/
+#if defined(MACH_KERNEL_PRIVATE) && defined(__arm64__)
+typedef mach_msg_mac_trailer64_t mach_msg_max_trailer64_t;
+typedef mach_msg_mac_trailer32_t mach_msg_max_trailer32_t;
+#endif
typedef mach_msg_mac_trailer_t mach_msg_max_trailer_t;
#define MAX_TRAILER_SIZE ((mach_msg_size_t)sizeof(mach_msg_max_trailer_t))
typedef mach_msg_security_trailer_t mach_msg_format_0_trailer_t;
/*typedef mach_msg_mac_trailer_t mach_msg_format_0_trailer_t;
-*/
+ */
#define MACH_MSG_TRAILER_FORMAT_0_SIZE sizeof(mach_msg_format_0_trailer_t)
#define KERNEL_SECURITY_TOKEN_VALUE { {0, 1} }
-extern security_token_t KERNEL_SECURITY_TOKEN;
+extern const security_token_t KERNEL_SECURITY_TOKEN;
#define KERNEL_AUDIT_TOKEN_VALUE { {0, 0, 0, 0, 0, 0, 0, 0} }
-extern audit_token_t KERNEL_AUDIT_TOKEN;
+extern const audit_token_t KERNEL_AUDIT_TOKEN;
-typedef integer_t mach_msg_options_t;
+typedef integer_t mach_msg_options_t;
-typedef struct
-{
- mach_msg_header_t header;
+typedef struct{
+ mach_msg_header_t header;
} mach_msg_empty_send_t;
-typedef struct
-{
- mach_msg_header_t header;
- mach_msg_trailer_t trailer;
+typedef struct{
+ mach_msg_header_t header;
+ mach_msg_trailer_t trailer;
} mach_msg_empty_rcv_t;
-typedef union
-{
- mach_msg_empty_send_t send;
- mach_msg_empty_rcv_t rcv;
+typedef union{
+ mach_msg_empty_send_t send;
+ mach_msg_empty_rcv_t rcv;
} mach_msg_empty_t;
-#pragma pack()
+#pragma pack(pop)
/* utility to round the message size - will become machine dependent */
-#define round_msg(x) (((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \
- ~(sizeof (natural_t) - 1))
+#define round_msg(x) (((mach_msg_size_t)(x) + sizeof (natural_t) - 1) & \
+ ~(sizeof (natural_t) - 1))
/*
* There is no fixed upper bound to the size of Mach messages.
*/
-#define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0)
+#define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0)
#if defined(__APPLE_API_PRIVATE)
/*
* In either case, waiting for memory is [currently] outside
* the scope of send timeout values provided to IPC.
*/
-#define MACH_MSG_SIZE_RELIABLE ((mach_msg_size_t) 256 * 1024)
+#define MACH_MSG_SIZE_RELIABLE ((mach_msg_size_t) 256 * 1024)
#endif
/*
* Compatibility definitions, for code written
* when there was a msgh_kind instead of msgh_seqno.
*/
-#define MACH_MSGH_KIND_NORMAL 0x00000000
-#define MACH_MSGH_KIND_NOTIFICATION 0x00000001
-#define msgh_kind msgh_seqno
-#define mach_msg_kind_t mach_port_seqno_t
+#define MACH_MSGH_KIND_NORMAL 0x00000000
+#define MACH_MSGH_KIND_NOTIFICATION 0x00000001
+#define msgh_kind msgh_seqno
+#define mach_msg_kind_t mach_port_seqno_t
typedef natural_t mach_msg_type_size_t;
typedef natural_t mach_msg_type_number_t;
* are not transferred, just the port name.)
*/
-#define MACH_MSG_TYPE_PORT_NONE 0
+#define MACH_MSG_TYPE_PORT_NONE 0
-#define MACH_MSG_TYPE_PORT_NAME 15
-#define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE
-#define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND
-#define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE
+#define MACH_MSG_TYPE_PORT_NAME 15
+#define MACH_MSG_TYPE_PORT_RECEIVE MACH_MSG_TYPE_MOVE_RECEIVE
+#define MACH_MSG_TYPE_PORT_SEND MACH_MSG_TYPE_MOVE_SEND
+#define MACH_MSG_TYPE_PORT_SEND_ONCE MACH_MSG_TYPE_MOVE_SEND_ONCE
-#define MACH_MSG_TYPE_LAST 22 /* Last assigned */
+#define MACH_MSG_TYPE_LAST 22 /* Last assigned */
/*
* A dummy value. Mostly used to indicate that the actual value
* will be filled in later, dynamically.
*/
-#define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1)
+#define MACH_MSG_TYPE_POLYMORPHIC ((mach_msg_type_name_t) -1)
/*
* Is a given item a port type?
*/
-#define MACH_MSG_TYPE_PORT_ANY(x) \
- (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
+#define MACH_MSG_TYPE_PORT_ANY(x) \
+ (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
-#define MACH_MSG_TYPE_PORT_ANY_SEND(x) \
- (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \
+#define MACH_MSG_TYPE_PORT_ANY_SEND(x) \
+ (((x) >= MACH_MSG_TYPE_MOVE_SEND) && \
((x) <= MACH_MSG_TYPE_MAKE_SEND_ONCE))
-#define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \
- (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
+#define MACH_MSG_TYPE_PORT_ANY_RIGHT(x) \
+ (((x) >= MACH_MSG_TYPE_MOVE_RECEIVE) && \
((x) <= MACH_MSG_TYPE_MOVE_SEND_ONCE))
typedef integer_t mach_msg_option_t;
-#define MACH_MSG_OPTION_NONE 0x00000000
+#define MACH_MSG_OPTION_NONE 0x00000000
-#define MACH_SEND_MSG 0x00000001
-#define MACH_RCV_MSG 0x00000002
+#define MACH_SEND_MSG 0x00000001
+#define MACH_RCV_MSG 0x00000002
-#define MACH_RCV_LARGE 0x00000004 /* report large message sizes */
-#define MACH_RCV_LARGE_IDENTITY 0x00000008 /* identify source of large messages */
+#define MACH_RCV_LARGE 0x00000004 /* report large message sizes */
+#define MACH_RCV_LARGE_IDENTITY 0x00000008 /* identify source of large messages */
-#define MACH_SEND_TIMEOUT 0x00000010 /* timeout value applies to send */
-#define MACH_SEND_INTERRUPT 0x00000040 /* don't restart interrupted sends */
-#define MACH_SEND_NOTIFY 0x00000080 /* arm send-possible notify */
-#define MACH_SEND_ALWAYS 0x00010000 /* ignore qlimits - kernel only */
-#define MACH_SEND_TRAILER 0x00020000 /* sender-provided trailer */
+#define MACH_SEND_TIMEOUT 0x00000010 /* timeout value applies to send */
+#define MACH_SEND_OVERRIDE 0x00000020 /* priority override for send */
+#define MACH_SEND_INTERRUPT 0x00000040 /* don't restart interrupted sends */
+#define MACH_SEND_NOTIFY 0x00000080 /* arm send-possible notify */
+#define MACH_SEND_ALWAYS 0x00010000 /* ignore qlimits - kernel only */
+#define MACH_SEND_TRAILER 0x00020000 /* sender-provided trailer */
#define MACH_SEND_NOIMPORTANCE 0x00040000 /* msg won't carry importance */
-#define MACH_SEND_NODENAP MACH_SEND_NOIMPORTANCE
-#define MACH_SEND_IMPORTANCE 0x00080000 /* msg carries importance - kernel only */
+#define MACH_SEND_NODENAP MACH_SEND_NOIMPORTANCE
+#define MACH_SEND_IMPORTANCE 0x00080000 /* msg carries importance - kernel only */
+#define MACH_SEND_SYNC_OVERRIDE 0x00100000 /* msg should do sync ipc override */
+#define MACH_SEND_PROPAGATE_QOS 0x00200000 /* IPC should propagate the caller's QoS */
+#define MACH_SEND_SYNC_USE_THRPRI MACH_SEND_PROPAGATE_QOS /* obsolete name */
+#define MACH_SEND_KERNEL 0x00400000 /* full send from kernel space - kernel only */
+#define MACH_SEND_SYNC_BOOTSTRAP_CHECKIN 0x00800000 /* special reply port should boost thread doing sync bootstrap checkin */
+
+#define MACH_RCV_TIMEOUT 0x00000100 /* timeout value applies to receive */
+#define MACH_RCV_NOTIFY 0x00000000 /* legacy name (value was: 0x00000200) */
+#define MACH_RCV_INTERRUPT 0x00000400 /* don't restart interrupted receive */
+#define MACH_RCV_VOUCHER 0x00000800 /* willing to receive voucher port */
+#define MACH_RCV_OVERWRITE 0x00000000 /* scatter receive (deprecated) */
+#define MACH_RCV_GUARDED_DESC 0x00001000 /* Can receive new guarded descriptor */
+#define MACH_RCV_SYNC_WAIT 0x00004000 /* sync waiter waiting for rcv */
+#define MACH_RCV_SYNC_PEEK 0x00008000 /* sync waiter waiting to peek */
+
+#define MACH_MSG_STRICT_REPLY 0x00000200 /* Enforce specific properties about the reply port, and
+ * the context in which a thread replies to a message.
+ * This flag must be passed on both the SEND and RCV */
+
+#ifdef XNU_KERNEL_PRIVATE
+#define MACH_RCV_STACK 0x00002000 /* receive into highest addr of buffer */
-#define MACH_RCV_TIMEOUT 0x00000100 /* timeout value applies to receive */
-#define MACH_RCV_NOTIFY 0x00000200 /* reserved - legacy */
-#define MACH_RCV_INTERRUPT 0x00000400 /* don't restart interrupted receive */
-#define MACH_RCV_VOUCHER 0x00000800 /* willing to receive voucher port */
-#define MACH_RCV_OVERWRITE 0x00001000 /* scatter receive */
+/*
+ * NOTE:
+ * This internal-only flag is intended for use by a single thread per-port/set!
+ * If more than one thread attempts to MACH_PEEK_MSG on a port or set, one of
+ * the threads may miss messages (in fact, it may never wake up).
+ */
+#define MACH_PEEK_MSG 0x80000000 /* receive, but leave msgs queued */
-/*
+#endif
+
+/*
* NOTE: a 0x00------ RCV mask implies to ask for
- * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements,
+ * a MACH_MSG_TRAILER_FORMAT_0 with 0 Elements,
* which is equivalent to a mach_msg_trailer_t.
*
* XXXMAC: unlike the rest of the MACH_RCV_* flags, MACH_RCV_TRAILER_LABELS
- * needs its own private bit since we only calculate its fields when absolutely
+ * needs its own private bit since we only calculate its fields when absolutely
* required.
*/
#define MACH_RCV_TRAILER_NULL 0
#define MACH_RCV_TRAILER_AV 7
#define MACH_RCV_TRAILER_LABELS 8
-#define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28)
-#define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24)
-#define MACH_RCV_TRAILER_MASK ((0xf << 24))
+#define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28)
+#define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24)
+#define MACH_RCV_TRAILER_MASK ((0xf << 24))
#define GET_RCV_ELEMENTS(y) (((y) >> 24) & 0xf)
#ifdef MACH_KERNEL_PRIVATE
/* The options that the kernel honors when passed from user space */
-#define MACH_SEND_USER (MACH_SEND_MSG | \
- MACH_SEND_TIMEOUT | MACH_SEND_NOTIFY | \
- MACH_SEND_TRAILER | MACH_SEND_NOIMPORTANCE )
+#define MACH_SEND_USER (MACH_SEND_MSG | MACH_SEND_TIMEOUT | \
+ MACH_SEND_NOTIFY | MACH_SEND_OVERRIDE | \
+ MACH_SEND_TRAILER | MACH_SEND_NOIMPORTANCE | \
+ MACH_SEND_SYNC_OVERRIDE | MACH_SEND_PROPAGATE_QOS | \
+ MACH_SEND_SYNC_BOOTSTRAP_CHECKIN | \
+ MACH_MSG_STRICT_REPLY | MACH_RCV_GUARDED_DESC)
-#define MACH_RCV_USER (MACH_RCV_MSG | \
- MACH_RCV_TIMEOUT | MACH_RCV_OVERWRITE | \
- MACH_RCV_LARGE | MACH_RCV_LARGE_IDENTITY | \
- MACH_RCV_VOUCHER | MACH_RCV_TRAILER_MASK)
+#define MACH_RCV_USER (MACH_RCV_MSG | MACH_RCV_TIMEOUT | \
+ MACH_RCV_LARGE | MACH_RCV_LARGE_IDENTITY | \
+ MACH_RCV_VOUCHER | MACH_RCV_TRAILER_MASK | \
+ MACH_RCV_SYNC_WAIT | MACH_RCV_SYNC_PEEK | \
+ MACH_RCV_GUARDED_DESC | MACH_MSG_STRICT_REPLY)
-#define MACH_MSG_OPTION_USER (MACH_SEND_USER | MACH_RCV_USER)
+#define MACH_MSG_OPTION_USER (MACH_SEND_USER | MACH_RCV_USER)
/* The options implemented by the library interface to mach_msg et. al. */
-#define MACH_MSG_OPTION_LIB (MACH_SEND_INTERRUPT | MACH_RCV_INTERRUPT)
-
-/* Default options to use when sending from the kernel */
-#if 11938665
- /*
- * Until we are sure of its effects, we are disabling
- * importance donation from the kernel-side of user
- * threads in importance-donating tasks.
- */
+#define MACH_MSG_OPTION_LIB (MACH_SEND_INTERRUPT | MACH_RCV_INTERRUPT)
+
+/*
+ * Default options to use when sending from the kernel.
+ *
+ * Until we are sure of its effects, we are disabling
+ * importance donation from the kernel-side of user
+ * threads in importance-donating tasks.
+ * (11938665 & 23925818)
+ */
#define MACH_SEND_KERNEL_DEFAULT (MACH_SEND_MSG | \
- MACH_SEND_ALWAYS | MACH_SEND_NOIMPORTANCE)
-#else
-#define MACH_SEND_KERNEL_DEFAULT (MACH_SEND_MSG | MACH_SEND_ALWAYS)
-#endif
+ MACH_SEND_ALWAYS | MACH_SEND_NOIMPORTANCE)
+
+#define MACH_SEND_WITH_STRICT_REPLY(_opts) (((_opts) & (MACH_MSG_STRICT_REPLY | MACH_SEND_MSG)) == \
+ (MACH_MSG_STRICT_REPLY | MACH_SEND_MSG))
+
+#define MACH_SEND_REPLY_IS_IMMOVABLE(_opts) (((_opts) & (MACH_MSG_STRICT_REPLY | \
+ MACH_SEND_MSG | MACH_RCV_MSG | \
+ MACH_RCV_GUARDED_DESC)) == \
+ (MACH_MSG_STRICT_REPLY | MACH_SEND_MSG | MACH_RCV_GUARDED_DESC))
+
+#define MACH_RCV_WITH_STRICT_REPLY(_opts) (((_opts) & (MACH_MSG_STRICT_REPLY | MACH_RCV_MSG)) == \
+ (MACH_MSG_STRICT_REPLY | MACH_RCV_MSG))
+
+#define MACH_RCV_WITH_IMMOVABLE_REPLY(_opts) (((_opts) & (MACH_MSG_STRICT_REPLY | \
+ MACH_RCV_MSG | MACH_RCV_GUARDED_DESC)) == \
+ (MACH_MSG_STRICT_REPLY | MACH_RCV_MSG | MACH_RCV_GUARDED_DESC))
#endif /* MACH_KERNEL_PRIVATE */
-/*
- * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS,
+/*
+ * XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS,
* we just fall through to mach_msg_max_trailer_t.
* This is correct behavior since mach_msg_max_trailer_t is defined as
* mac_msg_mac_trailer_t which is used for the LABELS trailer.
- * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed
+ * It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed
* with one of the other options.
*/
-#define REQUESTED_TRAILER_SIZE_NATIVE(y) \
- ((mach_msg_trailer_size_t) \
- ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \
- sizeof(mach_msg_trailer_t) : \
- ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \
- sizeof(mach_msg_seqno_trailer_t) : \
- ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \
- sizeof(mach_msg_security_trailer_t) : \
- ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \
- sizeof(mach_msg_audit_trailer_t) : \
- ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \
- sizeof(mach_msg_context_trailer_t) : \
- ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \
- sizeof(mach_msg_mac_trailer_t) : \
+#define REQUESTED_TRAILER_SIZE_NATIVE(y) \
+ ((mach_msg_trailer_size_t) \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \
+ sizeof(mach_msg_trailer_t) : \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \
+ sizeof(mach_msg_seqno_trailer_t) : \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \
+ sizeof(mach_msg_security_trailer_t) : \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \
+ sizeof(mach_msg_audit_trailer_t) : \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \
+ sizeof(mach_msg_context_trailer_t) : \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \
+ sizeof(mach_msg_mac_trailer_t) : \
sizeof(mach_msg_max_trailer_t))))))))
#ifdef XNU_KERNEL_PRIVATE
+#if defined(__arm64__)
+#define REQUESTED_TRAILER_SIZE(is64, y) \
+ ((mach_msg_trailer_size_t) \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \
+ sizeof(mach_msg_trailer_t) : \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SEQNO) ? \
+ sizeof(mach_msg_seqno_trailer_t) : \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_SENDER) ? \
+ sizeof(mach_msg_security_trailer_t) : \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AUDIT) ? \
+ sizeof(mach_msg_audit_trailer_t) : \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_CTX) ? \
+ ((is64) ? sizeof(mach_msg_context_trailer64_t) : sizeof(mach_msg_context_trailer32_t)) : \
+ ((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_AV) ? \
+ ((is64) ? sizeof(mach_msg_mac_trailer64_t) : sizeof(mach_msg_mac_trailer32_t)) : \
+ sizeof(mach_msg_max_trailer_t))))))))
+#else
#define REQUESTED_TRAILER_SIZE(is64, y) REQUESTED_TRAILER_SIZE_NATIVE(y)
+#endif
#else /* XNU_KERNEL_PRIVATE */
#define REQUESTED_TRAILER_SIZE(y) REQUESTED_TRAILER_SIZE_NATIVE(y)
typedef kern_return_t mach_msg_return_t;
-#define MACH_MSG_SUCCESS 0x00000000
-
-
-#define MACH_MSG_MASK 0x00003e00
- /* All special error code bits defined below. */
-#define MACH_MSG_IPC_SPACE 0x00002000
- /* No room in IPC name space for another capability name. */
-#define MACH_MSG_VM_SPACE 0x00001000
- /* No room in VM address space for out-of-line memory. */
-#define MACH_MSG_IPC_KERNEL 0x00000800
- /* Kernel resource shortage handling an IPC capability. */
-#define MACH_MSG_VM_KERNEL 0x00000400
- /* Kernel resource shortage handling out-of-line memory. */
-
-#define MACH_SEND_IN_PROGRESS 0x10000001
- /* Thread is waiting to send. (Internal use only.) */
-#define MACH_SEND_INVALID_DATA 0x10000002
- /* Bogus in-line data. */
-#define MACH_SEND_INVALID_DEST 0x10000003
- /* Bogus destination port. */
-#define MACH_SEND_TIMED_OUT 0x10000004
- /* Message not sent before timeout expired. */
-#define MACH_SEND_INVALID_VOUCHER 0x10000005
- /* Bogus voucher port. */
-#define MACH_SEND_INTERRUPTED 0x10000007
- /* Software interrupt. */
-#define MACH_SEND_MSG_TOO_SMALL 0x10000008
- /* Data doesn't contain a complete message. */
-#define MACH_SEND_INVALID_REPLY 0x10000009
- /* Bogus reply port. */
-#define MACH_SEND_INVALID_RIGHT 0x1000000a
- /* Bogus port rights in the message body. */
-#define MACH_SEND_INVALID_NOTIFY 0x1000000b
- /* Bogus notify port argument. */
-#define MACH_SEND_INVALID_MEMORY 0x1000000c
- /* Invalid out-of-line memory pointer. */
-#define MACH_SEND_NO_BUFFER 0x1000000d
- /* No message buffer is available. */
-#define MACH_SEND_TOO_LARGE 0x1000000e
- /* Send is too large for port */
-#define MACH_SEND_INVALID_TYPE 0x1000000f
- /* Invalid msg-type specification. */
-#define MACH_SEND_INVALID_HEADER 0x10000010
- /* A field in the header had a bad value. */
-#define MACH_SEND_INVALID_TRAILER 0x10000011
- /* The trailer to be sent does not match kernel format. */
-#define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015
- /* compatibility: no longer a returned error */
-
-#define MACH_RCV_IN_PROGRESS 0x10004001
- /* Thread is waiting for receive. (Internal use only.) */
-#define MACH_RCV_INVALID_NAME 0x10004002
- /* Bogus name for receive port/port-set. */
-#define MACH_RCV_TIMED_OUT 0x10004003
- /* Didn't get a message within the timeout value. */
-#define MACH_RCV_TOO_LARGE 0x10004004
- /* Message buffer is not large enough for inline data. */
-#define MACH_RCV_INTERRUPTED 0x10004005
- /* Software interrupt. */
-#define MACH_RCV_PORT_CHANGED 0x10004006
- /* compatibility: no longer a returned error */
-#define MACH_RCV_INVALID_NOTIFY 0x10004007
- /* Bogus notify port argument. */
-#define MACH_RCV_INVALID_DATA 0x10004008
- /* Bogus message buffer for inline data. */
-#define MACH_RCV_PORT_DIED 0x10004009
- /* Port/set was sent away/died during receive. */
-#define MACH_RCV_IN_SET 0x1000400a
- /* compatibility: no longer a returned error */
-#define MACH_RCV_HEADER_ERROR 0x1000400b
- /* Error receiving message header. See special bits. */
-#define MACH_RCV_BODY_ERROR 0x1000400c
- /* Error receiving message body. See special bits. */
-#define MACH_RCV_INVALID_TYPE 0x1000400d
- /* Invalid msg-type specification in scatter list. */
-#define MACH_RCV_SCATTER_SMALL 0x1000400e
- /* Out-of-line overwrite region is not large enough */
-#define MACH_RCV_INVALID_TRAILER 0x1000400f
- /* trailer type or number of trailer elements not supported */
+#define MACH_MSG_SUCCESS 0x00000000
+
+
+#define MACH_MSG_MASK 0x00003e00
+/* All special error code bits defined below. */
+#define MACH_MSG_IPC_SPACE 0x00002000
+/* No room in IPC name space for another capability name. */
+#define MACH_MSG_VM_SPACE 0x00001000
+/* No room in VM address space for out-of-line memory. */
+#define MACH_MSG_IPC_KERNEL 0x00000800
+/* Kernel resource shortage handling an IPC capability. */
+#define MACH_MSG_VM_KERNEL 0x00000400
+/* Kernel resource shortage handling out-of-line memory. */
+
+#define MACH_SEND_IN_PROGRESS 0x10000001
+/* Thread is waiting to send. (Internal use only.) */
+#define MACH_SEND_INVALID_DATA 0x10000002
+/* Bogus in-line data. */
+#define MACH_SEND_INVALID_DEST 0x10000003
+/* Bogus destination port. */
+#define MACH_SEND_TIMED_OUT 0x10000004
+/* Message not sent before timeout expired. */
+#define MACH_SEND_INVALID_VOUCHER 0x10000005
+/* Bogus voucher port. */
+#define MACH_SEND_INTERRUPTED 0x10000007
+/* Software interrupt. */
+#define MACH_SEND_MSG_TOO_SMALL 0x10000008
+/* Data doesn't contain a complete message. */
+#define MACH_SEND_INVALID_REPLY 0x10000009
+/* Bogus reply port. */
+#define MACH_SEND_INVALID_RIGHT 0x1000000a
+/* Bogus port rights in the message body. */
+#define MACH_SEND_INVALID_NOTIFY 0x1000000b
+/* Bogus notify port argument. */
+#define MACH_SEND_INVALID_MEMORY 0x1000000c
+/* Invalid out-of-line memory pointer. */
+#define MACH_SEND_NO_BUFFER 0x1000000d
+/* No message buffer is available. */
+#define MACH_SEND_TOO_LARGE 0x1000000e
+/* Send is too large for port */
+#define MACH_SEND_INVALID_TYPE 0x1000000f
+/* Invalid msg-type specification. */
+#define MACH_SEND_INVALID_HEADER 0x10000010
+/* A field in the header had a bad value. */
+#define MACH_SEND_INVALID_TRAILER 0x10000011
+/* The trailer to be sent does not match kernel format. */
+#define MACH_SEND_INVALID_CONTEXT 0x10000012
+/* The sending thread context did not match the context on the dest port */
+#define MACH_SEND_INVALID_RT_OOL_SIZE 0x10000015
+/* compatibility: no longer a returned error */
+#define MACH_SEND_NO_GRANT_DEST 0x10000016
+/* The destination port doesn't accept ports in body */
+
+#define MACH_RCV_IN_PROGRESS 0x10004001
+/* Thread is waiting for receive. (Internal use only.) */
+#define MACH_RCV_INVALID_NAME 0x10004002
+/* Bogus name for receive port/port-set. */
+#define MACH_RCV_TIMED_OUT 0x10004003
+/* Didn't get a message within the timeout value. */
+#define MACH_RCV_TOO_LARGE 0x10004004
+/* Message buffer is not large enough for inline data. */
+#define MACH_RCV_INTERRUPTED 0x10004005
+/* Software interrupt. */
+#define MACH_RCV_PORT_CHANGED 0x10004006
+/* compatibility: no longer a returned error */
+#define MACH_RCV_INVALID_NOTIFY 0x10004007
+/* Bogus notify port argument. */
+#define MACH_RCV_INVALID_DATA 0x10004008
+/* Bogus message buffer for inline data. */
+#define MACH_RCV_PORT_DIED 0x10004009
+/* Port/set was sent away/died during receive. */
+#define MACH_RCV_IN_SET 0x1000400a
+/* compatibility: no longer a returned error */
+#define MACH_RCV_HEADER_ERROR 0x1000400b
+/* Error receiving message header. See special bits. */
+#define MACH_RCV_BODY_ERROR 0x1000400c
+/* Error receiving message body. See special bits. */
+#define MACH_RCV_INVALID_TYPE 0x1000400d
+/* Invalid msg-type specification in scatter list. */
+#define MACH_RCV_SCATTER_SMALL 0x1000400e
+/* Out-of-line overwrite region is not large enough */
+#define MACH_RCV_INVALID_TRAILER 0x1000400f
+/* trailer type or number of trailer elements not supported */
#define MACH_RCV_IN_PROGRESS_TIMED 0x10004011
- /* Waiting for receive with timeout. (Internal use only.) */
+/* Waiting for receive with timeout. (Internal use only.) */
+#define MACH_RCV_INVALID_REPLY 0x10004012
+/* invalid reply port used in a STRICT_REPLY message */
+
+#ifdef XNU_KERNEL_PRIVATE
+#define MACH_PEEK_IN_PROGRESS 0x10008001
+/* Waiting for a peek. (Internal use only.) */
+#define MACH_PEEK_READY 0x10008002
+/* Waiting for a peek. (Internal use only.) */
+#endif
__BEGIN_DECLS
* already contain scatter control information to direct the
* receiving of the message.
*/
-
-extern mach_msg_return_t mach_msg_overwrite(
- mach_msg_header_t *msg,
- mach_msg_option_t option,
- mach_msg_size_t send_size,
- mach_msg_size_t rcv_size,
- mach_port_name_t rcv_name,
- mach_msg_timeout_t timeout,
- mach_port_name_t notify,
- mach_msg_header_t *rcv_msg,
- mach_msg_size_t rcv_limit);
-
-#ifndef KERNEL
+__WATCHOS_PROHIBITED __TVOS_PROHIBITED
+extern mach_msg_return_t mach_msg_overwrite(
+ mach_msg_header_t *msg,
+ mach_msg_option_t option,
+ mach_msg_size_t send_size,
+ mach_msg_size_t rcv_size,
+ mach_port_name_t rcv_name,
+ mach_msg_timeout_t timeout,
+ mach_port_name_t notify,
+ mach_msg_header_t *rcv_msg,
+ mach_msg_size_t rcv_limit);
+
+#ifndef KERNEL
/*
* Routine: mach_msg
* of that fact, then restart the appropriate parts of the
* operation silently (trap version does not restart).
*/
-extern mach_msg_return_t mach_msg(
- mach_msg_header_t *msg,
- mach_msg_option_t option,
- mach_msg_size_t send_size,
- mach_msg_size_t rcv_size,
- mach_port_name_t rcv_name,
- mach_msg_timeout_t timeout,
- mach_port_name_t notify);
+__WATCHOS_PROHIBITED __TVOS_PROHIBITED
+extern mach_msg_return_t mach_msg(
+ mach_msg_header_t *msg,
+ mach_msg_option_t option,
+ mach_msg_size_t send_size,
+ mach_msg_size_t rcv_size,
+ mach_port_name_t rcv_name,
+ mach_msg_timeout_t timeout,
+ mach_port_name_t notify);
/*
* Routine: mach_voucher_deallocate
* Deallocate a mach voucher created or received in a message. Drops
* one (send right) reference to the voucher.
*/
-extern kern_return_t mach_voucher_deallocate(
- mach_port_name_t voucher);
+__WATCHOS_PROHIBITED __TVOS_PROHIBITED
+extern kern_return_t mach_voucher_deallocate(
+ mach_port_name_t voucher);
#elif defined(MACH_KERNEL_PRIVATE)
-extern mach_msg_return_t mach_msg_receive_results(void);
+extern mach_msg_return_t mach_msg_receive_results(mach_msg_size_t *size);
-#endif /* KERNEL */
+#endif /* KERNEL */
__END_DECLS
-#endif /* _MACH_MESSAGE_H_ */
-
+#endif /* _MACH_MESSAGE_H_ */