]> git.saurik.com Git - apple/xnu.git/blob - bsd/kern/bsd_init.c
25395d3521da0ba40d17502f814a512be3433e4e
[apple/xnu.git] / bsd / kern / bsd_init.c
1 /*
2 * Copyright (c) 2000-2015 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 *
28 *
29 * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
30 * The Regents of the University of California. All rights reserved.
31 * (c) UNIX System Laboratories, Inc.
32 * All or some portions of this file are derived from material licensed
33 * to the University of California by American Telephone and Telegraph
34 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
35 * the permission of UNIX System Laboratories, Inc.
36 *
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the following conditions
39 * are met:
40 * 1. Redistributions of source code must retain the above copyright
41 * notice, this list of conditions and the following disclaimer.
42 * 2. Redistributions in binary form must reproduce the above copyright
43 * notice, this list of conditions and the following disclaimer in the
44 * documentation and/or other materials provided with the distribution.
45 * 3. All advertising materials mentioning features or use of this software
46 * must display the following acknowledgement:
47 * This product includes software developed by the University of
48 * California, Berkeley and its contributors.
49 * 4. Neither the name of the University nor the names of its contributors
50 * may be used to endorse or promote products derived from this software
51 * without specific prior written permission.
52 *
53 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
54 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
55 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
56 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
57 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
58 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
59 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
60 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
61 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
62 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * SUCH DAMAGE.
64 *
65 * @(#)init_main.c 8.16 (Berkeley) 5/14/95
66 */
67
68 /*
69 *
70 * Mach Operating System
71 * Copyright (c) 1987 Carnegie-Mellon University
72 * All rights reserved. The CMU software License Agreement specifies
73 * the terms and conditions for use and redistribution.
74 */
75 /*
76 * NOTICE: This file was modified by McAfee Research in 2004 to introduce
77 * support for mandatory and extensible security protections. This notice
78 * is included in support of clause 2.2 (b) of the Apple Public License,
79 * Version 2.0.
80 */
81
82 #include <sys/param.h>
83 #include <sys/filedesc.h>
84 #include <sys/kernel.h>
85 #include <sys/mount_internal.h>
86 #include <sys/proc_internal.h>
87 #include <sys/kauth.h>
88 #include <sys/systm.h>
89 #include <sys/vnode_internal.h>
90 #include <sys/conf.h>
91 #include <sys/buf_internal.h>
92 #include <sys/clist.h>
93 #include <sys/user.h>
94 #include <sys/time.h>
95 #include <sys/systm.h>
96 #include <sys/mman.h>
97
98 #include <security/audit/audit.h>
99
100 #include <sys/malloc.h>
101 #include <sys/dkstat.h>
102 #include <sys/codesign.h>
103
104 #include <kern/startup.h>
105 #include <kern/thread.h>
106 #include <kern/task.h>
107 #include <kern/ast.h>
108 #include <kern/kalloc.h>
109 #include <mach/mach_host.h>
110
111 #include <mach/vm_param.h>
112
113 #include <vm/vm_map.h>
114 #include <vm/vm_kern.h>
115
116 #include <sys/ux_exception.h> /* for ux_exception_port */
117
118 #include <sys/reboot.h>
119 #include <mach/exception_types.h>
120 #include <dev/busvar.h> /* for pseudo_inits */
121 #include <sys/kdebug.h>
122 #include <sys/monotonic.h>
123 #include <sys/reason.h>
124
125 #include <mach/mach_types.h>
126 #include <mach/vm_prot.h>
127 #include <mach/semaphore.h>
128 #include <mach/sync_policy.h>
129 #include <kern/clock.h>
130 #include <mach/kern_return.h>
131 #include <mach/thread_act.h> /* for thread_resume() */
132 #include <mach/task.h> /* for task_set_exception_ports() */
133 #include <sys/ux_exception.h> /* for ux_handler() */
134 #include <sys/ubc_internal.h> /* for ubc_init() */
135 #include <sys/mcache.h> /* for mcache_init() */
136 #include <sys/mbuf.h> /* for mbinit() */
137 #include <sys/event.h> /* for knote_init() */
138 #include <sys/eventhandler.h> /* for eventhandler_init() */
139 #include <sys/kern_memorystatus.h> /* for memorystatus_init() */
140 #include <sys/aio_kern.h> /* for aio_init() */
141 #include <sys/semaphore.h> /* for psem_cache_init() */
142 #include <net/dlil.h> /* for dlil_init() */
143 #include <net/kpi_protocol.h> /* for proto_kpi_init() */
144 #include <net/iptap.h> /* for iptap_init() */
145 #include <sys/pipe.h> /* for pipeinit() */
146 #include <sys/socketvar.h> /* for socketinit() */
147 #include <sys/protosw.h> /* for domaininit() */
148 #include <kern/sched_prim.h> /* for thread_wakeup() */
149 #include <net/if_ether.h> /* for ether_family_init() */
150 #include <net/if_gif.h> /* for gif_init() */
151 #include <vm/vm_protos.h> /* for vnode_pager_bootstrap() */
152 #include <miscfs/devfs/devfsdefs.h> /* for devfs_kernel_mount() */
153 #include <mach/host_priv.h> /* for host_set_exception_ports() */
154 #include <kern/host.h> /* for host_priv_self() */
155 #include <vm/vm_kern.h> /* for kmem_suballoc() */
156 #include <sys/semaphore.h> /* for psem_lock_init() */
157 #include <sys/msgbuf.h> /* for log_setsize() */
158 #include <sys/tty.h> /* for tty_init() */
159 #include <sys/proc_uuid_policy.h> /* proc_uuid_policy_init() */
160 #include <netinet/flow_divert.h> /* flow_divert_init() */
161 #include <net/content_filter.h> /* for cfil_init() */
162 #include <net/necp.h> /* for necp_init() */
163 #include <net/network_agent.h> /* for netagent_init() */
164 #include <net/packet_mangler.h> /* for pkt_mnglr_init() */
165 #include <net/if_utun.h> /* for utun_register_control() */
166 #include <net/if_ipsec.h> /* for ipsec_register_control() */
167 #include <net/net_str_id.h> /* for net_str_id_init() */
168 #include <net/netsrc.h> /* for netsrc_init() */
169 #include <net/ntstat.h> /* for nstat_init() */
170 #include <netinet/tcp_cc.h> /* for tcp_cc_init() */
171 #include <netinet/mptcp_var.h> /* for mptcp_control_register() */
172 #include <net/nwk_wq.h> /* for nwk_wq_init */
173 #include <kern/assert.h> /* for assert() */
174 #include <sys/kern_overrides.h> /* for init_system_override() */
175
176 #include <net/init.h>
177
178 #if CONFIG_MACF
179 #include <security/mac_framework.h>
180 #include <security/mac_internal.h> /* mac_init_bsd() */
181 #include <security/mac_mach_internal.h> /* mac_update_task_label() */
182 #endif
183
184 #include <machine/exec.h>
185
186 #if NFSCLIENT
187 #include <sys/netboot.h>
188 #endif
189
190 #if CONFIG_IMAGEBOOT
191 #include <sys/imageboot.h>
192 #endif
193
194 #if PFLOG
195 #include <net/if_pflog.h>
196 #endif
197
198
199 #include <pexpert/pexpert.h>
200 #include <machine/pal_routines.h>
201 #include <console/video_console.h>
202
203
204 void * get_user_regs(thread_t); /* XXX kludge for <machine/thread.h> */
205 void IOKitInitializeTime(void); /* XXX */
206 void IOSleep(unsigned int); /* XXX */
207 void loopattach(void); /* XXX */
208
209 const char copyright[] =
210 "Copyright (c) 1982, 1986, 1989, 1991, 1993\n\t"
211 "The Regents of the University of California. "
212 "All rights reserved.\n\n";
213
214 /* Components of the first process -- never freed. */
215 struct proc proc0;
216 struct session session0;
217 struct pgrp pgrp0;
218 struct filedesc filedesc0;
219 struct plimit limit0;
220 struct pstats pstats0;
221 struct sigacts sigacts0;
222 proc_t kernproc;
223 proc_t initproc;
224
225 long tk_cancc;
226 long tk_nin;
227 long tk_nout;
228 long tk_rawcc;
229
230 int lock_trace = 0;
231 /* Global variables to make pstat happy. We do swapping differently */
232 int nswdev, nswap;
233 int nswapmap;
234 void *swapmap;
235 struct swdevt swdevt[1];
236
237 dev_t rootdev; /* device of the root */
238 dev_t dumpdev; /* device to take dumps on */
239 long dumplo; /* offset into dumpdev */
240 long hostid;
241 char hostname[MAXHOSTNAMELEN];
242 int hostnamelen;
243 char domainname[MAXDOMNAMELEN];
244 int domainnamelen;
245
246 char rootdevice[DEVMAXNAMESIZE];
247
248 #if KMEMSTATS
249 struct kmemstats kmemstats[M_LAST];
250 #endif
251
252 struct vnode *rootvp;
253 int boothowto = RB_DEBUG;
254 int minimalboot = 0;
255 #if CONFIG_EMBEDDED
256 int darkboot = 0;
257 #endif
258
259 #if PROC_REF_DEBUG
260 __private_extern__ int proc_ref_tracking_disabled = 0; /* disable panics on leaked proc refs across syscall boundary */
261 #endif
262
263 #if OS_REASON_DEBUG
264 __private_extern__ int os_reason_debug_disabled = 0; /* disable asserts for when we fail to allocate OS reasons */
265 #endif
266
267 extern kern_return_t IOFindBSDRoot(char *, unsigned int, dev_t *, u_int32_t *);
268 extern void IOSecureBSDRoot(const char * rootName);
269 extern kern_return_t IOKitBSDInit(void );
270 extern void kminit(void);
271 extern void file_lock_init(void);
272 extern void kmeminit(void);
273 extern void bsd_bufferinit(void);
274 extern void oslog_setsize(int size);
275 extern void throttle_init(void);
276 extern void acct_init(void);
277
278 extern int serverperfmode;
279 extern int ncl;
280
281 vm_map_t bsd_pageable_map;
282 vm_map_t mb_map;
283
284 static int bsd_simul_execs;
285 static int bsd_pageable_map_size;
286 __private_extern__ int execargs_cache_size = 0;
287 __private_extern__ int execargs_free_count = 0;
288 __private_extern__ vm_offset_t * execargs_cache = NULL;
289
290 void bsd_exec_setup(int);
291
292 #if __arm64__
293 __private_extern__ int bootarg_no64exec = 0;
294 #endif
295 __private_extern__ int bootarg_vnode_cache_defeat = 0;
296
297 #if CONFIG_JETSAM && (DEVELOPMENT || DEBUG)
298 __private_extern__ int bootarg_no_vnode_jetsam = 0;
299 #endif /* CONFIG_JETSAM && (DEVELOPMENT || DEBUG) */
300
301 /*
302 * Prevent kernel-based ASLR from being used, for testing.
303 */
304 #if DEVELOPMENT || DEBUG
305 __private_extern__ int bootarg_disable_aslr = 0;
306 #endif
307
308 /*
309 * Allow an alternate dyld to be used for testing.
310 */
311
312 #if DEVELOPMENT || DEBUG
313 char dyld_alt_path[MAXPATHLEN];
314 int use_alt_dyld = 0;
315 #endif
316
317 int cmask = CMASK;
318 extern int customnbuf;
319
320 kern_return_t bsd_autoconf(void);
321 void bsd_utaskbootstrap(void);
322
323 static void parse_bsd_args(void);
324 #if CONFIG_DEV_KMEM
325 extern void dev_kmem_init(void);
326 #endif
327 extern void time_zone_slock_init(void);
328 extern void select_waitq_init(void);
329 static void process_name(const char *, proc_t);
330
331 static void setconf(void);
332
333 #if SYSV_SHM
334 extern void sysv_shm_lock_init(void);
335 #endif
336 #if SYSV_SEM
337 extern void sysv_sem_lock_init(void);
338 #endif
339 #if SYSV_MSG
340 extern void sysv_msg_lock_init(void);
341 #endif
342
343 extern void ulock_initialize(void);
344
345 #if CONFIG_MACF
346 #if defined (__i386__) || defined (__x86_64__)
347 /* MACF policy_check configuration flags; see policy_check.c for details */
348 int policy_check_flags = 0;
349
350 extern int check_policy_init(int);
351 #endif
352 #endif /* CONFIG_MACF */
353
354 /* If we are using CONFIG_DTRACE */
355 #if CONFIG_DTRACE
356 extern void dtrace_postinit(void);
357 #endif
358
359 /*
360 * Initialization code.
361 * Called from cold start routine as
362 * soon as a stack and segmentation
363 * have been established.
364 * Functions:
365 * turn on clock
366 * hand craft 0th process
367 * call all initialization routines
368 * hand craft 1st user process
369 */
370
371 /*
372 * Sets the name for the given task.
373 */
374 static void
375 process_name(const char *s, proc_t p)
376 {
377 strlcpy(p->p_comm, s, sizeof(p->p_comm));
378 strlcpy(p->p_name, s, sizeof(p->p_name));
379 }
380
381 /* To allow these values to be patched, they're globals here */
382 #include <machine/vmparam.h>
383 struct rlimit vm_initial_limit_stack = { DFLSSIZ, MAXSSIZ - PAGE_MAX_SIZE };
384 struct rlimit vm_initial_limit_data = { DFLDSIZ, MAXDSIZ };
385 struct rlimit vm_initial_limit_core = { DFLCSIZ, MAXCSIZ };
386
387 extern thread_t cloneproc(task_t, coalition_t, proc_t, int, int);
388 extern int (*mountroot)(void);
389
390 lck_grp_t * proc_lck_grp;
391 lck_grp_t * proc_slock_grp;
392 lck_grp_t * proc_fdmlock_grp;
393 lck_grp_t * proc_kqhashlock_grp;
394 lck_grp_t * proc_knhashlock_grp;
395 lck_grp_t * proc_ucred_mlock_grp;
396 lck_grp_t * proc_mlock_grp;
397 lck_grp_attr_t * proc_lck_grp_attr;
398 lck_attr_t * proc_lck_attr;
399 lck_mtx_t * proc_list_mlock;
400 lck_mtx_t * proc_klist_mlock;
401
402
403 extern lck_mtx_t * execargs_cache_lock;
404
405 /* hook called after root is mounted XXX temporary hack */
406 void (*mountroot_post_hook)(void);
407 void (*unmountroot_pre_hook)(void);
408
409 /*
410 * This function is called before IOKit initialization, so that globals
411 * like the sysctl tree are initialized before kernel extensions
412 * are started (since they may want to register sysctls
413 */
414 void
415 bsd_early_init(void)
416 {
417 sysctl_early_init();
418 }
419
420 /*
421 * This function is called very early on in the Mach startup, from the
422 * function start_kernel_threads() in osfmk/kern/startup.c. It's called
423 * in the context of the current (startup) task using a call to the
424 * function kernel_thread_create() to jump into start_kernel_threads().
425 * Internally, kernel_thread_create() calls thread_create_internal(),
426 * which calls uthread_alloc(). The function of uthread_alloc() is
427 * normally to allocate a uthread structure, and fill out the uu_sigmask,
428 * uu_context fields. It skips filling these out in the case of the "task"
429 * being "kernel_task", because the order of operation is inverted. To
430 * account for that, we need to manually fill in at least the contents
431 * of the uu_context.vc_ucred field so that the uthread structure can be
432 * used like any other.
433 */
434
435 void
436 bsd_init(void)
437 {
438 struct uthread *ut;
439 unsigned int i;
440 struct vfs_context context;
441 kern_return_t ret;
442 struct ucred temp_cred;
443 struct posix_cred temp_pcred;
444 #if NFSCLIENT || CONFIG_IMAGEBOOT
445 boolean_t netboot = FALSE;
446 #endif
447
448 #define bsd_init_kprintf(x...) /* kprintf("bsd_init: " x) */
449
450 throttle_init();
451
452 printf(copyright);
453
454 bsd_init_kprintf("calling kmeminit\n");
455 kmeminit();
456
457 bsd_init_kprintf("calling parse_bsd_args\n");
458 parse_bsd_args();
459
460 #if CONFIG_DEV_KMEM
461 bsd_init_kprintf("calling dev_kmem_init\n");
462 dev_kmem_init();
463 #endif
464
465 /* Initialize kauth subsystem before instancing the first credential */
466 bsd_init_kprintf("calling kauth_init\n");
467 kauth_init();
468
469 /* Initialize process and pgrp structures. */
470 bsd_init_kprintf("calling procinit\n");
471 procinit();
472
473 /* Initialize the ttys (MUST be before kminit()/bsd_autoconf()!)*/
474 tty_init();
475
476 kernproc = &proc0; /* implicitly bzero'ed */
477
478 /* kernel_task->proc = kernproc; */
479 set_bsdtask_info(kernel_task,(void *)kernproc);
480
481 /* give kernproc a name */
482 bsd_init_kprintf("calling process_name\n");
483 process_name("kernel_task", kernproc);
484
485 /* allocate proc lock group attribute and group */
486 bsd_init_kprintf("calling lck_grp_attr_alloc_init\n");
487 proc_lck_grp_attr= lck_grp_attr_alloc_init();
488
489 proc_lck_grp = lck_grp_alloc_init("proc", proc_lck_grp_attr);
490
491 #if CONFIG_FINE_LOCK_GROUPS
492 proc_slock_grp = lck_grp_alloc_init("proc-slock", proc_lck_grp_attr);
493 proc_ucred_mlock_grp = lck_grp_alloc_init("proc-ucred-mlock", proc_lck_grp_attr);
494 proc_mlock_grp = lck_grp_alloc_init("proc-mlock", proc_lck_grp_attr);
495 proc_fdmlock_grp = lck_grp_alloc_init("proc-fdmlock", proc_lck_grp_attr);
496 #endif
497 proc_kqhashlock_grp = lck_grp_alloc_init("proc-kqhashlock", proc_lck_grp_attr);
498 proc_knhashlock_grp = lck_grp_alloc_init("proc-knhashlock", proc_lck_grp_attr);
499 /* Allocate proc lock attribute */
500 proc_lck_attr = lck_attr_alloc_init();
501 #if 0
502 #if __PROC_INTERNAL_DEBUG
503 lck_attr_setdebug(proc_lck_attr);
504 #endif
505 #endif
506
507 #if CONFIG_FINE_LOCK_GROUPS
508 proc_list_mlock = lck_mtx_alloc_init(proc_mlock_grp, proc_lck_attr);
509 proc_klist_mlock = lck_mtx_alloc_init(proc_mlock_grp, proc_lck_attr);
510 lck_mtx_init(&kernproc->p_mlock, proc_mlock_grp, proc_lck_attr);
511 lck_mtx_init(&kernproc->p_fdmlock, proc_fdmlock_grp, proc_lck_attr);
512 lck_mtx_init(&kernproc->p_ucred_mlock, proc_ucred_mlock_grp, proc_lck_attr);
513 lck_spin_init(&kernproc->p_slock, proc_slock_grp, proc_lck_attr);
514 #else
515 proc_list_mlock = lck_mtx_alloc_init(proc_lck_grp, proc_lck_attr);
516 proc_klist_mlock = lck_mtx_alloc_init(proc_lck_grp, proc_lck_attr);
517 lck_mtx_init(&kernproc->p_mlock, proc_lck_grp, proc_lck_attr);
518 lck_mtx_init(&kernproc->p_fdmlock, proc_lck_grp, proc_lck_attr);
519 lck_mtx_init(&kernproc->p_ucred_mlock, proc_lck_grp, proc_lck_attr);
520 lck_spin_init(&kernproc->p_slock, proc_lck_grp, proc_lck_attr);
521 #endif
522
523 assert(bsd_simul_execs != 0);
524 execargs_cache_lock = lck_mtx_alloc_init(proc_lck_grp, proc_lck_attr);
525 execargs_cache_size = bsd_simul_execs;
526 execargs_free_count = bsd_simul_execs;
527 execargs_cache = (vm_offset_t *)kalloc(bsd_simul_execs * sizeof(vm_offset_t));
528 bzero(execargs_cache, bsd_simul_execs * sizeof(vm_offset_t));
529
530 if (current_task() != kernel_task)
531 printf("bsd_init: We have a problem, "
532 "current task is not kernel task\n");
533
534 bsd_init_kprintf("calling get_bsdthread_info\n");
535 ut = (uthread_t)get_bsdthread_info(current_thread());
536
537 #if CONFIG_MACF
538 /*
539 * Initialize the MAC Framework
540 */
541 mac_policy_initbsd();
542
543 #if defined (__i386__) || defined (__x86_64__)
544 /*
545 * We currently only support this on i386/x86_64, as that is the
546 * only lock code we have instrumented so far.
547 */
548 check_policy_init(policy_check_flags);
549 #endif
550 #endif /* MAC */
551
552 /* Initialize System Override call */
553 init_system_override();
554
555 ulock_initialize();
556
557 /*
558 * Create process 0.
559 */
560 proc_list_lock();
561 LIST_INSERT_HEAD(&allproc, kernproc, p_list);
562 kernproc->p_pgrp = &pgrp0;
563 LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash);
564 LIST_INIT(&pgrp0.pg_members);
565 #ifdef CONFIG_FINE_LOCK_GROUPS
566 lck_mtx_init(&pgrp0.pg_mlock, proc_mlock_grp, proc_lck_attr);
567 #else
568 lck_mtx_init(&pgrp0.pg_mlock, proc_lck_grp, proc_lck_attr);
569 #endif
570 /* There is no other bsd thread this point and is safe without pgrp lock */
571 LIST_INSERT_HEAD(&pgrp0.pg_members, kernproc, p_pglist);
572 kernproc->p_listflag |= P_LIST_INPGRP;
573 kernproc->p_pgrpid = 0;
574 kernproc->p_uniqueid = 0;
575
576 pgrp0.pg_session = &session0;
577 pgrp0.pg_membercnt = 1;
578
579 session0.s_count = 1;
580 session0.s_leader = kernproc;
581 session0.s_listflags = 0;
582 #ifdef CONFIG_FINE_LOCK_GROUPS
583 lck_mtx_init(&session0.s_mlock, proc_mlock_grp, proc_lck_attr);
584 #else
585 lck_mtx_init(&session0.s_mlock, proc_lck_grp, proc_lck_attr);
586 #endif
587 LIST_INSERT_HEAD(SESSHASH(0), &session0, s_hash);
588 proc_list_unlock();
589
590 #if CONFIG_PERSONAS
591 kernproc->p_persona = NULL;
592 #endif
593
594 kernproc->task = kernel_task;
595
596 kernproc->p_stat = SRUN;
597 kernproc->p_flag = P_SYSTEM;
598 kernproc->p_lflag = 0;
599 kernproc->p_ladvflag = 0;
600
601 #if defined(__LP64__)
602 kernproc->p_flag |= P_LP64;
603 #endif
604
605 #if DEVELOPMENT || DEBUG
606 if (bootarg_disable_aslr)
607 kernproc->p_flag |= P_DISABLE_ASLR;
608 #endif
609
610 kernproc->p_nice = NZERO;
611 kernproc->p_pptr = kernproc;
612
613 TAILQ_INIT(&kernproc->p_uthlist);
614 TAILQ_INSERT_TAIL(&kernproc->p_uthlist, ut, uu_list);
615
616 kernproc->sigwait = FALSE;
617 kernproc->sigwait_thread = THREAD_NULL;
618 kernproc->exit_thread = THREAD_NULL;
619 kernproc->p_csflags = CS_VALID;
620
621 /*
622 * Create credential. This also Initializes the audit information.
623 */
624 bsd_init_kprintf("calling bzero\n");
625 bzero(&temp_cred, sizeof(temp_cred));
626 bzero(&temp_pcred, sizeof(temp_pcred));
627 temp_pcred.cr_ngroups = 1;
628 /* kern_proc, shouldn't call up to DS for group membership */
629 temp_pcred.cr_flags = CRF_NOMEMBERD;
630 temp_cred.cr_audit.as_aia_p = audit_default_aia_p;
631
632 bsd_init_kprintf("calling kauth_cred_create\n");
633 /*
634 * We have to label the temp cred before we create from it to
635 * properly set cr_ngroups, or the create will fail.
636 */
637 posix_cred_label(&temp_cred, &temp_pcred);
638 kernproc->p_ucred = kauth_cred_create(&temp_cred);
639
640 /* update cred on proc */
641 PROC_UPDATE_CREDS_ONPROC(kernproc);
642
643 /* give the (already exisiting) initial thread a reference on it */
644 bsd_init_kprintf("calling kauth_cred_ref\n");
645 kauth_cred_ref(kernproc->p_ucred);
646 ut->uu_context.vc_ucred = kernproc->p_ucred;
647 ut->uu_context.vc_thread = current_thread();
648
649 TAILQ_INIT(&kernproc->p_aio_activeq);
650 TAILQ_INIT(&kernproc->p_aio_doneq);
651 kernproc->p_aio_total_count = 0;
652 kernproc->p_aio_active_count = 0;
653
654 bsd_init_kprintf("calling file_lock_init\n");
655 file_lock_init();
656
657 #if CONFIG_MACF
658 mac_cred_label_associate_kernel(kernproc->p_ucred);
659 #endif
660
661 /* Create the file descriptor table. */
662 kernproc->p_fd = &filedesc0;
663 filedesc0.fd_cmask = cmask;
664 filedesc0.fd_knlistsize = -1;
665 filedesc0.fd_knlist = NULL;
666 filedesc0.fd_knhash = NULL;
667 filedesc0.fd_knhashmask = 0;
668 lck_mtx_init(&filedesc0.fd_kqhashlock, proc_kqhashlock_grp, proc_lck_attr);
669 lck_mtx_init(&filedesc0.fd_knhashlock, proc_knhashlock_grp, proc_lck_attr);
670
671 /* Create the limits structures. */
672 kernproc->p_limit = &limit0;
673 for (i = 0; i < sizeof(kernproc->p_rlimit)/sizeof(kernproc->p_rlimit[0]); i++)
674 limit0.pl_rlimit[i].rlim_cur =
675 limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY;
676 limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur = NOFILE;
677 limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = maxprocperuid;
678 limit0.pl_rlimit[RLIMIT_NPROC].rlim_max = maxproc;
679 limit0.pl_rlimit[RLIMIT_STACK] = vm_initial_limit_stack;
680 limit0.pl_rlimit[RLIMIT_DATA] = vm_initial_limit_data;
681 limit0.pl_rlimit[RLIMIT_CORE] = vm_initial_limit_core;
682 limit0.pl_refcnt = 1;
683
684 kernproc->p_stats = &pstats0;
685 kernproc->p_sigacts = &sigacts0;
686
687 /*
688 * Charge root for one process: launchd.
689 */
690 bsd_init_kprintf("calling chgproccnt\n");
691 (void)chgproccnt(0, 1);
692
693 /*
694 * Allocate a kernel submap for pageable memory
695 * for temporary copying (execve()).
696 */
697 {
698 vm_offset_t minimum;
699
700 bsd_init_kprintf("calling kmem_suballoc\n");
701 assert(bsd_pageable_map_size != 0);
702 ret = kmem_suballoc(kernel_map,
703 &minimum,
704 (vm_size_t)bsd_pageable_map_size,
705 TRUE,
706 VM_FLAGS_ANYWHERE,
707 VM_MAP_KERNEL_FLAGS_NONE,
708 VM_KERN_MEMORY_BSD,
709 &bsd_pageable_map);
710 if (ret != KERN_SUCCESS)
711 panic("bsd_init: Failed to allocate bsd pageable map");
712 }
713
714 /*
715 * Initialize buffers and hash links for buffers
716 *
717 * SIDE EFFECT: Starts a thread for bcleanbuf_thread(), so must
718 * happen after a credential has been associated with
719 * the kernel task.
720 */
721 bsd_init_kprintf("calling bsd_bufferinit\n");
722 bsd_bufferinit();
723
724 /*
725 * Initialize the calendar.
726 */
727 bsd_init_kprintf("calling IOKitInitializeTime\n");
728 IOKitInitializeTime();
729
730 bsd_init_kprintf("calling ubc_init\n");
731 ubc_init();
732
733 /* Initialize the file systems. */
734 bsd_init_kprintf("calling vfsinit\n");
735 vfsinit();
736
737 #if CONFIG_PROC_UUID_POLICY
738 /* Initial proc_uuid_policy subsystem */
739 bsd_init_kprintf("calling proc_uuid_policy_init()\n");
740 proc_uuid_policy_init();
741 #endif
742
743 #if SOCKETS
744 /* Initialize per-CPU cache allocator */
745 mcache_init();
746
747 /* Initialize mbuf's. */
748 bsd_init_kprintf("calling mbinit\n");
749 mbinit();
750 net_str_id_init(); /* for mbuf tags */
751 #endif /* SOCKETS */
752
753 /*
754 * Initializes security event auditing.
755 * XXX: Should/could this occur later?
756 */
757 #if CONFIG_AUDIT
758 bsd_init_kprintf("calling audit_init\n");
759 audit_init();
760 #endif
761
762 /* Initialize kqueues */
763 bsd_init_kprintf("calling knote_init\n");
764 knote_init();
765
766 /* Initialize event handler */
767 bsd_init_kprintf("calling eventhandler_init\n");
768 eventhandler_init();
769
770 /* Initialize for async IO */
771 bsd_init_kprintf("calling aio_init\n");
772 aio_init();
773
774 /* Initialize pipes */
775 bsd_init_kprintf("calling pipeinit\n");
776 pipeinit();
777
778 /* Initialize SysV shm subsystem locks; the subsystem proper is
779 * initialized through a sysctl.
780 */
781 #if SYSV_SHM
782 bsd_init_kprintf("calling sysv_shm_lock_init\n");
783 sysv_shm_lock_init();
784 #endif
785 #if SYSV_SEM
786 bsd_init_kprintf("calling sysv_sem_lock_init\n");
787 sysv_sem_lock_init();
788 #endif
789 #if SYSV_MSG
790 bsd_init_kprintf("sysv_msg_lock_init\n");
791 sysv_msg_lock_init();
792 #endif
793 bsd_init_kprintf("calling pshm_lock_init\n");
794 pshm_lock_init();
795 bsd_init_kprintf("calling psem_lock_init\n");
796 psem_lock_init();
797
798 pthread_init();
799 /* POSIX Shm and Sem */
800 bsd_init_kprintf("calling pshm_cache_init\n");
801 pshm_cache_init();
802 bsd_init_kprintf("calling psem_cache_init\n");
803 psem_cache_init();
804 bsd_init_kprintf("calling time_zone_slock_init\n");
805 time_zone_slock_init();
806 bsd_init_kprintf("calling select_waitq_init\n");
807 select_waitq_init();
808
809 /*
810 * Initialize protocols. Block reception of incoming packets
811 * until everything is ready.
812 */
813 #if NETWORKING
814 bsd_init_kprintf("calling nwk_wq_init\n");
815 nwk_wq_init();
816 bsd_init_kprintf("calling dlil_init\n");
817 dlil_init();
818 bsd_init_kprintf("calling proto_kpi_init\n");
819 proto_kpi_init();
820 #endif /* NETWORKING */
821 #if SOCKETS
822 bsd_init_kprintf("calling socketinit\n");
823 socketinit();
824 bsd_init_kprintf("calling domaininit\n");
825 domaininit();
826 iptap_init();
827 #if FLOW_DIVERT
828 flow_divert_init();
829 #endif /* FLOW_DIVERT */
830 #endif /* SOCKETS */
831 kernproc->p_fd->fd_cdir = NULL;
832 kernproc->p_fd->fd_rdir = NULL;
833
834 #if CONFIG_FREEZE
835 #ifndef CONFIG_MEMORYSTATUS
836 #error "CONFIG_FREEZE defined without matching CONFIG_MEMORYSTATUS"
837 #endif
838 /* Initialise background freezing */
839 bsd_init_kprintf("calling memorystatus_freeze_init\n");
840 memorystatus_freeze_init();
841 #endif
842
843 #if CONFIG_MEMORYSTATUS
844 /* Initialize kernel memory status notifications */
845 bsd_init_kprintf("calling memorystatus_init\n");
846 memorystatus_init();
847 #endif /* CONFIG_MEMORYSTATUS */
848
849 bsd_init_kprintf("calling acct_init\n");
850 acct_init();
851
852 #ifdef GPROF
853 /* Initialize kernel profiling. */
854 kmstartup();
855 #endif
856
857 bsd_init_kprintf("calling sysctl_mib_init\n");
858 sysctl_mib_init()
859
860 bsd_init_kprintf("calling bsd_autoconf\n");
861 bsd_autoconf();
862
863 bsd_init_kprintf("calling os_reason_init\n");
864 os_reason_init();
865
866 #if CONFIG_DTRACE
867 dtrace_postinit();
868 #endif
869
870 /*
871 * We attach the loopback interface *way* down here to ensure
872 * it happens after autoconf(), otherwise it becomes the
873 * "primary" interface.
874 */
875 #include <loop.h>
876 #if NLOOP > 0
877 bsd_init_kprintf("calling loopattach\n");
878 loopattach(); /* XXX */
879 #endif
880 #if NGIF
881 /* Initialize gif interface (after lo0) */
882 gif_init();
883 #endif
884
885 #if PFLOG
886 /* Initialize packet filter log interface */
887 pfloginit();
888 #endif /* PFLOG */
889
890 #if NETHER > 0
891 /* Register the built-in dlil ethernet interface family */
892 bsd_init_kprintf("calling ether_family_init\n");
893 ether_family_init();
894 #endif /* ETHER */
895
896 #if NETWORKING
897 /* Call any kext code that wants to run just after network init */
898 bsd_init_kprintf("calling net_init_run\n");
899 net_init_run();
900
901 #if CONTENT_FILTER
902 cfil_init();
903 #endif
904
905 #if PACKET_MANGLER
906 pkt_mnglr_init();
907 #endif
908
909 #if NECP
910 /* Initialize Network Extension Control Policies */
911 necp_init();
912 #endif
913
914 netagent_init();
915
916 /* register user tunnel kernel control handler */
917 utun_register_control();
918 #if IPSEC
919 ipsec_register_control();
920 #endif /* IPSEC */
921 netsrc_init();
922 nstat_init();
923 tcp_cc_init();
924 #if MPTCP
925 mptcp_control_register();
926 #endif /* MPTCP */
927 #endif /* NETWORKING */
928
929 bsd_init_kprintf("calling vnode_pager_bootstrap\n");
930 vnode_pager_bootstrap();
931
932 bsd_init_kprintf("calling inittodr\n");
933 inittodr(0);
934
935 /* Mount the root file system. */
936 while( TRUE) {
937 int err;
938
939 bsd_init_kprintf("calling setconf\n");
940 setconf();
941 #if NFSCLIENT
942 netboot = (mountroot == netboot_mountroot);
943 #endif
944
945 bsd_init_kprintf("vfs_mountroot\n");
946 if (0 == (err = vfs_mountroot()))
947 break;
948 rootdevice[0] = '\0';
949 #if NFSCLIENT
950 if (netboot) {
951 PE_display_icon( 0, "noroot"); /* XXX a netboot-specific icon would be nicer */
952 vc_progress_set(FALSE, 0);
953 for (i=1; 1; i*=2) {
954 printf("bsd_init: failed to mount network root, error %d, %s\n",
955 err, PE_boot_args());
956 printf("We are hanging here...\n");
957 IOSleep(i*60*1000);
958 }
959 /*NOTREACHED*/
960 }
961 #endif
962 printf("cannot mount root, errno = %d\n", err);
963 boothowto |= RB_ASKNAME;
964 }
965
966 IOSecureBSDRoot(rootdevice);
967
968 context.vc_thread = current_thread();
969 context.vc_ucred = kernproc->p_ucred;
970 mountlist.tqh_first->mnt_flag |= MNT_ROOTFS;
971
972 bsd_init_kprintf("calling VFS_ROOT\n");
973 /* Get the vnode for '/'. Set fdp->fd_fd.fd_cdir to reference it. */
974 if (VFS_ROOT(mountlist.tqh_first, &rootvnode, &context))
975 panic("bsd_init: cannot find root vnode: %s", PE_boot_args());
976 rootvnode->v_flag |= VROOT;
977 (void)vnode_ref(rootvnode);
978 (void)vnode_put(rootvnode);
979 filedesc0.fd_cdir = rootvnode;
980
981 #if NFSCLIENT
982 if (netboot) {
983 int err;
984
985 netboot = TRUE;
986 /* post mount setup */
987 if ((err = netboot_setup()) != 0) {
988 PE_display_icon( 0, "noroot"); /* XXX a netboot-specific icon would be nicer */
989 vc_progress_set(FALSE, 0);
990 for (i=1; 1; i*=2) {
991 printf("bsd_init: NetBoot could not find root, error %d: %s\n",
992 err, PE_boot_args());
993 printf("We are hanging here...\n");
994 IOSleep(i*60*1000);
995 }
996 /*NOTREACHED*/
997 }
998 }
999 #endif
1000
1001
1002 #if CONFIG_IMAGEBOOT
1003 /*
1004 * See if a system disk image is present. If so, mount it and
1005 * switch the root vnode to point to it
1006 */
1007 if (netboot == FALSE && imageboot_needed()) {
1008 /*
1009 * An image was found. No turning back: we're booted
1010 * with a kernel from the disk image.
1011 */
1012 imageboot_setup();
1013 }
1014 #endif /* CONFIG_IMAGEBOOT */
1015
1016 /* set initial time; all other resource data is already zero'ed */
1017 microtime_with_abstime(&kernproc->p_start, &kernproc->p_stats->ps_start);
1018
1019 #if DEVFS
1020 {
1021 char mounthere[] = "/dev"; /* !const because of internal casting */
1022
1023 bsd_init_kprintf("calling devfs_kernel_mount\n");
1024 devfs_kernel_mount(mounthere);
1025 }
1026 #endif /* DEVFS */
1027
1028 /* Initialize signal state for process 0. */
1029 bsd_init_kprintf("calling siginit\n");
1030 siginit(kernproc);
1031
1032 bsd_init_kprintf("calling bsd_utaskbootstrap\n");
1033 bsd_utaskbootstrap();
1034
1035 pal_kernel_announce();
1036
1037 bsd_init_kprintf("calling mountroot_post_hook\n");
1038
1039 /* invoke post-root-mount hook */
1040 if (mountroot_post_hook != NULL)
1041 mountroot_post_hook();
1042
1043 #if 0 /* not yet */
1044 consider_zone_gc(FALSE);
1045 #endif
1046
1047 bsd_init_kprintf("done\n");
1048 }
1049
1050 void
1051 bsdinit_task(void)
1052 {
1053 proc_t p = current_proc();
1054 struct uthread *ut;
1055 thread_t thread;
1056
1057 process_name("init", p);
1058
1059 ux_handler_init();
1060
1061 thread = current_thread();
1062 (void) host_set_exception_ports(host_priv_self(),
1063 EXC_MASK_ALL & ~(EXC_MASK_RPC_ALERT),//pilotfish (shark) needs this port
1064 (mach_port_t) ux_exception_port,
1065 EXCEPTION_DEFAULT| MACH_EXCEPTION_CODES,
1066 0);
1067
1068 ut = (uthread_t)get_bsdthread_info(thread);
1069
1070 #if CONFIG_MACF
1071 mac_cred_label_associate_user(p->p_ucred);
1072 #endif
1073
1074 vm_init_before_launchd();
1075
1076
1077 bsd_init_kprintf("bsd_do_post - done");
1078
1079 load_init_program(p);
1080 lock_trace = 1;
1081 }
1082
1083 kern_return_t
1084 bsd_autoconf(void)
1085 {
1086 kprintf("bsd_autoconf: calling kminit\n");
1087 kminit();
1088
1089 /*
1090 * Early startup for bsd pseudodevices.
1091 */
1092 {
1093 struct pseudo_init *pi;
1094
1095 for (pi = pseudo_inits; pi->ps_func; pi++)
1096 (*pi->ps_func) (pi->ps_count);
1097 }
1098
1099 return( IOKitBSDInit());
1100 }
1101
1102
1103 #include <sys/disklabel.h> /* for MAXPARTITIONS */
1104
1105 static void
1106 setconf(void)
1107 {
1108 u_int32_t flags;
1109 kern_return_t err;
1110
1111 err = IOFindBSDRoot(rootdevice, sizeof(rootdevice), &rootdev, &flags);
1112 if( err) {
1113 printf("setconf: IOFindBSDRoot returned an error (%d);"
1114 "setting rootdevice to 'sd0a'.\n", err); /* XXX DEBUG TEMP */
1115 rootdev = makedev( 6, 0 );
1116 strlcpy(rootdevice, "sd0a", sizeof(rootdevice));
1117 flags = 0;
1118 }
1119
1120 #if NFSCLIENT
1121 if( flags & 1 ) {
1122 /* network device */
1123 mountroot = netboot_mountroot;
1124 } else {
1125 #endif
1126 /* otherwise have vfs determine root filesystem */
1127 mountroot = NULL;
1128 #if NFSCLIENT
1129 }
1130 #endif
1131
1132 }
1133
1134 void
1135 bsd_utaskbootstrap(void)
1136 {
1137 thread_t thread;
1138 struct uthread *ut;
1139
1140 /*
1141 * Clone the bootstrap process from the kernel process, without
1142 * inheriting either task characteristics or memory from the kernel;
1143 */
1144 thread = cloneproc(TASK_NULL, COALITION_NULL, kernproc, FALSE, TRUE);
1145
1146 /* Hold the reference as it will be dropped during shutdown */
1147 initproc = proc_find(1);
1148 #if __PROC_INTERNAL_DEBUG
1149 if (initproc == PROC_NULL)
1150 panic("bsd_utaskbootstrap: initproc not set\n");
1151 #endif
1152 /*
1153 * Since we aren't going back out the normal way to our parent,
1154 * we have to drop the transition locks explicitly.
1155 */
1156 proc_signalend(initproc, 0);
1157 proc_transend(initproc, 0);
1158
1159 ut = (struct uthread *)get_bsdthread_info(thread);
1160 ut->uu_sigmask = 0;
1161 act_set_astbsd(thread);
1162 task_clear_return_wait(get_threadtask(thread));
1163 }
1164
1165 static void
1166 parse_bsd_args(void)
1167 {
1168 char namep[16];
1169 int msgbuf;
1170
1171 if ( PE_parse_boot_argn("-s", namep, sizeof (namep)))
1172 boothowto |= RB_SINGLE;
1173
1174 if (PE_parse_boot_argn("-b", namep, sizeof (namep)))
1175 boothowto |= RB_NOBOOTRC;
1176
1177 if (PE_parse_boot_argn("-x", namep, sizeof (namep))) /* safe boot */
1178 boothowto |= RB_SAFEBOOT;
1179
1180 if (PE_parse_boot_argn("-minimalboot", namep, sizeof(namep))) {
1181 /*
1182 * -minimalboot indicates that we want userspace to be bootstrapped to a
1183 * minimal environment. What constitutes minimal is up to the bootstrap
1184 * process.
1185 */
1186 minimalboot = 1;
1187 }
1188
1189 #if __arm64__
1190 /* disable 64 bit grading */
1191 if (PE_parse_boot_argn("-no64exec", namep, sizeof (namep)))
1192 bootarg_no64exec = 1;
1193 #endif
1194
1195 /* disable vnode_cache_is_authorized() by setting vnode_cache_defeat */
1196 if (PE_parse_boot_argn("-vnode_cache_defeat", namep, sizeof (namep)))
1197 bootarg_vnode_cache_defeat = 1;
1198
1199 #if DEVELOPMENT || DEBUG
1200 if (PE_parse_boot_argn("-disable_aslr", namep, sizeof (namep)))
1201 bootarg_disable_aslr = 1;
1202 #endif
1203
1204 PE_parse_boot_argn("ncl", &ncl, sizeof (ncl));
1205 if (PE_parse_boot_argn("nbuf", &max_nbuf_headers,
1206 sizeof (max_nbuf_headers))) {
1207 customnbuf = 1;
1208 }
1209
1210 #if CONFIG_MACF
1211 #if defined (__i386__) || defined (__x86_64__)
1212 PE_parse_boot_argn("policy_check", &policy_check_flags, sizeof (policy_check_flags));
1213 #endif
1214 #endif /* CONFIG_MACF */
1215
1216 if (PE_parse_boot_argn("msgbuf", &msgbuf, sizeof (msgbuf))) {
1217 log_setsize(msgbuf);
1218 oslog_setsize(msgbuf);
1219 }
1220
1221 if (PE_parse_boot_argn("-novfscache", namep, sizeof(namep))) {
1222 nc_disabled = 1;
1223 }
1224
1225 #if CONFIG_JETSAM && (DEVELOPMENT || DEBUG)
1226 if (PE_parse_boot_argn("-no_vnode_jetsam", namep, sizeof(namep)))
1227 bootarg_no_vnode_jetsam = 1;
1228 #endif /* CONFIG_JETSAM && (DEVELOPMENT || DEBUG) */
1229
1230
1231 #if CONFIG_EMBEDDED
1232 /*
1233 * The darkboot flag is specified by the bootloader and is stored in
1234 * boot_args->bootFlags. This flag is available starting revision 2.
1235 */
1236 boot_args *args = (boot_args *) PE_state.bootArgs;
1237 if ((args != NULL) && (args->Revision >= kBootArgsRevision2)) {
1238 darkboot = (args->bootFlags & kBootFlagsDarkBoot) ? 1 : 0;
1239 } else {
1240 darkboot = 0;
1241 }
1242 #endif
1243
1244 #if PROC_REF_DEBUG
1245 if (PE_parse_boot_argn("-disable_procref_tracking", namep, sizeof(namep))) {
1246 proc_ref_tracking_disabled = 1;
1247 }
1248 #endif
1249
1250 #if OS_REASON_DEBUG
1251 if (PE_parse_boot_argn("-disable_osreason_debug", namep, sizeof(namep))) {
1252 os_reason_debug_disabled = 1;
1253 }
1254 #endif
1255
1256 PE_parse_boot_argn("sigrestrict", &sigrestrict_arg, sizeof(sigrestrict_arg));
1257
1258 #if DEVELOPMENT|| DEBUG
1259 if (PE_parse_boot_argn("-no_sigsys", namep, sizeof(namep))) {
1260 send_sigsys = false;
1261 }
1262 #endif
1263
1264 #if (DEVELOPMENT|| DEBUG)
1265 if (PE_parse_boot_argn("alt-dyld", dyld_alt_path, sizeof(dyld_alt_path))) {
1266 if (strlen(dyld_alt_path) > 0) {
1267 use_alt_dyld = 1;
1268 }
1269 }
1270 #endif
1271 }
1272
1273 void
1274 bsd_exec_setup(int scale)
1275 {
1276
1277 switch (scale) {
1278 case 0:
1279 case 1:
1280 bsd_simul_execs = BSD_SIMUL_EXECS;
1281 break;
1282 case 2:
1283 case 3:
1284 bsd_simul_execs = 65;
1285 break;
1286 case 4:
1287 case 5:
1288 bsd_simul_execs = 129;
1289 break;
1290 case 6:
1291 case 7:
1292 bsd_simul_execs = 257;
1293 break;
1294 default:
1295 bsd_simul_execs = 513;
1296 break;
1297
1298 }
1299 bsd_pageable_map_size = (bsd_simul_execs * BSD_PAGEABLE_SIZE_PER_EXEC);
1300 }
1301
1302 #if !NFSCLIENT
1303 int
1304 netboot_root(void);
1305
1306 int
1307 netboot_root(void)
1308 {
1309 return(0);
1310 }
1311 #endif