label_t now structure
[unix-history] / usr / src / sys / kern / init_main.c
index ec291d8..ab9da86 100644 (file)
@@ -1,9 +1,10 @@
-/*     init_main.c     4.29    82/04/19        */
+/*     init_main.c     4.37    82/09/06        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/dir.h"
 #include "../h/user.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/dir.h"
 #include "../h/user.h"
+#include "../h/kernel.h"
 #include "../h/fs.h"
 #include "../h/mount.h"
 #include "../h/map.h"
 #include "../h/fs.h"
 #include "../h/mount.h"
 #include "../h/map.h"
 #include "../h/buf.h"
 #include "../h/mtpr.h"
 #include "../h/pte.h"
 #include "../h/buf.h"
 #include "../h/mtpr.h"
 #include "../h/pte.h"
-#include "../h/clock.h"
 #include "../h/vm.h"
 #include "../h/cmap.h"
 #include "../h/text.h"
 #include "../h/vm.h"
 #include "../h/cmap.h"
 #include "../h/text.h"
-#include "../h/vlimit.h"
 #include "../h/clist.h"
 #ifdef INET
 #include "../h/protosw.h"
 #endif
 #include "../h/clist.h"
 #ifdef INET
 #include "../h/protosw.h"
 #endif
+#include "../h/quota.h"
 
 /*
  * Initialization code.
 
 /*
  * Initialization code.
@@ -45,7 +45,7 @@ main(firstaddr)
 {
        register int i;
        register struct proc *p;
 {
        register int i;
        register struct proc *p;
-       struct fs *fsp;
+       struct fs *fs;
 
        rqinit();
 #include "loop.h"
 
        rqinit();
 #include "loop.h"
@@ -64,21 +64,19 @@ main(firstaddr)
        setredzone(p->p_addr, (caddr_t)&u);
        u.u_procp = p;
        u.u_cmask = CMASK;
        setredzone(p->p_addr, (caddr_t)&u);
        u.u_procp = p;
        u.u_cmask = CMASK;
-       for (i = 1; i < sizeof(u.u_limit)/sizeof(u.u_limit[0]); i++)
-               switch (i) {
-
-               case LIM_STACK:
-                       u.u_limit[i] = 512*1024;
-                       continue;
-               case LIM_DATA:
-                       u.u_limit[i] = ctob(MAXDSIZ);
-                       continue;
-               default:
-                       u.u_limit[i] = INFINITY;
-                       continue;
-               }
-       p->p_maxrss = INFINITY/NBPG;
-       clkstart();
+       for (i = 1; i < NGROUPS; i++)
+               u.u_groups[i] = -1;
+       for (i = 0; i < sizeof(u.u_rlimit)/sizeof(u.u_rlimit[0]); i++)
+               u.u_rlimit[i].rlim_cur = u.u_rlimit[i].rlim_max = 
+                   RLIM_INFINITY;
+       u.u_rlimit[RLIMIT_STACK].rlim_cur = 512*1024;
+       u.u_rlimit[RLIMIT_DATA].rlim_cur = ctob(MAXDSIZ);
+       p->p_maxrss = RLIM_INFINITY/NBPG;
+#ifdef QUOTA
+       qtinit();
+       p->p_quota = u.u_quota = getquota(0, 0, Q_NDQ);
+#endif
+       clockstart();
 
        /*
         * Initialize tables, protocols, and set up well-known inodes.
 
        /*
         * Initialize tables, protocols, and set up well-known inodes.
@@ -96,13 +94,31 @@ main(firstaddr)
        bhinit();
        binit();
        bswinit();
        bhinit();
        binit();
        bswinit();
-       iinit();
-       fsp = getfs(rootdev);
-       rootdir = iget(rootdev, fsp, (ino_t)ROOTINO);
-       rootdir->i_flag &= ~ILOCK;
-       u.u_cdir = iget(rootdev, fsp, (ino_t)ROOTINO);
-       u.u_cdir->i_flag &= ~ILOCK;
+#ifdef GPROF
+       kmstartup();
+#endif
+
+       fs = mountfs(rootdev, 0, (struct inode *)0);
+       if (fs == 0)
+               panic("iinit");
+       bcopy("/", fs->fs_fsmnt, 2);
+
+/* initialize wall clock */
+       clockinit(fs->fs_time);
+       boottime = time;
+
+/* kick off timeout driven events by calling first time */
+       roundrobin();
+       schedcpu();
+       schedpaging();
+
+/* set up the root file system */
+       rootdir = iget(rootdev, fs, (ino_t)ROOTINO);
+       iunlock(rootdir);
+       u.u_cdir = iget(rootdev, fs, (ino_t)ROOTINO);
+       iunlock(u.u_cdir);
        u.u_rdir = NULL;
        u.u_rdir = NULL;
