]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
43866e37 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
43866e37 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
43866e37 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * @OSF_COPYRIGHT@ | |
27 | */ | |
28 | /* | |
29 | * Mach Operating System | |
30 | * Copyright (c) 1991,1990,1989 Carnegie Mellon University | |
31 | * All Rights Reserved. | |
32 | * | |
33 | * Permission to use, copy, modify and distribute this software and its | |
34 | * documentation is hereby granted, provided that both the copyright | |
35 | * notice and this permission notice appear in all copies of the | |
36 | * software, derivative works or modified versions, and any portions | |
37 | * thereof, and that both notices appear in supporting documentation. | |
38 | * | |
39 | * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" | |
40 | * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR | |
41 | * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. | |
42 | * | |
43 | * Carnegie Mellon requests users of this software to return to | |
44 | * | |
45 | * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU | |
46 | * School of Computer Science | |
47 | * Carnegie Mellon University | |
48 | * Pittsburgh PA 15213-3890 | |
49 | * | |
50 | * any improvements or extensions that they make and grant Carnegie Mellon | |
51 | * the rights to redistribute these changes. | |
52 | */ | |
53 | /* | |
54 | */ | |
55 | /* | |
56 | * File: ipc/ipc_init.c | |
57 | * Author: Rich Draves | |
58 | * Date: 1989 | |
59 | * | |
60 | * Functions to initialize the IPC system. | |
61 | */ | |
62 | ||
63 | #include <mach_debug.h> | |
64 | #include <mach_rt.h> | |
65 | ||
66 | #include <mach/kern_return.h> | |
67 | #include <kern/mach_param.h> | |
68 | #include <kern/ipc_host.h> | |
69 | #include <kern/misc_protos.h> | |
70 | #include <vm/vm_map.h> | |
71 | #include <vm/vm_kern.h> | |
72 | #include <ipc/ipc_entry.h> | |
73 | #include <ipc/ipc_space.h> | |
74 | #include <ipc/ipc_object.h> | |
75 | #include <ipc/ipc_port.h> | |
76 | #include <ipc/ipc_pset.h> | |
77 | #include <ipc/ipc_notify.h> | |
78 | #include <ipc/ipc_kmsg.h> | |
79 | #include <ipc/ipc_hash.h> | |
80 | #include <ipc/ipc_init.h> | |
81 | #include <mach/machine/ndr_def.h> /* NDR_record */ | |
82 | ||
83 | vm_map_t ipc_kernel_map; | |
84 | vm_size_t ipc_kernel_map_size = 1024 * 1024; | |
85 | ||
86 | vm_map_t ipc_kernel_copy_map; | |
87 | #define IPC_KERNEL_COPY_MAP_SIZE (8 * 1024 * 1024) | |
88 | vm_size_t ipc_kernel_copy_map_size = IPC_KERNEL_COPY_MAP_SIZE; | |
89 | vm_size_t ipc_kmsg_max_vm_space = (IPC_KERNEL_COPY_MAP_SIZE * 7)/8; | |
90 | ||
91 | int ipc_space_max = SPACE_MAX; | |
92 | int ipc_tree_entry_max = ITE_MAX; | |
93 | int ipc_port_max = PORT_MAX; | |
94 | int ipc_pset_max = SET_MAX; | |
95 | ||
96 | extern void mig_init(void); | |
97 | extern void ikm_cache_init(void); | |
98 | ||
99 | /* | |
100 | * Routine: ipc_bootstrap | |
101 | * Purpose: | |
102 | * Initialization needed before the kernel task | |
103 | * can be created. | |
104 | */ | |
105 | ||
106 | void | |
107 | ipc_bootstrap(void) | |
108 | { | |
109 | kern_return_t kr; | |
110 | ||
111 | ipc_port_multiple_lock_init(); | |
112 | ||
113 | ipc_port_timestamp_lock_init(); | |
114 | ipc_port_timestamp_data = 0; | |
115 | ||
116 | /* all IPC zones should be exhaustible */ | |
117 | ||
118 | ipc_space_zone = zinit(sizeof(struct ipc_space), | |
119 | ipc_space_max * sizeof(struct ipc_space), | |
120 | sizeof(struct ipc_space), | |
121 | "ipc spaces"); | |
122 | #if 0 | |
123 | /* make it exhaustible */ | |
124 | zone_change(ipc_space_zone, Z_EXHAUST, TRUE); | |
125 | #endif | |
126 | ||
127 | ipc_tree_entry_zone = | |
128 | zinit(sizeof(struct ipc_tree_entry), | |
129 | ipc_tree_entry_max * sizeof(struct ipc_tree_entry), | |
130 | sizeof(struct ipc_tree_entry), | |
131 | "ipc tree entries"); | |
132 | #if 0 | |
133 | /* make it exhaustible */ | |
134 | zone_change(ipc_tree_entry_zone, Z_EXHAUST, TRUE); | |
135 | #endif | |
136 | ||
137 | /* | |
138 | * populate all port(set) zones | |
139 | */ | |
140 | ipc_object_zones[IOT_PORT] = | |
141 | zinit(sizeof(struct ipc_port), | |
142 | ipc_port_max * sizeof(struct ipc_port), | |
143 | sizeof(struct ipc_port), | |
144 | "ipc ports"); | |
145 | /* | |
146 | * XXX Can't make the port zone exhaustible because the kernel | |
147 | * XXX panics when port allocation for an internal object fails. | |
148 | *zone_change(ipc_object_zones[IOT_PORT], Z_EXHAUST, TRUE); | |
149 | */ | |
150 | ||
151 | ipc_object_zones[IOT_PORT_SET] = | |
152 | zinit(sizeof(struct ipc_pset), | |
153 | ipc_pset_max * sizeof(struct ipc_pset), | |
154 | sizeof(struct ipc_pset), | |
155 | "ipc port sets"); | |
156 | /* make it exhaustible */ | |
157 | zone_change(ipc_object_zones[IOT_PORT_SET], Z_EXHAUST, TRUE); | |
158 | ||
159 | /* create special spaces */ | |
160 | ||
161 | kr = ipc_space_create_special(&ipc_space_kernel); | |
162 | assert(kr == KERN_SUCCESS); | |
163 | ||
164 | ||
165 | kr = ipc_space_create_special(&ipc_space_reply); | |
166 | assert(kr == KERN_SUCCESS); | |
167 | ||
168 | /* initialize modules with hidden data structures */ | |
169 | ||
170 | #if MACH_ASSERT | |
171 | ipc_port_debug_init(); | |
172 | #endif | |
173 | mig_init(); | |
174 | ipc_table_init(); | |
175 | ipc_notify_init(); | |
176 | ipc_hash_init(); | |
177 | ipc_kmsg_init(); | |
178 | semaphore_init(); | |
179 | lock_set_init(); | |
180 | } | |
181 | ||
182 | /* | |
183 | * XXX tunable, belongs in mach.message.h | |
184 | */ | |
185 | #define MSG_OOL_SIZE_SMALL_MAX 4096 | |
186 | vm_size_t msg_ool_size_small; | |
187 | ||
188 | /* | |
189 | * Routine: ipc_init | |
190 | * Purpose: | |
191 | * Final initialization of the IPC system. | |
192 | */ | |
193 | ||
194 | void | |
195 | ipc_init(void) | |
196 | { | |
197 | kern_return_t retval; | |
198 | vm_offset_t min, max; | |
199 | extern vm_size_t kalloc_max_prerounded; | |
200 | ||
201 | retval = kmem_suballoc(kernel_map, &min, ipc_kernel_map_size, | |
202 | TRUE, TRUE, &ipc_kernel_map); | |
203 | if (retval != KERN_SUCCESS) | |
204 | panic("ipc_init: kmem_suballoc of ipc_kernel_map failed"); | |
205 | ||
206 | retval = kmem_suballoc(kernel_map, &min, ipc_kernel_copy_map_size, | |
207 | TRUE, TRUE, &ipc_kernel_copy_map); | |
208 | if (retval != KERN_SUCCESS) | |
209 | panic("ipc_init: kmem_suballoc of ipc_kernel_copy_map failed"); | |
210 | ||
211 | ipc_kernel_copy_map->no_zero_fill = TRUE; | |
212 | ipc_kernel_copy_map->wait_for_space = TRUE; | |
213 | ||
214 | /* | |
215 | * As an optimization, 'small' out of line data regions using a | |
216 | * physical copy strategy are copied into kalloc'ed buffers. | |
217 | * The value of 'small' is determined here. Requests kalloc() | |
218 | * with sizes greater or equal to kalloc_max_prerounded may fail. | |
219 | */ | |
220 | if (kalloc_max_prerounded <= MSG_OOL_SIZE_SMALL_MAX) { | |
221 | msg_ool_size_small = kalloc_max_prerounded; | |
222 | } | |
223 | else { | |
224 | msg_ool_size_small = MSG_OOL_SIZE_SMALL_MAX; | |
225 | } | |
226 | ||
227 | ipc_host_init(); | |
228 | } |