X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/43866e378188c25dd1e2208016ab3cbeb086ae6c..5353443c9cd32307ab4ce5d2e263522955d5d5dd:/bsd/kern/bsd_init.c diff --git a/bsd/kern/bsd_init.c b/bsd/kern/bsd_init.c index 7b4a41efb..2864a6cfd 100644 --- a/bsd/kern/bsd_init.c +++ b/bsd/kern/bsd_init.c @@ -1,24 +1,21 @@ /* - * Copyright (c) 2000-2001 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * The contents of this file constitute Original Code as defined in and + * are subject to the Apple Public Source License Version 1.1 (the + * "License"). You may not use this file except in compliance with the + * License. Please obtain a copy of the License at + * http://www.apple.com/publicsource and read it before using this file. * - * This file contains Original Code and/or Modifications of Original Code - * as defined in and that are subject to the Apple Public Source License - * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. - * - * The Original Code and all software distributed under the License are - * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER + * This Original Code and all software distributed under the License are + * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. - * Please see the License for the specific language governing rights and - * limitations under the License. + * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the + * License for the specific language governing rights and limitations + * under the License. * * @APPLE_LICENSE_HEADER_END@ */ @@ -69,13 +66,6 @@ * All rights reserved. The CMU software License Agreement specifies * the terms and conditions for use and redistribution. */ -/* - * HISTORY - * 16-Apr-98 A. Ramesh at Apple - * Created for Apple Core from DR2 init_main.c. - */ - -#include #include #include @@ -88,7 +78,10 @@ #include #include #include -#include +#include +#include + +#include #include #include @@ -103,11 +96,11 @@ #include #include -#include +#include /* for ux_exception_port */ #include #include -#include +#include /* for pseudo_inits */ #include #include @@ -120,11 +113,12 @@ #include #include -extern shared_region_mapping_t system_shared_region; extern int app_profile; /* on/off switch for pre-heat cache */ char copyright[] = -"Copyright (c) 1982, 1986, 1989, 1991, 1993\n\tThe Regents of the University of California. All rights reserved.\n\n"; +"Copyright (c) 1982, 1986, 1989, 1991, 1993\n\t" +"The Regents of the University of California. " +"All rights reserved.\n\n"; extern void ux_handler(); @@ -155,9 +149,12 @@ dev_t dumpdev; /* device to take dumps on */ long dumplo; /* offset into dumpdev */ long hostid; char hostname[MAXHOSTNAMELEN]; -int hostnamelen; +int hostnamelen; char domainname[MAXDOMNAMELEN]; -int domainnamelen; +int domainnamelen; +char classichandler[32] = {0}; +long classichandler_fsid = -1L; +long classichandler_fileid = -1L; char rootdevice[16]; /* hfs device names have at least 9 chars */ struct timeval boottime; /* GRODY! This has to go... */ @@ -170,7 +167,7 @@ int lbolt; /* awoken once a second */ struct vnode *rootvp; int boothowto = RB_DEBUG; -#define BSD_PAGABLE_MAP_SIZE (4 * 512 * 1024) +#define BSD_PAGABLE_MAP_SIZE (16 * 512 * 1024) vm_map_t bsd_pageable_map; vm_map_t mb_map; semaphore_t execve_semaphore; @@ -183,8 +180,8 @@ extern task_t bsd_init_task; extern char init_task_failure_data[]; extern void time_zone_slock_init(void); -funnel_t * kernel_flock; -funnel_t * network_flock; +funnel_t *kernel_flock; +funnel_t *network_flock; int disable_funnel = 0; /* disables split funnel */ int enable_funnel = 0; /* disables split funnel */ @@ -194,13 +191,10 @@ int enable_funnel = 0; /* disables split funnel */ * soon as a stack and segmentation * have been established. * Functions: - * clear and free user core * turn on clock * hand craft 0th process * call all initialization routines - * fork - process 0 to schedule - * - process 1 execute bootstrap - * - process 2 to page out + * hand craft 1st user process */ /* @@ -247,19 +241,8 @@ bsd_init() extern void uthread_zone_init(); - -#if 1 /* split funnel is enabled by default */ PE_parse_boot_arg("dfnl", &disable_funnel); -#else - /* split funnel is disabled befault */ - disable_funnel = 1; - PE_parse_boot_arg("efnl", &enable_funnel); - if (enable_funnel) { - /* enable only if efnl is set in bootarg */ - disable_funnel = 0; - } -#endif kernel_flock = funnel_alloc(KERNEL_FUNNEL); if (kernel_flock == (funnel_t *)0 ) { @@ -339,11 +322,23 @@ bsd_init() p->p_cred = &cred0; p->p_ucred = crget(); p->p_ucred->cr_ngroups = 1; /* group 0 */ + + TAILQ_INIT(&p->aio_activeq); + TAILQ_INIT(&p->aio_doneq); + p->aio_active_count = 0; + p->aio_done_count = 0; + + /* Set the audit info for this process */ + audit_proc_init(p); /* Create the file descriptor table. */ filedesc0.fd_refcnt = 1+1; /* +1 so shutdown will not _FREE_ZONE */ p->p_fd = &filedesc0; filedesc0.fd_cmask = cmask; + filedesc0.fd_knlistsize = -1; + filedesc0.fd_knlist = NULL; + filedesc0.fd_knhash = NULL; + filedesc0.fd_knhashmask = 0; /* Create the limits structures. */ p->p_limit = &limit0; @@ -352,6 +347,7 @@ bsd_init() limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY; limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur = NOFILE; limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = MAXUPRC; + limit0.pl_rlimit[RLIMIT_NPROC].rlim_max = maxproc; limit0.pl_rlimit[RLIMIT_STACK] = vm_initial_limit_stack; limit0.pl_rlimit[RLIMIT_DATA] = vm_initial_limit_data; limit0.pl_rlimit[RLIMIT_CORE] = vm_initial_limit_core; @@ -404,6 +400,18 @@ bsd_init() /* Initialize syslog */ log_init(); + /* + * Initializes security event auditing. + * XXX: Should/could this occur later? + */ + audit_init(); + + /* Initialize kqueues */ + knote_init(); + + /* Initialize for async IO */ + aio_init(); + /* POSIX Shm and Sem */ pshm_cache_init(); psem_cache_init(); @@ -431,7 +439,7 @@ bsd_init() /* kick off timeout driven events by calling first time */ thread_wakeup(&lbolt); - timeout(lightning_bolt,0,hz); + timeout((void (*)(void *))lightning_bolt, 0, hz); bsd_autoconf(); @@ -459,7 +467,7 @@ bsd_init() * read the time after clock_initialize_calendar() * and before nfs mount */ - microtime(&time); + microtime((struct timeval *)&time); bsd_hardclockinit = -1; /* start ticking */ @@ -507,13 +515,11 @@ bsd_init() devfs_kernel_mount("/dev"); } -#endif DEVFS +#endif /* DEVFS */ /* Initialize signal state for process 0. */ siginit(p); - /* printf("Launching user process\n"); */ - bsd_utaskbootstrap(); /* invoke post-root-mount hook */ @@ -531,6 +537,7 @@ bsdinit_task(void) struct uthread *ut; kern_return_t kr; thread_act_t th_act; + shared_region_mapping_t system_region; proc_name("init", p); @@ -560,8 +567,14 @@ bsdinit_task(void) bsd_hardclockinit = 1; /* Start bsd hardclock */ bsd_init_task = get_threadtask(th_act); init_task_failure_data[0] = 0; - shared_region_mapping_ref(system_shared_region); - vm_set_shared_region(get_threadtask(th_act), system_shared_region); + system_region = lookup_default_shared_region(ENV_DEFAULT_ROOT, + machine_slot[cpu_number()].cpu_type); + if (system_region == NULL) { + shared_file_boot_time_init(ENV_DEFAULT_ROOT, + machine_slot[cpu_number()].cpu_type); + } else { + vm_set_shared_region(get_threadtask(th_act), system_region); + } load_init_program(p); /* turn on app-profiling i.e. pre-heating */ app_profile = 1; @@ -602,7 +615,7 @@ bsd_autoconf() } -#include // for MAXPARTITIONS +#include /* for MAXPARTITIONS */ setconf() { @@ -649,11 +662,7 @@ bsd_utaskbootstrap() ut = (struct uthread *)get_bsdthread_info(th_act); ut->uu_sigmask = 0; - thread_hold(th_act); - (void)thread_stop(getshuttle_thread(th_act)); act_set_astbsd(th_act); - thread_release(th_act); - thread_unstop(getshuttle_thread(th_act)); (void) thread_resume(th_act); } @@ -675,6 +684,7 @@ parse_bsd_args() else strcat(init_args,"-s"); } + if (PE_parse_boot_arg("-b", namep)) { boothowto |= RB_NOBOOTRC; len = strlen(init_args); @@ -708,6 +718,14 @@ parse_bsd_args() strcat(init_args,"-x"); } + if (PE_parse_boot_arg("-d", namep)) { + len = strlen(init_args); + if(len != 0) + strcat(init_args," -d"); + else + strcat(init_args,"-d"); + } + PE_parse_boot_arg("srv", &srv); PE_parse_boot_arg("ncl", &ncl); PE_parse_boot_arg("nbuf", &nbuf); @@ -720,7 +738,6 @@ thread_funnel_switch( int oldfnl, int newfnl) { - thread_t cur_thread; boolean_t funnel_state_prev; int curfnl; funnel_t * curflock; @@ -748,8 +765,6 @@ thread_funnel_switch( panic("thread_funnel_switch: no funnel held"); } - cur_thread = current_thread(); - if ((oldfnl == NETWORK_FUNNEL) && (curflock != network_flock)) panic("thread_funnel_switch: network funnel not held");