FreeBSD/Linux Kernel Cross Reference
sys/ipc/ipc_entry.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 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.6 92/05/21 17:10:01 jfriedl
30 * Appended 'U' to long constants that would otherwise be signed.
31 * [92/05/16 jfriedl]
32 *
33 * Revision 2.5 91/05/14 16:31:54 mrt
34 * Correcting copyright
35 *
36 * Revision 2.4 91/02/05 17:21:24 mrt
37 * Changed to new Mach copyright
38 * [91/02/01 15:44:29 mrt]
39 *
40 * Revision 2.3 91/01/08 15:13:06 rpd
41 * Removed MACH_IPC_GENNOS, IE_BITS_UNUSEDC, IE_BITS_UNUSEDG.
42 * [90/11/08 rpd]
43 *
44 * Revision 2.2 90/06/02 14:49:41 rpd
45 * Created for new IPC.
46 * [90/03/26 20:54:40 rpd]
47 *
48 */
49 /*
50 * File: ipc/ipc_entry.h
51 * Author: Rich Draves
52 * Date: 1989
53 *
54 * Definitions for translation entries, which represent
55 * tasks' capabilities for ports and port sets.
56 */
57
58 #ifndef _IPC_IPC_ENTRY_H_
59 #define _IPC_IPC_ENTRY_H_
60
61 #include <mach/port.h>
62 #include <mach/kern_return.h>
63 #include <kern/zalloc.h>
64 #include <ipc/port.h>
65 #include <ipc/ipc_table.h>
66 #include <ipc/ipc_port.h>
67
68 /*
69 * Spaces hold capabilities for ipc_object_t's (ports and port sets).
70 * Each ipc_entry_t records a capability. Most capabilities have
71 * small names, and the entries are elements of a table.
72 * Capabilities can have large names, and a splay tree holds
73 * those entries. The cutoff point between the table and the tree
74 * is adjusted dynamically to minimize memory consumption.
75 *
76 * The ie_index field of entries in the table implements
77 * a ordered hash table with open addressing and linear probing.
78 * This hash table converts (space, object) -> name.
79 * It is used independently of the other fields.
80 *
81 * Free (unallocated) entries in the table have null ie_object
82 * fields. The ie_bits field is zero except for IE_BITS_GEN.
83 * The ie_next (ie_request) field links free entries into a free list.
84 *
85 * The first entry in the table (index 0) is always free.
86 * It is used as the head of the free list.
87 */
88
89 typedef unsigned int ipc_entry_bits_t;
90 typedef ipc_table_elems_t ipc_entry_num_t; /* number of entries */
91
92 typedef struct ipc_entry {
93 ipc_entry_bits_t ie_bits;
94 struct ipc_object *ie_object;
95 union {
96 mach_port_index_t next;
97 ipc_port_request_index_t request;
98 } index;
99 union {
100 mach_port_index_t table;
101 struct ipc_tree_entry *tree;
102 } hash;
103 } *ipc_entry_t;
104
105 #define IE_NULL ((ipc_entry_t) 0)
106
107 #define ie_request index.request
108 #define ie_next index.next
109 #define ie_index hash.table
110
111 #define IE_BITS_UREFS_MASK 0x0000ffff /* 16 bits of user-reference */
112 #define IE_BITS_UREFS(bits) ((bits) & IE_BITS_UREFS_MASK)
113
114 #define IE_BITS_TYPE_MASK 0x001f0000 /* 5 bits of capability type */
115 #define IE_BITS_TYPE(bits) ((bits) & IE_BITS_TYPE_MASK)
116
117 #define IE_BITS_MAREQUEST 0x00200000 /* 1 bit for msg-accepted */
118
119 #define IE_BITS_COMPAT 0x00400000 /* 1 bit for compatibility */
120
121 #define IE_BITS_COLLISION 0x00800000 /* 1 bit for collisions */
122 #define IE_BITS_GEN_MASK 0xff000000U /* 8 bits for generation */
123 #define IE_BITS_GEN(bits) ((bits) & IE_BITS_GEN_MASK)
124 #define IE_BITS_GEN_ONE 0x01000000 /* low bit of generation */
125 #define IE_BITS_RIGHT_MASK 0x007fffff /* relevant to the right */
126
127
128 typedef struct ipc_tree_entry {
129 struct ipc_entry ite_entry;
130 mach_port_t ite_name;
131 struct ipc_space *ite_space;
132 struct ipc_tree_entry *ite_lchild;
133 struct ipc_tree_entry *ite_rchild;
134 } *ipc_tree_entry_t;
135
136 #define ITE_NULL ((ipc_tree_entry_t) 0)
137
138 #define ite_bits ite_entry.ie_bits
139 #define ite_object ite_entry.ie_object
140 #define ite_request ite_entry.ie_request
141 #define ite_next ite_entry.hash.tree
142
143 extern zone_t ipc_tree_entry_zone;
144
145 #define ite_alloc() ((ipc_tree_entry_t) zalloc(ipc_tree_entry_zone))
146 #define ite_free(ite) zfree(ipc_tree_entry_zone, (vm_offset_t) (ite))
147
148
149 extern ipc_entry_t
150 ipc_entry_lookup(/* ipc_space_t space, mach_port_t name */);
151
152 extern kern_return_t
153 ipc_entry_get(/* ipc_space_t space,
154 mach_port_t *namep, ipc_entry_t *entryp */);
155
156 extern kern_return_t
157 ipc_entry_alloc(/* ipc_space_t space,
158 mach_port_t *namep, ipc_entry_t *entryp */);
159
160 extern kern_return_t
161 ipc_entry_alloc_name(/* ipc_space_t space, mach_port_t name,
162 ipc_entry_t *entryp */);
163
164 extern void
165 ipc_entry_dealloc(/* ipc_space_t space, mach_port_t name,
166 ipc_entry_t entry */);
167
168 extern kern_return_t
169 ipc_entry_grow_table(/* ipc_space_t space */);
170
171 #endif _IPC_IPC_ENTRY_H_
Cache object: bc8cf16747225fd99de18fdf33f66baa
|