X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/ff6e181ae92fc6f1e89841290f461d1f2f9badd9..c0fea4742e91338fffdcf79f86a7c1d5e2b97eb1:/bsd/kern/bsd_init.c diff --git a/bsd/kern/bsd_init.c b/bsd/kern/bsd_init.c index e76b7763c..05b66d530 100644 --- a/bsd/kern/bsd_init.c +++ b/bsd/kern/bsd_init.c @@ -3,20 +3,19 @@ * * @APPLE_LICENSE_HEADER_START@ * - * 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 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. * - * 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@ */ @@ -118,6 +117,8 @@ #include <net/init.h> +#include <machine/exec.h> + extern int app_profile; /* on/off switch for pre-heat cache */ char copyright[] = @@ -157,9 +158,13 @@ char hostname[MAXHOSTNAMELEN]; int hostnamelen; char domainname[MAXDOMNAMELEN]; int domainnamelen; -char classichandler[32] = {0}; -uint32_t classichandler_fsid = -1L; -long classichandler_fileid = -1L; +#if __i386__ +struct exec_archhandler exec_archhandler_ppc = { + .path = "/usr/libexec/oah/translate", +}; +#else /* __i386__ */ +struct exec_archhandler exec_archhandler_ppc; +#endif /* __i386__ */ char rootdevice[16]; /* hfs device names have at least 9 chars */ @@ -177,6 +182,7 @@ vm_map_t mb_map; semaphore_t execve_semaphore; int cmask = CMASK; +extern int customnbuf; int parse_bsd_args(void); extern int bsd_hardclockinit; @@ -194,6 +200,12 @@ extern void sysv_sem_lock_init(void); extern void sysv_msg_lock_init(void); extern void pshm_lock_init(); extern void psem_lock_init(); +extern int maxprocperuid; + +/* kmem access not enabled by default; can be changed with boot-args */ +int setup_kmem = 0; + +extern void stackshot_lock_init(); /* * Initialization code. @@ -262,6 +274,7 @@ bsd_init() extern kauth_cred_t rootcred; register int i; int s; + int error; thread_t th; struct vfs_context context; void lightning_bolt(void ); @@ -303,17 +316,13 @@ bsd_init() /* give kernproc a name */ process_name("kernel_task", p); - /* allocate proc lock group attribute and group */ proc_lck_grp_attr= lck_grp_attr_alloc_init(); - lck_grp_attr_setstat(proc_lck_grp_attr); - + proc_lck_grp = lck_grp_alloc_init("proc", proc_lck_grp_attr); - /* Allocate proc lock attribute */ proc_lck_attr = lck_attr_alloc_init(); - //lck_attr_setdebug(proc_lck_attr); lck_mtx_init(&p->p_mlock, proc_lck_grp, proc_lck_attr); lck_mtx_init(&p->p_fdmlock, proc_lck_grp, proc_lck_attr); @@ -385,7 +394,7 @@ bsd_init() limit0.pl_rlimit[i].rlim_cur = 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_cur = maxprocperuid; 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; @@ -474,6 +483,8 @@ bsd_init() psem_cache_init(); time_zone_slock_init(); + /* Stack snapshot facility lock */ + stackshot_lock_init(); /* * Initialize protocols. Block reception of incoming packets * until everything is ready. @@ -585,6 +596,13 @@ bsd_init() bsd_utaskbootstrap(); +#if __i386__ + // this should be done after the root filesystem is mounted + error = set_archhandler(p, CPU_TYPE_POWERPC); + if (error) + exec_archhandler_ppc.path[0] = 0; +#endif + /* invoke post-root-mount hook */ if (mountroot_post_hook != NULL) mountroot_post_hook(); @@ -625,7 +643,6 @@ bsdinit_task(void) ut = (uthread_t)get_bsdthread_info(th_act); - ut->uu_ar0 = (void *)get_user_regs(th_act); bsd_hardclockinit = 1; /* Start bsd hardclock */ bsd_init_task = get_threadtask(th_act); @@ -795,7 +812,9 @@ parse_bsd_args() PE_parse_boot_arg("srv", &srv); PE_parse_boot_arg("ncl", &ncl); - PE_parse_boot_arg("nbuf", &nbuf); + if (PE_parse_boot_arg("nbuf", &max_nbuf_headers)) + customnbuf = 1; + PE_parse_boot_arg("kmem", &setup_kmem); return 0; }