#include <mach/machine/vm_types.h>
#include <sys/cdefs.h>
+#include <sys/appleapiopts.h>
/*
* The timeout mechanism uses mach_msg_timeout_t values,
#define MACH_MSGH_BITS_USER 0x8000ffffU
#define MACH_MSGH_BITS_CIRCULAR 0x40000000 /* internal use only */
-#define MACH_MSGH_BITS_USED 0xc000ffffU
+#define MACH_MSGH_BITS_RAISEIMP 0x20000000 /* importance raise, internal use only */
+#define MACH_MSGH_BITS_IMPHOLDASRT 0x10000000 /* holds assertion alredy, in userland */
+#define MACH_MSGH_BITS_USED 0xf000ffffU
#define MACH_MSGH_BITS_PORTS_MASK \
(MACH_MSGH_BITS_REMOTE_MASK|MACH_MSGH_BITS_LOCAL_MASK)
#define MACH_MSG_TRAILER_FORMAT_0 0
typedef unsigned int mach_msg_trailer_size_t;
+typedef char *mach_msg_trailer_info_t;
typedef struct
{
mach_port_seqno_t msgh_seqno;
security_token_t msgh_sender;
audit_token_t msgh_audit;
- mach_vm_address_t msgh_context;
+ mach_port_context_t msgh_context;
} mach_msg_context_trailer_t;
-
typedef struct
{
mach_port_name_t sender;
mach_port_seqno_t msgh_seqno;
security_token_t msgh_sender;
audit_token_t msgh_audit;
- mach_vm_address_t msgh_context;
+ mach_port_context_t msgh_context;
int msgh_ad;
msg_labels_t msgh_labels;
} mach_msg_mac_trailer_t;
* another module may exceed the local modules notion of
* MAX_TRAILER_SIZE.
*/
+
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))
/*
* There is no fixed upper bound to the size of Mach messages.
*/
-
#define MACH_MSG_SIZE_MAX ((mach_msg_size_t) ~0)
+#if defined(__APPLE_API_PRIVATE)
+/*
+ * But architectural limits of a given implementation, or
+ * temporal conditions may cause unpredictable send failures
+ * for messages larger than MACH_MSG_SIZE_RELIABLE.
+ *
+ * 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)
+#endif
/*
* Compatibility definitions, for code written
* when there was a msgh_kind instead of msgh_seqno.
#define MACH_SEND_MSG 0x00000001
#define MACH_RCV_MSG 0x00000002
-#define MACH_RCV_LARGE 0x00000004
-#define MACH_SEND_TIMEOUT 0x00000010
-#define MACH_SEND_INTERRUPT 0x00000040 /* libmach implements */
-#define MACH_SEND_CANCEL 0x00000080
-#define MACH_SEND_ALWAYS 0x00010000 /* internal use only */
-#define MACH_SEND_TRAILER 0x00020000
+#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_NOIMPORTANCE 0x00040000 /* msg won't carry importance */
+#define MACH_SEND_IMPORTANCE 0x00080000 /* msg carries importance - kernel only */
+
-#define MACH_RCV_TIMEOUT 0x00000100
-#define MACH_RCV_NOTIFY 0x00000200
-#define MACH_RCV_INTERRUPT 0x00000400 /* libmach implements */
-#define MACH_RCV_OVERWRITE 0x00001000
+#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_OVERWRITE 0x00001000 /* scatter receive */
/*
* NOTE: a 0x00------ RCV mask implies to ask for
#define MACH_RCV_TRAILER_TYPE(x) (((x) & 0xf) << 28)
#define MACH_RCV_TRAILER_ELEMENTS(x) (((x) & 0xf) << 24)
-#define MACH_RCV_TRAILER_MASK ((0xff << 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_RCV_USER (MACH_RCV_MSG | \
+ MACH_RCV_TIMEOUT | MACH_RCV_OVERWRITE | \
+ MACH_RCV_LARGE | MACH_RCV_LARGE_IDENTITY | \
+ MACH_RCV_TRAILER_MASK)
+
+#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_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
+
+#endif /* MACH_KERNEL_PRIVATE */
+
/*
* XXXMAC: note that in the case of MACH_RCV_TRAILER_LABELS,
* we just fall through to mach_msg_max_trailer_t.
* It also makes things work properly if MACH_RCV_TRAILER_LABELS is ORed
* with one of the other options.
*/
-#define REQUESTED_TRAILER_SIZE(y) \
+
+#define REQUESTED_TRAILER_SIZE_NATIVE(y) \
((mach_msg_trailer_size_t) \
((GET_RCV_ELEMENTS(y) == MACH_RCV_TRAILER_NULL) ? \
sizeof(mach_msg_trailer_t) : \
sizeof(mach_msg_mac_trailer_t) : \
sizeof(mach_msg_max_trailer_t))))))))
+
+#ifdef XNU_KERNEL_PRIVATE
+
+#define REQUESTED_TRAILER_SIZE(is64, y) REQUESTED_TRAILER_SIZE_NATIVE(y)
+
+#else /* XNU_KERNEL_PRIVATE */
+#define REQUESTED_TRAILER_SIZE(y) REQUESTED_TRAILER_SIZE_NATIVE(y)
+#endif /* XNU_KERNEL_PRIVATE */
+
/*
* Much code assumes that mach_msg_return_t == kern_return_t.
* This definition is useful for descriptive purposes.