conversion of ino_t from u_short to u_long (making dir entries 32 bytes each)
[unix-history] / usr / src / sys / kern / init_main.c
index 7d34b89..0d3f4ec 100644 (file)
@@ -1,4 +1,4 @@
-/*     init_main.c     4.5     %G%     */
+/*     init_main.c     4.22    81/11/18        */
 
 #include "../h/param.h"
 #include "../h/systm.h"
 
 #include "../h/param.h"
 #include "../h/systm.h"
 #include "../h/cmap.h"
 #include "../h/text.h"
 #include "../h/vlimit.h"
 #include "../h/cmap.h"
 #include "../h/text.h"
 #include "../h/vlimit.h"
+#include "../h/clist.h"
+#ifdef INET
+#include "../h/protosw.h"
+#endif
 
 /*
  * Initialization code.
 
 /*
  * Initialization code.
 main(firstaddr)
 {
        register int i;
 main(firstaddr)
 {
        register int i;
+       register struct proc *p;
 
 
-#ifdef FASTVAX
        rqinit();
        rqinit();
-#endif
        startup(firstaddr);
        startup(firstaddr);
-       if (lotsfree == 0)
-               lotsfree = LOTSFREE;
 
        /*
         * set up system process 0 (swapper)
         */
 
        /*
         * set up system process 0 (swapper)
         */
-
-       proc[0].p_p0br = (struct pte *)mfpr(P0BR);
-       proc[0].p_szpt = 1;
-       proc[0].p_addr = uaddr(&proc[0]);
-       proc[0].p_stat = SRUN;
-       proc[0].p_flag |= SLOAD|SSYS;
-       proc[0].p_nice = NZERO;
-       u.u_procp = &proc[0];
+       p = &proc[0];
+       p->p_p0br = (struct pte *)mfpr(P0BR);
+       p->p_szpt = 1;
+       p->p_addr = uaddr(p);
+       p->p_stat = SRUN;
+       p->p_flag |= SLOAD|SSYS;
+       p->p_nice = NZERO;
+       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) {
        u.u_cmask = CMASK;
        for (i = 1; i < sizeof(u.u_limit)/sizeof(u.u_limit[0]); i++)
                switch (i) {
@@ -73,13 +75,16 @@ main(firstaddr)
                        u.u_limit[i] = INFINITY;
                        continue;
                }
                        u.u_limit[i] = INFINITY;
                        continue;
                }
+       p->p_maxrss = INFINITY/NBPG;
        clkstart();
 
        /*
        clkstart();
 
        /*
-        * Initialize devices and
-        * set up 'known' i-nodes
+        * Initialize tables, protocols, and set up well-known inodes.
         */
         */
-
+       mbinit();
+#ifdef INET
+       pfinit();
+#endif
        ihinit();
        bhinit();
        cinit();
        ihinit();
        bhinit();
        cinit();
@@ -94,19 +99,23 @@ main(firstaddr)
        u.u_dmap = zdmap;
        u.u_smap = zdmap;
 
        u.u_dmap = zdmap;
        u.u_smap = zdmap;
 
+       /*
+        * Set the scan rate and other parameters of the paging subsystem.
+        */
+       setupclock();
+
        /*
         * make page-out daemon (process 2)
        /*
         * make page-out daemon (process 2)
-        * the daemon has ctopt(NSWBUF*CLSIZE*KLMAX) pages of page
+        * the daemon has ctopt(nswbuf*CLSIZE*KLMAX) pages of page
         * table so that it can map dirty pages into
         * its address space during asychronous pushes.
         */
         * table so that it can map dirty pages into
         * its address space during asychronous pushes.
         */
-
        mpid = 1;
        mpid = 1;
-       proc[0].p_szpt = clrnd(ctopt(NSWBUF*CLSIZE*KLMAX + UPAGES));
+       proc[0].p_szpt = clrnd(ctopt(nswbuf*CLSIZE*KLMAX + UPAGES));
        proc[1].p_stat = SZOMB;         /* force it to be in proc slot 2 */
        if (newproc(0)) {
                proc[2].p_flag |= SLOAD|SSYS;
        proc[1].p_stat = SZOMB;         /* force it to be in proc slot 2 */
        if (newproc(0)) {
                proc[2].p_flag |= SLOAD|SSYS;
-               proc[2].p_dsize = u.u_dsize = NSWBUF*CLSIZE*KLMAX; 
+               proc[2].p_dsize = u.u_dsize = nswbuf*CLSIZE*KLMAX; 
                pageout();
        }
 
                pageout();
        }
 
@@ -128,6 +137,13 @@ main(firstaddr)
                 */
                return;
        }
                 */
                return;
        }
