* Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
* Copyright (c) 2000-2006 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
* 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.
* 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.
* 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,
* 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.
* 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.
* Mach Operating System
* Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
* All Rights Reserved.
* 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.
* 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 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.
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
* School of Computer Science
* Carnegie Mellon University
* Pittsburgh PA 15213-3890
* 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.
*/
* any improvements or extensions that they make and grant Carnegie Mellon
* the rights to redistribute these changes.
*/
* [task-local] name to identify it - and the the various "rights"
* held by the task for that specific endpoint.
*
* [task-local] name to identify it - and the the various "rights"
* held by the task for that specific endpoint.
*
* mach_port_t - a named port right
*
* In the kernel, "rights" are represented [named] by pointers to
* mach_port_t - a named port right
*
* In the kernel, "rights" are represented [named] by pointers to
* code - including, but not limited to, Mach IPC code - lives in the
* limbo between the current user-level task and the "next" task. Very
* little of the kernel code runs in full kernel task context. So very
* code - including, but not limited to, Mach IPC code - lives in the
* limbo between the current user-level task and the "next" task. Very
* little of the kernel code runs in full kernel task context. So very
*
* Because of this implementation approach, all in-kernel rights for
* a given port coalesce [have the same name/pointer]. The actual
*
* Because of this implementation approach, all in-kernel rights for
* a given port coalesce [have the same name/pointer]. The actual
/*
* For kernel code that resides outside of Mach proper, we opaque the
* port structure definition.
*/
/*
* For kernel code that resides outside of Mach proper, we opaque the
* port structure definition.
*/
#define CAST_MACH_PORT_TO_NAME(x) ((mach_port_name_t)(uintptr_t)(x))
#define CAST_MACH_NAME_TO_PORT(x) ((x) == MACH_PORT_DEAD ? (mach_port_t)IPC_PORT_DEAD : (mach_port_t)(uintptr_t)(x))
#define CAST_MACH_PORT_TO_NAME(x) ((mach_port_name_t)(uintptr_t)(x))
#define CAST_MACH_NAME_TO_PORT(x) ((x) == MACH_PORT_DEAD ? (mach_port_t)IPC_PORT_DEAD : (mach_port_t)(uintptr_t)(x))
* mach_port_t - a named port right
*
* In user-space, "rights" are represented by the name of the
* right in the Mach port namespace. Even so, this type is
* presented as a unique one to more clearly denote the presence
* mach_port_t - a named port right
*
* In user-space, "rights" are represented by the name of the
* right in the Mach port namespace. Even so, this type is
* presented as a unique one to more clearly denote the presence
*
* Often, various rights for a port held in a single name space
* will coalesce and are, therefore, be identified by a single name
* [this is the case for send and receive rights]. But not
* always [send-once rights currently get a unique name for
*
* Often, various rights for a port held in a single name space
* will coalesce and are, therefore, be identified by a single name
* [this is the case for send and receive rights]. But not
* always [send-once rights currently get a unique name for
-#define MACH_PORT_NULL 0 /* intentional loose typing */
-#define MACH_PORT_DEAD ((mach_port_name_t) ~0)
-#define MACH_PORT_VALID(name) \
- (((name) != MACH_PORT_NULL) && \
- ((name) != MACH_PORT_DEAD))
+#define MACH_PORT_NULL 0 /* intentional loose typing */
+#define MACH_PORT_DEAD ((mach_port_name_t) ~0)
+#define MACH_PORT_VALID(name) \
+ (((name) != MACH_PORT_NULL) && \
+ ((name) != MACH_PORT_DEAD))
-#define MACH_PORT_INDEX(name) ((name) >> 8)
-#define MACH_PORT_GEN(name) (((name) & 0xff) << 24)
-#define MACH_PORT_MAKE(index, gen) \
- (((index) << 8) | (gen) >> 24)
+#define MACH_PORT_INDEX(name) ((name) >> 8)
+#define MACH_PORT_GEN(name) (((name) & 0xff) << 24)
+#define MACH_PORT_MAKE(index, gen) \
+ (((index) << 8) | (gen) >> 24)
-#define MACH_PORT_INDEX(name) (name)
-#define MACH_PORT_GEN(name) (0)
-#define MACH_PORT_MAKE(index, gen) (index)
+#define MACH_PORT_INDEX(name) (name)
+#define MACH_PORT_GEN(name) (0)
+#define MACH_PORT_MAKE(index, gen) (index)
-#define MACH_PORT_RIGHT_SEND ((mach_port_right_t) 0)
-#define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1)
-#define MACH_PORT_RIGHT_SEND_ONCE ((mach_port_right_t) 2)
-#define MACH_PORT_RIGHT_PORT_SET ((mach_port_right_t) 3)
-#define MACH_PORT_RIGHT_DEAD_NAME ((mach_port_right_t) 4)
-#define MACH_PORT_RIGHT_LABELH ((mach_port_right_t) 5)
-#define MACH_PORT_RIGHT_NUMBER ((mach_port_right_t) 6)
+#define MACH_PORT_RIGHT_SEND ((mach_port_right_t) 0)
+#define MACH_PORT_RIGHT_RECEIVE ((mach_port_right_t) 1)
+#define MACH_PORT_RIGHT_SEND_ONCE ((mach_port_right_t) 2)
+#define MACH_PORT_RIGHT_PORT_SET ((mach_port_right_t) 3)
+#define MACH_PORT_RIGHT_DEAD_NAME ((mach_port_right_t) 4)
+#define MACH_PORT_RIGHT_LABELH ((mach_port_right_t) 5)
+#define MACH_PORT_RIGHT_NUMBER ((mach_port_right_t) 6)
-#define MACH_PORT_TYPE(right) \
- ((mach_port_type_t)(((mach_port_type_t) 1) \
- << ((right) + ((mach_port_right_t) 16))))
-#define MACH_PORT_TYPE_NONE ((mach_port_type_t) 0L)
-#define MACH_PORT_TYPE_SEND MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND)
-#define MACH_PORT_TYPE_RECEIVE MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE)
+#define MACH_PORT_TYPE(right) \
+ ((mach_port_type_t)(((mach_port_type_t) 1) \
+ << ((right) + ((mach_port_right_t) 16))))
+#define MACH_PORT_TYPE_NONE ((mach_port_type_t) 0L)
+#define MACH_PORT_TYPE_SEND MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND)
+#define MACH_PORT_TYPE_RECEIVE MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE)
#define MACH_PORT_TYPE_DEAD_NAME MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME)
#define MACH_PORT_TYPE_LABELH MACH_PORT_TYPE(MACH_PORT_RIGHT_LABELH)
/* Convenient combinations. */
#define MACH_PORT_TYPE_DEAD_NAME MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME)
#define MACH_PORT_TYPE_LABELH MACH_PORT_TYPE(MACH_PORT_RIGHT_LABELH)
/* Convenient combinations. */
-#define MACH_PORT_TYPE_SEND_RECEIVE \
- (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE)
-#define MACH_PORT_TYPE_SEND_RIGHTS \
- (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE)
-#define MACH_PORT_TYPE_PORT_RIGHTS \
- (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE)
-#define MACH_PORT_TYPE_PORT_OR_DEAD \
- (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME)
-#define MACH_PORT_TYPE_ALL_RIGHTS \
- (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET)
+#define MACH_PORT_TYPE_SEND_RECEIVE \
+ (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE)
+#define MACH_PORT_TYPE_SEND_RIGHTS \
+ (MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE)
+#define MACH_PORT_TYPE_PORT_RIGHTS \
+ (MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE)
+#define MACH_PORT_TYPE_PORT_OR_DEAD \
+ (MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME)
+#define MACH_PORT_TYPE_ALL_RIGHTS \
+ (MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET)
-#define MACH_PORT_TYPE_DNREQUEST 0x80000000
-#define MACH_PORT_TYPE_SPREQUEST 0x40000000
-#define MACH_PORT_TYPE_SPREQUEST_DELAYED 0x20000000
+#define MACH_PORT_TYPE_DNREQUEST 0x80000000
+#define MACH_PORT_TYPE_SPREQUEST 0x40000000
+#define MACH_PORT_TYPE_SPREQUEST_DELAYED 0x20000000
-typedef natural_t mach_port_seqno_t; /* sequence number */
-typedef natural_t mach_port_mscount_t; /* make-send count */
-typedef natural_t mach_port_msgcount_t; /* number of msgs */
-typedef natural_t mach_port_rights_t; /* number of rights */
+typedef natural_t mach_port_seqno_t; /* sequence number */
+typedef natural_t mach_port_mscount_t; /* make-send count */
+typedef natural_t mach_port_msgcount_t; /* number of msgs */
+typedef natural_t mach_port_rights_t; /* number of rights */
-#define MACH_PORT_SRIGHTS_NONE 0 /* no srights */
-#define MACH_PORT_SRIGHTS_PRESENT 1 /* srights */
-typedef unsigned int mach_port_srights_t; /* status of send rights */
+#define MACH_PORT_SRIGHTS_NONE 0 /* no srights */
+#define MACH_PORT_SRIGHTS_PRESENT 1 /* srights */
+typedef unsigned int mach_port_srights_t; /* status of send rights */
- mach_port_rights_t mps_pset; /* count of containing port sets */
- mach_port_seqno_t mps_seqno; /* sequence number */
- mach_port_mscount_t mps_mscount; /* make-send count */
- mach_port_msgcount_t mps_qlimit; /* queue limit */
- mach_port_msgcount_t mps_msgcount; /* number in the queue */
- mach_port_rights_t mps_sorights; /* how many send-once rights */
- boolean_t mps_srights; /* do send rights exist? */
- boolean_t mps_pdrequest; /* port-deleted requested? */
- boolean_t mps_nsrequest; /* no-senders requested? */
- natural_t mps_flags; /* port flags */
+ mach_port_rights_t mps_pset; /* count of containing port sets */
+ mach_port_seqno_t mps_seqno; /* sequence number */
+ mach_port_mscount_t mps_mscount; /* make-send count */
+ mach_port_msgcount_t mps_qlimit; /* queue limit */
+ mach_port_msgcount_t mps_msgcount; /* number in the queue */
+ mach_port_rights_t mps_sorights; /* how many send-once rights */
+ boolean_t mps_srights; /* do send rights exist? */
+ boolean_t mps_pdrequest; /* port-deleted requested? */
+ boolean_t mps_nsrequest; /* no-senders requested? */
+ natural_t mps_flags; /* port flags */
-#define MACH_PORT_QLIMIT_ZERO (0)
-#define MACH_PORT_QLIMIT_BASIC (5)
-#define MACH_PORT_QLIMIT_SMALL (16)
-#define MACH_PORT_QLIMIT_LARGE (1024)
-#define MACH_PORT_QLIMIT_KERNEL (65534)
-#define MACH_PORT_QLIMIT_MIN MACH_PORT_QLIMIT_ZERO
-#define MACH_PORT_QLIMIT_DEFAULT MACH_PORT_QLIMIT_BASIC
-#define MACH_PORT_QLIMIT_MAX MACH_PORT_QLIMIT_LARGE
+#define MACH_PORT_QLIMIT_ZERO (0)
+#define MACH_PORT_QLIMIT_BASIC (5)
+#define MACH_PORT_QLIMIT_SMALL (16)
+#define MACH_PORT_QLIMIT_LARGE (1024)
+#define MACH_PORT_QLIMIT_KERNEL (65534)
+#define MACH_PORT_QLIMIT_MIN MACH_PORT_QLIMIT_ZERO
+#define MACH_PORT_QLIMIT_DEFAULT MACH_PORT_QLIMIT_BASIC
+#define MACH_PORT_QLIMIT_MAX MACH_PORT_QLIMIT_LARGE
-#define MACH_PORT_STATUS_FLAG_TEMPOWNER 0x01
-#define MACH_PORT_STATUS_FLAG_GUARDED 0x02
-#define MACH_PORT_STATUS_FLAG_STRICT_GUARD 0x04
-#define MACH_PORT_STATUS_FLAG_IMP_DONATION 0x08
-#define MACH_PORT_STATUS_FLAG_REVIVE 0x10
-#define MACH_PORT_STATUS_FLAG_TASKPTR 0x20
+#define MACH_PORT_STATUS_FLAG_TEMPOWNER 0x01
+#define MACH_PORT_STATUS_FLAG_GUARDED 0x02
+#define MACH_PORT_STATUS_FLAG_STRICT_GUARD 0x04
+#define MACH_PORT_STATUS_FLAG_IMP_DONATION 0x08
+#define MACH_PORT_STATUS_FLAG_REVIVE 0x10
+#define MACH_PORT_STATUS_FLAG_TASKPTR 0x20
-typedef int mach_port_flavor_t;
-#define MACH_PORT_LIMITS_INFO 1 /* uses mach_port_limits_t */
-#define MACH_PORT_RECEIVE_STATUS 2 /* uses mach_port_status_t */
-#define MACH_PORT_DNREQUESTS_SIZE 3 /* info is int */
-#define MACH_PORT_TEMPOWNER 4 /* indicates receive right will be reassigned to another task */
-#define MACH_PORT_IMPORTANCE_RECEIVER 5 /* indicates recieve right accepts priority donation */
-#define MACH_PORT_DENAP_RECEIVER 6 /* indicates receive right accepts de-nap donation */
-#define MACH_PORT_INFO_EXT 7 /* uses mach_port_info_ext_t */
-
-#define MACH_PORT_LIMITS_INFO_COUNT ((natural_t) \
+typedef int mach_port_flavor_t;
+#define MACH_PORT_LIMITS_INFO 1 /* uses mach_port_limits_t */
+#define MACH_PORT_RECEIVE_STATUS 2 /* uses mach_port_status_t */
+#define MACH_PORT_DNREQUESTS_SIZE 3 /* info is int */
+#define MACH_PORT_TEMPOWNER 4 /* indicates receive right will be reassigned to another task */
+#define MACH_PORT_IMPORTANCE_RECEIVER 5 /* indicates recieve right accepts priority donation */
+#define MACH_PORT_DENAP_RECEIVER 6 /* indicates receive right accepts de-nap donation */
+#define MACH_PORT_INFO_EXT 7 /* uses mach_port_info_ext_t */
+
+#define MACH_PORT_LIMITS_INFO_COUNT ((natural_t) \
(sizeof(mach_port_info_ext_t)/sizeof(natural_t)))
/*
* Structure used to pass information about port allocation requests.
* Must be padded to 64-bits total length.
*/
typedef struct mach_port_qos {
(sizeof(mach_port_info_ext_t)/sizeof(natural_t)))
/*
* Structure used to pass information about port allocation requests.
* Must be padded to 64-bits total length.
*/
typedef struct mach_port_qos {
-#define MPO_CONTEXT_AS_GUARD 0x01 /* Add guard to the port */
-#define MPO_QLIMIT 0x02 /* Set qlimit for the port msg queue */
-#define MPO_TEMPOWNER 0x04 /* Set the tempowner bit of the port */
-#define MPO_IMPORTANCE_RECEIVER 0x08 /* Mark the port as importance receiver */
-#define MPO_INSERT_SEND_RIGHT 0x10 /* Insert a send right for the port */
-#define MPO_STRICT 0x20 /* Apply strict guarding for port */
-#define MPO_DENAP_RECEIVER 0x40 /* Mark the port as App de-nap receiver */
+#define MPO_CONTEXT_AS_GUARD 0x01 /* Add guard to the port */
+#define MPO_QLIMIT 0x02 /* Set qlimit for the port msg queue */
+#define MPO_TEMPOWNER 0x04 /* Set the tempowner bit of the port */
+#define MPO_IMPORTANCE_RECEIVER 0x08 /* Mark the port as importance receiver */
+#define MPO_INSERT_SEND_RIGHT 0x10 /* Insert a send right for the port */
+#define MPO_STRICT 0x20 /* Apply strict guarding for port */
+#define MPO_DENAP_RECEIVER 0x40 /* Mark the port as App de-nap receiver */
- uint32_t flags; /* Flags defining attributes for port */
- mach_port_limits_t mpl; /* Message queue limit for port */
- uint64_t reserved[2]; /* Reserved */
+ uint32_t flags; /* Flags defining attributes for port */
+ mach_port_limits_t mpl; /* Message queue limit for port */
+ uint64_t reserved[2]; /* Reserved */
- kGUARD_EXC_DESTROY = 1u << 0,
- kGUARD_EXC_MOD_REFS = 1u << 1,
- kGUARD_EXC_SET_CONTEXT = 1u << 2,
- kGUARD_EXC_UNGUARDED = 1u << 3,
- kGUARD_EXC_INCORRECT_GUARD = 1u << 4,
- /* start of non-fatal guards */
+ kGUARD_EXC_DESTROY = 1u << 0,
+ kGUARD_EXC_MOD_REFS = 1u << 1,
+ kGUARD_EXC_SET_CONTEXT = 1u << 2,
+ kGUARD_EXC_UNGUARDED = 1u << 3,
+ kGUARD_EXC_INCORRECT_GUARD = 1u << 4,
+ /* start of non-fatal guards */
kGUARD_EXC_INVALID_RIGHT = 1u << 8,
kGUARD_EXC_INVALID_NAME = 1u << 9,
kGUARD_EXC_INVALID_VALUE = 1u << 10,
kGUARD_EXC_INVALID_RIGHT = 1u << 8,
kGUARD_EXC_INVALID_NAME = 1u << 9,
kGUARD_EXC_INVALID_VALUE = 1u << 10,
/*
* Mach 3.0 renamed everything to have mach_ in front of it.
* These types and macros are provided for backward compatibility
* but are deprecated.
*/
/*
* Mach 3.0 renamed everything to have mach_ in front of it.
* These types and macros are provided for backward compatibility
* but are deprecated.
*/
-typedef mach_port_t port_t;
-typedef mach_port_name_t port_name_t;
-typedef mach_port_name_t *port_name_array_t;
+typedef mach_port_t port_t;
+typedef mach_port_name_t port_name_t;
+typedef mach_port_name_t *port_name_array_t;