|
|
1.1 root 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 [email protected]
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: */
28: /*
29: * File: ipc/ipc_table.h
30: * Author: Rich Draves
31: * Date: 1989
32: *
33: * Definitions for tables, used for IPC capabilities (ipc_entry_t)
34: * and dead-name requests (ipc_port_request_t).
35: */
36:
37: #ifndef _IPC_IPC_TABLE_H_
38: #define _IPC_IPC_TABLE_H_
39:
40: #include <mach/boolean.h>
41: #include <mach/vm_param.h>
42:
43: /*
44: * The is_table_next field of an ipc_space_t points to
45: * an ipc_table_size structure. These structures must
46: * be elements of an array, ipc_table_entries.
47: *
1.1.1.3 ! root 48: * Every its_size value must must be a power of two.
! 49: *
1.1 root 50: * The array must end with two elements with the same its_size value.
51: * Except for the terminating element, the its_size values must
52: * be strictly increasing. The largest (last) its_size value
53: * must be less than or equal to MACH_PORT_INDEX(MACH_PORT_DEAD).
54: * This ensures that
55: * 1) MACH_PORT_INDEX(MACH_PORT_DEAD) isn't a valid index
56: * in the table, so ipc_entry_get won't allocate it.
57: * 2) MACH_PORT_MAKE(index+1, 0) and MAKE_PORT_MAKE(size, 0)
58: * won't ever overflow.
59: *
60: *
61: * The ipr_size field of the first element in a table of
62: * dead-name requests (ipc_port_request_t) points to the
63: * ipc_table_size structure. The structures must be elements
64: * of ipc_table_dnrequests. ipc_table_dnrequests must end
65: * with an element with zero its_size, and except for this last
66: * element, the its_size values must be strictly increasing.
67: *
68: * The is_table_next field points to the ipc_table_size structure
69: * for the next larger size of table, not the one currently in use.
70: * The ipr_size field points to the currently used ipc_table_size.
71: */
72:
73: typedef unsigned int ipc_table_index_t; /* index into tables */
74: typedef unsigned int ipc_table_elems_t; /* size of tables */
75:
76: typedef struct ipc_table_size {
77: ipc_table_elems_t its_size; /* number of elements in table */
78: } *ipc_table_size_t;
79:
80: #define ITS_NULL ((ipc_table_size_t) 0)
81:
82: extern ipc_table_size_t ipc_table_entries;
83: extern ipc_table_size_t ipc_table_dnrequests;
84:
85: extern void
1.1.1.2 root 86: ipc_table_init(void);
1.1 root 87:
88: /*
89: * Note that ipc_table_alloc, ipc_table_realloc, and ipc_table_free
90: * all potentially use the VM system. Hence simple locks can't
91: * be held across them.
92: *
93: * We can't use a copying realloc, because the realloc happens
94: * with the data unlocked. ipc_table_realloc remaps the data,
95: * so it is OK.
96: */
97:
98: /* Allocate a table */
99: extern vm_offset_t ipc_table_alloc(
100: vm_size_t size);
101:
102: /* Reallocate a big table */
103: extern vm_offset_t ipc_table_realloc(
104: vm_size_t old_size,
105: vm_offset_t old_table,
106: vm_size_t new_size);
107:
108: /* Free a table */
109: extern void ipc_table_free(
110: vm_size_t size,
111: vm_offset_t table);
112:
1.1.1.3 ! root 113: void ipc_table_fill(
! 114: ipc_table_size_t its,
! 115: unsigned int num,
! 116: unsigned int min,
! 117: vm_size_t elemsize);
! 118:
1.1 root 119: #define it_entries_alloc(its) \
120: ((ipc_entry_t) \
121: ipc_table_alloc((its)->its_size * sizeof(struct ipc_entry)))
122:
123: #define it_entries_reallocable(its) \
124: (((its)->its_size * sizeof(struct ipc_entry)) >= PAGE_SIZE)
125:
126: #define it_entries_realloc(its, table, nits) \
127: ((ipc_entry_t) \
128: ipc_table_realloc((its)->its_size * sizeof(struct ipc_entry), \
129: (vm_offset_t)(table), \
130: (nits)->its_size * sizeof(struct ipc_entry)))
131:
132: #define it_entries_free(its, table) \
133: ipc_table_free((its)->its_size * sizeof(struct ipc_entry), \
134: (vm_offset_t)(table))
135:
136: #define it_dnrequests_alloc(its) \
137: ((ipc_port_request_t) \
138: ipc_table_alloc((its)->its_size * \
139: sizeof(struct ipc_port_request)))
140:
141: #define it_dnrequests_free(its, table) \
142: ipc_table_free((its)->its_size * \
143: sizeof(struct ipc_port_request), \
144: (vm_offset_t)(table))
145:
146: #endif /* _IPC_IPC_TABLE_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.