FreeBSD/Linux Kernel Cross Reference
sys/ipc/ipc_space.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_space.h,v $
29 * Revision 2.7 91/06/17 15:46:29 jsb
30 * Renamed NORMA conditionals.
31 * [91/06/17 10:45:36 jsb]
32 *
33 * Revision 2.6 91/05/14 16:36:57 mrt
34 * Correcting copyright
35 *
36 * Revision 2.5 91/03/16 14:48:45 rpd
37 * Added is_growing.
38 * [91/03/04 rpd]
39 *
40 * Revision 2.4 91/02/05 17:23:48 mrt
41 * Changed to new Mach copyright
42 * [91/02/01 15:51:32 mrt]
43 *
44 * Revision 2.3 90/09/28 16:55:23 jsb
45 * Added NORMA_IPC support.
46 * [90/09/28 14:04:12 jsb]
47 *
48 * Revision 2.2 90/06/02 14:51:43 rpd
49 * Created for new IPC.
50 * [90/03/26 21:03:27 rpd]
51 *
52 */
53 /*
54 * File: ipc/ipc_space.h
55 * Author: Rich Draves
56 * Date: 1989
57 *
58 * Definitions for IPC spaces of capabilities.
59 */
60
61 #ifndef _IPC_IPC_SPACE_H_
62 #define _IPC_IPC_SPACE_H_
63
64 #include <mach_ipc_compat.h>
65 #include <norma_ipc.h>
66
67 #include <mach/boolean.h>
68 #include <mach/kern_return.h>
69 #include <kern/macro_help.h>
70 #include <kern/lock.h>
71 #include <kern/zalloc.h>
72 #include <ipc/ipc_entry.h>
73 #include <ipc/ipc_splay.h>
74
75 /*
76 * Every task has a space of IPC capabilities.
77 * IPC operations like send and receive use this space.
78 * IPC kernel calls manipulate the space of the target task.
79 *
80 * Every space has a non-NULL is_table with is_table_size entries.
81 * A space may have a NULL is_tree. is_tree_small records the
82 * number of entries in the tree that, if the table were to grow
83 * to the next larger size, would move from the tree to the table.
84 *
85 * is_growing marks when the table is in the process of growing.
86 * When the table is growing, it can't be freed or grown by another
87 * thread, because of krealloc/kmem_realloc's requirements.
88 */
89
90 typedef unsigned int ipc_space_refs_t;
91
92 typedef struct ipc_space {
93 decl_simple_lock_data(,is_ref_lock_data)
94 ipc_space_refs_t is_references;
95
96 decl_simple_lock_data(,is_lock_data)
97 boolean_t is_active; /* is the space alive? */
98 boolean_t is_growing; /* is the space growing? */
99 ipc_entry_t is_table; /* an array of entries */
100 ipc_entry_num_t is_table_size; /* current size of table */
101 struct ipc_table_size *is_table_next; /* info for larger table */
102 struct ipc_splay_tree is_tree; /* a splay tree of entries */
103 ipc_entry_num_t is_tree_total; /* number of entries in the tree */
104 ipc_entry_num_t is_tree_small; /* # of small entries in the tree */
105 ipc_entry_num_t is_tree_hash; /* # of hashed entries in the tree */
106
107 #if MACH_IPC_COMPAT
108 struct ipc_port *is_notify; /* notification port */
109 #endif MACH_IPC_COMPAT
110 } *ipc_space_t;
111
112 #define IS_NULL ((ipc_space_t) 0)
113
114 extern zone_t ipc_space_zone;
115
116 #define is_alloc() ((ipc_space_t) zalloc(ipc_space_zone))
117 #define is_free(is) zfree(ipc_space_zone, (vm_offset_t) (is))
118
119 extern ipc_space_t ipc_space_kernel;
120 extern ipc_space_t ipc_space_reply;
121 #if NORMA_IPC
122 extern ipc_space_t ipc_space_remote;
123 #endif NORMA_IPC
124
125 #define is_ref_lock_init(is) simple_lock_init(&(is)->is_ref_lock_data)
126
127 #define ipc_space_reference_macro(is) \
128 MACRO_BEGIN \
129 simple_lock(&(is)->is_ref_lock_data); \
130 assert((is)->is_references > 0); \
131 (is)->is_references++; \
132 simple_unlock(&(is)->is_ref_lock_data); \
133 MACRO_END
134
135 #define ipc_space_release_macro(is) \
136 MACRO_BEGIN \
137 ipc_space_refs_t _refs; \
138 \
139 simple_lock(&(is)->is_ref_lock_data); \
140 assert((is)->is_references > 0); \
141 _refs = --(is)->is_references; \
142 simple_unlock(&(is)->is_ref_lock_data); \
143 \
144 if (_refs == 0) \
145 is_free(is); \
146 MACRO_END
147
148 #define is_lock_init(is) simple_lock_init(&(is)->is_lock_data)
149
150 #define is_read_lock(is) simple_lock(&(is)->is_lock_data)
151 #define is_read_unlock(is) simple_unlock(&(is)->is_lock_data)
152
153 #define is_write_lock(is) simple_lock(&(is)->is_lock_data)
154 #define is_write_lock_try(is) simple_lock_try(&(is)->is_lock_data)
155 #define is_write_unlock(is) simple_unlock(&(is)->is_lock_data)
156
157 #define is_write_to_read_lock(is)
158
159 extern void ipc_space_reference(/* ipc_space_t space */);
160 extern void ipc_space_release(/* ipc_space_t space */);
161
162 #define is_reference(is) ipc_space_reference(is)
163 #define is_release(is) ipc_space_release(is)
164
165 extern kern_return_t
166 ipc_space_create(/* ipc_table_size_t, ipc_space_t * */);
167
168 extern kern_return_t
169 ipc_space_create_special(/* ipc_space_t * */);
170
171 extern void
172 ipc_space_destroy(/* ipc_space_t */);
173
174 #if MACH_IPC_COMPAT
175
176 /*
177 * Routine: ipc_space_make_notify
178 * Purpose:
179 * Given a space, return a send right for a notification.
180 * May return IP_NULL/IP_DEAD.
181 * Conditions:
182 * The space is locked (read or write) and active.
183 *
184 * ipc_port_t
185 * ipc_space_make_notify(space)
186 * ipc_space_t space;
187 */
188
189 #define ipc_space_make_notify(space) \
190 ipc_port_copy_send(space->is_notify)
191
192 #endif MACH_IPC_COMPAT
193 #endif _IPC_IPC_SPACE_H_
Cache object: d10471d8ba51f357bffcf75b78a50286
|