The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/bsd/kern/bsd_init.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*
    2  * Copyright (c) 2000-2009 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 
  110 #include <mach/vm_param.h>
  111 
  112 #include <vm/vm_map.h>
  113 #include <vm/vm_kern.h>
  114 
  115 #include <sys/ux_exception.h>   /* for ux_exception_port */
  116 
  117 #include <sys/reboot.h>
  118 #include <mach/exception_types.h>
  119 #include <dev/busvar.h>                 /* for pseudo_inits */
  120 #include <sys/kdebug.h>
  121 
  122 #include <mach/mach_types.h>
  123 #include <mach/vm_prot.h>
  124 #include <mach/semaphore.h>
  125 #include <mach/sync_policy.h>
  126 #include <kern/clock.h>
  127 #include <mach/kern_return.h>
  128 #include <mach/thread_act.h>            /* for thread_resume() */
  129 #include <mach/task.h>                  /* for task_set_exception_ports() */
  130 #include <sys/ux_exception.h>           /* for ux_handler() */
  131 #include <sys/ubc_internal.h>           /* for ubc_init() */
  132 #include <sys/mcache.h>                 /* for mcache_init() */
  133 #include <sys/mbuf.h>                   /* for mbinit() */
  134 #include <sys/event.h>                  /* for knote_init() */
  135 #include <sys/aio_kern.h>               /* for aio_init() */
  136 #include <sys/semaphore.h>              /* for psem_cache_init() */
  137 #include <net/dlil.h>                   /* for dlil_init() */
  138 #include <net/kpi_protocol.h>           /* for proto_kpi_init() */
  139 #include <sys/pipe.h>                   /* for pipeinit() */
  140 #include <sys/socketvar.h>              /* for socketinit() */
  141 #include <sys/protosw.h>                /* for domaininit() */
  142 #include <kern/sched_prim.h>            /* for thread_wakeup() */
  143 #include <net/if_ether.h>               /* for ether_family_init() */
  144 #include <vm/vm_protos.h>               /* for vnode_pager_bootstrap() */
  145 #include <miscfs/devfs/devfsdefs.h>     /* for devfs_kernel_mount() */
  146 #include <mach/host_priv.h>             /* for host_set_exception_ports() */
  147 #include <kern/host.h>                  /* for host_priv_self() */
  148 #include <vm/vm_kern.h>                 /* for kmem_suballoc() */
  149 #include <sys/semaphore.h>              /* for psem_lock_init() */
  150 #include <sys/msgbuf.h>                 /* for log_setsize() */
  151 #include <sys/tty.h>                    /* for tty_init() */
  152 #include <net/if_utun.h>                /* for utun_register_control() */
  153 #include <net/net_str_id.h>             /* for net_str_id_init() */
  154 
  155 #include <net/init.h>
  156 
  157 #if CONFIG_MACF
  158 #include <security/mac_framework.h>
  159 #include <security/mac_internal.h>      /* mac_init_bsd() */
  160 #include <security/mac_mach_internal.h> /* mac_update_task_label() */
  161 #endif
  162 
  163 #include <machine/exec.h>
  164 
  165 #if CONFIG_IMAGEBOOT
  166 #include <sys/imageboot.h>
  167 #endif
  168 
  169 #if PFLOG
  170 #include <net/if_pflog.h>
  171 #endif
  172 
  173 #include <pexpert/pexpert.h>
  174 
  175 #if CONFIG_EMBEDDED
  176 #include <libkern/OSKextLib.h>
  177 #endif
  178 
  179 void * get_user_regs(thread_t);         /* XXX kludge for <machine/thread.h> */
  180 void IOKitInitializeTime(void);         /* XXX */
  181 void IOSleep(unsigned int);             /* XXX */
  182 void loopattach(void);                  /* XXX */
  183 void vc_progress_set(boolean_t, uint32_t); /* XXX */
  184 
  185 const char    copyright[] =
  186 "Copyright (c) 1982, 1986, 1989, 1991, 1993\n\t"
  187 "The Regents of the University of California. "
  188 "All rights reserved.\n\n";
  189 
  190 /* Components of the first process -- never freed. */
  191 struct  proc proc0;
  192 struct  session session0;
  193 struct  pgrp pgrp0;
  194 struct  filedesc filedesc0;
  195 struct  plimit limit0;
  196 struct  pstats pstats0;
  197 struct  sigacts sigacts0;
  198 proc_t kernproc;
  199 proc_t initproc;
  200 
  201 long tk_cancc;
  202 long tk_nin;
  203 long tk_nout;
  204 long tk_rawcc;
  205 
  206 int lock_trace = 0;
  207 /* Global variables to make pstat happy. We do swapping differently */
  208 int nswdev, nswap;
  209 int nswapmap;
  210 void *swapmap;
  211 struct swdevt swdevt[1];
  212 
  213 dev_t   rootdev;                /* device of the root */
  214 dev_t   dumpdev;                /* device to take dumps on */
  215 long    dumplo;                 /* offset into dumpdev */
  216 long    hostid;
  217 char    hostname[MAXHOSTNAMELEN];
  218 int             hostnamelen;
  219 char    domainname[MAXDOMNAMELEN];
  220 int             domainnamelen;
  221 #if defined(__i386__) || defined(__x86_64__)
  222 struct exec_archhandler exec_archhandler_ppc = {
  223         .path = "/usr/libexec/oah/translate",
  224 };
  225 const char * const kRosettaStandIn_str = "/usr/libexec/oah/RosettaNonGrata";
  226 #else /* __i386__ */
  227 struct exec_archhandler exec_archhandler_ppc;
  228 #endif /* __i386__ */
  229 
  230 char rootdevice[16];    /* hfs device names have at least 9 chars */
  231 
  232 #if  KMEMSTATS
  233 struct  kmemstats kmemstats[M_LAST];
  234 #endif
  235 
  236 int     lbolt;                          /* awoken once a second */
  237 struct  vnode *rootvp;
  238 int boothowto = RB_DEBUG;
  239 
  240 void lightning_bolt(void *);
  241 extern kern_return_t IOFindBSDRoot(char *, unsigned int, dev_t *, u_int32_t *);
  242 extern void IOSecureBSDRoot(const char * rootName);
  243 extern kern_return_t IOKitBSDInit(void );
  244 extern void kminit(void);
  245 extern void klogwakeup(void);
  246 extern void file_lock_init(void);
  247 extern void kmeminit(void);
  248 extern void bsd_bufferinit(void);
  249 
  250 extern int srv;
  251 extern int ncl;
  252 
  253 vm_map_t        bsd_pageable_map;
  254 vm_map_t        mb_map;
  255 
  256 static  int bsd_simul_execs = BSD_SIMUL_EXECS;
  257 static int bsd_pageable_map_size = BSD_PAGABLE_MAP_SIZE;
  258 __private_extern__ int execargs_cache_size = BSD_SIMUL_EXECS;
  259 __private_extern__ int execargs_free_count = BSD_SIMUL_EXECS;
  260 __private_extern__ vm_offset_t * execargs_cache = NULL;
  261 
  262 void bsd_exec_setup(int);
  263 
  264 /*
  265  * Set to disable grading 64 bit Mach-o binaries as executable, for testing;
  266  * Intel only.
  267  */
  268 __private_extern__ int bootarg_no64exec = 0;
  269 
  270 int     cmask = CMASK;
  271 extern int customnbuf;
  272 
  273 void bsd_init(void) __attribute__((section("__TEXT, initcode")));
  274 kern_return_t bsd_autoconf(void) __attribute__((section("__TEXT, initcode")));
  275 void bsd_utaskbootstrap(void) __attribute__((section("__TEXT, initcode")));
  276 
  277 static void parse_bsd_args(void);
  278 extern task_t bsd_init_task;
  279 extern char    init_task_failure_data[];
  280 extern void time_zone_slock_init(void);
  281 static void process_name(const char *, proc_t);
  282 
  283 static void setconf(void);
  284 
  285 funnel_t *kernel_flock;
  286 
  287 #if SYSV_SHM
  288 extern void sysv_shm_lock_init(void);
  289 #endif
  290 #if SYSV_SEM
  291 extern void sysv_sem_lock_init(void);
  292 #endif
  293 #if SYSV_MSG
  294 extern void sysv_msg_lock_init(void);
  295 #endif
  296 extern void pthread_init(void);
  297 
  298 /* kmem access not enabled by default; can be changed with boot-args */
  299 int setup_kmem = 0;
  300 
  301 /* size of kernel trace buffer, disabled by default */
  302 unsigned int new_nkdbufs = 0;
  303 
  304 /* mach leak logging */
  305 int log_leaks = 0;
  306 int turn_on_log_leaks = 0;
  307 
  308 extern void stackshot_lock_init(void);
  309 
  310 
  311 /* If we are using CONFIG_DTRACE */
  312 #if CONFIG_DTRACE
  313         extern void dtrace_postinit(void);
  314 #endif
  315 
  316 
  317 /*
  318  * Initialization code.
  319  * Called from cold start routine as
  320  * soon as a stack and segmentation
  321  * have been established.
  322  * Functions:
  323  *      turn on clock
  324  *      hand craft 0th process
  325  *      call all initialization routines
  326  *  hand craft 1st user process
  327  */
  328 
  329 /*
  330  *      Sets the name for the given task.
  331  */
  332 static void
  333 process_name(const char *s, proc_t p)
  334 {
  335         size_t length = strlen(s);
  336 
  337         bcopy(s, p->p_comm,
  338                 length >= sizeof(p->p_comm) ? sizeof(p->p_comm) :
  339                         length + 1);
  340 }
  341 
  342 /* To allow these values to be patched, they're globals here */
  343 #include <machine/vmparam.h>
  344 struct rlimit vm_initial_limit_stack = { DFLSSIZ, MAXSSIZ - PAGE_SIZE };
  345 struct rlimit vm_initial_limit_data = { DFLDSIZ, MAXDSIZ };
  346 struct rlimit vm_initial_limit_core = { DFLCSIZ, MAXCSIZ };
  347 
  348 extern thread_t cloneproc(task_t, proc_t, int);
  349 extern int      (*mountroot)(void);
  350 extern int      netboot_mountroot(void);        /* netboot.c */
  351 extern int      netboot_setup(void);
  352 
  353 lck_grp_t * proc_lck_grp;
  354 lck_grp_t * proc_slock_grp;
  355 lck_grp_t * proc_fdmlock_grp;
  356 lck_grp_t * proc_mlock_grp;
  357 lck_grp_attr_t * proc_lck_grp_attr;
  358 lck_attr_t * proc_lck_attr;
  359 lck_mtx_t * proc_list_mlock;
  360 lck_mtx_t * proc_klist_mlock;
  361 
  362 extern lck_mtx_t * execargs_cache_lock;
  363 
  364 /* hook called after root is mounted XXX temporary hack */
  365 void (*mountroot_post_hook)(void);
  366 void (*unmountroot_pre_hook)(void);
  367 
  368 /*
  369  * This function is called very early on in the Mach startup, from the
  370  * function start_kernel_threads() in osfmk/kern/startup.c.  It's called
  371  * in the context of the current (startup) task using a call to the
  372  * function kernel_thread_create() to jump into start_kernel_threads().
  373  * Internally, kernel_thread_create() calls thread_create_internal(),
  374  * which calls uthread_alloc().  The function of uthread_alloc() is
  375  * normally to allocate a uthread structure, and fill out the uu_sigmask,
  376  * uu_context fields.  It skips filling these out in the case of the "task"
  377  * being "kernel_task", because the order of operation is inverted.  To
  378  * account for that, we need to manually fill in at least the contents
  379  * of the uu_context.vc_ucred field so that the uthread structure can be
  380  * used like any other.
  381  */
  382 void
  383 bsd_init(void)
  384 {
  385         struct uthread *ut;
  386         unsigned int i;
  387 #if __i386__ || __x86_64__
  388         int error;
  389 #endif  
  390         struct vfs_context context;
  391         kern_return_t   ret;
  392         struct ucred temp_cred;
  393 
  394 #define bsd_init_kprintf(x...) /* kprintf("bsd_init: " x) */
  395 
  396         kernel_flock = funnel_alloc(KERNEL_FUNNEL);
  397         if (kernel_flock == (funnel_t *)0 ) {
  398                 panic("bsd_init: Failed to allocate kernel funnel");
  399         }
  400         
  401         printf(copyright);
  402         
  403         bsd_init_kprintf("calling kmeminit\n");
  404         kmeminit();
  405         
  406         bsd_init_kprintf("calling parse_bsd_args\n");
  407         parse_bsd_args();
  408 
  409         /* Initialize kauth subsystem before instancing the first credential */
  410         bsd_init_kprintf("calling kauth_init\n");
  411         kauth_init();
  412 
  413         /* Initialize process and pgrp structures. */
  414         bsd_init_kprintf("calling procinit\n");
  415         procinit();
  416 
  417         /* Initialize the ttys (MUST be before kminit()/bsd_autoconf()!)*/
  418         tty_init();
  419 
  420         kernproc = &proc0;      /* implicitly bzero'ed */
  421 
  422         /* kernel_task->proc = kernproc; */
  423         set_bsdtask_info(kernel_task,(void *)kernproc);
  424 
  425         /* give kernproc a name */
  426         bsd_init_kprintf("calling process_name\n");
  427         process_name("kernel_task", kernproc);
  428 
  429         /* allocate proc lock group attribute and group */
  430         bsd_init_kprintf("calling lck_grp_attr_alloc_init\n");
  431         proc_lck_grp_attr= lck_grp_attr_alloc_init();
  432 
  433         proc_lck_grp = lck_grp_alloc_init("proc",  proc_lck_grp_attr);
  434 #ifndef CONFIG_EMBEDDED
  435         proc_slock_grp = lck_grp_alloc_init("proc-slock",  proc_lck_grp_attr);
  436         proc_fdmlock_grp = lck_grp_alloc_init("proc-fdmlock",  proc_lck_grp_attr);
  437         proc_mlock_grp = lck_grp_alloc_init("proc-mlock",  proc_lck_grp_attr);
  438 #endif
  439         /* Allocate proc lock attribute */
  440         proc_lck_attr = lck_attr_alloc_init();
  441 #if 0
  442 #if __PROC_INTERNAL_DEBUG
  443         lck_attr_setdebug(proc_lck_attr);
  444 #endif
  445 #endif
  446 
  447 #ifdef CONFIG_EMBEDDED
  448         proc_list_mlock = lck_mtx_alloc_init(proc_lck_grp, proc_lck_attr);
  449         proc_klist_mlock = lck_mtx_alloc_init(proc_lck_grp, proc_lck_attr);
  450         lck_mtx_init(&kernproc->p_mlock, proc_lck_grp, proc_lck_attr);
  451         lck_mtx_init(&kernproc->p_fdmlock, proc_lck_grp, proc_lck_attr);
  452         lck_spin_init(&kernproc->p_slock, proc_lck_grp, proc_lck_attr);
  453 #else   
  454         proc_list_mlock = lck_mtx_alloc_init(proc_mlock_grp, proc_lck_attr);
  455         proc_klist_mlock = lck_mtx_alloc_init(proc_mlock_grp, proc_lck_attr);
  456         lck_mtx_init(&kernproc->p_mlock, proc_mlock_grp, proc_lck_attr);
  457         lck_mtx_init(&kernproc->p_fdmlock, proc_fdmlock_grp, proc_lck_attr);
  458         lck_spin_init(&kernproc->p_slock, proc_slock_grp, proc_lck_attr);
  459 #endif
  460 
  461         execargs_cache_lock = lck_mtx_alloc_init(proc_lck_grp, proc_lck_attr);
  462         execargs_cache_size = bsd_simul_execs;
  463         execargs_free_count = bsd_simul_execs;
  464         execargs_cache = (vm_offset_t *)kalloc(bsd_simul_execs * sizeof(vm_offset_t));
  465         bzero(execargs_cache, bsd_simul_execs * sizeof(vm_offset_t));
  466         
  467         if (current_task() != kernel_task)
  468                 printf("bsd_init: We have a problem, "
  469                                 "current task is not kernel task\n");
  470         
  471         bsd_init_kprintf("calling get_bsdthread_info\n");
  472         ut = (uthread_t)get_bsdthread_info(current_thread());
  473 
  474 #if CONFIG_MACF
  475         /*
  476          * Initialize the MAC Framework
  477          */
  478         mac_policy_initbsd();
  479         kernproc->p_mac_enforce = 0;
  480 #endif /* MAC */
  481 
  482         /*
  483          * Create process 0.
  484          */
  485         proc_list_lock();
  486         LIST_INSERT_HEAD(&allproc, kernproc, p_list);
  487         kernproc->p_pgrp = &pgrp0;
  488         LIST_INSERT_HEAD(PGRPHASH(0), &pgrp0, pg_hash);
  489         LIST_INIT(&pgrp0.pg_members);
  490 #ifdef CONFIG_EMBEDDED
  491         lck_mtx_init(&pgrp0.pg_mlock, proc_lck_grp, proc_lck_attr);     
  492 #else
  493         lck_mtx_init(&pgrp0.pg_mlock, proc_mlock_grp, proc_lck_attr);
  494 #endif
  495         /* There is no other bsd thread this point and is safe without pgrp lock */
  496         LIST_INSERT_HEAD(&pgrp0.pg_members, kernproc, p_pglist);
  497         kernproc->p_listflag |= P_LIST_INPGRP;
  498         kernproc->p_pgrpid = 0;
  499 
  500         pgrp0.pg_session = &session0;
  501         pgrp0.pg_membercnt = 1;
  502 
  503         session0.s_count = 1;
  504         session0.s_leader = kernproc;
  505         session0.s_listflags = 0;
  506 #ifdef CONFIG_EMBEDDED
  507         lck_mtx_init(&session0.s_mlock, proc_lck_grp, proc_lck_attr);
  508 #else
  509         lck_mtx_init(&session0.s_mlock, proc_mlock_grp, proc_lck_attr);
  510 #endif
  511         LIST_INSERT_HEAD(SESSHASH(0), &session0, s_hash);
  512         proc_list_unlock();
  513 
  514 #if CONFIG_LCTX
  515         kernproc->p_lctx = NULL;
  516 #endif
  517 
  518         kernproc->task = kernel_task;
  519         
  520         kernproc->p_stat = SRUN;
  521         kernproc->p_flag = P_SYSTEM;
  522         kernproc->p_nice = NZERO;
  523         kernproc->p_pptr = kernproc;
  524 
  525         TAILQ_INIT(&kernproc->p_uthlist);
  526         TAILQ_INSERT_TAIL(&kernproc->p_uthlist, ut, uu_list);
  527         
  528         kernproc->sigwait = FALSE;
  529         kernproc->sigwait_thread = THREAD_NULL;
  530         kernproc->exit_thread = THREAD_NULL;
  531         kernproc->p_csflags = CS_VALID;
  532 
  533         /*
  534          * Create credential.  This also Initializes the audit information.
  535          */
  536         bsd_init_kprintf("calling bzero\n");
  537         bzero(&temp_cred, sizeof(temp_cred));
  538         temp_cred.cr_ngroups = 1;
  539 
  540         temp_cred.cr_audit.as_aia_p = &audit_default_aia;
  541         /* XXX the following will go away with cr_au */
  542         temp_cred.cr_au.ai_auid = AU_DEFAUDITID;
  543 
  544         bsd_init_kprintf("calling kauth_cred_create\n");
  545         kernproc->p_ucred = kauth_cred_create(&temp_cred); 
  546 
  547         /* give the (already exisiting) initial thread a reference on it */
  548         bsd_init_kprintf("calling kauth_cred_ref\n");
  549         kauth_cred_ref(kernproc->p_ucred);
  550         ut->uu_context.vc_ucred = kernproc->p_ucred;
  551         ut->uu_context.vc_thread = current_thread();
  552 
  553         TAILQ_INIT(&kernproc->p_aio_activeq);
  554         TAILQ_INIT(&kernproc->p_aio_doneq);
  555         kernproc->p_aio_total_count = 0;
  556         kernproc->p_aio_active_count = 0;
  557 
  558         bsd_init_kprintf("calling file_lock_init\n");
  559         file_lock_init();
  560 
  561 #if CONFIG_MACF
  562         mac_cred_label_associate_kernel(kernproc->p_ucred);
  563         mac_task_label_update_cred (kernproc->p_ucred, (struct task *) kernproc->task);
  564 #endif
  565 
  566         /* Create the file descriptor table. */
  567         filedesc0.fd_refcnt = 1+1;      /* +1 so shutdown will not _FREE_ZONE */
  568         kernproc->p_fd = &filedesc0;
  569         filedesc0.fd_cmask = cmask;
  570         filedesc0.fd_knlistsize = -1;
  571         filedesc0.fd_knlist = NULL;
  572         filedesc0.fd_knhash = NULL;
  573         filedesc0.fd_knhashmask = 0;
  574 
  575         /* Create the limits structures. */
  576         kernproc->p_limit = &limit0;
  577         for (i = 0; i < sizeof(kernproc->p_rlimit)/sizeof(kernproc->p_rlimit[0]); i++)
  578                 limit0.pl_rlimit[i].rlim_cur = 
  579                         limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY;
  580         limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur = NOFILE;
  581         limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur = maxprocperuid;
  582         limit0.pl_rlimit[RLIMIT_NPROC].rlim_max = maxproc;
  583         limit0.pl_rlimit[RLIMIT_STACK] = vm_initial_limit_stack;
  584         limit0.pl_rlimit[RLIMIT_DATA] = vm_initial_limit_data;
  585         limit0.pl_rlimit[RLIMIT_CORE] = vm_initial_limit_core;
  586         limit0.pl_refcnt = 1;
  587 
  588         kernproc->p_stats = &pstats0;
  589         kernproc->p_sigacts = &sigacts0;
  590 
  591         /*
  592          * Charge root for two  processes: init and mach_init.
  593          */
  594         bsd_init_kprintf("calling chgproccnt\n");
  595         (void)chgproccnt(0, 1);
  596 
  597         /*
  598          *      Allocate a kernel submap for pageable memory
  599          *      for temporary copying (execve()).
  600          */
  601         {
  602                 vm_offset_t     minimum;
  603 
  604                 bsd_init_kprintf("calling kmem_suballoc\n");
  605                 ret = kmem_suballoc(kernel_map,
  606                                 &minimum,
  607                                 (vm_size_t)bsd_pageable_map_size,
  608                                 TRUE,
  609                                 VM_FLAGS_ANYWHERE,
  610                                 &bsd_pageable_map);
  611                 if (ret != KERN_SUCCESS) 
  612                         panic("bsd_init: Failed to allocate bsd pageable map");
  613         }
  614 
  615         /*
  616          * Initialize buffers and hash links for buffers
  617          *
  618          * SIDE EFFECT: Starts a thread for bcleanbuf_thread(), so must
  619          *              happen after a credential has been associated with
  620          *              the kernel task.
  621          */
  622         bsd_init_kprintf("calling bsd_bufferinit\n");
  623         bsd_bufferinit();
  624 
  625         /* Initialize the execve() semaphore */
  626         bsd_init_kprintf("calling semaphore_create\n");
  627 
  628         if (ret != KERN_SUCCESS)
  629                 panic("bsd_init: Failed to create execve semaphore");
  630 
  631         /*
  632          * Initialize the calendar.
  633          */
  634         bsd_init_kprintf("calling IOKitInitializeTime\n");
  635         IOKitInitializeTime();
  636 
  637         if (turn_on_log_leaks && !new_nkdbufs)
  638                 new_nkdbufs = 200000;
  639         start_kern_tracing(new_nkdbufs);
  640         if (turn_on_log_leaks)
  641                 log_leaks = 1;
  642 
  643         bsd_init_kprintf("calling ubc_init\n");
  644         ubc_init();
  645 
  646         /* Initialize the file systems. */
  647         bsd_init_kprintf("calling vfsinit\n");
  648         vfsinit();
  649 
  650 #if SOCKETS
  651         /* Initialize per-CPU cache allocator */
  652         mcache_init();
  653 
  654         /* Initialize mbuf's. */
  655         bsd_init_kprintf("calling mbinit\n");
  656         mbinit();
  657         net_str_id_init(); /* for mbuf tags */
  658 #endif /* SOCKETS */
  659 
  660         /*
  661          * Initializes security event auditing.
  662          * XXX: Should/could this occur later?
  663          */
  664 #if CONFIG_AUDIT
  665         bsd_init_kprintf("calling audit_init\n");
  666         audit_init();  
  667 #endif
  668 
  669         /* Initialize kqueues */
  670         bsd_init_kprintf("calling knote_init\n");
  671         knote_init();
  672 
  673 #if CONFIG_EMBEDDED
  674         /* Initialize kernel memory status notifications */
  675         bsd_init_kprintf("calling kern_memorystatus_init\n");
  676         kern_memorystatus_init();
  677 #endif
  678 
  679         /* Initialize for async IO */
  680         bsd_init_kprintf("calling aio_init\n");
  681         aio_init();
  682 
  683         /* Initialize pipes */
  684         bsd_init_kprintf("calling pipeinit\n");
  685         pipeinit();
  686 
  687         /* Initialize SysV shm subsystem locks; the subsystem proper is
  688          * initialized through a sysctl.
  689          */
  690 #if SYSV_SHM
  691         bsd_init_kprintf("calling sysv_shm_lock_init\n");
  692         sysv_shm_lock_init();
  693 #endif
  694 #if SYSV_SEM
  695         bsd_init_kprintf("calling sysv_sem_lock_init\n");
  696         sysv_sem_lock_init();
  697 #endif
  698 #if SYSV_MSG
  699         bsd_init_kprintf("sysv_msg_lock_init\n");
  700         sysv_msg_lock_init();
  701 #endif
  702         bsd_init_kprintf("calling pshm_lock_init\n");
  703         pshm_lock_init();
  704         bsd_init_kprintf("calling psem_lock_init\n");
  705         psem_lock_init();
  706 
  707         pthread_init();
  708         /* POSIX Shm and Sem */
  709         bsd_init_kprintf("calling pshm_cache_init\n");
  710         pshm_cache_init();
  711         bsd_init_kprintf("calling psem_cache_init\n");
  712         psem_cache_init();
  713         bsd_init_kprintf("calling time_zone_slock_init\n");
  714         time_zone_slock_init();
  715 
  716         /* Stack snapshot facility lock */
  717         stackshot_lock_init();
  718         /*
  719          * Initialize protocols.  Block reception of incoming packets
  720          * until everything is ready.
  721          */
  722         bsd_init_kprintf("calling sysctl_register_fixed\n");
  723         sysctl_register_fixed(); 
  724         bsd_init_kprintf("calling sysctl_mib_init\n");
  725         sysctl_mib_init();
  726 #if NETWORKING
  727         bsd_init_kprintf("calling dlil_init\n");
  728         dlil_init();
  729         bsd_init_kprintf("calling proto_kpi_init\n");
  730         proto_kpi_init();
  731 #endif /* NETWORKING */
  732 #if SOCKETS
  733         bsd_init_kprintf("calling socketinit\n");
  734         socketinit();
  735         bsd_init_kprintf("calling domaininit\n");
  736         domaininit();
  737 #endif /* SOCKETS */
  738 
  739         kernproc->p_fd->fd_cdir = NULL;
  740         kernproc->p_fd->fd_rdir = NULL;
  741 
  742 #ifdef GPROF
  743         /* Initialize kernel profiling. */
  744         kmstartup();
  745 #endif
  746 
  747         /* kick off timeout driven events by calling first time */
  748         thread_wakeup(&lbolt);
  749         timeout(lightning_bolt, 0, hz);
  750 
  751         bsd_init_kprintf("calling bsd_autoconf\n");
  752         bsd_autoconf();
  753 
  754 #if CONFIG_DTRACE
  755         dtrace_postinit();
  756 #endif
  757 
  758         /*
  759          * We attach the loopback interface *way* down here to ensure
  760          * it happens after autoconf(), otherwise it becomes the
  761          * "primary" interface.
  762          */
  763 #include <loop.h>
  764 #if NLOOP > 0
  765         bsd_init_kprintf("calling loopattach\n");
  766         loopattach();                   /* XXX */
  767 #endif
  768 
  769 #if PFLOG
  770         /* Initialize packet filter log interface */
  771         pfloginit();
  772 #endif /* PFLOG */
  773 
  774 #if NETHER > 0
  775         /* Register the built-in dlil ethernet interface family */
  776         bsd_init_kprintf("calling ether_family_init\n");
  777         ether_family_init();
  778 #endif /* ETHER */
  779 
  780 #if NETWORKING
  781         /* Call any kext code that wants to run just after network init */
  782         bsd_init_kprintf("calling net_init_run\n");
  783         net_init_run();
  784         
  785         /* register user tunnel kernel control handler */
  786         utun_register_control();
  787 #endif /* NETWORKING */
  788 
  789         bsd_init_kprintf("calling vnode_pager_bootstrap\n");
  790         vnode_pager_bootstrap();
  791 #if 0
  792         /* XXX Hack for early debug stop */
  793         printf("\nabout to sleep for 10 seconds\n");
  794         IOSleep( 10 * 1000 );
  795         /* Debugger("hello"); */
  796 #endif
  797 
  798         bsd_init_kprintf("calling inittodr\n");
  799         inittodr(0);
  800 
  801 #if CONFIG_EMBEDDED
  802         {
  803                 /* print out early VM statistics */
  804                 kern_return_t kr1;
  805                 vm_statistics_data_t stat;
  806                 mach_msg_type_number_t count;
  807 
  808                 count = HOST_VM_INFO_COUNT;
  809                 kr1 = host_statistics(host_self(),
  810                                       HOST_VM_INFO,
  811                                       (host_info_t)&stat,
  812                                       &count);
  813                 kprintf("Mach Virtual Memory Statistics (page size of 4096) bytes\n"
  814                         "Pages free:\t\t\t%u.\n"
  815                         "Pages active:\t\t\t%u.\n"
  816                         "Pages inactive:\t\t\t%u.\n"
  817                         "Pages wired down:\t\t%u.\n"
  818                         "\"Translation faults\":\t\t%u.\n"
  819                         "Pages copy-on-write:\t\t%u.\n"
  820                         "Pages zero filled:\t\t%u.\n"
  821                         "Pages reactivated:\t\t%u.\n"
  822                         "Pageins:\t\t\t%u.\n"
  823                         "Pageouts:\t\t\t%u.\n"
  824                         "Object cache: %u hits of %u lookups (%d%% hit rate)\n",
  825 
  826                         stat.free_count,
  827                         stat.active_count,
  828                         stat.inactive_count,
  829                         stat.wire_count,
  830                         stat.faults,
  831                         stat.cow_faults,
  832                         stat.zero_fill_count,
  833                         stat.reactivations,
  834                         stat.pageins,
  835                         stat.pageouts,
  836                         stat.hits,
  837                         stat.lookups,
  838                         (stat.hits == 0) ? 100 :
  839                                            ((stat.lookups * 100) / stat.hits));
  840         }
  841 #endif /* CONFIG_EMBEDDED */
  842         
  843         /* Mount the root file system. */
  844         while( TRUE) {
  845                 int err;
  846 
  847                 bsd_init_kprintf("calling setconf\n");
  848                 setconf();
  849 
  850                 bsd_init_kprintf("vfs_mountroot\n");
  851                 if (0 == (err = vfs_mountroot()))
  852                         break;
  853                 rootdevice[0] = '\0';
  854 #if NFSCLIENT
  855                 if (mountroot == netboot_mountroot) {
  856                         PE_display_icon( 0, "noroot");  /* XXX a netboot-specific icon would be nicer */
  857                         vc_progress_set(FALSE, 0);
  858                         for (i=1; 1; i*=2) {
  859                                 printf("bsd_init: failed to mount network root, error %d, %s\n",
  860                                         err, PE_boot_args());
  861                                 printf("We are hanging here...\n");
  862                                 IOSleep(i*60*1000);
  863                         }
  864                         /*NOTREACHED*/
  865                 }
  866 #endif
  867                 printf("cannot mount root, errno = %d\n", err);
  868                 boothowto |= RB_ASKNAME;
  869         }
  870 
  871         IOSecureBSDRoot(rootdevice);
  872 
  873         context.vc_thread = current_thread();
  874         context.vc_ucred = kernproc->p_ucred;
  875         mountlist.tqh_first->mnt_flag |= MNT_ROOTFS;
  876 
  877         bsd_init_kprintf("calling VFS_ROOT\n");
  878         /* Get the vnode for '/'.  Set fdp->fd_fd.fd_cdir to reference it. */
  879         if (VFS_ROOT(mountlist.tqh_first, &rootvnode, &context))
  880                 panic("bsd_init: cannot find root vnode: %s", PE_boot_args());
  881         rootvnode->v_flag |= VROOT;
  882         (void)vnode_ref(rootvnode);
  883         (void)vnode_put(rootvnode);
  884         filedesc0.fd_cdir = rootvnode;
  885 
  886 #if NFSCLIENT
  887         if (mountroot == netboot_mountroot) {
  888                 int err;
  889                 /* post mount setup */
  890                 if ((err = netboot_setup()) != 0) {
  891                         PE_display_icon( 0, "noroot");  /* XXX a netboot-specific icon would be nicer */
  892                         vc_progress_set(FALSE, 0);
  893                         for (i=1; 1; i*=2) {
  894                                 printf("bsd_init: NetBoot could not find root, error %d: %s\n",
  895                                         err, PE_boot_args());
  896                                 printf("We are hanging here...\n");
  897                                 IOSleep(i*60*1000);
  898                         }
  899                         /*NOTREACHED*/
  900                 }
  901         }
  902 #endif
  903         
  904 
  905 #if CONFIG_IMAGEBOOT
  906         /*
  907          * See if a system disk image is present. If so, mount it and
  908          * switch the root vnode to point to it
  909          */ 
  910   
  911         if(imageboot_needed()) {
  912                 int err;
  913 
  914                 /* An image was found */
  915                 if((err = imageboot_setup())) {
  916                         /*
  917                          * this is not fatal. Keep trying to root
  918                          * off the original media
  919                          */
  920                         printf("%s: imageboot could not find root, %d\n",
  921                                 __FUNCTION__, err);
  922                 }
  923         }
  924 #endif /* CONFIG_IMAGEBOOT */
  925   
  926         /* set initial time; all other resource data is  already zero'ed */
  927         microtime(&kernproc->p_start);
  928         kernproc->p_stats->p_start = kernproc->p_start; /* for compat */
  929 
  930 #if DEVFS
  931         {
  932             char mounthere[] = "/dev";  /* !const because of internal casting */
  933 
  934             bsd_init_kprintf("calling devfs_kernel_mount\n");
  935             devfs_kernel_mount(mounthere);
  936         }
  937 #endif /* DEVFS */
  938         
  939         /* Initialize signal state for process 0. */
  940         bsd_init_kprintf("calling siginit\n");
  941         siginit(kernproc);
  942 
  943         bsd_init_kprintf("calling bsd_utaskbootstrap\n");
  944         bsd_utaskbootstrap();
  945 
  946 #if defined(__LP64__)
  947         kernproc->p_flag |= P_LP64;
  948         printf("Kernel is LP64\n");
  949 #endif
  950 #if __i386__ || __x86_64__
  951         /* this should be done after the root filesystem is mounted */
  952         error = set_archhandler(kernproc, CPU_TYPE_POWERPC);
  953         // 10/30/08 - gab: <rdar://problem/6324501>
  954         // if default 'translate' can't be found, see if the understudy is available
  955         if (ENOENT == error) {
  956                 strlcpy(exec_archhandler_ppc.path, kRosettaStandIn_str, MAXPATHLEN);
  957                 error = set_archhandler(kernproc, CPU_TYPE_POWERPC);
  958         }
  959         if (error) /* XXX make more generic */
  960                 exec_archhandler_ppc.path[0] = 0;
  961 #endif  
  962 
  963         bsd_init_kprintf("calling mountroot_post_hook\n");
  964 
  965         /* invoke post-root-mount hook */
  966         if (mountroot_post_hook != NULL)
  967                 mountroot_post_hook();
  968 
  969 #if 0 /* not yet */
  970         consider_zone_gc(FALSE);
  971 #endif
  972 
  973 #if CONFIG_EMBEDDED
  974         /*
  975          * XXX workaround for:
  976          * <rdar://problem/6378731> Kirkwood7A135: PPP KEXT no longer loads
  977          */
  978         OSKextLoadKextWithIdentifier("com.apple.nke.ppp");
  979         OSKextLoadKextWithIdentifier("com.apple.nke.l2tp");
  980         OSKextLoadKextWithIdentifier("com.apple.nke.pptp");
  981 #endif
  982 
  983         bsd_init_kprintf("done\n");
  984 }
  985 
  986 /* Called with kernel funnel held */
  987 void
  988 bsdinit_task(void)
  989 {
  990         proc_t p = current_proc();
  991         struct uthread *ut;
  992         thread_t thread;
  993 
  994         process_name("init", p);
  995 
  996         ux_handler_init();
  997 
  998         thread = current_thread();
  999         (void) host_set_exception_ports(host_priv_self(),
 1000                                         EXC_MASK_ALL & ~(EXC_MASK_RPC_ALERT),//pilotfish (shark) needs this port
 1001                                         (mach_port_t) ux_exception_port,
 1002                                         EXCEPTION_DEFAULT| MACH_EXCEPTION_CODES,
 1003                                         0);
 1004 
 1005         ut = (uthread_t)get_bsdthread_info(thread);
 1006 
 1007         bsd_init_task = get_threadtask(thread);
 1008         init_task_failure_data[0] = 0;
 1009 
 1010 #if CONFIG_MACF
 1011         mac_cred_label_associate_user(p->p_ucred);
 1012         mac_task_label_update_cred (p->p_ucred, (struct task *) p->task);
 1013 #endif
 1014         load_init_program(p);
 1015         lock_trace = 1;
 1016 }
 1017 
 1018 void
 1019 lightning_bolt(__unused void *dummy)
 1020 {                       
 1021         boolean_t       funnel_state;
 1022 
 1023         funnel_state = thread_funnel_set(kernel_flock, TRUE);
 1024 
 1025         thread_wakeup(&lbolt);
 1026         timeout(lightning_bolt,0,hz);
 1027         klogwakeup();
 1028 
 1029         (void) thread_funnel_set(kernel_flock, FALSE);
 1030 }
 1031 
 1032 kern_return_t
 1033 bsd_autoconf(void)
 1034 {
 1035         kprintf("bsd_autoconf: calling kminit\n");
 1036         kminit();
 1037 
 1038         /* 
 1039          * Early startup for bsd pseudodevices.
 1040          */
 1041         {
 1042             struct pseudo_init *pi;
 1043         
 1044             for (pi = pseudo_inits; pi->ps_func; pi++)
 1045                 (*pi->ps_func) (pi->ps_count);
 1046         }
 1047 
 1048         return( IOKitBSDInit());
 1049 }
 1050 
 1051 
 1052 #include <sys/disklabel.h>  /* for MAXPARTITIONS */
 1053 
 1054 static void
 1055 setconf(void)
 1056 {       
 1057         u_int32_t       flags;
 1058         kern_return_t   err;
 1059 
 1060         /*
 1061          * calls into IOKit can generate networking registrations
 1062          * which needs to be under network funnel. Right thing to do
 1063          * here is to drop the funnel alltogether and regrab it afterwards
 1064          */
 1065         err = IOFindBSDRoot(rootdevice, sizeof(rootdevice), &rootdev, &flags);
 1066         if( err) {
 1067                 printf("setconf: IOFindBSDRoot returned an error (%d);"
 1068                         "setting rootdevice to 'sd0a'.\n", err); /* XXX DEBUG TEMP */
 1069                 rootdev = makedev( 6, 0 );
 1070                 strlcpy(rootdevice, "sd0a", sizeof(rootdevice));
 1071                 flags = 0;
 1072         }
 1073 
 1074 #if NFSCLIENT
 1075         if( flags & 1 ) {
 1076                 /* network device */
 1077                 mountroot = netboot_mountroot;
 1078         } else {
 1079 #endif
 1080                 /* otherwise have vfs determine root filesystem */
 1081                 mountroot = NULL;
 1082 #if NFSCLIENT
 1083         }
 1084 #endif
 1085 
 1086 }
 1087 
 1088 void
 1089 bsd_utaskbootstrap(void)
 1090 {
 1091         thread_t thread;
 1092         struct uthread *ut;
 1093 
 1094         /*
 1095          * Clone the bootstrap process from the kernel process, without
 1096          * inheriting either task characteristics or memory from the kernel;
 1097          */
 1098         thread = cloneproc(TASK_NULL, kernproc, FALSE);
 1099 
 1100         /* Hold the reference as it will be dropped during shutdown */
 1101         initproc = proc_find(1);                                
 1102 #if __PROC_INTERNAL_DEBUG
 1103         if (initproc == PROC_NULL)
 1104                 panic("bsd_utaskbootstrap: initproc not set\n");
 1105 #endif
 1106         /*
 1107          * Since we aren't going back out the normal way to our parent,
 1108          * we have to drop the transition locks explicitly.
 1109          */
 1110         proc_signalend(initproc, 0);
 1111         proc_transend(initproc, 0);
 1112 
 1113         ut = (struct uthread *)get_bsdthread_info(thread);
 1114         ut->uu_sigmask = 0;
 1115         act_set_astbsd(thread);
 1116         (void) thread_resume(thread);
 1117 }
 1118 
 1119 static void
 1120 parse_bsd_args(void)
 1121 {
 1122         char namep[16];
 1123         int msgbuf;
 1124 
 1125         if (PE_parse_boot_argn("-s", namep, sizeof (namep)))
 1126                 boothowto |= RB_SINGLE;
 1127 
 1128         if (PE_parse_boot_argn("-b", namep, sizeof (namep)))
 1129                 boothowto |= RB_NOBOOTRC;
 1130 
 1131         if (PE_parse_boot_argn("-x", namep, sizeof (namep))) /* safe boot */
 1132                 boothowto |= RB_SAFEBOOT;
 1133 
 1134         if (PE_parse_boot_argn("-l", namep, sizeof (namep))) /* leaks logging */
 1135                 turn_on_log_leaks = 1;
 1136 
 1137         /* disable 64 bit grading */
 1138         if (PE_parse_boot_argn("-no64exec", namep, sizeof (namep)))
 1139                 bootarg_no64exec = 1;
 1140 
 1141         PE_parse_boot_argn("ncl", &ncl, sizeof (ncl));
 1142         if (PE_parse_boot_argn("nbuf", &max_nbuf_headers,
 1143                                 sizeof (max_nbuf_headers))) {
 1144                 customnbuf = 1;
 1145         }
 1146 #if !defined(SECURE_KERNEL)
 1147         PE_parse_boot_argn("kmem", &setup_kmem, sizeof (setup_kmem));
 1148 #endif
 1149         PE_parse_boot_argn("trace", &new_nkdbufs, sizeof (new_nkdbufs));
 1150 
 1151         if (PE_parse_boot_argn("msgbuf", &msgbuf, sizeof (msgbuf))) {
 1152                 log_setsize(msgbuf);
 1153         }
 1154 }
 1155 
 1156 void
 1157 bsd_exec_setup(int scale)
 1158 {
 1159 
 1160         switch (scale) {
 1161                 case 0:
 1162                 case 1:
 1163                         bsd_simul_execs = BSD_SIMUL_EXECS;
 1164                         break;
 1165                 case 2:
 1166                 case 3:
 1167                         bsd_simul_execs = 65;
 1168                         break;
 1169                 case 4:
 1170                 case 5:
 1171                         bsd_simul_execs = 129;
 1172                         break;
 1173                 case 6:
 1174                 case 7:
 1175                         bsd_simul_execs = 257;
 1176                         break;
 1177                 default:
 1178                         bsd_simul_execs = 513;
 1179                         break;
 1180                         
 1181         }
 1182         bsd_pageable_map_size = (bsd_simul_execs * (NCARGS + PAGE_SIZE));
 1183 }
 1184 
 1185 #if !NFSCLIENT
 1186 int 
 1187 netboot_root(void)
 1188 {
 1189         return(0);
 1190 }
 1191 #endif

Cache object: fa1d16138cc5fe6159c4361983ee9500


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.