]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
91447636 | 2 | * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
8f6c56a5 | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* | |
29 | * @OSF_COPYRIGHT@ | |
30 | */ | |
31 | /* | |
32 | * Mach Operating System | |
33 | * Copyright (c) 1991,1990,1989 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 | */ | |
58 | /* | |
59 | * File: ipc/ipc_entry.h | |
60 | * Author: Rich Draves | |
61 | * Date: 1989 | |
62 | * | |
63 | * Definitions for translation entries, which represent | |
64 | * tasks' capabilities for ports and port sets. | |
65 | */ | |
66 | ||
67 | #ifndef _IPC_IPC_ENTRY_H_ | |
68 | #define _IPC_IPC_ENTRY_H_ | |
69 | ||
91447636 | 70 | #include <mach/mach_types.h> |
1c79356b A |
71 | #include <mach/port.h> |
72 | #include <mach/kern_return.h> | |
91447636 A |
73 | |
74 | #include <kern/kern_types.h> | |
1c79356b | 75 | #include <kern/zalloc.h> |
91447636 | 76 | |
1c79356b A |
77 | #include <ipc/ipc_types.h> |
78 | ||
79 | /* | |
80 | * Spaces hold capabilities for ipc_object_t's. | |
81 | * Each ipc_entry_t records a capability. Most capabilities have | |
82 | * small names, and the entries are elements of a table. | |
1c79356b A |
83 | * |
84 | * The ie_index field of entries in the table implements | |
85 | * a ordered hash table with open addressing and linear probing. | |
86 | * This hash table converts (space, object) -> name. | |
87 | * It is used independently of the other fields. | |
88 | * | |
89 | * Free (unallocated) entries in the table have null ie_object | |
90 | * fields. The ie_bits field is zero except for IE_BITS_GEN. | |
91 | * The ie_next (ie_request) field links free entries into a free list. | |
92 | * | |
93 | * The first entry in the table (index 0) is always free. | |
94 | * It is used as the head of the free list. | |
95 | */ | |
96 | ||
91447636 | 97 | struct ipc_entry { |
1c79356b A |
98 | struct ipc_object *ie_object; |
99 | ipc_entry_bits_t ie_bits; | |
316670eb | 100 | mach_port_index_t ie_index; |
1c79356b A |
101 | union { |
102 | mach_port_index_t next; /* next in freelist, or... */ | |
103 | ipc_table_index_t request; /* dead name request notify */ | |
104 | } index; | |
91447636 | 105 | }; |
1c79356b A |
106 | |
107 | #define ie_request index.request | |
108 | #define ie_next index.next | |
1c79356b | 109 | |
6d2010ae A |
110 | #define IE_REQ_NONE 0 /* no request */ |
111 | ||
1c79356b A |
112 | #define IE_BITS_UREFS_MASK 0x0000ffff /* 16 bits of user-reference */ |
113 | #define IE_BITS_UREFS(bits) ((bits) & IE_BITS_UREFS_MASK) | |
114 | ||
115 | #define IE_BITS_TYPE_MASK 0x001f0000 /* 5 bits of capability type */ | |
116 | #define IE_BITS_TYPE(bits) ((bits) & IE_BITS_TYPE_MASK) | |
117 | ||
1c79356b A |
118 | #ifndef NO_PORT_GEN |
119 | #define IE_BITS_GEN_MASK 0xff000000 /* 8 bits for generation */ | |
120 | #define IE_BITS_GEN(bits) ((bits) & IE_BITS_GEN_MASK) | |
121 | #define IE_BITS_GEN_ONE 0x04000000 /* low bit of generation */ | |
122 | #define IE_BITS_NEW_GEN(old) (((old) + IE_BITS_GEN_ONE) & IE_BITS_GEN_MASK) | |
123 | #else | |
124 | #define IE_BITS_GEN_MASK 0 | |
125 | #define IE_BITS_GEN(bits) 0 | |
126 | #define IE_BITS_GEN_ONE 0 | |
127 | #define IE_BITS_NEW_GEN(old) (old) | |
128 | #endif /* !USE_PORT_GEN */ | |
129 | ||
130 | ||
131 | #define IE_BITS_RIGHT_MASK 0x007fffff /* relevant to the right */ | |
132 | ||
1c79356b A |
133 | /* |
134 | * Exported interfaces | |
135 | */ | |
136 | ||
137 | /* Search for entry in a space by name */ | |
138 | extern ipc_entry_t ipc_entry_lookup( | |
139 | ipc_space_t space, | |
140 | mach_port_name_t name); | |
141 | ||
fe8ab488 A |
142 | /* Hold a number of entries in a locked space */ |
143 | extern kern_return_t ipc_entries_hold( | |
144 | ipc_space_t space, | |
145 | natural_t count); | |
146 | ||
147 | /* claim and initialize a held entry in a locked space */ | |
148 | extern kern_return_t ipc_entry_claim( | |
149 | ipc_space_t space, | |
150 | mach_port_name_t *namep, | |
151 | ipc_entry_t *entryp); | |
152 | ||
1c79356b A |
153 | /* Allocate an entry in a space */ |
154 | extern kern_return_t ipc_entry_get( | |
155 | ipc_space_t space, | |
156 | mach_port_name_t *namep, | |
157 | ipc_entry_t *entryp); | |
158 | ||
159 | /* Allocate an entry in a space, growing the space if necessary */ | |
160 | extern kern_return_t ipc_entry_alloc( | |
161 | ipc_space_t space, | |
162 | mach_port_name_t *namep, | |
163 | ipc_entry_t *entryp); | |
164 | ||
165 | /* Allocate/find an entry in a space with a specific name */ | |
166 | extern kern_return_t ipc_entry_alloc_name( | |
167 | ipc_space_t space, | |
168 | mach_port_name_t name, | |
169 | ipc_entry_t *entryp); | |
170 | ||
171 | /* Deallocate an entry from a space */ | |
172 | extern void ipc_entry_dealloc( | |
173 | ipc_space_t space, | |
174 | mach_port_name_t name, | |
175 | ipc_entry_t entry); | |
176 | ||
316670eb A |
177 | /* Mark and entry modified in a space */ |
178 | extern void ipc_entry_modified( | |
179 | ipc_space_t space, | |
180 | mach_port_name_t name, | |
181 | ipc_entry_t entry); | |
182 | ||
1c79356b A |
183 | /* Grow the table in a space */ |
184 | extern kern_return_t ipc_entry_grow_table( | |
91447636 A |
185 | ipc_space_t space, |
186 | ipc_table_elems_t target_size); | |
1c79356b A |
187 | |
188 | #endif /* _IPC_IPC_ENTRY_H_ */ |