|
|
1.1 root 1: /*
2: * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
6: * The contents of this file constitute Original Code as defined in and
7: * are subject to the Apple Public Source License Version 1.1 (the
8: * "License"). You may not use this file except in compliance with the
9: * License. Please obtain a copy of the License at
10: * http://www.apple.com/publicsource and read it before using this file.
11: *
12: * This Original Code and all software distributed under the License are
13: * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14: * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15: * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17: * License for the specific language governing rights and limitations
18: * under the License.
19: *
20: * @APPLE_LICENSE_HEADER_END@
21: */
22: /*
23: * @OSF_COPYRIGHT@
24: */
25: /*
26: * HISTORY
27: * Revision 1.1.1.1 1998/09/22 21:05:29 wsanchez
28: * Import of Mac OS X kernel (~semeria)
29: *
30: * Revision 1.1.1.1 1998/03/07 02:26:15 wsanchez
31: * Import of OSF Mach kernel (~mburg)
32: *
33: * Revision 1.2.35.1 1997/10/15 15:54:14 barbou
34: * Made the "ipc_space" and "ipc_tree_entry" zones non-exhaustible. They
35: * need to grow with the "task" zone which is itself non-exhaustible.
36: * [1997/10/15 15:52:29 barbou]
37: *
38: * Revision 1.2.24.7 1995/06/09 02:26:59 mmp
39: * Add a call to initialize the ikm cache.
40: * [95/04/20 alanl]
41: *
42: * Revision 1.2.24.6 1995/02/24 16:58:12 alanl
43: * Promoted MACH_RT to a full-fledged build option. (w/mmp)
44: * [95/02/21 alanl]
45: *
46: * DIPC: Merge from nmk17b2 to nmk18b8.
47: * [95/01/03 mmp]
48: *
49: * Revision 1.2.21.3 1994/12/06 20:09:33 alanl
50: * Intel merge, Oct 94 code drop.
51: *
52: * Revision 1.6 1994/07/12 19:21:45 andyp
53: * Merge of the NORMA2 branch back to the mainline.
54: *
55: * [...]
56: *
57: * Add hook to initialize ipc object subsystem for debugging.
58: * [[email protected]]
59: * [94/11/10 alanl]
60: *
61: * Revision 1.2.21.2 1994/08/11 14:42:31 rwd
62: * Update zone intialization to use zchange.
63: * [94/08/04 rwd]
64: *
65: * Revision 1.2.15.3 1994/05/20 18:32:49 alanl
66: * Initialize ipc_space_remote for DIPC.
67: * [94/05/17 rwd]
68: *
69: * Revision 1.2.15.2 1994/04/28 00:26:52 alanl
70: * Removed redundant dipc_bootstrap call, which was only required
71: * when all ipc_ports were also having dipc_ports allocated for
72: * them, automatically.
73: * [1994/04/27 23:33:49 alanl]
74: *
75: * Revision 1.2.15.1 1994/04/20 18:41:46 alanl
76: * DIPC: Delete all support for send notifications. They have
77: * been removed from the Mach specification and DIPC is easier
78: * to implement without this feature. In this file: removed
79: * initialization of marequest module.
80: * DIPC: add call to bootstrap DIPC.
81: * [1994/04/20 18:29:30 alanl]
82: *
83: * Revision 1.2.21.1 1994/08/04 02:21:21 mmp
84: * NOTE: file was moved back to b11 version for dipc2_shared.
85: * Initialize ipc_space_remote for DIPC.
86: * [94/05/17 rwd]
87: *
88: * Revision 1.2.29.2 1994/12/09 22:16:19 dwm
89: * mk6 CR801 - merge up from nmk18b4 to nmk18b7
90: * * Rev 1.2.24.4 1994/10/14 10:29:31 bolinger
91: * Fix ri-osc CR665: re-enable the use of a conventional IPC
92: * namespace for collocated tasks.
93: * [1994/12/09 20:53:10 dwm]
94: *
95: * Revision 1.2.29.1 1994/11/04 10:05:04 dwm
96: * mk6 CR668 - 1.3b26 merge
97: * * Revision 1.2.5.6 1993/11/08 15:04:09 gm
98: * CR9710: Updated to new zinit() and zone_change() interfaces.
99: * * End1.3merge
100: * [1994/11/04 09:16:22 dwm]
101: *
102: * Revision 1.2.24.3 1994/09/23 02:07:44 ezf
103: * change marker to not FREE
104: * [1994/09/22 21:28:59 ezf]
105: *
106: * Revision 1.2.24.2 1994/08/18 23:10:37 widyono
107: * ipc_init(), init msg_ool_size_small_rt
108: * [1994/07/28 22:15:24 widyono]
109: *
110: * Revision 1.2.24.1 1994/08/07 20:45:30 bolinger
111: * Merge up to colo_shared (post-b7, pre-MP).
112: * [1994/08/07 18:34:17 bolinger]
113: *
114: * Revision 1.2.12.8 1994/07/13 03:53:06 dwm
115: * Back out zalloc module changes in the interest of stability.
116: * [1994/07/13 03:51:03 dwm]
117: *
118: * Revision 1.2.12.7 1994/07/07 06:42:03 dwm
119: * mk6 CR219 - pick up changes from IK (via 1.3) to zalloc module;
120: * convert zchange() to new zone_change() interface.
121: * [1994/07/07 06:40:15 dwm]
122: *
123: * Revision 1.2.12.6 1994/06/14 19:11:36 dwm
124: * CR107: back out misguided conditional ipc_entry storage changes.
125: * [1994/06/14 18:37:10 dwm]
126: *
127: * Revision 1.2.12.5 1994/06/08 20:11:28 dswartz
128: * Preemption merge.
129: * [1994/06/08 20:09:02 dswartz]
130: *
131: * Revision 1.2.12.4 1994/05/13 20:38:33 dwm
132: * Make ipc_entry storage conditional on is_is_kloaded_space,
133: * using a separate object type.
134: * [1994/05/13 20:32:02 dwm]
135: *
136: * Revision 1.2.12.3 1994/04/19 02:18:23 bolinger
137: * Under MACH_DEBUG, enable access to all of the ports in an IPC space
138: * for kernel-loaded tasks.
139: * [1994/04/19 02:13:45 bolinger]
140: *
141: * Revision 1.2.12.2 1994/01/22 03:38:34 bolinger
142: * Add code to create new IPC space for kernel-loaded tasks.
143: * [1994/01/21 22:32:28 bolinger]
144: *
145: * Revision 1.2.12.1 1994/01/05 19:42:49 bolinger
146: * Update calls to kmem_suballoc().
147: * [1994/01/05 17:41:22 bolinger]
148: *
149: * Revision 1.2.5.5 1993/09/09 16:06:26 jeffc
150: * CR9745 - Delete message accepted notifications
151: * [1993/09/03 20:44:41 jeffc]
152: *
153: * Revision 1.2.5.4 1993/08/05 19:07:06 jeffc
154: * CR9508 - delete dead Mach3 code. Remove MACH_IPC_TYPED
155: * [1993/08/04 17:11:50 jeffc]
156: *
157: * Revision 1.2.5.3 1993/07/22 16:16:01 rod
158: * Add ANSI prototypes. CR #9523.
159: * [1993/07/22 13:29:53 rod]
160: *
161: * Revision 1.2.5.2 1993/06/09 02:31:32 gm
162: * CR9176 - ANSI C violations: trailing tokens on CPP
163: * directives, extra semicolons after decl_ ..., asm keywords
164: * [1993/06/07 19:01:21 jeffc]
165: *
166: * Added to OSF/1 R1.3 from NMK15.0.
167: * [1993/06/02 21:09:26 jeffc]
168: *
169: * Revision 1.2 1993/04/19 16:19:54 devrcs
170: * Allocate ipc_kernel_copy_map under !MACH_IPC_TYPED. [rod.osf.org]
171: * [1993/04/06 14:32:18 travos]
172: *
173: * Untyped ipc merge:
174: * Put mig_init() @ #if !MACH_IPC_TYPED
175: * [1993/03/04 13:42:28 travos]
176: * New dispatching model for kernel services: hash instead of linear search
177: * [1993/03/01 21:51:28 travos]
178: * Initialization of NDR_record
179: * [1993/02/17 22:13:07 travos]
180: * Make msg_ool_size_small a function of kalloc_max_prerounded.
181: * [1993/02/16 15:09:03 rod]
182: * Allocate kernel submap for eager ipc copyin
183: * and mark it wait_for_space and no_zero_fill. [[email protected]]
184: * [1993/01/27 00:46:09 rod]
185: *
186: * Revision 1.1 1992/09/30 02:07:22 robert
187: * Initial revision
188: *
189: * $EndLog$
190: */
191: /* CMU_HIST */
192: /*
193: * Revision 2.12.2.2 92/03/03 16:18:29 jeffreyh
194: * 19-Feb-92 David L. Black (dlb) at Open Software Foundation
195: * Don't make port zone exhaustible. Kernel panics when
196: * it fails to allocate an internal port after exhaustion.
197: * [92/02/26 11:41:12 jeffreyh]
198: *
199: * Revision 2.12.2.1 92/01/03 16:34:52 jsb
200: * Corrected log.
201: * [91/12/24 14:18:23 jsb]
202: *
203: * Revision 2.12 91/12/10 13:25:41 jsb
204: * Removed reference counting bug workaround.
205: * [91/12/10 11:17:21 jsb]
206: *
207: * Revision 2.11 91/11/19 09:54:12 rvb
208: * Added reference counting bug workaround.
209: * [91/11/00 jsb]
210: *
211: * Revision 2.10 91/08/03 18:18:12 jsb
212: * Removed call to ipc_clport_init.
213: * [91/07/24 22:11:04 jsb]
214: *
215: * Revision 2.9 91/06/17 15:46:00 jsb
216: * Renamed NORMA conditionals.
217: * [91/06/17 10:45:48 jsb]
218: *
219: * Revision 2.8 91/06/06 17:05:46 jsb
220: * Added call to ipc_clport_init.
221: * [91/05/13 17:17:10 jsb]
222: *
223: * Revision 2.7 91/05/14 16:32:33 mrt
224: * Correcting copyright
225: *
226: * Revision 2.6 91/02/05 17:21:37 mrt
227: * Changed to new Mach copyright
228: * [91/02/01 15:45:02 mrt]
229: *
230: * Revision 2.5 91/01/08 15:13:40 rpd
231: * Changed zchange calls to make the IPC zones non-collectable.
232: * [90/12/29 rpd]
233: *
234: * Revision 2.4 90/12/20 16:38:41 jeffreyh
235: * Changes to zchange to account for new collectable field. Made all
236: * ipc zones collectable.
237: * [90/12/11 jeffreyh]
238: *
239: * Revision 2.3 90/09/28 16:54:44 jsb
240: * Added NORMA_IPC support.
241: * [90/09/28 14:02:05 jsb]
242: *
243: * Revision 2.2 90/06/02 14:49:55 rpd
244: * Created for new IPC.
245: * [90/03/26 20:55:13 rpd]
246: *
247: */
248: /* CMU_ENDHIST */
249: /*
250: * Mach Operating System
251: * Copyright (c) 1991,1990,1989 Carnegie Mellon University
252: * All Rights Reserved.
253: *
254: * Permission to use, copy, modify and distribute this software and its
255: * documentation is hereby granted, provided that both the copyright
256: * notice and this permission notice appear in all copies of the
257: * software, derivative works or modified versions, and any portions
258: * thereof, and that both notices appear in supporting documentation.
259: *
260: * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
261: * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
262: * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
263: *
264: * Carnegie Mellon requests users of this software to return to
265: *
266: * Software Distribution Coordinator or [email protected]
267: * School of Computer Science
268: * Carnegie Mellon University
269: * Pittsburgh PA 15213-3890
270: *
271: * any improvements or extensions that they make and grant Carnegie Mellon
272: * the rights to redistribute these changes.
273: */
274: /*
275: */
276: /*
277: * File: ipc/ipc_init.c
278: * Author: Rich Draves
279: * Date: 1989
280: *
281: * Functions to initialize the IPC system.
282: */
283:
284: #include <mach_debug.h>
285: #include <dipc.h>
286: #include <mach_rt.h>
287:
288: #include <mach/kern_return.h>
289: #include <kern/mach_param.h>
290: #include <kern/ipc_host.h>
291: #include <kern/misc_protos.h>
292: #include <vm/vm_map.h>
293: #include <vm/vm_kern.h>
294: #include <ipc/ipc_entry.h>
295: #include <ipc/ipc_space.h>
296: #include <ipc/ipc_object.h>
297: #include <ipc/ipc_port.h>
298: #include <ipc/ipc_pset.h>
299: #include <ipc/ipc_notify.h>
300: #include <ipc/ipc_kmsg.h>
301: #include <ipc/ipc_hash.h>
302: #include <ipc/ipc_init.h>
303: #include <mach/machine/ndr_def.h> /* NDR_record */
304:
305: vm_map_t ipc_kernel_map;
306: vm_size_t ipc_kernel_map_size = 1024 * 1024;
307:
308: vm_map_t ipc_kernel_copy_map;
309: #define IPC_KERNEL_COPY_MAP_SIZE (8 * 1024 * 1024)
310: vm_size_t ipc_kernel_copy_map_size = IPC_KERNEL_COPY_MAP_SIZE;
311: vm_size_t ipc_kmsg_max_vm_space = (IPC_KERNEL_COPY_MAP_SIZE * 7)/8;
312:
313: int ipc_space_max = SPACE_MAX;
314: int ipc_tree_entry_max = ITE_MAX;
315: int ipc_port_max = PORT_MAX;
316: int ipc_pset_max = SET_MAX;
317:
318: extern void mig_init(void);
319: extern void ikm_cache_init(void);
320:
321: /*
322: * Routine: ipc_bootstrap
323: * Purpose:
324: * Initialization needed before the kernel task
325: * can be created.
326: */
327:
328: void
329: ipc_bootstrap(void)
330: {
331: kern_return_t kr;
332:
333: ipc_port_multiple_lock_init();
334:
335: ipc_port_timestamp_lock_init();
336: ipc_port_timestamp_data = 0;
337:
338: /* all IPC zones should be exhaustible */
339:
340: ipc_space_zone = zinit(sizeof(struct ipc_space),
341: ipc_space_max * sizeof(struct ipc_space),
342: sizeof(struct ipc_space),
343: "ipc spaces");
344: #if 0
345: /* make it exhaustible */
346: zone_change(ipc_space_zone, Z_EXHAUST, TRUE);
347: #endif
348:
349: ipc_tree_entry_zone =
350: zinit(sizeof(struct ipc_tree_entry),
351: ipc_tree_entry_max * sizeof(struct ipc_tree_entry),
352: sizeof(struct ipc_tree_entry),
353: "ipc tree entries");
354: #if 0
355: /* make it exhaustible */
356: zone_change(ipc_tree_entry_zone, Z_EXHAUST, TRUE);
357: #endif
358:
359: /*
360: * populate all port(set) zones
361: */
362: ipc_object_zones[IOT_PORT] =
363: zinit(sizeof(struct ipc_port),
364: ipc_port_max * sizeof(struct ipc_port),
365: sizeof(struct ipc_port),
366: "ipc ports");
367: /*
368: * XXX Can't make the port zone exhaustible because the kernel
369: * XXX panics when port allocation for an internal object fails.
370: *zone_change(ipc_object_zones[IOT_PORT], Z_EXHAUST, TRUE);
371: */
372:
373: ipc_object_zones[IOT_PORT_SET] =
374: zinit(sizeof(struct ipc_pset),
375: ipc_pset_max * sizeof(struct ipc_pset),
376: sizeof(struct ipc_pset),
377: "ipc port sets");
378: /* make it exhaustible */
379: zone_change(ipc_object_zones[IOT_PORT_SET], Z_EXHAUST, TRUE);
380:
381: /* create special spaces */
382:
383: kr = ipc_space_create_special(&ipc_space_kernel);
384: assert(kr == KERN_SUCCESS);
385:
386:
387: kr = ipc_space_create_special(&ipc_space_reply);
388: assert(kr == KERN_SUCCESS);
389:
390: #if DIPC
391: kr = ipc_space_create_special(&ipc_space_remote);
392: assert(kr == KERN_SUCCESS);
393: #endif /* DIPC */
394:
395: /* initialize modules with hidden data structures */
396:
397: #if MACH_ASSERT
398: ipc_port_debug_init();
399: #endif
400: mig_init();
401: ipc_table_init();
402: ipc_notify_init();
403: ipc_hash_init();
404: ikm_cache_init();
405: }
406:
407: /*
408: * XXX tunable, belongs in mach.message.h
409: */
410: #define MSG_OOL_SIZE_SMALL 2049
411: vm_size_t msg_ool_size_small;
412:
413: #if MACH_RT
414: vm_size_t msg_ool_size_small_rt;
415: #endif /* MACH_RT */
416:
417: /*
418: * Routine: ipc_init
419: * Purpose:
420: * Final initialization of the IPC system.
421: */
422:
423: void
424: ipc_init(void)
425: {
426: kern_return_t retval;
427: vm_offset_t min, max;
428: extern vm_size_t kalloc_max_prerounded;
429: #if MACH_RT
430: extern vm_size_t rtmalloc_max_prerounded;
431: #endif /* MACH_RT */
432:
433: retval = kmem_suballoc(kernel_map, &min, ipc_kernel_map_size,
434: TRUE, TRUE, &ipc_kernel_map);
435: if (retval != KERN_SUCCESS)
436: panic("ipc_init: kmem_suballoc of ipc_kernel_map failed");
437:
438: retval = kmem_suballoc(kernel_map, &min, ipc_kernel_copy_map_size,
439: TRUE, TRUE, &ipc_kernel_copy_map);
440: if (retval != KERN_SUCCESS)
441: panic("ipc_init: kmem_suballoc of ipc_kernel_copy_map failed");
442:
443: ipc_kernel_copy_map->no_zero_fill = TRUE;
444: ipc_kernel_copy_map->wait_for_space = TRUE;
445:
446: /*
447: * As an optimization, 'small' out of line data regions using a
448: * physical copy strategy are copied into kalloc'ed buffers.
449: * The value of 'small' is determined here. Requests kalloc()
450: * with sizes greater or equal to kalloc_max_prerounded may fail.
451: */
452: if (kalloc_max_prerounded <= MSG_OOL_SIZE_SMALL) {
453: msg_ool_size_small = kalloc_max_prerounded;
454: }
455: else {
456: msg_ool_size_small = MSG_OOL_SIZE_SMALL;
457: }
458:
459: #if MACH_RT
460: /*
461: * Real-time IPC, on the other hand, requires that all out-of-line
462: * data be obtained from rtmalloc'ed buffers.
463: */
464: msg_ool_size_small_rt = rtmalloc_max_prerounded;
465: #endif /* MACH_RT */
466:
467: ipc_host_init();
468: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.