+
        u.u_dmap = zdmap;
        u.u_smap = zdmap;
 
        u.u_dmap = zdmap;
        u.u_smap = zdmap;
 
@@ -144,56 +160,36 @@ main(firstaddr)
                 */
                return;
        }
                 */
                return;
        }
+#ifdef MUSH
+       /*
+        * start MUSH daemon
+        *                      pid == 3
+        */
+       if (newproc(0)) {
+               expand(clrnd((int)btoc(szmcode)), P0BR);
+               (void) swpexpand(u.u_dsize, 0, &u.u_dmap, &u.u_smap);
+               (void) copyout((caddr_t)mcode, (caddr_t)0, (unsigned)szmcode);
+               /*
+                * Return goes to loc. 0 of user mush
+                * code just copied out.
+                */
+               return;
+       }
+#endif
        proc[0].p_szpt = 1;
        sched();
 }
 
 /*
        proc[0].p_szpt = 1;
        sched();
 }
 
 /*
- * iinit is called once (from main)
- * very early in initialization.
- * It reads the root's super block
- * and initializes the current date
- * from the last modified date.
- *
- * panic: iinit -- cannot read the super
- * block. Usually because of an IO error.
+ * Initialize hash links for buffers.
  */
  */
-iinit()
+bhinit()
 {
 {
-       register struct buf *bp;
-       register struct fs *fp;
        register int i;
        register int i;
-       int blks;
+       register struct bufhd *bp;
 
 
-       (*bdevsw[major(rootdev)].d_open)(rootdev, 1);
-       bp = bread(rootdev, SBLOCK, SBSIZE);
-       if(u.u_error)
-               panic("iinit");
-       bp->b_flags |= B_LOCKED;                /* block can never be re-used */
-       brelse(bp);
-       mount[0].m_dev = rootdev;
-       mount[0].m_bufp = bp;
-       fp = bp->b_un.b_fs;
-       if (fp->fs_magic != FS_MAGIC)
-               panic("root bad magic number");
-       if (fp->fs_bsize > MAXBSIZE)
-               panic("root fs_bsize too big");
-       fp->fs_ronly = 0;
-       fp->fs_fsmnt[0] = '/';
-       for (i = 1; i < sizeof(fp->fs_fsmnt); i++)
-               fp->fs_fsmnt[i] = 0;
-       blks = howmany(fp->fs_cssize, fp->fs_fsize);
-       for (i = 0; i < blks; i += fp->fs_frag) {
-               bp = bread(rootdev, fsbtodb(fp, fp->fs_csaddr + i),
-                   blks - i < fp->fs_frag ?
-                       (blks - i) * fp->fs_fsize :
-                       fp->fs_bsize);
-               if (u.u_error)
-                       panic("root can't read csum");
-               fp->fs_csp[i / fp->fs_frag] = bp->b_un.b_cs;
-               bp->b_flags |= B_LOCKED;
-               brelse(bp);
-       }
+       for (bp = bufhash, i = 0; i < BUFHSZ; i++, bp++)
+               bp->b_forw = bp->b_back = (struct buf *)bp;
 }
 
 /*
 }
 
 /*