Annotation of src/sys/kern/init_main.c, Revision 1.512
1.512 ! ad 1: /* $NetBSD: init_main.c,v 1.511 2019/12/21 13:00:24 ad Exp $ */
1.347 ad 2:
3: /*-
1.507 ad 4: * Copyright (c) 2008, 2009, 2019 The NetBSD Foundation, Inc.
1.347 ad 5: * All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: *
16: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26: * POSSIBILITY OF SUCH DAMAGE.
27: */
1.61 mycroft 28:
29: /*
30: * Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
31: * The Regents of the University of California. All rights reserved.
32: * (c) UNIX System Laboratories, Inc.
33: * All or some portions of this file are derived from material licensed
34: * to the University of California by American Telephone and Telegraph
35: * Co. or Unix System Laboratories, Inc. and are reproduced herein with
36: * the permission of UNIX System Laboratories, Inc.
37: *
38: * Redistribution and use in source and binary forms, with or without
39: * modification, are permitted provided that the following conditions
40: * are met:
41: * 1. Redistributions of source code must retain the above copyright
42: * notice, this list of conditions and the following disclaimer.
43: * 2. Redistributions in binary form must reproduce the above copyright
44: * notice, this list of conditions and the following disclaimer in the
45: * documentation and/or other materials provided with the distribution.
1.224 agc 46: * 3. Neither the name of the University nor the names of its contributors
47: * may be used to endorse or promote products derived from this software
48: * without specific prior written permission.
49: *
50: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60: * SUCH DAMAGE.
61: *
62: * @(#)init_main.c 8.16 (Berkeley) 5/14/95
63: */
64:
65: /*
66: * Copyright (c) 1995 Christopher G. Demetriou. All rights reserved.
67: *
68: * Redistribution and use in source and binary forms, with or without
69: * modification, are permitted provided that the following conditions
70: * are met:
71: * 1. Redistributions of source code must retain the above copyright
72: * notice, this list of conditions and the following disclaimer.
73: * 2. Redistributions in binary form must reproduce the above copyright
74: * notice, this list of conditions and the following disclaimer in the
75: * documentation and/or other materials provided with the distribution.
1.61 mycroft 76: * 3. All advertising materials mentioning features or use of this software
77: * must display the following acknowledgement:
78: * This product includes software developed by the University of
79: * California, Berkeley and its contributors.
80: * 4. Neither the name of the University nor the names of its contributors
81: * may be used to endorse or promote products derived from this software
82: * without specific prior written permission.
83: *
84: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
85: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
87: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
88: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
94: * SUCH DAMAGE.
95: *
1.118 fvdl 96: * @(#)init_main.c 8.16 (Berkeley) 5/14/95
1.61 mycroft 97: */
1.196 lukem 98:
99: #include <sys/cdefs.h>
1.512 ! ad 100: __KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.511 2019/12/21 13:00:24 ad Exp $");
1.115 mrg 101:
1.370 tsutsui 102: #include "opt_ddb.h"
1.475 ozaki-r 103: #include "opt_inet.h"
1.223 jonathan 104: #include "opt_ipsec.h"
1.382 apb 105: #include "opt_modular.h"
1.267 kardel 106: #include "opt_ntp.h"
1.198 jdolecek 107: #include "opt_pipe.h"
1.172 soren 108: #include "opt_syscall_debug.h"
1.267 kardel 109: #include "opt_sysv.h"
1.292 ad 110: #include "opt_fileassoc.h"
111: #include "opt_ktrace.h"
1.281 elad 112: #include "opt_pax.h"
1.380 christos 113: #include "opt_compat_netbsd.h"
1.361 simonb 114: #include "opt_wapbl.h"
1.404 elad 115: #include "opt_ptrace.h"
1.458 tls 116: #include "opt_rnd_printf.h"
1.465 nat 117: #include "opt_splash.h"
1.489 pgoyette 118: #include "opt_kernhist.h"
1.495 maxv 119: #include "opt_gprof.h"
1.465 nat 120:
1.470 uebayasi 121: #if defined(SPLASHSCREEN) && defined(makeoptions_SPLASHSCREEN_IMAGE)
1.465 nat 122: extern void *_binary_splash_image_start;
123: extern void *_binary_splash_image_end;
124: #endif
1.61 mycroft 125:
1.377 he 126: #include "ksyms.h"
1.441 tls 127:
1.276 dogcow 128: #include "veriexec.h"
1.106 explorer 129:
1.61 mycroft 130: #include <sys/param.h>
1.164 enami 131: #include <sys/acct.h>
1.61 mycroft 132: #include <sys/filedesc.h>
1.131 thorpej 133: #include <sys/file.h>
1.61 mycroft 134: #include <sys/errno.h>
1.162 thorpej 135: #include <sys/callout.h>
1.302 yamt 136: #include <sys/cpu.h>
1.436 jruoho 137: #include <sys/cpufreq.h>
1.408 dyoung 138: #include <sys/spldebug.h>
1.61 mycroft 139: #include <sys/kernel.h>
140: #include <sys/mount.h>
141: #include <sys/proc.h>
1.136 thorpej 142: #include <sys/kthread.h>
1.61 mycroft 143: #include <sys/resourcevar.h>
144: #include <sys/signalvar.h>
145: #include <sys/systm.h>
146: #include <sys/vnode.h>
1.288 hannken 147: #include <sys/fstrans.h>
1.87 thorpej 148: #include <sys/tty.h>
1.61 mycroft 149: #include <sys/conf.h>
1.95 thorpej 150: #include <sys/disklabel.h>
1.61 mycroft 151: #include <sys/buf.h>
152: #include <sys/device.h>
1.186 jdolecek 153: #include <sys/exec.h>
1.128 thorpej 154: #include <sys/socketvar.h>
1.61 mycroft 155: #include <sys/protosw.h>
1.338 yamt 156: #include <sys/percpu.h>
1.434 christos 157: #include <sys/pserialize.h>
1.342 rmind 158: #include <sys/pset.h>
1.338 yamt 159: #include <sys/sysctl.h>
1.61 mycroft 160: #include <sys/reboot.h>
1.209 jdolecek 161: #include <sys/event.h>
1.227 jonathan 162: #include <sys/mbuf.h>
1.302 yamt 163: #include <sys/sched.h>
1.292 ad 164: #include <sys/sleepq.h>
1.455 rmind 165: #include <sys/ipi.h>
1.284 ad 166: #include <sys/iostat.h>
1.304 yamt 167: #include <sys/vmem.h>
1.307 ad 168: #include <sys/uuid.h>
169: #include <sys/extent.h>
1.309 ad 170: #include <sys/disk.h>
1.325 ad 171: #include <sys/msgbuf.h>
1.340 ad 172: #include <sys/module.h>
1.509 pgoyette 173: #include <sys/module_hook.h>
1.343 ad 174: #include <sys/event.h>
1.357 ad 175: #include <sys/lockf.h>
1.364 pooka 176: #include <sys/once.h>
1.435 rmind 177: #include <sys/kcpuset.h>
1.367 ad 178: #include <sys/ksyms.h>
1.365 pooka 179: #include <sys/uidinfo.h>
1.379 pooka 180: #include <sys/kprintf.h>
1.485 pgoyette 181: #include <sys/bufq.h>
1.501 thorpej 182: #include <sys/threadpool.h>
1.449 christos 183: #ifdef IPSEC
1.223 jonathan 184: #include <netipsec/ipsec.h>
185: #endif
1.82 christos 186: #include <sys/domain.h>
1.94 mouse 187: #include <sys/namei.h>
1.103 explorer 188: #include <sys/rnd.h>
1.192 jdolecek 189: #include <sys/pipe.h>
1.273 elad 190: #if NVERIEXEC > 0
1.245 blymn 191: #include <sys/verified_exec.h>
1.273 elad 192: #endif /* NVERIEXEC > 0 */
1.292 ad 193: #ifdef KTRACE
194: #include <sys/ktrace.h>
195: #endif
1.266 elad 196: #include <sys/kauth.h>
1.252 skrll 197: #include <net80211/ieee80211_netbsd.h>
1.437 tls 198: #include <sys/cprng.h>
1.504 ozaki-r 199: #include <sys/psref.h>
1.510 ad 200: #include <sys/radixtree.h>
1.61 mycroft 201:
1.77 christos 202: #include <sys/syscall.h>
1.68 cgd 203: #include <sys/syscallargs.h>
204:
1.281 elad 205: #include <sys/pax.h>
1.334 elad 206:
1.438 jym 207: #include <secmodel/secmodel.h>
208:
1.61 mycroft 209: #include <ufs/ufs/quota.h>
210:
1.159 fvdl 211: #include <miscfs/genfs/genfs.h>
1.410 elad 212: #include <miscfs/specfs/specdev.h>
1.159 fvdl 213:
1.323 ad 214: #include <sys/cpu.h>
1.61 mycroft 215:
1.425 uebayasi 216: #include <uvm/uvm.h> /* extern struct uvm uvm */
1.114 mrg 217:
1.202 lukem 218: #include <dev/cons.h>
1.465 nat 219: #include <dev/splash/splash.h>
1.310 xtraeme 220:
1.414 pooka 221: #include <net/bpf.h>
1.81 christos 222: #include <net/if.h>
1.490 ryo 223: #include <net/pfil.h>
1.81 christos 224: #include <net/raw_cb.h>
1.468 ozaki-r 225: #include <net/if_llatbl.h>
1.61 mycroft 226:
1.399 pooka 227: #include <prop/proplib.h>
228:
1.398 pooka 229: #include <sys/userconf.h>
230:
1.251 junyoung 231: extern struct lwp lwp0;
1.311 pooka 232: extern time_t rootfstime;
1.251 junyoung 233:
1.216 thorpej 234: #ifndef curlwp
235: struct lwp *curlwp = &lwp0;
1.133 pk 236: #endif
1.105 mycroft 237: struct proc *initproc;
1.61 mycroft 238:
239: struct vnode *rootvp, *swapdev_vp;
240: int boothowto;
1.494 msaitoh 241: int cold __read_mostly = 1; /* still working on startup */
1.380 christos 242: struct timespec boottime; /* time at system startup - will only follow settime deltas */
1.61 mycroft 243:
1.356 ad 244: int start_init_exec; /* semaphore for start_init() */
1.163 thorpej 245:
1.437 tls 246: cprng_strong_t *kern_cprng;
247:
1.260 christos 248: static void check_console(struct lwp *l);
1.176 thorpej 249: static void start_init(void *);
1.398 pooka 250: static void configure(void);
251: static void configure2(void);
1.421 tsutsui 252: static void configure3(void);
1.176 thorpej 253: void main(void);
1.280 christos 254:
1.61 mycroft 255: /*
256: * System startup; initialize the world, create process 0, mount root
257: * filesystem, and fork to create init and pagedaemon. Most of the
258: * hard work is done in the lower-level initialization routines including
259: * startup(), which does memory initialization and autoconfiguration.
260: */
1.81 christos 261: void
1.176 thorpej 262: main(void)
1.61 mycroft 263: {
1.380 christos 264: struct timespec time;
1.216 thorpej 265: struct lwp *l;
1.144 thorpej 266: struct proc *p;
1.204 thorpej 267: int s, error;
1.175 jdolecek 268: #ifdef NVNODE_IMPLICIT
269: int usevnodes;
270: #endif
1.312 ad 271: CPU_INFO_ITERATOR cii;
272: struct cpu_info *ci;
1.61 mycroft 273:
1.493 chs 274: #ifdef DIAGNOSTIC
275: /*
276: * Verify that CPU_INFO_FOREACH() knows about the boot CPU
277: * and only the boot CPU at this point.
278: */
279: int cpucount = 0;
280: for (CPU_INFO_FOREACH(cii, ci)) {
281: KASSERT(ci == curcpu());
282: cpucount++;
283: }
284: KASSERT(cpucount == 1);
285: #endif
286:
1.216 thorpej 287: l = &lwp0;
1.327 matt 288: #ifndef LWP0_CPU_INFO
1.216 thorpej 289: l->l_cpu = curcpu();
1.327 matt 290: #endif
1.394 yamt 291: l->l_pflag |= LP_RUNNING;
1.233 junyoung 292:
1.317 ad 293: /*
1.61 mycroft 294: * Attempt to find console and initialize
295: * in case of early panic or other messages.
296: */
297: consinit();
298:
1.321 ad 299: kernel_lock_init();
1.364 pooka 300: once_init();
1.434 christos 301:
1.440 rmind 302: mi_cpu_init();
1.423 pgoyette 303: kernconfig_lock_init();
1.429 rmind 304: kthread_sysinit();
1.179 thorpej 305:
1.397 pooka 306: /* Initialize the device switch tables. */
307: devsw_init();
308:
1.432 rmind 309: /* Initialize event counters. */
310: evcnt_init();
311:
1.114 mrg 312: uvm_init();
1.457 riastrad 313: ubchist_init();
1.435 rmind 314: kcpuset_sysinit();
1.127 thorpej 315:
1.399 pooka 316: prop_kern_init();
317:
1.377 he 318: #if ((NKSYMS > 0) || (NDDB > 0) || (NMODULAR > 0))
1.376 martin 319: ksyms_init();
1.377 he 320: #endif
1.379 pooka 321: kprintf_init();
1.376 martin 322:
1.338 yamt 323: percpu_init();
324:
1.347 ad 325: /* Initialize lock caches. */
326: mutex_obj_init();
1.389 ad 327: rw_obj_init();
1.347 ad 328:
1.434 christos 329: /* Passive serialization. */
330: pserialize_init();
331:
1.307 ad 332: /* Initialize the extent manager. */
333: extent_init();
334:
1.145 thorpej 335: /* Do machine-dependent initialization. */
336: cpu_startup();
1.162 thorpej 337:
1.378 pooka 338: /* Initialize the sysctl subsystem. */
339: sysctl_init();
340:
1.307 ad 341: /* Initialize callouts, part 1. */
1.166 enami 342: callout_startup();
1.145 thorpej 343:
1.409 elad 344: /* Initialize the kernel authorization subsystem. */
345: kauth_init();
346:
1.438 jym 347: secmodel_init();
348:
1.409 elad 349: spec_init();
350:
1.414 pooka 351: /*
352: * Set BPF op vector. Can't do this in bpf attach, since
353: * network drivers attach before bpf.
354: */
355: bpf_setops();
356:
1.403 elad 357: /* Start module system. */
1.417 pooka 358: module_init();
1.509 pgoyette 359: module_hook_init();
1.403 elad 360:
1.291 elad 361: /*
362: * Initialize the kernel authorization subsystem and start the
363: * default security model, if any. We need to do this early
364: * enough so that subsystems relying on any of the aforementioned
365: * can work properly. Since the security model may dictate the
366: * credential inheritance policy, it is needed at least before
367: * any process is created, specifically proc0.
368: */
1.403 elad 369: module_init_class(MODULE_CLASS_SECMODEL);
1.290 elad 370:
1.228 pk 371: /* Initialize the buffer cache */
372: bufinit();
1.488 pgoyette 373: biohist_init();
1.228 pk 374:
1.489 pgoyette 375: #ifdef KERNHIST
376: sysctl_kernhist_init();
377: #endif
378:
1.465 nat 379:
380: #if defined(SPLASHSCREEN) && defined(SPLASHSCREEN_IMAGE)
381: size_t splash_size = (&_binary_splash_image_end -
382: &_binary_splash_image_start) * sizeof(void *);
383: splash_setimage(&_binary_splash_image_start, splash_size);
384: #endif
385:
1.128 thorpej 386: /* Initialize sockets. */
387: soinit();
1.127 thorpej 388:
1.156 thorpej 389: /*
1.212 thorpej 390: * The following things must be done before autoconfiguration.
1.156 thorpej 391: */
1.437 tls 392: rnd_init(); /* initialize entropy pool */
393:
394: cprng_init(); /* initialize cryptographic PRNG */
1.176 thorpej 395:
1.236 simonb 396: /* Initialize process and pgrp structures. */
1.63 mycroft 397: procinit();
1.279 thorpej 398: lwpinit();
1.210 thorpej 399:
1.504 ozaki-r 400: /* Must be called after lwpinit (lwpinit_specificdata) */
401: psref_init();
402:
1.251 junyoung 403: /* Initialize signal-related data structures. */
404: signal_init();
1.61 mycroft 405:
1.333 ad 406: /* Initialize resource management. */
407: resource_init();
408:
1.407 rmind 409: /* Create process 0. */
1.251 junyoung 410: proc0_init();
1.420 pooka 411: lwp0_init();
1.61 mycroft 412:
1.383 yamt 413: /* Disable preemption during boot. */
414: kpreempt_disable();
415:
1.501 thorpej 416: /* Initialize the threadpool system. */
417: threadpools_init();
418:
1.307 ad 419: /* Initialize the UID hash table. */
420: uid_init();
421:
422: /* Charge root for one process. */
1.61 mycroft 423: (void)chgproccnt(0, 1);
424:
1.330 ad 425: /* Initialize timekeeping. */
426: time_init();
427:
1.292 ad 428: /* Initialize the run queues, turnstiles and sleep queues. */
1.302 yamt 429: sched_rqinit();
1.292 ad 430: turnstile_init();
431: sleeptab_init(&sleeptab);
432:
1.405 elad 433: sched_init();
434:
1.339 rmind 435: /* Initialize processor-sets */
436: psets_init();
437:
1.436 jruoho 438: /* Initialize cpufreq(9) */
439: cpufreq_init();
440:
1.302 yamt 441: /* MI initialization of the boot cpu */
442: error = mi_cpu_attach(curcpu());
443: KASSERT(error == 0);
444:
1.350 ad 445: /* Initialize timekeeping, part 2. */
446: time_init2();
447:
1.338 yamt 448: /*
449: * Initialize mbuf's. Do this now because we might attempt to
450: * allocate mbufs or mbuf clusters during autoconfiguration.
451: */
452: mbinit();
453:
1.284 ad 454: /* Initialize I/O statistics. */
455: iostat_init();
456:
1.325 ad 457: /* Initialize the log device. */
458: loginit();
459:
1.403 elad 460: /* Second part of module system initialization. */
1.422 pgoyette 461: module_start_unload_thread();
1.355 ad 462:
1.61 mycroft 463: /* Initialize the file systems. */
1.194 matt 464: #ifdef NVNODE_IMPLICIT
465: /*
466: * If maximum number of vnodes in namei vnode cache is not explicitly
467: * defined in kernel config, adjust the number such as we use roughly
1.359 ad 468: * 10% of memory for vnodes and associated data structures in the
469: * assumed worst case. Do not provide fewer than NVNODE vnodes.
1.194 matt 470: */
1.448 para 471: usevnodes = calc_cache_size(vmem_size(kmem_arena, VMEM_FREE|VMEM_ALLOC),
472: 10, VNODE_KMEM_MAXPCT) / VNODE_COST;
1.205 sommerfe 473: if (usevnodes > desiredvnodes)
1.194 matt 474: desiredvnodes = usevnodes;
475: #endif
1.61 mycroft 476:
1.288 hannken 477: /* Initialize fstrans. */
478: fstrans_init();
1.267 kardel 479:
1.510 ad 480: radix_tree_init(); /* used for page cache */
1.503 hannken 481: vfsinit();
482: lf_init();
483:
1.319 ad 484: /* Initialize the file descriptor system. */
1.343 ad 485: fd_sys_init();
1.319 ad 486:
1.375 pooka 487: /* Initialize cwd structures */
488: cwd_sys_init();
489:
1.344 ad 490: /* Initialize kqueue. */
1.343 ad 491: kqueue_init();
1.307 ad 492:
1.268 kardel 493: inittimecounter();
1.267 kardel 494: ntp_init();
495:
1.326 ad 496: /* Initialize tty subsystem. */
497: tty_init();
498: ttyldisc_init();
499:
1.336 ad 500: /* Initialize the buffer cache, part 2. */
501: bufinit2();
502:
1.309 ad 503: /* Initialize the disk wedge subsystem. */
504: dkwedge_init();
505:
1.437 tls 506: /* Initialize the kernel strong PRNG. */
507: kern_cprng = cprng_strong_create("kernel", IPL_VM,
508: CPRNG_INIT_ANY|CPRNG_REKEY_ANY);
1.458 tls 509:
1.490 ryo 510: /* Initialize pfil */
511: pfil_init();
512:
1.360 yamt 513: /* Initialize interfaces. */
514: ifinit1();
515:
1.408 dyoung 516: spldebug_start();
517:
1.433 bouyer 518: /* Initialize sockets thread(s) */
519: soinit1();
520:
1.486 pgoyette 521: /*
1.487 pgoyette 522: * Initialize the bufq strategy sub-system and any built-in
523: * strategy modules - they may be needed by some devices during
524: * auto-configuration
1.486 pgoyette 525: */
1.487 pgoyette 526: bufq_init();
1.486 pgoyette 527: module_init_class(MODULE_CLASS_BUFQ);
528:
1.156 thorpej 529: /* Configure the system hardware. This will enable interrupts. */
530: configure();
1.61 mycroft 531:
1.459 riastrad 532: /* Once all CPUs are detected, initialize the per-CPU cprng_fast. */
533: cprng_fast_init();
534:
1.381 christos 535: ssp_init();
536:
1.424 eeh 537: ubc_init(); /* must be after autoconfig */
538:
1.432 rmind 539: mm_init();
540:
1.381 christos 541: configure2();
1.456 rmind 542:
543: ipi_sysinit();
544:
1.383 yamt 545: /* Now timer is working. Enable preemption. */
546: kpreempt_enable();
547:
1.461 uebayasi 548: /* Get the threads going and into any sleeps before continuing. */
549: yield();
550:
1.453 riastrad 551: /* Enable deferred processing of RNG samples */
552: rnd_init_softint();
553:
1.458 tls 554: #ifdef RND_PRINTF
555: /* Enable periodic injection of console output into entropy pool */
556: kprintf_init_callout();
557: #endif
558:
1.418 cegger 559: vmem_rehash_start(); /* must be before exec_init */
560:
561: /* Initialize exec structures */
562: exec_init(1); /* seminit calls exithook_establish() */
563:
1.273 elad 564: #if NVERIEXEC > 0
1.283 elad 565: /*
566: * Initialise the Veriexec subsystem.
567: */
568: veriexec_init();
1.273 elad 569: #endif /* NVERIEXEC > 0 */
1.251 junyoung 570:
1.281 elad 571: pax_init();
572:
1.449 christos 573: #ifdef IPSEC
1.223 jonathan 574: /* Attach network crypto subsystem */
575: ipsec_attach();
576: #endif
1.61 mycroft 577:
578: /*
579: * Initialize protocols. Block reception of incoming packets
580: * until everything is ready.
581: */
1.190 thorpej 582: s = splnet();
1.61 mycroft 583: ifinit();
1.475 ozaki-r 584: #if defined(INET) || defined(INET6)
1.468 ozaki-r 585: lltableinit();
1.469 ozaki-r 586: #endif
1.390 pooka 587: domaininit(true);
1.498 ozaki-r 588: ifinit_post();
1.200 itojun 589: if_attachdomain();
1.61 mycroft 590: splx(s);
591:
592: #ifdef GPROF
593: /* Initialize kernel profiling. */
594: kmstartup();
595: #endif
1.164 enami 596:
1.351 sborrill 597: /* Initialize system accounting. */
1.164 enami 598: acct_init();
1.61 mycroft 599:
1.301 ad 600: #ifndef PIPE_SOCKETPAIR
1.300 ad 601: /* Initialize pipes. */
602: pipe_init();
1.301 ad 603: #endif
1.300 ad 604:
1.292 ad 605: #ifdef KTRACE
606: /* Initialize ktrace. */
607: ktrinit();
608: #endif
609:
1.406 elad 610: machdep_init();
611:
1.427 pooka 612: procinit_sysctl();
613:
1.472 mrg 614: scdebug_init();
615:
1.163 thorpej 616: /*
617: * Create process 1 (init(8)). We do this now, as Unix has
618: * historically had init be process 1, and changing this would
619: * probably upset a lot of people.
620: *
621: * Note that process 1 won't immediately exec init(8), but will
622: * wait for us to inform it that the root file system has been
623: * mounted.
624: */
1.497 kamil 625: if (fork1(l, 0, SIGCHLD, NULL, 0, start_init, NULL, NULL))
1.163 thorpej 626: panic("fork init");
627:
628: /*
1.502 kamil 629: * The initproc variable cannot be initialized in start_init as there
630: * is a race between vfs_mountroot and start_init.
631: */
632: mutex_enter(proc_lock);
633: initproc = proc_find_raw(1);
634: mutex_exit(proc_lock);
635:
636: /*
1.340 ad 637: * Load any remaining builtin modules, and hand back temporary
1.422 pgoyette 638: * storage to the VM system. Then require force when loading any
639: * remaining un-init'ed built-in modules to avoid later surprises.
1.340 ad 640: */
641: module_init_class(MODULE_CLASS_ANY);
1.422 pgoyette 642: module_builtin_require_force();
1.340 ad 643:
644: /*
1.208 thorpej 645: * Finalize configuration now that all real devices have been
646: * found. This needs to be done before the root device is
647: * selected, since finalization may create the root device.
648: */
649: config_finalize();
1.163 thorpej 650:
1.400 pooka 651: sysctl_finalize();
652:
1.163 thorpej 653: /*
654: * Now that autoconfiguration has completed, we can determine
655: * the root and dump devices.
656: */
1.445 mlelstv 657: cpu_rootconf();
1.101 thorpej 658: cpu_dumpconf();
1.61 mycroft 659:
660: /* Mount the root file system. */
1.95 thorpej 661: do {
1.416 pooka 662: domountroothook(root_device);
1.95 thorpej 663: if ((error = vfs_mountroot())) {
1.97 thorpej 664: printf("cannot mount root, error = %d\n", error);
1.95 thorpej 665: boothowto |= RB_ASKNAME;
666: setroot(root_device,
1.152 thorpej 667: (rootdev != NODEV) ? DISKPART(rootdev) : 0);
1.95 thorpej 668: }
669: } while (error != 0);
670: mountroothook_destroy();
671:
1.421 tsutsui 672: configure3();
673:
1.239 pk 674: /*
675: * Initialise the time-of-day clock, passing the time recorded
676: * in the root filesystem (if any) for use by systems that
677: * don't have a non-volatile time-of-day device.
678: */
679: inittodr(rootfstime);
680:
1.61 mycroft 681: /*
682: * Now can look at time, having had a chance to verify the time
1.292 ad 683: * from the file system. Reset l->l_rtime as it may have been
1.61 mycroft 684: * munched in mi_switch() after the time got set.
685: */
1.380 christos 686: getnanotime(&time);
1.500 kre 687: {
688: struct timespec ut;
689: /*
690: * was:
691: * boottime = time;
692: * but we can do better
693: */
694: nanouptime(&ut);
695: timespecsub(&time, &ut, &boottime);
696: }
1.447 pgoyette 697:
1.352 ad 698: mutex_enter(proc_lock);
1.225 jdolecek 699: LIST_FOREACH(p, &allproc, p_list) {
1.295 pavel 700: KASSERT((p->p_flag & PK_MARKER) == 0);
1.353 ad 701: mutex_enter(p->p_lock);
1.380 christos 702: TIMESPEC_TO_TIMEVAL(&p->p_stats->p_start, &time);
1.225 jdolecek 703: LIST_FOREACH(l, &p->p_lwps, l_sibling) {
1.292 ad 704: lwp_lock(l);
1.332 yamt 705: memset(&l->l_rtime, 0, sizeof(l->l_rtime));
1.292 ad 706: lwp_unlock(l);
1.225 jdolecek 707: }
1.353 ad 708: mutex_exit(p->p_lock);
1.163 thorpej 709: }
1.352 ad 710: mutex_exit(proc_lock);
1.332 yamt 711: binuptime(&curlwp->l_stime);
1.61 mycroft 712:
1.312 ad 713: for (CPU_INFO_FOREACH(cii, ci)) {
714: ci->ci_schedstate.spc_lastmod = time_second;
715: }
716:
1.163 thorpej 717: /* Create the pageout daemon kernel thread. */
718: uvm_swap_init();
1.336 ad 719: if (kthread_create(PRI_PGDAEMON, KTHREAD_MPSAFE, NULL, uvm_pageout,
1.307 ad 720: NULL, NULL, "pgdaemon"))
1.135 thorpej 721: panic("fork pagedaemon");
1.61 mycroft 722:
1.163 thorpej 723: /* Create the filesystem syncer kernel thread. */
1.336 ad 724: if (kthread_create(PRI_IOFLUSH, KTHREAD_MPSAFE, NULL, sched_sync,
725: NULL, NULL, "ioflush"))
1.159 fvdl 726: panic("fork syncer");
1.185 chs 727:
728: /* Create the aiodone daemon kernel thread. */
1.286 yamt 729: if (workqueue_create(&uvm.aiodone_queue, "aiodoned",
1.336 ad 730: uvm_aiodone_worker, NULL, PRI_VM, IPL_NONE, WQ_MPSAFE))
1.185 chs 731: panic("fork aiodoned");
1.137 thorpej 732:
1.462 mrg 733: /* Wait for final configure threads to complete. */
734: config_finalize_mountroot();
735:
1.163 thorpej 736: /*
737: * Okay, now we can let init(8) exec! It's off to userland!
738: */
1.356 ad 739: mutex_enter(proc_lock);
1.163 thorpej 740: start_init_exec = 1;
1.356 ad 741: cv_broadcast(&lbolt);
742: mutex_exit(proc_lock);
1.163 thorpej 743:
1.61 mycroft 744: /* The scheduler is an infinite loop. */
1.114 mrg 745: uvm_scheduler();
1.61 mycroft 746: /* NOTREACHED */
747: }
748:
1.398 pooka 749: /*
750: * Configure the system's hardware.
751: */
752: static void
753: configure(void)
754: {
755:
756: /* Initialize autoconf data structures. */
1.401 pooka 757: config_init_mi();
1.398 pooka 758: /*
759: * XXX
760: * callout_setfunc() requires mutex(9) so it can't be in config_init()
761: * on amiga and atari which use config_init() and autoconf(9) fucntions
762: * to initialize console devices.
763: */
764: config_twiddle_init();
765:
766: pmf_init();
767:
1.471 jmcneill 768: /* Initialize driver modules */
769: module_init_class(MODULE_CLASS_DRIVER);
770:
1.430 uebayasi 771: userconf_init();
1.398 pooka 772: if (boothowto & RB_USERCONF)
1.430 uebayasi 773: userconf_prompt();
1.398 pooka 774:
775: if ((boothowto & (AB_SILENT|AB_VERBOSE)) == AB_SILENT) {
776: printf_nolog("Detecting hardware...");
777: }
778:
779: /*
780: * Do the machine-dependent portion of autoconfiguration. This
781: * sets the configuration machinery here in motion by "finding"
782: * the root bus. When this function returns, we expect interrupts
783: * to be enabled.
784: */
785: cpu_configure();
786: }
787:
788: static void
789: configure2(void)
790: {
791: CPU_INFO_ITERATOR cii;
792: struct cpu_info *ci;
793: int s;
794:
1.508 ad 795: /* Fix up CPU topology info, which has all been collected by now. */
796: cpu_topology_init();
797:
1.398 pooka 798: /*
799: * Now that we've found all the hardware, start the real time
800: * and statistics clocks.
801: */
802: initclocks();
803:
804: cold = 0; /* clocks are running, we're warm now! */
805: s = splsched();
806: curcpu()->ci_schedstate.spc_flags |= SPCF_RUNNING;
807: splx(s);
808:
1.507 ad 809: /* Setup the runqueues and scheduler. */
810: runq_init();
811: synch_init();
812:
1.398 pooka 813: /* Boot the secondary processors. */
814: for (CPU_INFO_FOREACH(cii, ci)) {
815: uvm_cpu_attach(ci);
816: }
817: mp_online = true;
818: #if defined(MULTIPROCESSOR)
819: cpu_boot_secondary_processors();
820: #endif
821:
822: /*
823: * Bus scans can make it appear as if the system has paused, so
824: * twiddle constantly while config_interrupts() jobs are running.
825: */
826: config_twiddle_fn(NULL);
827:
828: /*
829: * Create threads to call back and finish configuration for
830: * devices that want interrupts enabled.
831: */
832: config_create_interruptthreads();
833: }
834:
1.93 mouse 835: static void
1.421 tsutsui 836: configure3(void)
837: {
838:
839: /*
840: * Create threads to call back and finish configuration for
841: * devices that want the mounted root file system.
842: */
843: config_create_mountrootthreads();
844:
845: /* Get the threads going and into any sleeps before continuing. */
846: yield();
847: }
848:
849: static void
1.443 mlelstv 850: rootconf_handle_wedges(void)
851: {
1.477 christos 852: struct disklabel label;
1.443 mlelstv 853: struct partition *p;
854: struct vnode *vp;
855: daddr_t startblk;
856: uint64_t nblks;
1.482 msaitoh 857: device_t dev;
1.443 mlelstv 858: int error;
859:
860: if (booted_nblks) {
861: /*
862: * bootloader passed geometry
863: */
864: dev = booted_device;
865: startblk = booted_startblk;
866: nblks = booted_nblks;
867:
868: /*
869: * keep booted_device and booted_partition
870: * in case the kernel doesn't identify a wedge
871: */
872: } else {
873: /*
874: * bootloader passed partition number
875: *
876: * We cannot ask the partition device directly when it is
877: * covered by a wedge. Instead we look up the geometry in
878: * the disklabel.
879: */
880: vp = opendisk(booted_device);
1.444 martin 881:
882: if (vp == NULL)
883: return;
884:
1.477 christos 885: error = VOP_IOCTL(vp, DIOCGDINFO, &label, FREAD, NOCRED);
1.443 mlelstv 886: VOP_CLOSE(vp, FREAD, NOCRED);
887: vput(vp);
888: if (error)
889: return;
890:
891: KASSERT(booted_partition >= 0
892: && booted_partition < MAXPARTITIONS);
893:
1.477 christos 894: p = &label.d_partitions[booted_partition];
1.443 mlelstv 895:
896: dev = booted_device;
897: startblk = p->p_offset;
898: nblks = p->p_size;
899: }
900:
901: dev = dkwedge_find_partition(dev, startblk, nblks);
902: if (dev != NULL) {
903: booted_device = dev;
904: booted_partition = 0;
905: }
906: }
907:
1.445 mlelstv 908: void
1.443 mlelstv 909: rootconf(void)
910: {
1.445 mlelstv 911: if (booted_device != NULL)
912: rootconf_handle_wedges();
1.443 mlelstv 913:
914: setroot(booted_device, booted_partition);
915: }
916:
917: static void
1.260 christos 918: check_console(struct lwp *l)
1.93 mouse 919: {
1.391 dholland 920: struct vnode *vp;
1.93 mouse 921: int error;
922:
1.391 dholland 923: error = namei_simple_kernel("/dev/console",
924: NSM_FOLLOW_NOEMULROOT, &vp);
1.499 martin 925: if (error == 0) {
1.391 dholland 926: vrele(vp);
1.499 martin 927: } else if (error == ENOENT) {
928: if (boothowto & (AB_VERBOSE|AB_DEBUG))
929: printf("warning: no /dev/console\n");
930: } else {
1.96 cgd 931: printf("warning: lookup /dev/console: error %d\n", error);
1.499 martin 932: }
1.93 mouse 933: }
934:
1.61 mycroft 935: /*
936: * List of paths to try when searching for "init".
937: */
1.327 matt 938: static const char * const initpaths[] = {
1.61 mycroft 939: "/sbin/init",
940: "/sbin/oinit",
941: "/sbin/init.bak",
1.454 apb 942: "/rescue/init",
1.61 mycroft 943: NULL,
944: };
945:
946: /*
947: * Start the initial user process; try exec'ing each pathname in "initpaths".
948: * The program is invoked with one argument containing the boot flags.
949: */
950: static void
1.176 thorpej 951: start_init(void *arg)
1.61 mycroft 952: {
1.216 thorpej 953: struct lwp *l = arg;
954: struct proc *p = l->l_proc;
1.130 eeh 955: vaddr_t addr;
1.78 mycroft 956: struct sys_execve_args /* {
1.108 mycroft 957: syscallarg(const char *) path;
1.92 cgd 958: syscallarg(char * const *) argp;
959: syscallarg(char * const *) envp;
1.68 cgd 960: } */ args;
961: int options, i, error;
962: register_t retval[2];
1.66 mycroft 963: char flags[4], *flagsp;
1.202 lukem 964: const char *path, *slash;
1.474 christos 965: char *ucp, **uap, *arg0, *arg1, *argv[3];
1.202 lukem 966: char ipath[129];
967: int ipx, len;
1.61 mycroft 968:
1.76 cgd 969: /*
970: * Now in process 1.
971: */
1.146 gwr 972: strncpy(p->p_comm, "init", MAXCOMLEN);
1.163 thorpej 973:
974: /*
975: * Wait for main() to tell us that it's safe to exec.
976: */
1.356 ad 977: mutex_enter(proc_lock);
1.163 thorpej 978: while (start_init_exec == 0)
1.356 ad 979: cv_wait(&lbolt, proc_lock);
980: mutex_exit(proc_lock);
1.93 mouse 981:
982: /*
983: * This is not the right way to do this. We really should
984: * hand-craft a descriptor onto /dev/console to hand to init,
985: * but that's a _lot_ more work, and the benefit from this easy
986: * hack makes up for the "good is the enemy of the best" effect.
987: */
1.260 christos 988: check_console(l);
1.61 mycroft 989:
990: /*
991: * Need just enough stack to hold the faked-up "execve()" arguments.
992: */
1.211 chs 993: addr = (vaddr_t)STACK_ALLOC(USRSTACK, PAGE_SIZE);
1.205 sommerfe 994: if (uvm_map(&p->p_vmspace->vm_map, &addr, PAGE_SIZE,
1.483 maxv 995: NULL, UVM_UNKNOWN_OFFSET, 0,
996: UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW, UVM_INH_COPY,
997: UVM_ADV_NORMAL,
998: UVM_FLAG_FIXED|UVM_FLAG_OVERLAY|UVM_FLAG_COPYONW)) != 0)
1.114 mrg 999: panic("init: couldn't allocate argument space");
1.297 christos 1000: p->p_vmspace->vm_maxsaddr = (void *)STACK_MAX(addr, PAGE_SIZE);
1.61 mycroft 1001:
1.202 lukem 1002: ipx = 0;
1003: while (1) {
1004: if (boothowto & RB_ASKNAME) {
1005: printf("init path");
1006: if (initpaths[ipx])
1007: printf(" (default %s)", initpaths[ipx]);
1008: printf(": ");
1009: len = cngetsn(ipath, sizeof(ipath)-1);
1.371 tsutsui 1010: if (len == 4 && strcmp(ipath, "halt") == 0) {
1.370 tsutsui 1011: cpu_reboot(RB_HALT, NULL);
1012: } else if (len == 6 && strcmp(ipath, "reboot") == 0) {
1013: cpu_reboot(0, NULL);
1014: #if defined(DDB)
1015: } else if (len == 3 && strcmp(ipath, "ddb") == 0) {
1016: console_debugger();
1017: continue;
1018: #endif
1.371 tsutsui 1019: } else if (len > 0 && ipath[0] == '/') {
1.202 lukem 1020: ipath[len] = '\0';
1021: path = ipath;
1.371 tsutsui 1022: } else if (len == 0 && initpaths[ipx] != NULL) {
1023: path = initpaths[ipx++];
1024: } else {
1025: printf("use absolute path, ");
1026: #if defined(DDB)
1027: printf("\"ddb\", ");
1028: #endif
1029: printf("\"halt\", or \"reboot\"\n");
1030: continue;
1.202 lukem 1031: }
1032: } else {
1.370 tsutsui 1033: if ((path = initpaths[ipx++]) == NULL) {
1034: ipx = 0;
1035: boothowto |= RB_ASKNAME;
1036: continue;
1037: }
1.202 lukem 1038: }
1039:
1.211 chs 1040: ucp = (char *)USRSTACK;
1.64 mycroft 1041:
1.61 mycroft 1042: /*
1.64 mycroft 1043: * Construct the boot flag argument.
1.61 mycroft 1044: */
1.66 mycroft 1045: flagsp = flags;
1046: *flagsp++ = '-';
1.61 mycroft 1047: options = 0;
1.66 mycroft 1048:
1.61 mycroft 1049: if (boothowto & RB_SINGLE) {
1.64 mycroft 1050: *flagsp++ = 's';
1.61 mycroft 1051: options = 1;
1052: }
1053: #ifdef notyet
1054: if (boothowto & RB_FASTBOOT) {
1.64 mycroft 1055: *flagsp++ = 'f';
1.61 mycroft 1056: options = 1;
1057: }
1058: #endif
1.64 mycroft 1059:
1060: /*
1061: * Move out the flags (arg 1), if necessary.
1062: */
1063: if (options != 0) {
1064: *flagsp++ = '\0';
1065: i = flagsp - flags;
1066: #ifdef DEBUG
1.415 hubertf 1067: aprint_normal("init: copying out flags `%s' %d\n", flags, i);
1.64 mycroft 1068: #endif
1.211 chs 1069: arg1 = STACK_ALLOC(ucp, i);
1070: ucp = STACK_MAX(arg1, i);
1.474 christos 1071: if ((error = copyout((void *)flags, arg1, i)) != 0)
1072: goto copyerr;
1073: } else
1074: arg1 = NULL;
1.61 mycroft 1075:
1076: /*
1077: * Move out the file name (also arg 0).
1078: */
1.64 mycroft 1079: i = strlen(path) + 1;
1080: #ifdef DEBUG
1.415 hubertf 1081: aprint_normal("init: copying out path `%s' %d\n", path, i);
1.202 lukem 1082: #else
1.203 lukem 1083: if (boothowto & RB_ASKNAME || path != initpaths[0])
1.202 lukem 1084: printf("init: trying %s\n", path);
1.64 mycroft 1085: #endif
1.211 chs 1086: arg0 = STACK_ALLOC(ucp, i);
1087: ucp = STACK_MAX(arg0, i);
1.474 christos 1088: if ((error = copyout(path, arg0, i)) != 0)
1089: goto copyerr;
1.61 mycroft 1090:
1091: /*
1092: * Move out the arg pointers.
1093: */
1.439 christos 1094: ucp = (void *)STACK_ALIGN(ucp, STACK_ALIGNBYTES);
1.479 macallan 1095: uap = (char **)STACK_ALLOC(ucp, sizeof(argv));
1.211 chs 1096: SCARG(&args, path) = arg0;
1097: SCARG(&args, argp) = uap;
1098: SCARG(&args, envp) = NULL;
1.142 mycroft 1099: slash = strrchr(path, '/');
1.474 christos 1100:
1101: argv[0] = slash ? arg0 + (slash + 1 - path) : arg0;
1102: argv[1] = arg1;
1103: argv[2] = NULL;
1.479 macallan 1104: if ((error = copyout(argv, uap, sizeof(argv))) != 0)
1.474 christos 1105: goto copyerr;
1.61 mycroft 1106:
1107: /*
1.481 palle 1108: * Now try to exec the program. If it can't for any reason
1.61 mycroft 1109: * other than it doesn't exist, complain.
1110: */
1.260 christos 1111: error = sys_execve(l, &args, retval);
1.179 thorpej 1112: if (error == 0 || error == EJUSTRETURN) {
1.292 ad 1113: KERNEL_UNLOCK_LAST(l);
1.61 mycroft 1114: return;
1.179 thorpej 1115: }
1.202 lukem 1116: printf("exec %s: error %d\n", path, error);
1.61 mycroft 1117: }
1.90 christos 1118: printf("init: not found\n");
1.61 mycroft 1119: panic("no init");
1.474 christos 1120: copyerr:
1121: panic("copyout %d", error);
1.61 mycroft 1122: }
1.345 yamt 1123:
1124: /*
1.448 para 1125: * calculate cache size (in bytes) from physmem and vsize.
1.345 yamt 1126: */
1127: vaddr_t
1.448 para 1128: calc_cache_size(vsize_t vsize, int pct, int va_pct)
1.345 yamt 1129: {
1130: paddr_t t;
1131:
1132: /* XXX should consider competing cache if any */
1133: /* XXX should consider submaps */
1.346 yamt 1134: t = (uintmax_t)physmem * pct / 100 * PAGE_SIZE;
1.448 para 1135: if (vsize != 0) {
1.346 yamt 1136: vsize = (uintmax_t)vsize * va_pct / 100;
1137: if (t > vsize) {
1138: t = vsize;
1139: }
1.345 yamt 1140: }
1141: return t;
1142: }
1.385 ad 1143:
1144: /*
1145: * Print the system start up banner.
1146: *
1147: * - Print a limited banner if AB_SILENT.
1148: * - Always send normal banner to the log.
1149: */
1.388 tsutsui 1150: #define MEM_PBUFSIZE sizeof("99999 MB")
1151:
1.385 ad 1152: void
1153: banner(void)
1154: {
1155: static char notice[] = " Notice: this software is "
1156: "protected by copyright";
1.386 ad 1157: char pbuf[81];
1.446 christos 1158: void (*pr)(const char *, ...) __printflike(1, 2);
1.385 ad 1159: int i;
1160:
1161: if ((boothowto & AB_SILENT) != 0) {
1162: snprintf(pbuf, sizeof(pbuf), "%s %s (%s)",
1163: ostype, osrelease, kernel_ident);
1.392 ad 1164: printf_nolog("%s", pbuf);
1.387 ad 1165: for (i = 80 - strlen(pbuf) - sizeof(notice); i > 0; i--)
1.385 ad 1166: printf(" ");
1.392 ad 1167: printf_nolog("%s\n", notice);
1.385 ad 1168: pr = aprint_normal;
1169: } else {
1.492 joerg 1170: pr = printf;
1.385 ad 1171: }
1172:
1173: memset(pbuf, 0, sizeof(pbuf));
1174: (*pr)("%s%s", copyright, version);
1.388 tsutsui 1175: format_bytes(pbuf, MEM_PBUFSIZE, ctob((uint64_t)physmem));
1.385 ad 1176: (*pr)("total memory = %s\n", pbuf);
1.512 ! ad 1177: format_bytes(pbuf, MEM_PBUFSIZE, ctob((uint64_t)uvm_free()));
1.385 ad 1178: (*pr)("avail memory = %s\n", pbuf);
1179: }
CVSweb <webmaster@jp.NetBSD.org>