|
|
1.1 root 1: /*
2: * Mach Operating System
3: * Copyright (c) 1991,1990,1989 Carnegie Mellon University.
4: * Copyright (c) 1993,1994 The University of Utah and
5: * the Computer Systems Laboratory (CSL).
6: * All rights reserved.
7: *
8: * Permission to use, copy, modify and distribute this software and its
9: * documentation is hereby granted, provided that both the copyright
10: * notice and this permission notice appear in all copies of the
11: * software, derivative works or modified versions, and any portions
12: * thereof, and that both notices appear in supporting documentation.
13: *
14: * CARNEGIE MELLON, THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF
15: * THIS SOFTWARE IN ITS "AS IS" CONDITION, AND DISCLAIM ANY LIABILITY
16: * OF ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF
17: * THIS SOFTWARE.
18: *
19: * Carnegie Mellon requests users of this software to return to
20: *
21: * Software Distribution Coordinator or [email protected]
22: * School of Computer Science
23: * Carnegie Mellon University
24: * Pittsburgh PA 15213-3890
25: *
26: * any improvements or extensions that they make and grant Carnegie Mellon
27: * the rights to redistribute these changes.
28: */
29: /*
30: * File: ipc/ipc_entry.h
31: * Author: Rich Draves
32: * Date: 1989
33: *
34: * Definitions for translation entries, which represent
35: * tasks' capabilities for ports and port sets.
36: */
37:
38: #ifndef _IPC_IPC_ENTRY_H_
39: #define _IPC_IPC_ENTRY_H_
40:
41: #include <mach/port.h>
42: #include <mach/kern_return.h>
43: #include <kern/zalloc.h>
44: #include <ipc/port.h>
45: #include <ipc/ipc_table.h>
46:
47: /*
48: * Spaces hold capabilities for ipc_object_t's (ports and port sets).
49: * Each ipc_entry_t records a capability. Most capabilities have
50: * small names, and the entries are elements of a table.
51: * Capabilities can have large names, and a splay tree holds
52: * those entries. The cutoff point between the table and the tree
53: * is adjusted dynamically to minimize memory consumption.
54: *
55: * The ie_index field of entries in the table implements
56: * a ordered hash table with open addressing and linear probing.
57: * This hash table converts (space, object) -> name.
58: * It is used independently of the other fields.
59: *
60: * Free (unallocated) entries in the table have null ie_object
61: * fields. The ie_bits field is zero except for IE_BITS_GEN.
62: * The ie_next (ie_request) field links free entries into a free list.
63: *
64: * The first entry in the table (index 0) is always free.
65: * It is used as the head of the free list.
66: */
67:
68: typedef unsigned int ipc_entry_bits_t;
69: typedef ipc_table_elems_t ipc_entry_num_t; /* number of entries */
70:
71: typedef struct ipc_entry {
72: ipc_entry_bits_t ie_bits;
73: struct ipc_object *ie_object;
74: union {
75: mach_port_index_t next;
76: /*XXX ipc_port_request_index_t request;*/
77: unsigned int request;
78: } index;
79: union {
80: mach_port_index_t table;
81: struct ipc_tree_entry *tree;
82: } hash;
83: } *ipc_entry_t;
84:
85: #define IE_NULL ((ipc_entry_t) 0)
86:
87: #define ie_request index.request
88: #define ie_next index.next
89: #define ie_index hash.table
90:
91: #define IE_BITS_UREFS_MASK 0x0000ffff /* 16 bits of user-reference */
92: #define IE_BITS_UREFS(bits) ((bits) & IE_BITS_UREFS_MASK)
93:
94: #define IE_BITS_TYPE_MASK 0x001f0000 /* 5 bits of capability type */
95: #define IE_BITS_TYPE(bits) ((bits) & IE_BITS_TYPE_MASK)
96:
97: #define IE_BITS_MAREQUEST 0x00200000 /* 1 bit for msg-accepted */
98:
99: #define IE_BITS_COMPAT 0x00400000 /* 1 bit for compatibility */
100:
101: #define IE_BITS_COLLISION 0x00800000 /* 1 bit for collisions */
102: #define IE_BITS_RIGHT_MASK 0x007fffff /* relevant to the right */
103:
104: #if PORT_GENERATIONS
105: #define IE_BITS_GEN_MASK 0xff000000U /* 8 bits for generation */
106: #define IE_BITS_GEN(bits) ((bits) & IE_BITS_GEN_MASK)
107: #define IE_BITS_GEN_ONE 0x01000000 /* low bit of generation */
108: #else
109: #define IE_BITS_GEN_MASK 0
110: #define IE_BITS_GEN(bits) 0
111: #define IE_BITS_GEN_ONE 0
112: #endif
113:
114:
115: typedef struct ipc_tree_entry {
116: struct ipc_entry ite_entry;
117: mach_port_t ite_name;
118: struct ipc_space *ite_space;
119: struct ipc_tree_entry *ite_lchild;
120: struct ipc_tree_entry *ite_rchild;
121: } *ipc_tree_entry_t;
122:
123: #define ITE_NULL ((ipc_tree_entry_t) 0)
124:
125: #define ite_bits ite_entry.ie_bits
126: #define ite_object ite_entry.ie_object
127: #define ite_request ite_entry.ie_request
128: #define ite_next ite_entry.hash.tree
129:
130: extern zone_t ipc_tree_entry_zone;
131:
132: #define ite_alloc() ((ipc_tree_entry_t) zalloc(ipc_tree_entry_zone))
133: #define ite_free(ite) zfree(ipc_tree_entry_zone, (vm_offset_t) (ite))
134:
135:
136: extern ipc_entry_t
137: ipc_entry_lookup(/* ipc_space_t space, mach_port_t name */);
138:
139: extern kern_return_t
140: ipc_entry_get(/* ipc_space_t space,
141: mach_port_t *namep, ipc_entry_t *entryp */);
142:
143: extern kern_return_t
144: ipc_entry_alloc(/* ipc_space_t space,
145: mach_port_t *namep, ipc_entry_t *entryp */);
146:
147: extern kern_return_t
148: ipc_entry_alloc_name(/* ipc_space_t space, mach_port_t name,
149: ipc_entry_t *entryp */);
150:
151: extern void
152: ipc_entry_dealloc(/* ipc_space_t space, mach_port_t name,
153: ipc_entry_t entry */);
154:
155: extern kern_return_t
156: ipc_entry_grow_table(/* ipc_space_t space */);
157:
158: #endif /* _IPC_IPC_ENTRY_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.