This commit was generated by cvs2svn to track changes on a CVS vendor
[unix-history] / sys / kern / init_main.c
index 50e1b78..4e3470e 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.15 1994/03/06 03:20:31 jkh Exp $
  */
  */
-static char rcsid[] = "$Header: /a/cvs/386BSD/src/sys/kern/init_main.c,v 1.3 1993/08/27 02:10:18 rgrimes 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.3 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.3 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.
@@ -83,7 +77,7 @@ struct        filedesc0 filedesc0;
 struct plimit limit0;
 struct vmspace vmspace0;
 struct proc *curproc = &proc0;
 struct plimit limit0;
 struct vmspace vmspace0;
 struct proc *curproc = &proc0;
-struct proc *initproc, *pageproc;
+struct proc *initproc, *pageproc, *pagescanproc, *updateproc;
 
 int    cmask = CMASK;
 extern struct user *proc0paddr;
 
 int    cmask = CMASK;
 extern struct user *proc0paddr;
@@ -92,6 +86,19 @@ extern       int (*mountroot)();
 struct vnode *rootvp, *swapdev_vp;
 int    boothowto;
 
 struct vnode *rootvp, *swapdev_vp;
 int    boothowto;
 
+#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 +106,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 +128,6 @@ main()
        startrtclock();
        consinit();
 
        startrtclock();
        consinit();
 
-       printf("\n%s  [1.%s]\n", bsd_version, version+9);
        printf("%s", copyright);
 
        vm_mem_init();
        printf("%s", copyright);
 
        vm_mem_init();
@@ -222,21 +230,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 +249,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 +276,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 +324,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,
@@ -327,7 +349,7 @@ main()
         * Start up pageout daemon (process 2).
         */
        if (fork(p, (void *) NULL, rval))
         * Start up pageout daemon (process 2).
         */
        if (fork(p, (void *) NULL, rval))
-               panic("fork pager");
+               panic("failed fork pageout daemon");
        if (rval[1]) {
                /*
                 * Now in process 2.
        if (rval[1]) {
                /*
                 * Now in process 2.
@@ -340,6 +362,38 @@ main()
                /*NOTREACHED*/
        }
 
                /*NOTREACHED*/
        }
 
+#if 1
+       /*
+        * Start page scanner daemon (process 3).
+        */
+       if (fork(p, (void *) NULL, rval))
+               panic("failed fork page scanner daemon");
+       if (rval[1]) {
+               p = curproc;
+               pagescanproc = p;
+               p->p_flag |= SLOAD|SSYS;
+               bcopy("pagescan", p->p_comm, sizeof("pagescan"));
+               vm_pagescan();
+               /*NOTREACHED*/
+       }
+#endif
+
+       /*
+        * Start update daemon (process 4).
+        */
+#ifndef LAPTOP
+       if (fork(p, (void *) NULL, rval))
+               panic("failed fork update daemon");
+       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
         */