Chameleon

Chameleon Svn Source Tree

Root/tags/2.3/i386/include/mach/port.h

Source at commit 2862 created 7 years 25 days ago.
By ifabio, Tag 2.3 release, bump svn to 2.4
1/*
2 * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/*
29 * @OSF_COPYRIGHT@
30 */
31/*
32 * Mach Operating System
33 * Copyright (c) 1991,1990,1989,1988,1987 Carnegie Mellon University
34 * All Rights Reserved.
35 *
36 * Permission to use, copy, modify and distribute this software and its
37 * documentation is hereby granted, provided that both the copyright
38 * notice and this permission notice appear in all copies of the
39 * software, derivative works or modified versions, and any portions
40 * thereof, and that both notices appear in supporting documentation.
41 *
42 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
43 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
44 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
45 *
46 * Carnegie Mellon requests users of this software to return to
47 *
48 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
49 * School of Computer Science
50 * Carnegie Mellon University
51 * Pittsburgh PA 15213-3890
52 *
53 * any improvements or extensions that they make and grant Carnegie Mellon
54 * the rights to redistribute these changes.
55 */
56/*
57 * NOTICE: This file was modified by McAfee Research in 2004 to introduce
58 * support for mandatory and extensible security protections. This notice
59 * is included in support of clause 2.2 (b) of the Apple Public License,
60 * Version 2.0.
61 */
62/*
63 */
64/*
65 *File:mach/port.h
66 *
67 *Definition of a Mach port
68 *
69 *Mach ports are the endpoints to Mach-implemented communications
70 *channels (usually uni-directional message queues, but other types
71 *also exist).
72 *
73 *Unique collections of these endpoints are maintained for each
74 *Mach task. Each Mach port in the task's collection is given a
75 *[task-local] name to identify it - and the the various "rights"
76 *held by the task for that specific endpoint.
77 *
78 *This header defines the types used to identify these Mach ports
79 *and the various rights associated with them. For more info see:
80 *
81 *<mach/mach_port.h> - manipulation of port rights in a given space
82 *<mach/message.h> - message queue [and port right passing] mechanism
83 *
84 */
85
86#ifndef_MACH_PORT_H_
87#define _MACH_PORT_H_
88
89#include <sys/cdefs.h>
90#include <stdint.h>
91#include <mach/boolean.h>
92#include <mach/machine/vm_types.h>
93
94/*
95 *mach_port_name_t - the local identity for a Mach port
96 *
97 *The name is Mach port namespace specific. It is used to
98 *identify the rights held for that port by the task whose
99 *namespace is implied [or specifically provided].
100 *
101 *Use of this type usually implies just a name - no rights.
102 *See mach_port_t for a type that implies a "named right."
103 *
104 */
105
106typedef natural_t mach_port_name_t;
107typedef mach_port_name_t *mach_port_name_array_t;
108
109
110/*
111 *mach_port_t - a named port right
112 *
113 *In user-space, "rights" are represented by the name of the
114 *right in the Mach port namespace. Even so, this type is
115 *presented as a unique one to more clearly denote the presence
116 *of a right coming along with the name.
117 *
118 *Often, various rights for a port held in a single name space
119 *will coalesce and are, therefore, be identified by a single name
120 *[this is the case for send and receive rights]. But not
121 *always [send-once rights currently get a unique name for
122 *each right].
123 *
124 */
125
126#ifndef _MACH_PORT_T
127#define _MACH_PORT_T
128typedef mach_port_name_t mach_port_t;
129#endif
130
131
132typedef mach_port_t*mach_port_array_t;
133
134/*
135 * MACH_PORT_NULL is a legal value that can be carried in messages.
136 * It indicates the absence of any port or port rights. (A port
137 * argument keeps the message from being "simple", even if the
138 * value is MACH_PORT_NULL.) The value MACH_PORT_DEAD is also a legal
139 * value that can be carried in messages. It indicates
140 * that a port right was present, but it died.
141 */
142
143#define MACH_PORT_NULL0 /* intentional loose typing */
144#define MACH_PORT_DEAD((mach_port_name_t) ~0)
145#define MACH_PORT_VALID(name)\
146(((name) != MACH_PORT_NULL) && \
147 ((name) != MACH_PORT_DEAD))
148
149
150/*
151 *For kernel-selected [assigned] port names, the name is
152 *comprised of two parts: a generation number and an index.
153 *This approach keeps the exact same name from being generated
154 *and reused too quickly [to catch right/reference counting bugs].
155 *The dividing line between the constituent parts is exposed so
156 *that efficient "mach_port_name_t to data structure pointer"
157 *conversion implementation can be made. But it is possible
158 *for user-level code to assign their own names to Mach ports.
159 *These are not required to participate in this algorithm. So
160 *care should be taken before "assuming" this model.
161 *
162 */
163
164#ifndefNO_PORT_GEN
165
166#defineMACH_PORT_INDEX(name)((name) >> 8)
167#defineMACH_PORT_GEN(name)(((name) & 0xff) << 24)
168#defineMACH_PORT_MAKE(index, gen)\
169(((index) << 8) | (gen) >> 24)
170
171#else/* NO_PORT_GEN */
172
173#defineMACH_PORT_INDEX(name)(name)
174#defineMACH_PORT_GEN(name)(0)
175#defineMACH_PORT_MAKE(index, gen)(index)
176
177#endif/* NO_PORT_GEN */
178
179
180/*
181 * These are the different rights a task may have for a port.
182 * The MACH_PORT_RIGHT_* definitions are used as arguments
183 * to mach_port_allocate, mach_port_get_refs, etc, to specify
184 * a particular right to act upon. The mach_port_names and
185 * mach_port_type calls return bitmasks using the MACH_PORT_TYPE_*
186 * definitions. This is because a single name may denote
187 * multiple rights.
188 */
189
190typedef natural_t mach_port_right_t;
191
192#define MACH_PORT_RIGHT_SEND((mach_port_right_t) 0)
193#define MACH_PORT_RIGHT_RECEIVE((mach_port_right_t) 1)
194#define MACH_PORT_RIGHT_SEND_ONCE((mach_port_right_t) 2)
195#define MACH_PORT_RIGHT_PORT_SET((mach_port_right_t) 3)
196#define MACH_PORT_RIGHT_DEAD_NAME((mach_port_right_t) 4)
197#define MACH_PORT_RIGHT_LABELH ((mach_port_right_t) 5)
198#define MACH_PORT_RIGHT_NUMBER((mach_port_right_t) 6)
199
200typedef natural_t mach_port_type_t;
201typedef mach_port_type_t *mach_port_type_array_t;
202
203#define MACH_PORT_TYPE(right)\
204((mach_port_type_t)(((mach_port_type_t) 1) \
205<< ((right) + ((mach_port_right_t) 16))))
206#define MACH_PORT_TYPE_NONE ((mach_port_type_t) 0L)
207#define MACH_PORT_TYPE_SEND MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND)
208#define MACH_PORT_TYPE_RECEIVE MACH_PORT_TYPE(MACH_PORT_RIGHT_RECEIVE)
209#define MACH_PORT_TYPE_SEND_ONCE MACH_PORT_TYPE(MACH_PORT_RIGHT_SEND_ONCE)
210#define MACH_PORT_TYPE_PORT_SET MACH_PORT_TYPE(MACH_PORT_RIGHT_PORT_SET)
211#define MACH_PORT_TYPE_DEAD_NAME MACH_PORT_TYPE(MACH_PORT_RIGHT_DEAD_NAME)
212#define MACH_PORT_TYPE_LABELH MACH_PORT_TYPE(MACH_PORT_RIGHT_LABELH)
213
214/* Convenient combinations. */
215
216#define MACH_PORT_TYPE_SEND_RECEIVE\
217(MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_RECEIVE)
218#defineMACH_PORT_TYPE_SEND_RIGHTS\
219(MACH_PORT_TYPE_SEND|MACH_PORT_TYPE_SEND_ONCE)
220#defineMACH_PORT_TYPE_PORT_RIGHTS\
221(MACH_PORT_TYPE_SEND_RIGHTS|MACH_PORT_TYPE_RECEIVE)
222#defineMACH_PORT_TYPE_PORT_OR_DEAD\
223(MACH_PORT_TYPE_PORT_RIGHTS|MACH_PORT_TYPE_DEAD_NAME)
224#define MACH_PORT_TYPE_ALL_RIGHTS\
225(MACH_PORT_TYPE_PORT_OR_DEAD|MACH_PORT_TYPE_PORT_SET)
226
227/* Dummy type bits that mach_port_type/mach_port_names can return. */
228
229#define MACH_PORT_TYPE_DNREQUEST0x80000000
230
231/* User-references for capabilities. */
232
233typedef natural_t mach_port_urefs_t;
234typedef integer_t mach_port_delta_t;/* change in urefs */
235
236/* Attributes of ports. (See mach_port_get_receive_status.) */
237
238typedef natural_t mach_port_seqno_t;/* sequence number */
239typedef natural_t mach_port_mscount_t;/* make-send count */
240typedef natural_t mach_port_msgcount_t;/* number of msgs */
241typedef natural_t mach_port_rights_t;/* number of rights */
242
243/*
244 *Are there outstanding send rights for a given port?
245 */
246#defineMACH_PORT_SRIGHTS_NONE0/* no srights */
247#defineMACH_PORT_SRIGHTS_PRESENT1/* srights */
248typedef unsigned int mach_port_srights_t;/* status of send rights */
249
250typedef struct mach_port_status {
251mach_port_rights_tmps_pset;/* count of containing port sets */
252mach_port_seqno_tmps_seqno;/* sequence number */
253mach_port_mscount_tmps_mscount;/* make-send count */
254mach_port_msgcount_tmps_qlimit;/* queue limit */
255mach_port_msgcount_tmps_msgcount;/* number in the queue */
256mach_port_rights_tmps_sorights;/* how many send-once rights */
257boolean_tmps_srights;/* do send rights exist? */
258boolean_tmps_pdrequest;/* port-deleted requested? */
259boolean_tmps_nsrequest;/* no-senders requested? */
260natural_tmps_flags;/* port flags */
261} mach_port_status_t;
262
263/* System-wide values for setting queue limits on a port */
264#define MACH_PORT_QLIMIT_ZERO((mach_port_msgcount_t) 0)
265#define MACH_PORT_QLIMIT_BASIC((mach_port_msgcount_t) 5)
266#define MACH_PORT_QLIMIT_SMALL((mach_port_msgcount_t) 16)
267#define MACH_PORT_QLIMIT_LARGE((mach_port_msgcount_t) 1024)
268#define MACH_PORT_QLIMIT_KERNEL((mach_port_msgcount_t) 65536)
269#define MACH_PORT_QLIMIT_MINMACH_PORT_QLIMIT_ZERO
270#define MACH_PORT_QLIMIT_DEFAULTMACH_PORT_QLIMIT_BASIC
271#define MACH_PORT_QLIMIT_MAXMACH_PORT_QLIMIT_LARGE
272
273typedef struct mach_port_limits {
274mach_port_msgcount_tmpl_qlimit;/* number of msgs */
275} mach_port_limits_t;
276
277typedef integer_t *mach_port_info_t;/* varying array of natural_t */
278
279/* Flavors for mach_port_get/set_attributes() */
280typedef intmach_port_flavor_t;
281#define MACH_PORT_LIMITS_INFO1/* uses mach_port_status_t */
282#define MACH_PORT_RECEIVE_STATUS2/* uses mach_port_limits_t */
283#define MACH_PORT_DNREQUESTS_SIZE3/* info is int */
284
285#define MACH_PORT_LIMITS_INFO_COUNT((natural_t) \
286(sizeof(mach_port_limits_t)/sizeof(natural_t)))
287#define MACH_PORT_RECEIVE_STATUS_COUNT((natural_t) \
288(sizeof(mach_port_status_t)/sizeof(natural_t)))
289#define MACH_PORT_DNREQUESTS_SIZE_COUNT 1
290
291/*
292 * Structure used to pass information about port allocation requests.
293 * Must be padded to 64-bits total length.
294 */
295typedef struct mach_port_qos {
296unsigned intname:1;/* name given */
297unsigned int prealloc:1;/* prealloced message */
298boolean_tpad1:30;
299natural_tlen;
300} mach_port_qos_t;
301
302#if!__DARWIN_UNIX03 && !defined(_NO_PORT_T_FROM_MACH)
303/*
304 * Mach 3.0 renamed everything to have mach_ in front of it.
305 * These types and macros are provided for backward compatibility
306 *but are deprecated.
307 */
308typedef mach_port_tport_t;
309typedef mach_port_name_tport_name_t;
310typedef mach_port_name_t*port_name_array_t;
311
312#define PORT_NULL((port_t) 0)
313#define PORT_DEAD((port_t) ~0)
314#define PORT_VALID(name) \
315((port_t)(name) != PORT_NULL && (port_t)(name) != PORT_DEAD)
316
317#endif/* !__DARWIN_UNIX03 && !_NO_PORT_T_FROM_MACH */
318
319#endif/* _MACH_PORT_H_ */
320

Archive Download this file

Revision: 2862