+
+#ifdef BBNNET 
+       /*
+        * Initialize bbn network.
+        */
+       netmain();
+#endif BBNNET
        proc[0].p_szpt = 1;
        sched();
 }
        proc[0].p_szpt = 1;
        sched();
 }
@@ -146,6 +162,7 @@ iinit()
 {
        register struct buf *bp;
        register struct filsys *fp;
 {
        register struct buf *bp;
        register struct filsys *fp;
+       register int i;
 
        (*bdevsw[major(rootdev)].d_open)(rootdev, 1);
        bp = bread(rootdev, SUPERB);
 
        (*bdevsw[major(rootdev)].d_open)(rootdev, 1);
        bp = bread(rootdev, SUPERB);
@@ -161,23 +178,13 @@ iinit()
        fp->s_ronly = 0;
        fp->s_lasti = 1;
        fp->s_nbehind = 0;
        fp->s_ronly = 0;
        fp->s_lasti = 1;
        fp->s_nbehind = 0;
+       fp->s_fsmnt[0] = '/';
+       for (i = 1; i < sizeof(fp->s_fsmnt); i++)
+               fp->s_fsmnt[i] = 0;
        clkinit(fp->s_time);
        bootime = time;
 }
 
        clkinit(fp->s_time);
        bootime = time;
 }
 
-/*
- * This is the set of buffers proper, whose heads
- * were declared in buf.h.  There can exist buffer
- * headers not pointing here that are used purely
- * as arguments to the I/O routines to describe
- * I/O to be done-- e.g. swap headers swbuf[] for
- * swapping.
- *
- * These are actually allocated kernel map slots and space is
- * allocated in locore.s for them.
- */
-char   buffers[NBUF][BSIZE];
-
 /*
  * Initialize the buffer I/O system by freeing
  * all buffers and setting all device buffer lists to empty.
 /*
  * Initialize the buffer I/O system by freeing
  * all buffers and setting all device buffer lists to empty.
@@ -195,10 +202,10 @@ binit()
                dp->b_flags = B_HEAD;
        }
        dp--;                           /* dp = &bfreelist[BQUEUES-1]; */
                dp->b_flags = B_HEAD;
        }
        dp--;                           /* dp = &bfreelist[BQUEUES-1]; */
-       for (i=0; i<NBUF; i++) {
+       for (i=0; i<nbuf; i++) {
                bp = &buf[i];
                bp->b_dev = NODEV;
                bp = &buf[i];
                bp->b_dev = NODEV;
-               bp->b_un.b_addr = buffers[i];
+               bp->b_un.b_addr = buffers + i * BSIZE;
                bp->b_back = dp;
                bp->b_forw = dp->b_forw;
                dp->b_forw->b_back = bp;
                bp->b_back = dp;
                bp->b_forw = dp->b_forw;
                dp->b_forw->b_back = bp;
@@ -218,6 +225,8 @@ binit()
                nswdev++;
        if (nswdev == 0)
                panic("binit");
                nswdev++;
        if (nswdev == 0)
                panic("binit");
+       if (nswdev > 1)
+               nswap = (nswap/DMMAX)*DMMAX;
        nswap *= nswdev;
        maxpgio *= nswdev;
        swfree(0);
        nswap *= nswdev;
        maxpgio *= nswdev;
        swfree(0);
@@ -232,9 +241,33 @@ binit()
 bswinit()
 {
        register int i;
 bswinit()
 {
        register int i;
+       register struct buf *sp = swbuf;
+
+       bswlist.av_forw = sp;
+       for (i=0; i<nswbuf-1; i++, sp++)
+               sp->av_forw = sp+1;
+       sp->av_forw = NULL;
+}
+
+/*
+ * Initialize clist by freeing all character blocks, then count
+ * number of character devices. (Once-only routine)
+ */
+cinit()
+{
+       register int ccp;
+       register struct cblock *cp;
+       register struct cdevsw *cdp;
 
 
-       bswlist.av_forw = &swbuf[0];
-       for (i=0; i<NSWBUF-1; i++)
-               swbuf[i].av_forw = &swbuf[i+1];
-       swbuf[NSWBUF-1].av_forw = NULL;
+       ccp = (int)cfree;
+       ccp = (ccp+CROUND) & ~CROUND;
+       for(cp=(struct cblock *)ccp; cp < &cfree[nclist-1]; cp++) {
+               cp->c_next = cfreelist;
+               cfreelist = cp;
+               cfreecount += CBSIZE;
+       }
+       ccp = 0;
+       for(cdp = cdevsw; cdp->d_open; cdp++)
+               ccp++;
+       nchrdev = ccp;
 }
 }