FreeBSD/Linux Kernel Cross Reference
sys/ipc/ipc_entry.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1993,1992,1991,1990,1989 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: ipc_entry.h,v $
29 * Revision 2.7 93/11/17 16:56:01 dbg
30 * Added ANSI function prototypes.
31 * [93/06/03 dbg]
32 *
33 * Revision 2.6 92/05/21 17:10:01 jfriedl
34 * Appended 'U' to long constants that would otherwise be signed.
35 * [92/05/16 jfriedl]
36 *
37 * Revision 2.5 91/05/14 16:31:54 mrt
38 * Correcting copyright
39 *
40 * Revision 2.4 91/02/05 17:21:24 mrt
41 * Changed to new Mach copyright
42 * [91/02/01 15:44:29 mrt]
43 *
44 * Revision 2.3 91/01/08 15:13:06 rpd
45 * Removed MACH_IPC_GENNOS, IE_BITS_UNUSEDC, IE_BITS_UNUSEDG.
46 * [90/11/08 rpd]
47 *
48 * Revision 2.2 90/06/02 14:49:41 rpd
49 * Created for new IPC.
50 * [90/03/26 20:54:40 rpd]
51 *
52 */
53 /*
54 * File: ipc/ipc_entry.h
55 * Author: Rich Draves
56 * Date: 1989
57 *
58 * Definitions for translation entries, which represent
59 * tasks' capabilities for ports and port sets.
60 */
61
62 #ifndef _IPC_IPC_ENTRY_H_
63 #define _IPC_IPC_ENTRY_H_
64
65 #include <mach/port.h>
66 #include <mach/kern_return.h>
67 #include <kern/zalloc.h>
68 #include <ipc/port.h>
69 #include <ipc/ipc_table.h>
70 #include <ipc/ipc_port.h>
71
72 /*
73 * Spaces hold capabilities for ipc_object_t's (ports and port sets).
74 * Each ipc_entry_t records a capability. Most capabilities have
75 * small names, and the entries are elements of a table.
76 * Capabilities can have large names, and a splay tree holds
77 * those entries. The cutoff point between the table and the tree
78 * is adjusted dynamically to minimize memory consumption.
79 *
80 * The ie_index field of entries in the table implements
81 * a ordered hash table with open addressing and linear probing.
82 * This hash table converts (space, object) -> name.
83 * It is used independently of the other fields.
84 *
85 * Free (unallocated) entries in the table have null ie_object
86 * fields. The ie_bits field is zero except for IE_BITS_GEN.
87 * The ie_next (ie_request) field links free entries into a free list.
88 *
89 * The first entry in the table (index 0) is always free.
90 * It is used as the head of the free list.
91 */
92
93 typedef unsigned int ipc_entry_bits_t;
94 typedef ipc_table_elems_t ipc_entry_num_t; /* number of entries */
95
96 typedef struct ipc_entry {
97 ipc_entry_bits_t ie_bits;
98 struct ipc_object *ie_object;
99 union {
100 mach_port_index_t next;
101 ipc_port_request_index_t request;
102 } index;
103 union {
104 mach_port_index_t table;
105 struct ipc_tree_entry *tree;
106 } hash;
107 } *ipc_entry_t;
108
109 #define IE_NULL ((ipc_entry_t) 0)
110
111 #define ie_request index.request
112 #define ie_next index.next
113 #define ie_index hash.table
114
115 #define IE_BITS_UREFS_MASK 0x0000ffff /* 16 bits of user-reference */
116 #define IE_BITS_UREFS(bits) ((bits) & IE_BITS_UREFS_MASK)
117
118 #define IE_BITS_TYPE_MASK 0x001f0000 /* 5 bits of capability type */
119 #define IE_BITS_TYPE(bits) ((bits) & IE_BITS_TYPE_MASK)
120
121 #define IE_BITS_MAREQUEST 0x00200000 /* 1 bit for msg-accepted */
122
123 #define IE_BITS_COMPAT 0x00400000 /* 1 bit for compatibility */
124
125 #define IE_BITS_COLLISION 0x00800000 /* 1 bit for collisions */
126 #define IE_BITS_GEN_MASK 0xff000000U /* 8 bits for generation */
127 #define IE_BITS_GEN(bits) ((bits) & IE_BITS_GEN_MASK)
128 #define IE_BITS_GEN_ONE 0x01000000 /* low bit of generation */
129 #define IE_BITS_RIGHT_MASK 0x007fffff /* relevant to the right */
130
131
132 typedef struct ipc_tree_entry {
133 struct ipc_entry ite_entry;
134 mach_port_t ite_name;
135 struct ipc_space *ite_space;
136 struct ipc_tree_entry *ite_lchild;
137 struct ipc_tree_entry *ite_rchild;
138 } *ipc_tree_entry_t;
139
140 #define ITE_NULL ((ipc_tree_entry_t) 0)
141
142 #define ite_bits ite_entry.ie_bits
143 #define ite_object ite_entry.ie_object
144 #define ite_request ite_entry.ie_request
145 #define ite_next ite_entry.hash.tree
146
147 extern zone_t ipc_tree_entry_zone;
148
149 #define ite_alloc() ((ipc_tree_entry_t) zalloc(ipc_tree_entry_zone))
150 #define ite_free(ite) zfree(ipc_tree_entry_zone, (vm_offset_t) (ite))
151
152
153 extern ipc_entry_t
154 ipc_entry_lookup(
155 ipc_space_t space,
156 mach_port_t name);
157
158 extern kern_return_t
159 ipc_entry_get(
160 ipc_space_t space,
161 mach_port_t *namep,
162 ipc_entry_t *entryp);
163
164 extern kern_return_t
165 ipc_entry_alloc(
166 ipc_space_t space,
167 mach_port_t *namep,
168 ipc_entry_t *entryp);
169
170 extern kern_return_t
171 ipc_entry_alloc_name(
172 ipc_space_t space,
173 mach_port_t name,
174 ipc_entry_t *entryp);
175
176 extern void
177 ipc_entry_dealloc(
178 ipc_space_t space,
179 mach_port_t name,
180 ipc_entry_t entry);
181
182 extern kern_return_t
183 ipc_entry_grow_table(
184 ipc_space_t space);
185
186 #endif /* _IPC_IPC_ENTRY_H_ */
Cache object: 7abe04435e90cb9a6685962c79e96628
|