Eliminated the "physstrat" wart and merged it into kern_physio.c. This
[unix-history] / sys / kern / init_main.c
index 9b04862..7e7428b 100644 (file)
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
  * 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
- *
- * PATCHES MAGIC                LEVEL   PATCH THAT GOT US HERE
- * --------------------         -----   ----------------------
- * CURRENT PATCH LEVEL:         1       00162
- * --------------------         -----   ----------------------
- *
- * 26 May 93   Holger Veit             Remove hard coded escapes
- *             Rodney W. Grimes        Added two more \n to clean up output
+ *     from: @(#)init_main.c   7.41 (Berkeley) 5/15/91
+ *     $Id: init_main.c,v 1.14 1994/01/14 16:24:45 davidg Exp $
  */
  */
-static char rcsid[] = "$Header: /a/cvs/386BSD/src/sys/kern/init_main.c,v 1.4 1993/09/10 05:53:10 nate Exp $";
 
 #include "param.h"
 #include "filedesc.h"
 
 #include "param.h"
 #include "filedesc.h"
@@ -57,6 +49,7 @@ static char rcsid[] = "$Header: /a/cvs/386BSD/src/sys/kern/init_main.c,v 1.4 199
 #include "protosw.h"
 #include "reboot.h"
 #include "user.h"
 #include "protosw.h"
 #include "reboot.h"
 #include "user.h"
+#include "utsname.h"
 
 #include "ufs/quota.h"
 
 
 #include "ufs/quota.h"
 
@@ -64,13 +57,14 @@ static char rcsid[] = "$Header: /a/cvs/386BSD/src/sys/kern/init_main.c,v 1.4 199
 
 #include "vm/vm.h"
 
 
 #include "vm/vm.h"
 
-char   bsd_version[] =
-"FreeBSD release 1.0";
-char   copyright[] =
+const char     copyright[] =
 "Copyright (c) 1989,1990,1991,1992 William F. Jolitz. All rights reserved.\n\
 Copyright (c) 1982,1986,1989,1991 The Regents of the University\n\
 of California.  All rights reserved.\n\n";
 
 "Copyright (c) 1989,1990,1991,1992 William F. Jolitz. All rights reserved.\n\
 Copyright (c) 1982,1986,1989,1991 The Regents of the University\n\
 of California.  All rights reserved.\n\n";
 
+/* For uname() */
+struct utsname utsname;
+
 /*
  * Components of process 0;
  * never freed.
 /*
  * Components of process 0;
  * never freed.
@@ -92,6 +86,21 @@ extern       int (*mountroot)();
 struct vnode *rootvp, *swapdev_vp;
 int    boothowto;
 
 struct vnode *rootvp, *swapdev_vp;
 int    boothowto;
 
+struct proc *updateproc;
+
+#if __GNUC__ >= 2
+void __main() {}
+#endif
+
+/*
+ * This table is filled in by the linker with functions that need to be
+ * called to initialize various pseudo-devices and whatnot.
+ */
+typedef void (*pseudo_func_t)(void);
+extern const struct linker_set pseudo_set;
+static const pseudo_func_t *pseudos = 
+  (const pseudo_func_t *)&pseudo_set.ls_items[0];
+
 /*
  * 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.
@@ -99,12 +108,14 @@ int        boothowto;
  * routines including startup(), which does memory initialization
  * and autoconfiguration.
  */
  * routines including startup(), which does memory initialization
  * and autoconfiguration.
  */
+void
 main()
 {
        register int i;
        register struct proc *p;
        register struct filedesc0 *fdp;
        int s, rval[2];
 main()
 {
        register int i;
        register struct proc *p;
        register struct filedesc0 *fdp;
        int s, rval[2];
+       const char *cp;
 
        /*
         * Initialize curproc before any possible traps/probes
 
        /*
         * Initialize curproc before any possible traps/probes
@@ -119,7 +130,6 @@ main()
        startrtclock();
        consinit();
 
        startrtclock();
        consinit();
 
-       printf("\n%s  [1.0.%s]\n", bsd_version, version+9);
        printf("%s", copyright);
 
        vm_mem_init();
        printf("%s", copyright);
 
        vm_mem_init();
@@ -222,21 +232,11 @@ main()
         * Initialize tables, protocols, and set up well-known inodes.
         */
        mbinit();
         * Initialize tables, protocols, and set up well-known inodes.
         */
        mbinit();
-#ifdef SYSVSHM
-       shminit();
-#endif
-#include "sl.h"
-#if NSL > 0
-       slattach();                     /* XXX */
-#endif
-#include "ppp.h"
-#if NPPP > 0
-       pppattach();                    /* XXX */
-#endif
-#include "loop.h"
-#if NLOOP > 0
-       loattach();                     /* XXX */
-#endif
+
+       while(*pseudos) {
+               (**pseudos++)();
+       }
+
        /*
         * Block reception of incoming packets
         * until protocols have been initialized.
        /*
         * Block reception of incoming packets
         * until protocols have been initialized.
@@ -251,8 +251,8 @@ main()
 #endif
 
        /* kick off timeout driven events by calling first time */
 #endif
 
        /* kick off timeout driven events by calling first time */
-       roundrobin();
-       schedcpu();
+       roundrobin(0, 0);
+       schedcpu(0, 0);
        enablertclock();                /* enable realtime clock interrupts */
 
        /*
        enablertclock();                /* enable realtime clock interrupts */
 
        /*
@@ -278,6 +278,28 @@ main()
         */
        boottime = p->p_stats->p_start = time;
 
         */
        boottime = p->p_stats->p_start = time;
 
+       /*
+        * Setup version number for uname syscall
+        * XXX probably should go elsewhere.
+        */
+       bzero(utsname.sysname, sizeof(utsname.sysname));
+       for (cp = version, i= 0; *cp && *cp != ' ' && i <= sizeof(utsname.sysname);)
+               utsname.sysname[i++] = *cp++;
+       bzero(utsname.release, sizeof(utsname.release));
+       for (cp++, i= 0; *cp && *cp != ' ' && i <= sizeof(utsname.release);)
+               utsname.release[i++] = *cp++;
+       bzero(utsname.version, sizeof(utsname.version));
+       for (; *cp != '('; cp++);
+       for (cp++, i= 0; *cp && *cp != ')' && i <= sizeof(utsname.version);)
+               utsname.version[i++] = *cp++;
+       for (; *cp != '#'; cp++);
+       if(i <= sizeof(utsname.version))
+               utsname.version[i++] = '#';
+       for (cp++; *cp && *cp != ':' && i <= sizeof(utsname.version);)
+               utsname.version[i++] = *cp++;
+       strncpy(utsname.machine, MACHINE, sizeof(utsname.machine));
+       utsname.machine[sizeof(utsname.machine)-1] = '\0';
+
        /*
         * make init process
         */
        /*
         * make init process
         */
@@ -304,6 +326,8 @@ main()
                if (boothowto&RB_FASTBOOT)
                        *ip++ = 'f';
 #endif
                if (boothowto&RB_FASTBOOT)
                        *ip++ = 'f';
 #endif
+               if (ip == initflags + 1)
+                       *ip++ = '-';
                *ip++ = '\0';
 
                if (vm_allocate(&p->p_vmspace->vm_map, &addr,
                *ip++ = '\0';
 
                if (vm_allocate(&p->p_vmspace->vm_map, &addr,
@@ -340,6 +364,22 @@ main()
                /*NOTREACHED*/
        }
 
                /*NOTREACHED*/
        }
 
+       /*
+        * Start update daemon (process 3).
+        */
+#ifndef LAPTOP
+       if (fork(p, (void *) NULL, rval))
+               panic("fork update");
+       if (rval[1]) {
+               p = curproc;
+               updateproc = p;
+               p->p_flag |= SLOAD|SSYS;
+               bcopy("update", p->p_comm, sizeof("update"));
+               vfs_update();
+               /*NOTREACHED*/
+       }
+#endif
+
        /*
         * enter scheduling loop
         */
        /*
         * enter scheduling loop
         */