BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / kern / init_main.c
index 93f3019..e9e1cd1 100644 (file)
@@ -2,9 +2,35 @@
  * Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1982, 1986, 1989, 1991 Regents of the University of California.
  * All rights reserved.
  *
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)init_main.c 7.37 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)init_main.c 7.41 (Berkeley) 5/15/91
  */
 
 #include "param.h"
  */
 
 #include "param.h"
 #include "reboot.h"
 #include "user.h"
 
 #include "reboot.h"
 #include "user.h"
 
+#include "ufs/quota.h"
 
 #include "machine/cpu.h"
 
 #include "vm/vm.h"
 
 
 #include "machine/cpu.h"
 
 #include "vm/vm.h"
 
+char   copyright[] =
+"Copyright (c) 1982,1986,1989,1991 The Regents of the University of California.\nAll rights reserved.\n\n";
+
 /*
  * Components of process 0;
  * never freed.
 /*
  * Components of process 0;
  * never freed.
@@ -46,9 +76,12 @@ struct       proc *curproc = &proc0;
 struct proc *initproc, *pageproc;
 
 int    cmask = CMASK;
 struct proc *initproc, *pageproc;
 
 int    cmask = CMASK;
-extern caddr_t proc0paddr;
+extern struct user *proc0paddr;
 extern int (*mountroot)();
 
 extern int (*mountroot)();
 
+struct vnode *rootvp, *swapdev_vp;
+int    boothowto;
+
 /*
  * System startup; initialize the world, create process 0,
  * mount root filesystem, and fork to create init and pagedaemon.
 /*
  * System startup; initialize the world, create process 0,
  * mount root filesystem, and fork to create init and pagedaemon.
@@ -56,8 +89,7 @@ extern        int (*mountroot)();
  * routines including startup(), which does memory initialization
  * and autoconfiguration.
  */
  * routines including startup(), which does memory initialization
  * and autoconfiguration.
  */
-main(firstaddr)
-       int firstaddr;
+main()
 {
        register int i;
        register struct proc *p;
 {
        register int i;
        register struct proc *p;
@@ -75,10 +107,11 @@ main(firstaddr)
         * in case of early panic or other messages.
         */
        consinit();
         * in case of early panic or other messages.
         */
        consinit();
+       printf(copyright);
 
        vm_mem_init();
        kmeminit();
 
        vm_mem_init();
        kmeminit();
-       startup(firstaddr);
+       cpu_startup();
 
        /*
         * set up system process 0 (swapper)
 
        /*
         * set up system process 0 (swapper)
@@ -103,6 +136,7 @@ main(firstaddr)
        /*
         * Setup credentials
         */
        /*
         * Setup credentials
         */
+       cred0.p_refcnt = 1;
        p->p_cred = &cred0;
        p->p_ucred = crget();
        p->p_ucred->cr_ngroups = 1;     /* group 0 */
        p->p_cred = &cred0;
        p->p_ucred = crget();
        p->p_ucred->cr_ngroups = 1;     /* group 0 */
@@ -144,8 +178,8 @@ main(firstaddr)
         * We continue to place resource usage info
         * and signal actions in the user struct so they're pageable.
         */
         * We continue to place resource usage info
         * and signal actions in the user struct so they're pageable.
         */
-       p->p_stats = &((struct user *)p->p_addr)->u_stats;
-       p->p_sigacts = &((struct user *)p->p_addr)->u_sigacts;
+       p->p_stats = &p->p_addr->u_stats;
+       p->p_sigacts = &p->p_addr->u_sigacts;
 
        rqinit();
 
 
        rqinit();
 
@@ -158,12 +192,10 @@ main(firstaddr)
        /*
         * Initialize the file systems.
         *
        /*
         * Initialize the file systems.
         *
-        * Get vnodes for swapdev, argdev, and rootdev.
+        * Get vnodes for swapdev and rootdev.
         */
        vfsinit();
         */
        vfsinit();
-       if (bdevvp(swapdev, &swapdev_vp) ||
-           bdevvp(argdev, &argdev_vp) ||
-           bdevvp(rootdev, &rootvp))
+       if (bdevvp(swapdev, &swapdev_vp) || bdevvp(rootdev, &rootvp))
                panic("can't setup bdevvp's");
 
        startrtclock();
                panic("can't setup bdevvp's");
 
        startrtclock();
@@ -241,6 +273,8 @@ main(firstaddr)
                static char initflags[] = "-sf";
                char *ip = initflags + 1;
                vm_offset_t addr = 0;
                static char initflags[] = "-sf";
                char *ip = initflags + 1;
                vm_offset_t addr = 0;
+               extern int icode[];             /* user init code */
+               extern int szicode;             /* size of icode */
 
                /*
                 * Now in process 1.  Set init flags into icode,
 
                /*
                 * Now in process 1.  Set init flags into icode,
@@ -263,7 +297,7 @@ main(firstaddr)
                        panic("init: couldn't allocate at zero");
 
                /* need just enough stack to exec from */
                        panic("init: couldn't allocate at zero");
 
                /* need just enough stack to exec from */
-               addr = trunc_page(VM_MAX_ADDRESS - PAGE_SIZE);
+               addr = trunc_page(USRSTACK - PAGE_SIZE);
                if (vm_allocate(&p->p_vmspace->vm_map, &addr,
                    PAGE_SIZE, FALSE) != KERN_SUCCESS)
                        panic("vm_allocate init stack");
                if (vm_allocate(&p->p_vmspace->vm_map, &addr,
                    PAGE_SIZE, FALSE) != KERN_SUCCESS)
                        panic("vm_allocate init stack");
@@ -295,42 +329,3 @@ main(firstaddr)
         */
        sched();
 }
         */
        sched();
 }
-
-/* MOVE TO vfs_bio.c (bufinit) XXX */
-/*
- * Initialize buffers and hash links for buffers.
- */
-bufinit()
-{
-       register int i;
-       register struct buf *bp, *dp;
-       register struct bufhd *hp;
-       int base, residual;
-
-       for (hp = bufhash, i = 0; i < BUFHSZ; i++, hp++)
-               hp->b_forw = hp->b_back = (struct buf *)hp;
-
-       for (dp = bfreelist; dp < &bfreelist[BQUEUES]; dp++) {
-               dp->b_forw = dp->b_back = dp->av_forw = dp->av_back = dp;
-               dp->b_flags = B_HEAD;
-       }
-       base = bufpages / nbuf;
-       residual = bufpages % nbuf;
-       for (i = 0; i < nbuf; i++) {
-               bp = &buf[i];
-               bp->b_dev = NODEV;
-               bp->b_bcount = 0;
-               bp->b_rcred = NOCRED;
-               bp->b_wcred = NOCRED;
-               bp->b_dirtyoff = 0;
-               bp->b_dirtyend = 0;
-               bp->b_un.b_addr = buffers + i * MAXBSIZE;
-               if (i < residual)
-                       bp->b_bufsize = (base + 1) * CLBYTES;
-               else
-                       bp->b_bufsize = base * CLBYTES;
-               binshash(bp, &bfreelist[BQ_AGE]);
-               bp->b_flags = B_BUSY|B_INVAL;
-               brelse(bp);
-       }
-}