BSD 4_2 development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Fri, 29 Jul 1983 00:23:10 +0000 (16:23 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Fri, 29 Jul 1983 00:23:10 +0000 (16:23 -0800)
Work on file usr/src/sys/vax/conf.c
Work on file usr/src/sys/vax/clock.h
Work on file usr/src/sys/vax/cons.c
Work on file usr/src/sys/vax/clock.c
Work on file usr/src/sys/vax/cons.h
Work on file usr/src/sys/vax/cpu.h
Work on file usr/src/sys/vax/flp.c
Work on file usr/src/sys/vax/cpudata.c
Work on file usr/src/sys/vax/dkbad.c
Work on file usr/src/sys/vax/dkio.h
Work on file usr/src/sys/vax/flp.h
Work on file usr/src/sys/vax/frame.h
Work on file usr/src/sys/vax/genassym.c
Work on file usr/src/sys/vax/mem.c
Work on file usr/src/sys/vax/in_cksum.c
Work on file usr/src/sys/vax/pcb.h
Work on file usr/src/sys/vax/pcb.m
Work on file usr/src/sys/vax/mem.h
Work on file usr/src/sys/vax/param.h
Work on file usr/src/sys/vax/mtpr.h
Work on file usr/src/sys/vax/mscp.h
Work on file usr/src/sys/vax/psl.h
Work on file usr/src/sys/vax/reg.h
Work on file usr/src/sys/vax/pte.h
Work on file usr/src/sys/vax/rsp.h
Work on file usr/src/sys/vax/pup_cksum.c
Work on file usr/src/sys/vax/rpb.h
Work on file usr/src/sys/vax/sys_machdep.c
Work on file usr/src/sys/vax/udiv.s
Work on file usr/src/sys/vax/trap.h
Work on file usr/src/sys/vax/ufs_machdep.c
Work on file usr/src/sys/vax/vm_machdep.c
Work on file usr/src/sys/vax/vmparam.h
Work on file usr/src/sys/vax/urem.s

Synthesized-from: CSRG/cd1/4.2

34 files changed:
usr/src/sys/vax/clock.c [new file with mode: 0644]
usr/src/sys/vax/clock.h [new file with mode: 0644]
usr/src/sys/vax/conf.c [new file with mode: 0644]
usr/src/sys/vax/cons.c [new file with mode: 0644]
usr/src/sys/vax/cons.h [new file with mode: 0644]
usr/src/sys/vax/cpu.h [new file with mode: 0644]
usr/src/sys/vax/cpudata.c [new file with mode: 0644]
usr/src/sys/vax/dkbad.c [new file with mode: 0644]
usr/src/sys/vax/dkio.h [new file with mode: 0644]
usr/src/sys/vax/flp.c [new file with mode: 0644]
usr/src/sys/vax/flp.h [new file with mode: 0644]
usr/src/sys/vax/frame.h [new file with mode: 0644]
usr/src/sys/vax/genassym.c [new file with mode: 0644]
usr/src/sys/vax/in_cksum.c [new file with mode: 0644]
usr/src/sys/vax/mem.c [new file with mode: 0644]
usr/src/sys/vax/mem.h [new file with mode: 0644]
usr/src/sys/vax/mscp.h [new file with mode: 0644]
usr/src/sys/vax/mtpr.h [new file with mode: 0644]
usr/src/sys/vax/param.h [new file with mode: 0644]
usr/src/sys/vax/pcb.h [new file with mode: 0644]
usr/src/sys/vax/pcb.m [new file with mode: 0644]
usr/src/sys/vax/psl.h [new file with mode: 0644]
usr/src/sys/vax/pte.h [new file with mode: 0644]
usr/src/sys/vax/pup_cksum.c [new file with mode: 0644]
usr/src/sys/vax/reg.h [new file with mode: 0644]
usr/src/sys/vax/rpb.h [new file with mode: 0644]
usr/src/sys/vax/rsp.h [new file with mode: 0644]
usr/src/sys/vax/sys_machdep.c [new file with mode: 0644]
usr/src/sys/vax/trap.h [new file with mode: 0644]
usr/src/sys/vax/udiv.s [new file with mode: 0644]
usr/src/sys/vax/ufs_machdep.c [new file with mode: 0644]
usr/src/sys/vax/urem.s [new file with mode: 0644]
usr/src/sys/vax/vm_machdep.c [new file with mode: 0644]
usr/src/sys/vax/vmparam.h [new file with mode: 0644]

diff --git a/usr/src/sys/vax/clock.c b/usr/src/sys/vax/clock.c
new file mode 100644 (file)
index 0000000..b378151
--- /dev/null
@@ -0,0 +1,122 @@
+/*     clock.c 6.1     83/07/29        */
+
+#include "../h/param.h"
+#include "../h/time.h"
+#include "../h/kernel.h"
+
+#include "../vax/mtpr.h"
+#include "../vax/clock.h"
+
+/*
+ * Machine-dependent clock routines.
+ *
+ * Startrtclock restarts the real-time clock, which provides
+ * hardclock interrupts to kern_clock.c.
+ *
+ * Inittodr initializes the time of day hardware which provides
+ * date functions.  Its primary function is to use some file
+ * system information in case the hardare clock lost state.
+ *
+ * Resettodr restores the time of day hardware after a time change.
+ */
+
+/*
+ * Start the real-time clock.
+ */
+startrtclock()
+{
+
+       mtpr(NICR, -1000000/hz);
+       mtpr(ICCS, ICCS_RUN+ICCS_IE+ICCS_TRANS+ICCS_INT+ICCS_ERR);
+}
+
+/*
+ * Initialze the time of day register, based on the time base which is, e.g.
+ * from a filesystem.  Base provides the time to within six months,
+ * and the time of year clock provides the rest.
+ */
+inittodr(base)
+       time_t base;
+{
+       register u_int todr = mfpr(TODR);
+       long deltat;
+       int year = YRREF;
+
+       if (base < 5*SECYR) {
+               printf("WARNING: preposterous time in file system");
+               time.tv_sec = 6*SECYR + 186*SECDAY + SECDAY/2;
+               resettodr();
+               goto check;
+       }
+       /*
+        * TODRZERO is base used by VMS, which runs on local time.
+        */
+       if (todr < TODRZERO) {
+               printf("WARNING: todr too small");
+               time.tv_sec = base;
+               /*
+                * Believe the time in the file system for lack of
+                * anything better, resetting the TODR.
+                */
+               resettodr();
+               goto check;
+       }
+
+       /*
+        * Sneak to within 6 month of the time in the filesystem,
+        * by starting with the time of the year suggested by the TODR,
+        * and advancing through succesive years.  Adding the number of
+        * seconds in the current year takes us to the end of the current year
+        * and then around into the next year to the same position.
+        */
+       time.tv_sec = (todr-TODRZERO)/100;
+       while (time.tv_sec < base-SECYR/2) {
+               if (LEAPYEAR(year))
+                       time.tv_sec += SECDAY;
+               year++;
+               time.tv_sec += SECYR;
+       }
+
+       /*
+        * See if we gained/lost two or more days;
+        * if so, assume something is amiss.
+        */
+       deltat = time.tv_sec - base;
+       if (deltat < 0)
+               deltat = -deltat;
+       if (deltat < 2*SECDAY)
+               return;
+       printf("WARNING: clock %s %d days",
+           time.tv_sec < base ? "lost" : "gained", deltat / SECDAY);
+check:
+       printf(" -- CHECK AND RESET THE DATE!\n");
+}
+
+/*
+ * Reset the TODR based on the time value; used when the TODR
+ * has a preposterous value and also when the time is reset
+ * by the stime system call.  Also called when the TODR goes past
+ * TODRZERO + 100*(SECYEAR+2*SECDAY) (e.g. on Jan 2 just after midnight)
+ * to wrap the TODR around.
+ */
+resettodr()
+{
+       int year = YRREF;
+       u_int secyr;
+       u_int yrtime = time.tv_sec;
+
+       /*
+        * Whittle the time down to an offset in the current year,
+        * by subtracting off whole years as long as possible.
+        */
+       for (;;) {
+               secyr = SECYR;
+               if (LEAPYEAR(year))
+                       secyr += SECDAY;
+               if (yrtime < secyr)
+                       break;
+               yrtime -= secyr;
+               year++;
+       }
+       mtpr(TODR, TODRZERO + yrtime*100);
+}
diff --git a/usr/src/sys/vax/clock.h b/usr/src/sys/vax/clock.h
new file mode 100644 (file)
index 0000000..3c7913a
--- /dev/null
@@ -0,0 +1,33 @@
+/*     clock.h 6.1     83/07/29        */
+
+/*
+ * VAX clock registers
+ */
+
+#define        ICCS_RUN        0x00000001
+#define        ICCS_TRANS      0x00000010
+#define        ICCS_SS         0x00000020
+#define        ICCS_IE         0x00000040
+#define        ICCS_INT        0x00000080
+#define        ICCS_ERR        0x80000000
+       
+#define        SECDAY          ((unsigned)(24*60*60))          /* seconds per day */
+#define        SECYR           ((unsigned)(365*SECDAY))        /* per common year */
+/*
+ * TODRZERO is the what the TODR should contain when the ``year'' begins.
+ * The TODR should always contain a number between 0 and SECYR+SECDAY.
+ */
+#define        TODRZERO        ((unsigned)(1<<28))
+
+#define        YRREF           1970
+#define        LEAPYEAR(year)  ((year)%4==0)   /* good till time becomes negative */
+
+/*
+ * Has the time-of-day clock wrapped around?
+ */
+#define        clkwrap()       (((unsigned)mfpr(TODR) - TODRZERO)/100 > SECYR+SECDAY)
+
+/*
+ * Software clock is software interrupt level 8,
+ * implemented as mtpr(SIRR, 0x8) in asm.sed.
+ */
diff --git a/usr/src/sys/vax/conf.c b/usr/src/sys/vax/conf.c
new file mode 100644 (file)
index 0000000..da88f09
--- /dev/null
@@ -0,0 +1,564 @@
+/*     conf.c  6.1     83/07/29        */
+
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/buf.h"
+#include "../h/tty.h"
+#include "../h/conf.h"
+
+int    nulldev();
+int    nodev();
+
+#include "hp.h"
+#if NHP > 0
+int    hpopen(),hpstrategy(),hpread(),hpwrite(),hpdump(),hpioctl(),hpsize();
+#else
+#define        hpopen          nodev
+#define        hpstrategy      nodev
+#define        hpread          nodev
+#define        hpwrite         nodev
+#define        hpdump          nodev
+#define        hpioctl         nodev
+#define        hpsize          0
+#endif
+#include "tu.h"
+#if NHT > 0
+int    htopen(),htclose(),htstrategy(),htread(),htwrite(),htdump(),htioctl();
+#else
+#define        htopen          nodev
+#define        htclose         nodev
+#define        htstrategy      nodev
+#define        htread          nodev
+#define        htwrite         nodev
+#define        htdump          nodev
+#define        htioctl         nodev
+#endif
+
+#include "rk.h"
+#if NHK > 0
+int    rkopen(),rkstrategy(),rkread(),rkwrite(),rkintr();
+int    rkdump(),rkreset(),rksize();
+#else
+#define        rkopen          nodev
+#define        rkstrategy      nodev
+#define        rkread          nodev
+#define        rkwrite         nodev
+#define        rkintr          nodev
+#define        rkdump          nodev
+#define        rkreset         nodev
+#define        rksize          0
+#endif
+
+#include "te.h"
+#if NTE > 0
+int    tmopen(),tmclose(),tmstrategy(),tmread(),tmwrite();
+int    tmioctl(),tmdump(),tmreset();
+#else
+#define        tmopen          nodev
+#define        tmclose         nodev
+#define        tmstrategy      nodev
+#define        tmread          nodev
+#define        tmwrite         nodev
+#define        tmioctl         nodev
+#define        tmdump          nodev
+#define        tmreset         nodev
+#endif
+
+#include "ts.h"
+#if NTS > 0
+int    tsopen(),tsclose(),tsstrategy(),tsread(),tswrite();
+int    tsioctl(),tsdump(),tsreset();
+#else
+#define        tsopen          nodev
+#define        tsclose         nodev
+#define        tsstrategy      nodev
+#define        tsread          nodev
+#define        tswrite         nodev
+#define        tsioctl         nodev
+#define        tsdump          nodev
+#define        tsreset         nodev
+#endif
+
+#include "mu.h"
+#if NMT > 0
+int    mtopen(),mtclose(),mtstrategy(),mtread(),mtwrite();
+int    mtioctl(),mtdump();
+#else
+#define        mtopen          nodev
+#define        mtclose         nodev
+#define        mtstrategy      nodev
+#define        mtread          nodev
+#define        mtwrite         nodev
+#define        mtioctl         nodev
+#define        mtdump          nodev
+#endif
+
+#include "ra.h"
+#if NUDA > 0
+int    udopen(),udstrategy(),udread(),udwrite(),udreset(),uddump(),udsize();
+#else
+#define        udopen          nodev
+#define        udstrategy      nodev
+#define        udread          nodev
+#define        udwrite         nodev
+#define        udreset         nulldev
+#define        uddump          nodev
+#define        udsize          0
+#endif
+
+#include "up.h"
+#if NSC > 0
+int    upopen(),upstrategy(),upread(),upwrite(),upreset(),updump(),upsize();
+#else
+#define        upopen          nodev
+#define        upstrategy      nodev
+#define        upread          nodev
+#define        upwrite         nodev
+#define        upreset         nulldev
+#define        updump          nodev
+#define        upsize          0
+#endif
+
+#include "tj.h"
+#if NUT > 0
+int    utopen(),utclose(),utstrategy(),utread(),utwrite(),utioctl();
+int    utreset(),utdump();
+#else
+#define        utopen          nodev
+#define        utclose         nodev
+#define        utread          nodev
+#define        utstrategy      nodev
+#define        utwrite         nodev
+#define        utreset         nulldev
+#define        utioctl         nodev
+#define        utdump          nodev
+#endif
+
+#include "rb.h"
+#if NIDC > 0
+int    idcopen(),idcstrategy(),idcread(),idcwrite();
+int    idcreset(),idcdump(),idcsize();;
+#else
+#define        idcopen         nodev
+#define        idcstrategy     nodev
+#define        idcread         nodev
+#define        idcwrite        nodev
+#define        idcreset        nulldev
+#define        idcdump         nodev
+#define        idcsize         0
+#endif
+
+#if defined(VAX750) || defined(VAX730)
+int    tuopen(),tuclose(),tustrategy();
+#else
+#define        tuopen          nodev
+#define        tuclose         nodev
+#define        tustrategy      nodev
+#endif
+
+#include "rx.h"
+#if NFX > 0
+int    rxopen(),rxstrategy(),rxclose(),rxread(),rxwrite(),rxreset(),rxioctl();
+#else
+#define        rxopen          nodev
+#define rxstrategy     nodev
+#define        rxclose         nodev
+#define        rxread          nodev
+#define        rxwrite         nodev
+#define        rxreset         nulldev
+#define        rxioctl         nodev
+#endif
+
+#include "uu.h"
+#if NUU > 0
+int    uuopen(),uustrategy(),uuclose(),uureset(),uuioctl();
+#else
+#define        uuopen          nodev
+#define uustrategy     nodev
+#define        uuclose         nodev
+#define        uureset         nulldev
+#define        uuioctl         nodev
+#endif
+
+#include "rl.h"
+#if NRL > 0
+int    rlopen(),rlstrategy(),rlread(),rlwrite();
+int    rlreset(),rldump(),rlsize();
+#else
+#define        rlopen          nodev
+#define        rlstrategy      nodev
+#define        rlread          nodev
+#define        rlwrite         nodev
+#define        rlreset         nulldev
+#define        rldump          nodev
+#define        rlsize          0
+#endif
+
+int    swstrategy(),swread(),swwrite();
+
+struct bdevsw  bdevsw[] =
+{
+       { hpopen,       nulldev,        hpstrategy,     hpdump,         /*0*/
+         hpsize,       0 },
+       { htopen,       htclose,        htstrategy,     htdump,         /*1*/
+         0,            B_TAPE },
+       { upopen,       nulldev,        upstrategy,     updump,         /*2*/
+         upsize,       0 },
+       { rkopen,       nulldev,        rkstrategy,     rkdump,         /*3*/
+         rksize,       0 },
+       { nodev,        nodev,          swstrategy,     nodev,          /*4*/
+         0,            0 },
+       { tmopen,       tmclose,        tmstrategy,     tmdump,         /*5*/
+         0,            B_TAPE },
+       { tsopen,       tsclose,        tsstrategy,     tsdump,         /*6*/
+         0,            B_TAPE },
+       { mtopen,       mtclose,        mtstrategy,     mtdump,         /*7*/
+         0,            B_TAPE },
+       { tuopen,       tuclose,        tustrategy,     nodev,          /*8*/
+         0,            B_TAPE },
+       { udopen,       nulldev,        udstrategy,     uddump,         /*9*/
+         udsize,       0 },
+       { utopen,       utclose,        utstrategy,     utdump,         /*10*/
+         0,            B_TAPE },
+       { idcopen,      nodev,          idcstrategy,    idcdump,        /*11*/
+         idcsize,      0 },
+       { rxopen,       rxclose,        rxstrategy,     nodev,          /*12*/
+         0,            0 },
+       { uuopen,       uuclose,        uustrategy,     nodev,          /*13*/
+         0,            0 },
+       { rlopen,       nodev,          rlstrategy,     rldump,         /*14*/
+         rlsize,       0 },
+};
+int    nblkdev = sizeof (bdevsw) / sizeof (bdevsw[0]);
+
+int    cnopen(),cnclose(),cnread(),cnwrite(),cnioctl();
+struct tty cons;
+
+#include "acc.h"
+#if NACC > 0
+int     accreset();
+#else
+#define accreset nulldev
+#endif
+
+#include "ct.h"
+#if NCT > 0
+int    ctopen(),ctclose(),ctwrite();
+#else
+#define        ctopen  nulldev
+#define        ctclose nulldev
+#define        ctwrite nulldev
+#endif
+
+#include "dh.h"
+#if NDH == 0
+#define        dhopen  nodev
+#define        dhclose nodev
+#define        dhread  nodev
+#define        dhwrite nodev
+#define        dhioctl nodev
+#define        dhstop  nodev
+#define        dhreset nulldev
+#define        dh11    0
+#else
+int    dhopen(),dhclose(),dhread(),dhwrite(),dhioctl(),dhstop(),dhreset();
+struct tty dh11[];
+#endif
+
+#include "dmf.h"
+#if NDMF == 0
+#define        dmfopen nodev
+#define        dmfclose        nodev
+#define        dmfread nodev
+#define        dmfwrite        nodev
+#define        dmfioctl        nodev
+#define        dmfstop nodev
+#define        dmfreset        nulldev
+#define        dmf_tty 0
+#else
+int    dmfopen(),dmfclose(),dmfread(),dmfwrite(),dmfioctl(),dmfstop(),dmfreset();
+struct tty dmf_tty[];
+#endif
+
+#if VAX780
+int    flopen(),flclose(),flread(),flwrite();
+#else
+#define        flopen  nodev
+#define        flclose nodev
+#define        flread  nodev
+#define        flwrite nodev
+#endif
+
+#include "dz.h"
+#if NDZ == 0
+#define        dzopen  nodev
+#define        dzclose nodev
+#define        dzread  nodev
+#define        dzwrite nodev
+#define        dzioctl nodev
+#define        dzstop  nodev
+#define        dzreset nulldev
+#define        dz_tty  0
+#else
+int    dzopen(),dzclose(),dzread(),dzwrite(),dzioctl(),dzstop(),dzreset();
+struct tty dz_tty[];
+#endif
+
+#include "lp.h"
+#if NLP > 0
+int    lpopen(),lpclose(),lpwrite(),lpreset();
+#else
+#define        lpopen          nodev
+#define        lpclose         nodev
+#define        lpwrite         nodev
+#define        lpreset         nulldev
+#endif
+
+int    syopen(),syread(),sywrite(),syioctl(),syselect();
+
+int    mmread(),mmwrite();
+#define        mmselect        seltrue
+
+#include "va.h"
+#if NVA > 0
+int    vaopen(),vaclose(),vawrite(),vaioctl(),vareset(),vaselect();
+#else
+#define        vaopen          nodev
+#define        vaclose         nodev
+#define        vawrite         nodev
+#define        vaopen          nodev
+#define        vaioctl         nodev
+#define        vareset         nulldev
+#define        vaselect        nodev
+#endif
+
+#include "vp.h"
+#if NVP > 0
+int    vpopen(),vpclose(),vpwrite(),vpioctl(),vpreset(),vpselect();
+#else
+#define        vpopen          nodev
+#define        vpclose         nodev
+#define        vpwrite         nodev
+#define        vpioctl         nodev
+#define        vpreset         nulldev
+#define        vpselect        nodev
+#endif
+
+#include "pty.h"
+#if NPTY > 0
+int    ptsopen(),ptsclose(),ptsread(),ptswrite(),ptsstop();
+int    ptcopen(),ptcclose(),ptcread(),ptcwrite(),ptcselect();
+int    ptyioctl();
+struct tty pt_tty[];
+#else
+#define ptsopen                nodev
+#define ptsclose       nodev
+#define ptsread                nodev
+#define ptswrite       nodev
+#define ptcopen                nodev
+#define ptcclose       nodev
+#define ptcread                nodev
+#define ptcwrite       nodev
+#define ptyioctl       nodev
+#define        pt_tty          0
+#define        ptcselect       nodev
+#define        ptsstop         nulldev
+#endif
+
+#include "lpa.h"
+#if NLPA > 0
+int    lpaopen(),lpaclose(),lparead(),lpawrite(),lpaioctl();
+#else
+#define        lpaopen         nodev
+#define        lpaclose        nodev
+#define        lparead         nodev
+#define        lpawrite        nodev
+#define        lpaioctl        nodev
+#endif
+
+#include "dn.h"
+#if NDN > 0
+int    dnopen(),dnclose(),dnwrite();
+#else
+#define        dnopen          nodev
+#define        dnclose         nodev
+#define        dnwrite         nodev
+#endif
+
+#include "gpib.h"
+#if NGPIB > 0
+int    gpibopen(),gpibclose(),gpibread(),gpibwrite(),gpibioctl();
+#else
+#define        gpibopen        nodev
+#define        gpibclose       nodev
+#define        gpibread        nodev
+#define        gpibwrite       nodev
+#define        gpibioctl       nodev
+#endif
+
+#include "ik.h"
+#if NIK > 0
+int    ikopen(),ikclose(),ikread(),ikwrite(),ikioctl(),ikreset();
+#else
+#define ikopen nodev
+#define ikclose nodev
+#define ikread nodev
+#define ikwrite nodev
+#define ikioctl nodev
+#define ikreset nodev
+#endif
+
+#include "ps.h"
+#if NPS > 0
+int    psopen(),psclose(),psread(),pswrite(),psioctl(),psreset();
+#else
+#define psopen nodev
+#define psclose nodev
+#define psread nodev
+#define pswrite nodev
+#define psopen nodev
+#define psioctl nodev
+#define psreset nodev
+#endif
+
+#include "ib.h"
+#if NIB > 0
+int    ibopen(),ibclose(),ibread(),ibwrite(),ibioctl();
+#else
+#define        ibopen  nodev
+#define        ibclose nodev
+#define        ibread  nodev
+#define        ibwrite nodev
+#define        ibioctl nodev
+#endif
+
+#include "ad.h"
+#if NAD > 0
+int    adopen(),adclose(),adioctl(),adreset();
+#else
+#define adopen nodev
+#define adclose nodev
+#define adioctl nodev
+#define adreset nodev
+#endif
+
+int    ttselect(), seltrue();
+
+struct cdevsw  cdevsw[] =
+{
+       cnopen,         cnclose,        cnread,         cnwrite,        /*0*/
+       cnioctl,        nulldev,        nulldev,        &cons,
+       ttselect,       nodev,
+       dzopen,         dzclose,        dzread,         dzwrite,        /*1*/
+       dzioctl,        dzstop,         dzreset,        dz_tty,
+       ttselect,       nodev,
+       syopen,         nulldev,        syread,         sywrite,        /*2*/
+       syioctl,        nulldev,        nulldev,        0,
+       syselect,       nodev,
+       nulldev,        nulldev,        mmread,         mmwrite,        /*3*/
+       nodev,          nulldev,        nulldev,        0,
+       mmselect,       nodev,
+       hpopen,         nulldev,        hpread,         hpwrite,        /*4*/
+       hpioctl,        nodev,          nulldev,        0,
+       seltrue,        nodev,
+       htopen,         htclose,        htread,         htwrite,        /*5*/
+       htioctl,        nodev,          nulldev,        0,
+       seltrue,        nodev,
+       vpopen,         vpclose,        nodev,          vpwrite,        /*6*/
+       vpioctl,        nulldev,        vpreset,        0,
+       vpselect,       nodev,
+       nulldev,        nulldev,        swread,         swwrite,        /*7*/
+       nodev,          nodev,          nulldev,        0,
+       nodev,          nodev,
+       flopen,         flclose,        flread,         flwrite,        /*8*/
+       nodev,          nodev,          nulldev,        0,
+       seltrue,        nodev,
+       udopen,         nulldev,        udread,         udwrite,        /*9*/
+       nodev,          nodev,          udreset,                0,
+       seltrue,        nodev,
+       vaopen,         vaclose,        nodev,          vawrite,        /*10*/
+       vaioctl,        nulldev,        vareset,        0,
+       vaselect,       nodev,
+       rkopen,         nulldev,        rkread,         rkwrite,        /*11*/
+       nodev,          nodev,          rkreset,        0,
+       seltrue,        nodev,
+       dhopen,         dhclose,        dhread,         dhwrite,        /*12*/
+       dhioctl,        dhstop,         dhreset,        dh11,
+       ttselect,       nodev,
+       upopen,         nulldev,        upread,         upwrite,        /*13*/
+       nodev,          nodev,          upreset,        0,
+       seltrue,        nodev,
+       tmopen,         tmclose,        tmread,         tmwrite,        /*14*/
+       tmioctl,        nodev,          tmreset,        0,
+       seltrue,        nodev,
+       lpopen,         lpclose,        nodev,          lpwrite,        /*15*/
+       nodev,          nodev,          lpreset,        0,
+       seltrue,        nodev,
+       tsopen,         tsclose,        tsread,         tswrite,        /*16*/
+       tsioctl,        nodev,          tsreset,        0,
+       seltrue,        nodev,
+       utopen,         utclose,        utread,         utwrite,        /*17*/
+       utioctl,        nodev,          utreset,        0,
+       seltrue,        nodev,
+       ctopen,         ctclose,        nodev,          ctwrite,        /*18*/
+       nodev,          nodev,          nulldev,        0,
+       seltrue,        nodev,
+       mtopen,         mtclose,        mtread,         mtwrite,        /*19*/
+       mtioctl,        nodev,          nodev,          0,
+       seltrue,        nodev,
+       ptsopen,        ptsclose,       ptsread,        ptswrite,       /*20*/
+       ptyioctl,       ptsstop,        nodev,          pt_tty,
+       ttselect,       nodev,
+       ptcopen,        ptcclose,       ptcread,        ptcwrite,       /*21*/
+       ptyioctl,       nulldev,        nodev,          pt_tty,
+       ptcselect,      nodev,
+       dmfopen,        dmfclose,       dmfread,        dmfwrite,       /*22*/
+       dmfioctl,       dmfstop,        dmfreset,       dmf_tty,
+       ttselect,       nodev,
+       idcopen,        nulldev,        idcread,        idcwrite,       /*23*/
+       nodev,          nodev,          idcreset,       0,
+       seltrue,        nodev,
+       dnopen,         dnclose,        nodev,          dnwrite,        /*24*/
+       nodev,          nodev,          nodev,          0,
+       seltrue,        nodev,
+/* 25-29 reserved to local sites */
+       gpibopen,       gpibclose,      gpibread,       gpibwrite,      /*25*/
+       gpibioctl,      nulldev,        nodev,          0,
+       seltrue,        nodev,
+       lpaopen,        lpaclose,       lparead,        lpawrite,       /*26*/
+       lpaioctl,       nodev,          nulldev,        0,
+       seltrue,        nodev,
+       psopen,         psclose,        psread,         pswrite,        /*27*/
+       psioctl,        nodev,          psreset,        0,
+       seltrue,        nodev,
+       ibopen,         ibclose,        ibread,         ibwrite,        /*28*/
+       ibioctl,        nodev,          nodev,          0,
+       seltrue,        nodev,
+       adopen,         adclose,        nodev,          nodev,          /*29*/
+       adioctl,        nodev,          adreset,        0,
+       seltrue,        nodev,
+       rxopen,         rxclose,        rxread,         rxwrite,        /*30*/
+       rxioctl,        nodev,          rxreset,        0,
+       seltrue,        nodev,
+       ikopen,         ikclose,        ikread,         ikwrite,        /*31*/
+       ikioctl,        nodev,          ikreset,        0,
+       seltrue,        nodev,
+       rlopen,         nodev,          rlread,         rlwrite,        /* 32 */
+       nodev,          nodev,          rlreset,        0,
+       seltrue,        nodev,
+};
+int    nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
+
+int    mem_no = 3;     /* major device number of memory special file */
+
+/*
+ * Swapdev is a fake device implemented
+ * in sw.c used only internally to get to swstrategy.
+ * It cannot be provided to the users, because the
+ * swstrategy routine munches the b_dev and b_blkno entries
+ * before calling the appropriate driver.  This would horribly
+ * confuse, e.g. the hashing routines. Instead, /dev/drum is
+ * provided as a character (raw) device.
+ */
+dev_t  swapdev = makedev(4, 0);
diff --git a/usr/src/sys/vax/cons.c b/usr/src/sys/vax/cons.c
new file mode 100644 (file)
index 0000000..72ba286
--- /dev/null
@@ -0,0 +1,206 @@
+/*     cons.c  6.1     83/07/29        */
+
+/*
+ * VAX console driver (and floppy interface)
+ */
+#include "../h/param.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/ioctl.h"
+#include "../h/tty.h"
+#include "../h/systm.h"
+#include "../h/uio.h"
+
+#include "../vax/cpu.h"
+#include "../vax/cons.h"
+#include "../vax/mtpr.h"
+
+struct tty cons;
+int    cnstart();
+int    ttrstrt();
+char   partab[];
+
+/*ARGSUSED*/
+cnopen(dev, flag)
+       dev_t dev;
+{
+       register struct tty *tp = &cons;
+
+       tp->t_oproc = cnstart;
+       if ((tp->t_state&TS_ISOPEN) == 0) {
+               ttychars(tp);
+               tp->t_state = TS_ISOPEN|TS_CARR_ON;
+               tp->t_flags = EVENP|ECHO|XTABS|CRMOD;
+       }
+       if (tp->t_state&TS_XCLUDE && u.u_uid != 0)
+               return (EBUSY);
+       mtpr(RXCS, mfpr(RXCS)|RXCS_IE);
+       mtpr(TXCS, mfpr(TXCS)|TXCS_IE);
+       return ((*linesw[tp->t_line].l_open)(dev, tp));
+}
+
+/*ARGSUSED*/
+cnclose(dev)
+       dev_t dev;
+{
+       register struct tty *tp = &cons;
+
+       (*linesw[tp->t_line].l_close)(tp);
+       ttyclose(tp);
+}
+
+/*ARGSUSED*/
+cnread(dev, uio)
+       dev_t dev;
+       struct uio *uio;
+{
+       register struct tty *tp = &cons;
+
+       return ((*linesw[tp->t_line].l_read)(tp, uio));
+}
+
+/*ARGSUSED*/
+cnwrite(dev, uio)
+       dev_t dev;
+       struct uio *uio;
+{
+       register struct tty *tp = &cons;
+
+       return ((*linesw[tp->t_line].l_write)(tp, uio));
+}
+
+/*
+ * Got a level-20 receive interrupt -
+ * the LSI wants to give us a character.
+ * Catch the character, and see who it goes to.
+ */
+/*ARGSUSED*/
+cnrint(dev)
+       dev_t dev;
+{
+       register int c;
+       register struct tty *tp;
+
+       c = mfpr(RXDB);
+       if (c&RXDB_ID) {
+#if VAX780
+               if (cpu == VAX_780)
+                       cnrfl(c);
+#endif
+               return;
+       }
+       tp = &cons;
+       (*linesw[tp->t_line].l_rint)(c, tp);
+}
+
+/*ARGSUSED*/
+cnioctl(dev, cmd, addr, flag)
+       dev_t dev;
+       caddr_t addr;
+{
+       register struct tty *tp = &cons;
+       int error;
+       error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, addr);
+       if (error >= 0)
+               return (error);
+       error = ttioctl(tp, cmd, addr, flag);
+       if (error < 0)
+               error = ENOTTY;
+       return (error);
+}
+
+int    consdone = 1;
+/*
+ * Got a level-20 transmission interrupt -
+ * the LSI wants another character.  First,
+ * see if we can send something to the typewriter.
+ * If not, try the floppy.
+ */
+/*ARGSUSED*/
+cnxint(dev)
+       dev_t dev;
+{
+       register struct tty *tp = &cons;
+
+       consdone++;
+       tp->t_state &= ~TS_BUSY;
+       if (tp->t_line)
+               (*linesw[tp->t_line].l_start)(tp);
+       else
+               cnstart(tp);
+#if VAX780
+       if (cpu==VAX_780 && (tp->t_state & TS_BUSY) == 0)
+               conxfl();
+#endif
+}
+
+cnstart(tp)
+       register struct tty *tp;
+{
+       register int c, s;
+
+       s = spl5();
+       if (tp->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP))
+               goto out;
+       if (tp->t_outq.c_cc <= TTLOWAT(tp)) {
+               if (tp->t_state&TS_ASLEEP) {
+                       tp->t_state &= ~TS_ASLEEP;
+                       wakeup((caddr_t)&tp->t_outq);
+               }
+               if (tp->t_wsel) {
+                       selwakeup(tp->t_wsel, tp->t_state & TS_WCOLL);
+                       tp->t_wsel = 0;
+                       tp->t_state &= ~TS_WCOLL;
+               }
+       }
+       if (tp->t_outq.c_cc == 0)
+               goto out;
+       if (consdone == 0)
+               return;
+       c = getc(&tp->t_outq);
+       if (tp->t_flags&(RAW|LITOUT))
+               mtpr(TXDB, c&0xff);
+       else if (c <= 0177)
+               mtpr(TXDB, (c | (partab[c]&0200))&0xff);
+       else {
+               timeout(ttrstrt, (caddr_t)tp, (c&0177));
+               tp->t_state |= TS_TIMEOUT;
+               goto out;
+       }
+       consdone = 0;
+       tp->t_state |= TS_BUSY;
+out:
+       splx(s);
+}
+
+/*
+ * Print a character on console.
+ * Attempts to save and restore device
+ * status.
+ */
+cnputc(c)
+       register int c;
+{
+       register int s, timo;
+
+       timo = 30000;
+       /*
+        * Try waiting for the console tty to come ready,
+        * otherwise give up after a reasonable time.
+        */
+       while ((mfpr(TXCS)&TXCS_RDY) == 0)
+               if(--timo == 0)
+                       break;
+       if (c == 0)
+               return;
+       s = mfpr(TXCS);
+       mtpr(TXCS, 0);
+       mtpr(TXDB, c&0xff);
+       if (c == '\n')
+               cnputc('\r');
+       cnputc(0);
+       mtpr(TXCS, s);
+}
diff --git a/usr/src/sys/vax/cons.h b/usr/src/sys/vax/cons.h
new file mode 100644 (file)
index 0000000..83c3939
--- /dev/null
@@ -0,0 +1,22 @@
+/*     cons.h  6.1     83/07/29        */
+
+/*
+ * VAX console interface registers
+ */
+
+#define        RXCS_IE         0x00000040      /* receiver interrupt enable */
+#define        RXCS_DONE       0x00000080      /* receiver done */
+
+#define        RXDB_DATA       0x000000ff      /* received character */
+#define        RXDB_ID         0x00000f00      /* channel id */
+#define        RXDB_ERR        0x80000000      /* receiver error */
+
+#define        TXCS_IE         0x00000040      /* transmitter interrupt enable */
+#define        TXCS_RDY        0x00000080      /* transmitter ready for next char */
+#define        TXDB_DATA       0x000000ff      /* transmitter byte */
+#define        TXDB_ID         0x00000f00      /* channel id */
+
+#define        TXDB_DONE       0xf01           /* software done */
+#define        TXDB_BOOT       0xf02           /* reboot */
+#define        TXDB_CWSI       0xf03           /* clear warm start inhibit */
+#define        TXDB_CCSI       0xf04           /* clear cold-start inhibit */
diff --git a/usr/src/sys/vax/cpu.h b/usr/src/sys/vax/cpu.h
new file mode 100644 (file)
index 0000000..db8e980
--- /dev/null
@@ -0,0 +1,58 @@
+/*     cpu.h   6.1     83/07/29        */
+
+#ifndef LOCORE
+/*
+ * Cpu identification, from SID register.
+ */
+union cpusid {
+       int     cpusid;
+       struct cpuany {
+               u_int   :24,
+                       cp_type:8;
+       } cpuany;
+       struct cpu780 {
+               u_int   cp_sno:12,              /* serial number */
+                       cp_plant:3,             /* plant number */
+                       cp_eco:9,               /* eco level */
+                       cp_type:8;              /* VAX_780 */
+       } cpu780;
+       struct cpu750 {
+               u_int   cp_hrev:8,              /* hardware rev level */
+                       cp_urev:8,              /* ucode rev level */
+                       :8,
+                       cp_type:8;              /* VAX_750 */
+       } cpu750;
+       /* need structure for 730 */
+};
+#endif
+#define        VAX_780         1
+#define        VAX_750         2
+#define        VAX_730         3
+
+#define        VAX_MAX         3
+
+#ifndef LOCORE
+/*
+ * Per-cpu information for system.
+ */
+struct percpu {
+       short   pc_cputype;             /* cpu type code */
+       short   pc_nnexus;              /* number of nexus slots */
+       struct  nexus *pc_nexbase;      /* base of nexus space */
+/* we should be able to have just one address for the unibus memories */
+/* and calculate successive addresses by adding to the base, but the 750 */
+/* doesn't obey the sensible rule: uba1 has a lower address than uba0! */
+       caddr_t *pc_umaddr;             /* unibus memory addresses */
+       short   pc_nubabdp;             /* number of bdp's per uba */
+       short   pc_haveubasr;           /* have uba status register */
+/* the 750 has some slots which don't promise to tell you their types */
+/* if this pointer is non-zero, then you get the type from this array */
+/* rather than from the (much more sensible) low byte of the config register */
+       short   *pc_nextype;            /* botch */
+};
+
+#ifdef KERNEL
+int    cpu;
+struct percpu percpu[];
+#endif
+#endif
diff --git a/usr/src/sys/vax/cpudata.c b/usr/src/sys/vax/cpudata.c
new file mode 100644 (file)
index 0000000..fe1487f
--- /dev/null
@@ -0,0 +1,67 @@
+/*     cpudata.c       6.1     83/07/29        */
+
+#include "../machine/pte.h"
+
+#include "../h/param.h"
+
+#include "../vax/cpu.h"
+#include "../vax/nexus.h"
+#include "../vaxuba/ubareg.h"
+
+/*
+ * Initialization of per-cpu data structures.
+ */
+
+/*
+ * These are the (fixed) addresses of the (last 8k bytes of)
+ * unibus memory for each of the possible unibus adapters.  Note that the
+ * unibus memory addresses are actually indexed by the unibus adapter type code.
+ */
+#if VAX780
+caddr_t        umaddr780[4] = {
+       (caddr_t) UMEM780(0), (caddr_t) UMEM780(1),
+       (caddr_t) UMEM780(2), (caddr_t) UMEM780(3)
+};
+#endif
+#if VAX750
+caddr_t        umaddr750[2] = {
+       (caddr_t) UMEM750(0), (caddr_t) UMEM750(1),
+};
+#endif
+#if VAX730
+caddr_t        umaddr730[1] = {
+       (caddr_t) UMEM730
+};
+#endif
+
+/*
+ * Information to patch around the stupidity of configuration
+ * registers not returning types on some of the processors.
+ */
+#if VAX750
+short  nexty750[NNEX750] = {
+       NEX_MEM16,      NEX_MEM16,      NEX_MEM16,      NEX_MEM16,
+       NEX_MBA,        NEX_MBA,        NEX_MBA,        NEX_MBA,
+       NEX_UBA0,       NEX_UBA1,       NEX_ANY,        NEX_ANY,
+       NEX_ANY,        NEX_ANY,        NEX_ANY,        NEX_ANY
+};
+#endif
+#if VAX730
+short  nexty730[NNEX730] = {
+       NEX_MEM16,      NEX_ANY,        NEX_ANY,        NEX_ANY,
+       NEX_ANY,        NEX_ANY,        NEX_ANY,        NEX_ANY,
+};
+#endif
+
+struct percpu percpu[] = {
+#if VAX780
+       VAX_780, NNEX780, NEX780, umaddr780, NBDP780, 1, 0,
+#endif
+#if VAX750
+       VAX_750, NNEX750, NEX750, umaddr750, NBDP750, 0, nexty750,
+#endif
+#if VAX730
+       VAX_730, NNEX730, NEX730, umaddr730, NBDP730, 0, nexty730,
+#endif
+       0,
+};
diff --git a/usr/src/sys/vax/dkbad.c b/usr/src/sys/vax/dkbad.c
new file mode 100644 (file)
index 0000000..6996905
--- /dev/null
@@ -0,0 +1,30 @@
+/*     dkbad.c 6.1     83/07/29        */
+
+#ifndef NOBADSECT
+#include "../h/param.h"
+#include "../h/buf.h"
+#include "../h/dkbad.h"
+
+/*
+ * Search the bad sector table looking for
+ * the specified sector.  Return index if found.
+ * Return -1 if not found.
+ */
+
+isbad(bt, cyl, trk, sec)
+       register struct dkbad *bt;
+{
+       register int i;
+       register long blk, bblk;
+
+       blk = ((long)cyl << 16) + (trk << 8) + sec;
+       for (i = 0; i < 126; i++) {
+               bblk = ((long)bt->bt_bad[i].bt_cyl << 16) + bt->bt_bad[i].bt_trksec;
+               if (blk == bblk)
+                       return (i);
+               if (blk < bblk || bblk < 0)
+                       break;
+       }
+       return (-1);
+}
+#endif
diff --git a/usr/src/sys/vax/dkio.h b/usr/src/sys/vax/dkio.h
new file mode 100644 (file)
index 0000000..22f0b82
--- /dev/null
@@ -0,0 +1,11 @@
+/*     dkio.h  6.1     83/07/29        */
+/*
+ * Structures and definitions for disk io control commands
+ *
+ * THIS WHOLE AREA NEEDS MORE THOUGHT.  FOR NOW JUST IMPLEMENT
+ * ENOUGH TO READ AND WRITE HEADERS ON MASSBUS DISKS.  EVENTUALLY
+ * SHOULD BE ABLE TO DETERMINE DRIVE TYPE AND DO OTHER GOOD STUFF.
+ */
+
+/* disk io control commands */
+#define DKIOCHDR       _IO(d, 1)       /* next I/O will read/write header */
diff --git a/usr/src/sys/vax/flp.c b/usr/src/sys/vax/flp.c
new file mode 100644 (file)
index 0000000..0338eed
--- /dev/null
@@ -0,0 +1,267 @@
+/*     flp.c   6.1     83/07/29        */
+
+#if VAX780
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/conf.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+#include "../h/uio.h"
+
+#include "../vax/cons.h"
+#include "../vax/cpu.h"
+#include "../vax/flp.h"
+#include "../vax/mtpr.h"
+
+struct {
+       short   fl_state;               /* open and busy flags */
+       short   fl_active;              /* driver state flag */
+       struct  buf *fl_buf;            /* buffer we're using */
+       unsigned char *fl_xaddr;        /* transfer address */
+       short   fl_errcnt;
+} fltab;
+
+/*ARGSUSED*/
+flopen(dev, flag)
+       dev_t dev;
+       int flag;
+{
+       struct buf *geteblk();
+
+#if VAX750
+       if (cpu != VAX_780)
+               return (ENXIO);
+#endif
+       if (fltab.fl_state != 0)
+               return (ENXIO);
+       fltab.fl_state = FL_OPEN;
+       fltab.fl_buf = geteblk(512);
+       fltab.fl_active = FL_IDLE;
+       return (0);
+}
+
+/*ARGSUSED*/
+flclose(dev, flag)
+       dev_t dev;
+       int flag;
+{
+
+       brelse(fltab.fl_buf);
+       fltab.fl_state = 0;
+}
+
+floperation(rw, uio)
+       enum uio_rw rw;
+       struct uio *uio;
+{
+       register struct buf *bp;
+       register int i;
+       int error;
+
+       /*
+        * Assume one block read/written for each call - 
+        * and enforce this by checking for block size of 128.
+        * Use the b_blkno field to address
+        * physical, 128-byte blocks (u.u_offset/128).
+        * This is checked for validity, and is further interpreted as:
+        *
+        *      track# * (sectors/track) + sector #
+        */
+       if (uio->uio_resid == 0) 
+               return (0);
+       (void) spl4();
+       while (fltab.fl_state & FL_BUSY)
+               sleep((caddr_t)&fltab, PRIBIO);
+       fltab.fl_state |= FL_BUSY;
+       (void) spl0();
+
+       bp = fltab.fl_buf;
+       error = 0;
+       while ((i = imin(RXBYSEC, uio->uio_resid)) > 0) {
+               bp->b_blkno = uio->uio_offset>>7;
+               if (bp->b_blkno >= MAXSEC || (uio->uio_offset & 0177) != 0)
+                       return (ENXIO);
+               if (rw == UIO_WRITE) {
+                       error = uiomove(bp->b_un.b_addr, i, UIO_WRITE, uio);
+                       if (error)
+                               break;
+               }
+               bp->b_flags = rw == UIO_WRITE ? B_WRITE : B_READ;
+               (void) spl4(); 
+               flstart();
+               while ((bp->b_flags & B_DONE) == 0)
+                       sleep((caddr_t)bp, PRIBIO);     
+               (void) spl0();
+               if (bp->b_flags & B_ERROR) {
+                       error = EIO;
+                       break;
+               }
+               if (rw == UIO_READ) {
+                       error = uiomove(bp->b_un.b_addr, i, UIO_READ, uio);
+                       if (error)
+                               break;
+               }
+       }
+       fltab.fl_state &= ~FL_BUSY;
+       wakeup((caddr_t)&fltab);
+       return (error);
+}
+
+/*ARGSUSED*/
+flread(dev, uio)
+       dev_t dev;
+       struct uio *uio;
+{
+
+       return (floperation(UIO_READ, uio));
+}
+
+/*ARGSUSED*/
+flwrite(dev, uio)
+       dev_t dev;
+       struct uio *uio;
+{
+
+       return (floperation(UIO_WRITE, uio));
+}
+
+flstart()
+{
+       register struct buf *bp;
+
+       bp = fltab.fl_buf;
+       fltab.fl_active = FL_MAND;
+       fltab.fl_errcnt = 0;
+       fltab.fl_xaddr = (unsigned char *) bp->b_un.b_addr;
+       bp->b_resid = 0;
+       bp->b_bcount = RXBYSEC; /* always transfer a full sector */
+
+       if ((mfpr(TXCS) & TXCS_RDY) == 0)
+               /* not ready to receive order */
+               return;
+       /*
+        * Wake up floppy LSI software with command
+        */
+       fltab.fl_active = FL_SEC;
+       if ((bp->b_flags&B_READ) == B_READ)
+               mtpr(TXDB, FL_RS);
+       else
+               mtpr(TXDB, FL_WS);
+}
+
+/*
+ * See if we want to transmit something
+ * to the floppy - and do it
+ */
+conxfl()
+{
+       register int databyte;
+       register struct buf *bp;
+
+       bp = fltab.fl_buf;
+       switch (fltab.fl_active) {
+
+       case FL_MAND:           /* send command */
+               if ((bp->b_flags&B_READ) == B_READ)
+                       mtpr(TXDB,FL_RS);
+               else
+                       mtpr(TXDB,  FL_WS);
+               fltab.fl_active = FL_SEC;
+               break;
+
+       case FL_SEC:            /* send sector address */
+               databyte = (int)bp->b_blkno % RXSTRK + 1;
+               mtpr(TXDB, FL_DATA | databyte);
+               fltab.fl_active = FL_TRACK;
+               break;
+
+       case FL_TRACK:          /* send track address */
+               databyte = (int)bp->b_blkno / RXSTRK;
+               mtpr(TXDB , FL_DATA | databyte);
+               if ((bp->b_flags&B_READ) == B_READ)
+                       /* prepare to receive complete */
+                       fltab.fl_active = FL_COM;
+               else
+                       /* prepare to send data */
+                       fltab.fl_active = FL_DAX;
+               break;
+
+       case FL_DAX:
+               databyte = *(fltab.fl_xaddr++);
+               mtpr(TXDB, FL_DATA | databyte);
+               if (--bp->b_bcount == 0)
+                       fltab.fl_active = FL_COM;
+               break;
+
+       case FL_CAN:            /* give cancel order */
+               mtpr(TXDB, FL_CANCEL);
+               if (++fltab.fl_errcnt <= FLERRS) {
+                       /* If error count permits, retry order */
+                       fltab.fl_active = FL_MAND;
+                       bp->b_bcount = RXBYSEC;
+                       fltab.fl_xaddr = (unsigned char *) bp->b_un.b_addr;
+               } else {
+                       /*
+                        * We're really stupid today - call it an
+                        * error and give up
+                        */
+                       bp->b_flags |= B_ERROR | B_DONE;
+                       bp->b_resid = -RXBYSEC;
+                       fltab.fl_active = FL_IDLE;
+                       wakeup((caddr_t)bp);
+               }
+       }
+}
+
+cnrfl(c)
+       int c;
+{
+       register int datum;
+       register struct buf *bp;
+
+       datum = c;
+       bp = fltab.fl_buf;
+       if (datum == FL_PERR) {
+               /*
+                * Got a protocol error - cancel the
+                * current function and try again if error count isn't
+                * too great.  First, though, make sure that an actual
+                * transaction is in progress (so a spurious error from
+                * the LSI won't screw us up too much!
+                */
+               if (fltab.fl_active != FL_IDLE)
+                       fltab.fl_active = FL_CAN;
+       } else switch(fltab.fl_active ) {
+
+       case FL_DAR:            /* expecting a datum */
+               if ((c&RXDB_ID) != FL_DATA)
+                       goto error;
+               *(fltab.fl_xaddr++) = (c & RXDB_DATA);
+               if (--bp->b_bcount==0) {
+                       fltab.fl_active = FL_IDLE;
+                       bp->b_flags |= B_DONE;
+                       wakeup((caddr_t)bp);
+               }
+               break;
+
+       case FL_COM:            /* expecting a "function complete" */
+               if ((c&RXDB_ID)!= FL_FFC || (c&FL_ERR) == FL_ERR){
+error:
+                       bp->b_flags |= B_ERROR | B_DONE;
+                       bp->b_resid = -bp->b_bcount;
+                       fltab.fl_active = FL_IDLE;
+                       wakeup((caddr_t)bp);
+               } else if ((bp->b_flags&B_READ) == B_READ)
+                       /* got function complete, now get data */
+                       fltab.fl_active = FL_DAR;
+               else {
+                       /* got function complete on write - finish up */
+                       fltab.fl_active = FL_IDLE;
+                       bp->b_flags |= B_DONE;
+                               wakeup((caddr_t)bp);
+               }
+               break;
+       }
+}
+#endif
diff --git a/usr/src/sys/vax/flp.h b/usr/src/sys/vax/flp.h
new file mode 100644 (file)
index 0000000..88b3c55
--- /dev/null
@@ -0,0 +1,45 @@
+/*     flp.h   6.1     83/07/29        */
+
+#if VAX780
+/*
+ * Console floppy command/status and sectoring information.
+ */
+#define        FL_FFC          0x200           /* floppy function complete */
+#define        FL_ERR          0x80            /* error bit in floppy status byte */
+#define        FL_PERR         0x905           /* floppy protocol error */
+#define        FL_DATA         0x100           /* floppy data select code */
+#define        FL_RS           0x900           /* floppy read sector command */
+#define        FL_WS           0x901           /* floppy write sector command*/
+#define        FL_STAT         0x902           /* floppy get status command*/
+#define        FL_CANCEL       0x904           /* cancel floppy function */
+
+#define        RXFTRK  77              /* tracks/floppy */
+#define        RXSTRK  26              /* sectors/track */
+#define        RXBYSEC 128             /* bytes/sector */
+#define        MAXSEC (RXFTRK*RXSTRK)  /* sectors/floppy */
+
+/*
+ * In the floppy driver routines, the device active byte is used
+ * not as a boolean, but as an indicator of the state we are in.
+ * That is, it contains what to do on the next interrupt.
+ */
+
+#define        FL_IDLE         0       /* floppy idle */
+#define        FL_MAND         1       /* about to send read/write command */
+#define        FL_SEC          2       /* about to send sector # to LSI */
+#define        FL_TRACK        3       /* about to send track # to LSI */
+#define        FL_DAX          4       /* transmitting data */
+#define        FL_DAR          5       /* receiving data */
+#define        FL_COM          6       /* completing transmission */
+#define        FL_CAN          7       /* give cancel order - we had an error,
+                                  and are to restart */
+
+#define        FLERRS          5       /* number of retries before quitting */
+
+/*
+ * The state byte is used to retain exclusivity,
+ * and contains the busy flag.
+ */
+#define        FL_OPEN         1
+#define        FL_BUSY         2
+#endif
diff --git a/usr/src/sys/vax/frame.h b/usr/src/sys/vax/frame.h
new file mode 100644 (file)
index 0000000..44926e8
--- /dev/null
@@ -0,0 +1,16 @@
+/*     frame.h 6.1     83/07/29        */
+
+/*
+ * Definition of the vax calls/callg frame.
+ */
+struct frame {
+       int     fr_handler;
+       u_int   fr_psw:16,              /* saved psw */
+               fr_mask:12,             /* register save mask */
+               :1,
+               fr_s:1,                 /* call was a calls, not callg */
+               fr_spa:2;               /* stack pointer alignment */
+       int     fr_savap;               /* saved arg pointer */
+       int     fr_savfp;               /* saved frame pointer */
+       int     fr_savpc;               /* saved program counter */
+};
diff --git a/usr/src/sys/vax/genassym.c b/usr/src/sys/vax/genassym.c
new file mode 100644 (file)
index 0000000..5ed4963
--- /dev/null
@@ -0,0 +1,77 @@
+#define        VAX780  1
+#define        VAX750  1
+#define        VAX730  1
+
+#include "../machine/pte.h"
+
+#include "../h/param.h"
+#include "../h/buf.h"
+#include "../h/vmmeter.h"
+#include "../h/vmparam.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/cmap.h"
+#include "../h/map.h"
+#include "../vaxuba/ubareg.h"
+#include "../vaxuba/ubavar.h"
+#include "../h/proc.h"
+#include "../h/text.h"
+#include "../vax/rpb.h"
+#include "../h/mbuf.h"
+#include "../h/msgbuf.h"
+
+main()
+{
+       register struct proc *p = (struct proc *)0;
+       register struct uba_regs *uba = (struct uba_regs *)0;
+       register struct uba_hd *uh = (struct uba_hd *)0;
+       register struct vmmeter *vm = (struct vmmeter *)0;
+       register struct user *up = (struct user *)0;
+       register struct rusage *rup = (struct rusage *)0;
+       struct rpb *rp = (struct rpb *)0;
+       struct text *tp = (struct text *)0;
+
+       printf("#ifdef LOCORE\n");
+       printf("#define\tP_LINK %d\n", &p->p_link);
+       printf("#define\tP_RLINK %d\n", &p->p_rlink);
+       printf("#define\tP_XLINK %d\n", &p->p_xlink);
+       printf("#define\tP_ADDR %d\n", &p->p_addr);
+       printf("#define\tP_PRI %d\n", &p->p_pri);
+       printf("#define\tP_STAT %d\n", &p->p_stat);
+       printf("#define\tP_WCHAN %d\n", &p->p_wchan);
+       printf("#define\tP_TSIZE %d\n", &p->p_tsize);
+       printf("#define\tP_SSIZE %d\n", &p->p_ssize);
+       printf("#define\tP_P0BR %d\n", &p->p_p0br);
+       printf("#define\tP_SZPT %d\n", &p->p_szpt);
+       printf("#define\tP_TEXTP %d\n", &p->p_textp);
+       printf("#define\tP_FLAG %d\n", &p->p_flag);
+       printf("#define\tSSLEEP %d\n", SSLEEP);
+       printf("#define\tSRUN %d\n", SRUN);
+       printf("#define\tUBA_BRRVR %d\n", uba->uba_brrvr);
+       printf("#define\tUH_UBA %d\n", &uh->uh_uba);
+       printf("#define\tUH_VEC %d\n", &uh->uh_vec);
+       printf("#define\tUH_SIZE %d\n", sizeof (struct uba_hd));
+       printf("#define\tRP_FLAG %d\n", &rp->rp_flag);
+       printf("#define\tX_CADDR %d\n", &tp->x_caddr);
+       printf("#define\tV_SWTCH %d\n", &vm->v_swtch);
+       printf("#define\tV_TRAP %d\n", &vm->v_trap);
+       printf("#define\tV_SYSCALL %d\n", &vm->v_syscall);
+       printf("#define\tV_INTR %d\n", &vm->v_intr);
+       printf("#define\tV_PDMA %d\n", &vm->v_pdma);
+       printf("#define\tV_FAULTS %d\n", &vm->v_faults);
+       printf("#define\tV_PGREC %d\n", &vm->v_pgrec);
+       printf("#define\tV_FASTPGREC %d\n", &vm->v_fastpgrec);
+       printf("#define\tUPAGES %d\n", UPAGES);
+       printf("#define\tCLSIZE %d\n", CLSIZE);
+       printf("#define\tSYSPTSIZE %d\n", SYSPTSIZE);
+       printf("#define\tUSRPTSIZE %d\n", USRPTSIZE);
+       printf("#define\tMSGBUFPTECNT %d\n", btoc(sizeof (struct msgbuf)));
+       printf("#define\tNMBCLUSTERS %d\n", NMBCLUSTERS);
+       printf("#define\tU_PROCP %d\n", &up->u_procp);
+       printf("#define\tU_RU %d\n", &up->u_ru);
+       printf("#define\tRU_MINFLT %d\n", &rup->ru_minflt);
+       printf("#else\n");
+       printf("asm(\".set\tU_ARG,%d\");\n", up->u_arg);
+       printf("asm(\".set\tU_QSAVE,%d\");\n", up->u_qsave);
+       printf("#endif\n");
+}
diff --git a/usr/src/sys/vax/in_cksum.c b/usr/src/sys/vax/in_cksum.c
new file mode 100644 (file)
index 0000000..168baa3
--- /dev/null
@@ -0,0 +1,127 @@
+/*     in_cksum.c      6.1     83/07/29        */
+
+#include "../h/types.h"
+#include "../h/mbuf.h"
+#include "../netinet/in.h"
+#include "../netinet/in_systm.h"
+
+/*
+ * Checksum routine for Internet Protocol family headers (VAX Version).
+ *
+ * This routine is very heavily used in the network
+ * code and should be modified for each CPU to be as fast as possible.
+ */
+
+in_cksum(m, len)
+       register struct mbuf *m;
+       register int len;
+{
+       register u_short *w;            /* on vax, known to be r9 */
+       register int sum = 0;           /* on vax, known to be r8 */
+       register int mlen = 0;
+
+       for (;;) {
+               /*
+                * Each trip around loop adds in
+                * word from one mbuf segment.
+                */
+               w = mtod(m, u_short *);
+               if (mlen == -1) {
+                       /*
+                        * There is a byte left from the last segment;
+                        * add it into the checksum.  Don't have to worry
+                        * about a carry-out here because we make sure
+                        * that high part of (32 bit) sum is small below.
+                        */
+                       sum += *(u_char *)w << 8;
+                       w = (u_short *)((char *)w + 1);
+                       mlen = m->m_len - 1;
+                       len--;
+               } else
+                       mlen = m->m_len;
+               m = m->m_next;
+               if (len < mlen)
+                       mlen = len;
+               len -= mlen;
+               /*
+                * Force to long boundary so we do longword aligned
+                * memory operations.  It is too hard to do byte
+                * adjustment, do only word adjustment.
+                */
+               if (((int)w&0x2) && mlen >= 2) {
+                       sum += *w++;
+                       mlen -= 2;
+               }
+               /*
+                * Do as much of the checksum as possible 32 bits at at time.
+                * In fact, this loop is unrolled to make overhead from
+                * branches &c small.
+                *
+                * We can do a 16 bit ones complement sum 32 bits at a time
+                * because the 32 bit register is acting as two 16 bit
+                * registers for adding, with carries from the low added
+                * into the high (by normal carry-chaining) and carries
+                * from the high carried into the low on the next word
+                * by use of the adwc instruction.  This lets us run
+                * this loop at almost memory speed.
+                *
+                * Here there is the danger of high order carry out, and
+                * we carefully use adwc.
+                */
+               while ((mlen -= 32) >= 0) {
+#undef ADD
+                       asm("clrl r0");         /* clears carry */
+#define ADD            asm("adwc (r9)+,r8;");
+                       ADD; ADD; ADD; ADD; ADD; ADD; ADD; ADD;
+                       asm("adwc $0,r8");
+               }
+               mlen += 32;
+               while ((mlen -= 8) >= 0) {
+                       asm("clrl r0");
+                       ADD; ADD;
+                       asm("adwc $0,r8");
+               }
+               mlen += 8;
+               /*
+                * Now eliminate the possibility of carry-out's by
+                * folding back to a 16 bit number (adding high and
+                * low parts together.)  Then mop up trailing words
+                * and maybe an odd byte.
+                */
+               { asm("ashl $-16,r8,r0; addw2 r0,r8");
+                 asm("adwc $0,r8; movzwl r8,r8"); }
+               while ((mlen -= 2) >= 0) {
+                       asm("movzwl (r9)+,r0; addl2 r0,r8");
+               }
+               if (mlen == -1) {
+                       sum += *(u_char *)w;
+               }
+               if (len == 0)
+                       break;
+               /*
+                * Locate the next block with some data.
+                * If there is a word split across a boundary we
+                * will wrap to the top with mlen == -1 and
+                * then add it in shifted appropriately.
+                */
+               for (;;) {
+                       if (m == 0) {
+                               printf("cksum: out of data\n");
+                               goto done;
+                       }
+                       if (m->m_len)
+                               break;
+                       m = m->m_next;
+               }
+       }
+done:
+       /*
+        * Add together high and low parts of sum
+        * and carry to get cksum.
+        * Have to be careful to not drop the last
+        * carry here.
+        */
+       { asm("ashl $-16,r8,r0; addw2 r0,r8; adwc $0,r8");
+         asm("mcoml r8,r8; movzwl r8,r8"); }
+       return (sum);
+}
diff --git a/usr/src/sys/vax/mem.c b/usr/src/sys/vax/mem.c
new file mode 100644 (file)
index 0000000..ad382e7
--- /dev/null
@@ -0,0 +1,138 @@
+/*     mem.c   6.1     83/07/29        */
+
+/*
+ * Memory special file
+ */
+
+#include "../machine/pte.h"
+
+#include "../h/param.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+#include "../h/systm.h"
+#include "../h/vm.h"
+#include "../h/cmap.h"
+#include "../h/uio.h"
+
+#include "../vax/mtpr.h"
+
+mmread(dev, uio)
+       dev_t dev;
+       struct uio *uio;
+{
+
+       return (mmrw(dev, uio, UIO_READ));
+}
+
+mmwrite(dev, uio)
+       dev_t dev;
+       struct uio *uio;
+{
+
+       return (mmrw(dev, uio, UIO_WRITE));
+}
+
+mmrw(dev, uio, rw)
+       dev_t dev;
+       struct uio *uio;
+       enum uio_rw rw;
+{
+       register int o;
+       register u_int c, v;
+       register struct iovec *iov;
+       int error = 0;
+       extern int umbabeg, umbaend;
+
+
+       while (uio->uio_resid > 0 && error == 0) {
+               iov = uio->uio_iov;
+               if (iov->iov_len == 0) {
+                       uio->uio_iov++;
+                       uio->uio_iovcnt--;
+                       if (uio->uio_iovcnt < 0)
+                               panic("mmrw");
+                       continue;
+               }
+               switch (minor(dev)) {
+
+/* minor device 0 is physical memory */
+               case 0:
+                       v = btop(uio->uio_offset);
+                       if (v >= physmem)
+                               goto fault;
+                       *(int *)mmap = v | PG_V |
+                               (rw == UIO_READ ? PG_KR : PG_KW);
+                       mtpr(TBIS, vmmap);
+                       o = (int)uio->uio_offset & PGOFSET;
+                       c = min((u_int)(NBPG - o), (u_int)iov->iov_len);
+                       c = min(c, (u_int)(NBPG - ((int)iov->iov_base&PGOFSET)));
+                       error = uiomove((caddr_t)&vmmap[o], (int)c, rw, uio);
+                       continue;
+
+/* minor device 1 is kernel memory */
+               case 1:
+                       if ((caddr_t)uio->uio_offset < (caddr_t)&umbabeg &&
+                           (caddr_t)uio->uio_offset + uio->uio_resid >= (caddr_t)&umbabeg)
+                               goto fault;
+                       if ((caddr_t)uio->uio_offset >= (caddr_t)&umbabeg &&
+                           (caddr_t)uio->uio_offset < (caddr_t)&umbaend)
+                               goto fault;
+                       c = iov->iov_len;
+                       if (!kernacc((caddr_t)uio->uio_offset, c, rw == UIO_READ ? B_READ : B_WRITE))
+                               goto fault;
+                       error = uiomove((caddr_t)uio->uio_offset, (int)c, rw, uio);
+                       continue;
+
+/* minor device 2 is EOF/RATHOLE */
+               case 2:
+                       if (rw == UIO_READ)
+                               return (0);
+                       c = iov->iov_len;
+                       break;
+
+/* minor device 3 is unibus memory (addressed by shorts) */
+               case 3:
+                       c = iov->iov_len;
+                       if (!kernacc((caddr_t)uio->uio_offset, c, rw == UIO_READ ? B_READ : B_WRITE))
+                               goto fault;
+                       if (!useracc(iov->iov_base, c, rw == UIO_READ ? B_WRITE : B_READ))
+                               goto fault;
+                       error = UNIcpy((caddr_t)uio->uio_offset, iov->iov_base,
+                           (int)c, rw);
+                       break;
+               }
+               if (error)
+                       break;
+               iov->iov_base += c;
+               iov->iov_len -= c;
+               uio->uio_offset += c;
+               uio->uio_resid -= c;
+       }
+       return (error);
+fault:
+       return (EFAULT);
+}
+
+/*
+ * UNIBUS Address Space <--> User Space transfer
+ */
+UNIcpy(uniadd, usradd, n, rw)
+       caddr_t uniadd, usradd;
+       register int n;
+       enum uio_rw rw;
+{
+       register short *from, *to;
+       if (rw == UIO_READ) {
+               from = (short *)uniadd;
+               to = (short *)usradd;
+       } else {
+               from = (short *)usradd;
+               to = (short *)uniadd;
+       }
+       for (n >>= 1; n > 0; n--)
+               *to++ = *from++;
+       return (0);
+}
diff --git a/usr/src/sys/vax/mem.h b/usr/src/sys/vax/mem.h
new file mode 100644 (file)
index 0000000..7b4404b
--- /dev/null
@@ -0,0 +1,84 @@
+/*     mem.h   6.1     83/07/29        */
+
+/*
+ * Memory controller registers
+ *
+ * The way in which the data is stored in these registers varies
+ * per cpu, so we define macros here to mask that.
+ */
+struct mcr {
+       int     mc_reg[3];
+};
+
+/*
+ * Compute maximum possible number of memory controllers,
+ * for sizing of the mcraddr array.
+ */
+#if VAX780
+#define        MAXNMCR         4
+#else
+#define        MAXNMCR         1
+#endif
+
+/*
+ * For each processor type we define 5 macros:
+ *     M???_INH(mcr)           inhibits further crd interrupts from mcr
+ *     M???_ENA(mcr)           enables another crd interrupt from mcr
+ *     M???_ERR(mcr)           tells whether an error is waiting
+ *     M???_SYN(mcr)           gives the syndrome bits of the error
+ *     M???_ADDR(mcr)          gives the address of the error
+ */
+#if VAX780
+#define        M780_ICRD       0x40000000      /* inhibit crd interrupts, in [2] */
+#define        M780_HIER       0x20000000      /* high error rate, in reg[2] */
+#define        M780_ERLOG      0x10000000      /* error log request, in reg[2] */
+/* on a 780, memory crd's occur only when bit 15 is set in the SBIER */
+/* register; bit 14 there is an error bit which we also clear */
+/* these bits are in the back of the ``red book'' (or in the VMS code) */
+
+#define        M780_INH(mcr)   \
+       (((mcr)->mc_reg[2] = (M780_ICRD|M780_HIER|M780_ERLOG)), mtpr(SBIER, 0))
+#define        M780_ENA(mcr)   \
+       (((mcr)->mc_reg[2] = (M780_HIER|M780_ERLOG)), mtpr(SBIER, 3<<14))
+#define        M780_ERR(mcr)   \
+       ((mcr)->mc_reg[2] & (M780_ERLOG))
+
+#define        M780_SYN(mcr)   ((mcr)->mc_reg[2] & 0xff)
+#define        M780_ADDR(mcr)  (((mcr)->mc_reg[2] >> 8) & 0xfffff)
+#endif
+
+#if VAX750
+#define        M750_ICRD       0x10000000      /* inhibit crd interrupts, in [1] */
+#define        M750_UNCORR     0xc0000000      /* uncorrectable error, in [0] */
+#define        M750_CORERR     0x20000000      /* correctable error, in [0] */
+
+#define        M750_INH(mcr)   ((mcr)->mc_reg[1] = 0)
+#define        M750_ENA(mcr)   ((mcr)->mc_reg[0] = (M750_UNCORR|M750_CORERR), \
+                           (mcr)->mc_reg[1] = M750_ICRD)
+#define        M750_ERR(mcr)   ((mcr)->mc_reg[0] & (M750_UNCORR|M750_CORERR))
+
+#define        M750_SYN(mcr)   ((mcr)->mc_reg[0] & 0x7f)
+#define        M750_ADDR(mcr)  (((mcr)->mc_reg[0] >> 9) & 0x7fff)
+#endif
+
+#if VAX730
+#define        M730_CRD        0x40000000      /* crd, in [1] */
+#define        M730_FTBPE      0x20000000      /* force tbuf parity error, in [1] */
+#define        M730_ENACRD     0x10000000      /* enable crd interrupt, in [1] */
+#define        M730_MME        0x08000000      /* mem-man enable (ala ipr), in [1] */
+#define        M730_DM         0x04000000      /* diagnostic mode, in [1] */
+#define        M730_DISECC     0x02000000      /* disable ecc, in [1] */
+
+#define        M730_INH(mcr)   ((mcr)->mc_reg[1] = M730_MME)
+#define        M730_ENA(mcr)   ((mcr)->mc_reg[1] = (M730_MME|M730_ENACRD))
+#define        M730_ERR(mcr)   ((mcr)->mc_reg[1] & M730_CRD)
+#define        M730_SYN(mcr)   ((mcr)->mc_reg[0] & 0x7f)
+#define        M730_ADDR(mcr)  (((mcr)->mc_reg[0] >> 8) & 0x7fff)
+#endif
+
+#define        MEMINTVL        (60*10)         /* 10 minutes */
+
+#ifdef KERNEL
+int    nmcr;
+struct mcr *mcraddr[MAXNMCR];
+#endif
diff --git a/usr/src/sys/vax/mscp.h b/usr/src/sys/vax/mscp.h
new file mode 100644 (file)
index 0000000..4afff20
--- /dev/null
@@ -0,0 +1,307 @@
+/*     mscp.h  6.1     83/07/29        */
+/*
+ * Definitions for the Mass Storage Control Protocol
+ */
+
+
+/*
+ * Control message opcodes
+ */
+#define        M_OP_ABORT      0001    /* Abort command */
+#define        M_OP_GTCMD      0002    /* Get command status command */
+#define        M_OP_GTUNT      0003    /* Get unit status command */
+#define        M_OP_STCON      0004    /* Set controller characteristics command */
+#define        M_OP_SEREX      0007    /* Serious exception end message */
+#define        M_OP_AVAIL      0010    /* Available command */
+#define        M_OP_ONLIN      0011    /* Online command */
+#define        M_OP_STUNT      0012    /* Set unit characteristics command */
+#define        M_OP_DTACP      0013    /* Determine access paths command */
+#define        M_OP_ACCES      0020    /* Access command */
+#define        M_OP_CMPCD      0021    /* Compare controller data command */
+#define        M_OP_ERASE      0022    /* Erase command */
+#define        M_OP_FLUSH      0023    /* Flush command */
+#define        M_OP_REPLC      0024    /* Replace command */
+#define        M_OP_COMP       0040    /* Compare host data command */
+#define        M_OP_READ       0041    /* Read command */
+#define        M_OP_WRITE      0042    /* Write command */
+#define        M_OP_AVATN      0100    /* Available attention message */
+#define        M_OP_DUPUN      0101    /* Duplicate unit number attention message */
+#define        M_OP_ACPTH      0102    /* Access path attention message */
+#define        M_OP_END        0200    /* End message flag */
+
+
+/*
+ * Generic command modifiers
+ */
+#define        M_MD_EXPRS      0100000         /* Express request */
+#define        M_MD_COMP       0040000         /* Compare */
+#define        M_MD_CLSEX      0020000         /* Clear serious exception */
+#define        M_MD_ERROR      0010000         /* Force error */
+#define        M_MD_SCCHH      0004000         /* Suppress caching (high speed) */
+#define        M_MD_SCCHL      0002000         /* Suppress caching (low speed) */
+#define        M_MD_SECOR      0001000         /* Suppress error correction */
+#define        M_MD_SEREC      0000400         /* Suppress error recovery */
+#define        M_MD_SSHDW      0000200         /* Suppress shadowing */
+#define        M_MD_WBKNV      0000100         /* Write back (non-volatile) */
+#define        M_MD_WBKVL      0000040         /* Write back (volatile) */
+#define        M_MD_WRSEQ      0000020         /* Write shadow set one unit at a time */
+
+/*
+ * AVAILABLE command modifiers
+ */
+#define        M_MD_ALLCD      0000002         /* All class drivers */
+#define        M_MD_SPNDW      0000001         /* Spin down */
+
+/*
+ * FLUSH command modifiers
+ */
+#define        M_MD_FLENU      0000001         /* Flush entire unit */
+#define        M_MD_VOLTL      0000002         /* Volatile only */
+
+/*
+ * GET UNIT STATUS command modifiers
+ */
+#define        M_MD_NXUNT      0000001         /* Next unit */
+
+/*
+ * ONLINE command modifiers
+ */
+#define        M_MD_RIP        0000001         /* Allow self destruction */
+#define        M_MD_IGNMF      0000002         /* Ignore media format error */
+
+/*
+ * ONLINE and SET UNIT CHARACTERISTICS command modifiers
+ */
+#define        M_MD_ALTHI      0000040         /* Alter host identifier */
+#define        M_MD_SHDSP      0000020         /* Shadow unit specified */
+#define        M_MD_CLWBL      0000010         /* Clear write-back data lost */
+#define        M_MD_STWRP      0000004         /* Set write protect */
+
+/*
+ * REPLACE command modifiers
+ */
+#define        M_MD_PRIMR      0000001         /* Primary replacement block */
+
+
+/*
+ * End message flags
+ */
+#define        M_EF_BBLKR      0200    /* Bad block reported */
+#define        M_EF_BBLKU      0100    /* Bad block unreported */
+#define        M_EF_ERLOG      0040    /* Error log generated */
+#define        M_EF_SEREX      0020    /* Serious exception */
+
+
+/*
+ * Controller flags
+ */
+#define        M_CF_ATTN       0200    /* Enable attention messages */
+#define        M_CF_MISC       0100    /* Enable miscellaneous error log messages */
+#define        M_CF_OTHER      0040    /* Enable other host's error log messages */
+#define        M_CF_THIS       0020    /* Enable this host's error log messages */
+#define        M_CF_MLTHS      0004    /* Multi-host */
+#define        M_CF_SHADW      0002    /* Shadowing */
+#define        M_CF_576        0001    /* 576 byte sectors */
+
+
+/*
+ * Unit flags
+ */
+#define        M_UF_REPLC      0100000         /* Controller initiated bad block replacement */
+#define        M_UF_INACT      0040000         /* Inactive shadow set unit */
+#define        M_UF_WRTPH      0020000         /* Write protect (hardware) */
+#define        M_UF_WRTPS      0010000         /* Write protect (software or volume) */
+#define        M_UF_SCCHH      0004000         /* Suppress caching (high speed) */
+#define        M_UF_SCCHL      0002000         /* Suppress caching (low speed) */
+#define        M_UF_RMVBL      0000200         /* Removable media */
+#define        M_UF_WBKNV      0000100         /* Write back (non-volatile) */
+#define        M_UF_576        0000004         /* 576 byte sectors */
+#define        M_UF_CMPWR      0000002         /* Compare writes */
+#define        M_UF_CMPRD      0000001         /* Compare reads */
+
+
+/*
+ * Status codes
+ */
+#define        M_ST_MASK       037             /* Status code mask */
+#define        M_ST_SUCC       000             /* Success */
+#define        M_ST_ICMD       001             /* Invalid command */
+#define        M_ST_ABRTD      002             /* Command aborted */
+#define        M_ST_OFFLN      003             /* Unit offline */
+#define        M_ST_AVLBL      004             /* Unit available */
+#define        M_ST_MFMTE      005             /* Media format error */
+#define        M_ST_WRTPR      006             /* Write protected */
+#define        M_ST_COMP       007             /* Compare error */
+#define        M_ST_DATA       010             /* Data error */
+#define        M_ST_HSTBF      011             /* Host buffer access error */
+#define        M_ST_CNTLR      012             /* Controller error */
+#define        M_ST_DRIVE      013             /* Drive error */
+#define        M_ST_DIAG       037             /* Message from an internal diagnostic */
+
+/*
+ * An MSCP packet
+ */
+
+struct mscp {
+       struct  mscp_header mscp_header;/* device specific header */
+       long    mscp_cmdref;            /* command reference number */
+       short   mscp_unit;              /* unit number */
+       short   mscp_xxx1;              /* unused */
+       u_char  mscp_opcode;            /* opcode */
+       u_char  mscp_flags;             /* end message flags */
+       short   mscp_modifier;          /* modifiers */
+       union {
+       struct {
+               long    Mscp_bytecnt;   /* byte count */
+               long    Mscp_buffer;    /* buffer descriptor */
+               long    Mscp_xxx2[2];   /* unused */
+               long    Mscp_lbn;       /* logical block number */
+               long    Mscp_xxx4;      /* unused */
+               long    *Mscp_dscptr;   /* pointer to descriptor (software) */
+               long    Mscp_sftwds[4]; /* software words, padding */
+       } mscp_generic;
+       struct {
+               short   Mscp_version;   /* MSCP version */
+               short   Mscp_cntflgs;   /* controller flags */
+               short   Mscp_hsttmo;    /* host timeout */
+               short   Mscp_usefrac;   /* use fraction */
+               long    Mscp_time;      /* time and date */
+       } mscp_setcntchar;
+       struct {
+               short   Mscp_multunt;   /* multi-unit code */
+               short   Mscp_unitflgs;  /* unit flags */
+               long    Mscp_hostid;    /* host identifier */
+               quad    Mscp_unitid;    /* unit identifier */
+               long    Mscp_mediaid;   /* media type identifier */
+               short   Mscp_shdwunt;   /* shadow unit */
+               short   Mscp_shdwsts;   /* shadow status */
+               short   Mscp_track;     /* track size */
+               short   Mscp_group;     /* group size */
+               short   Mscp_cylinder;  /* cylinder size */
+               short   Mscp_xxx3;      /* reserved */
+               short   Mscp_rctsize;   /* RCT table size */
+               char    Mscp_rbns;      /* RBNs / track */
+               char    Mscp_rctcpys;   /* RCT copies */
+       } mscp_getunitsts;
+       } mscp_un;
+};
+
+/*
+ * generic packet
+ */
+
+#define        mscp_bytecnt    mscp_un.mscp_generic.Mscp_bytecnt
+#define        mscp_buffer     mscp_un.mscp_generic.Mscp_buffer
+#define        mscp_lbn        mscp_un.mscp_generic.Mscp_lbn
+#define        mscp_dscptr     mscp_un.mscp_generic.Mscp_dscptr
+#define        mscp_sftwds     mscp_un.mscp_generic.Mscp_sftwds
+#define        mscp_status     mscp_modifier
+
+/*
+ * Abort / Get Command Status packet
+ */
+
+#define        mscp_outref     mscp_bytecnt
+
+/*
+ * Online / Set Unit Characteristics packet
+ */
+
+#define        mscp_errlgfl    mscp_lbn
+#define        mscp_copyspd    mscp_shdwsts
+
+/*
+ * Replace packet
+ */
+
+#define        mscp_rbn        mscp_bytecnt
+
+/*
+ * Set Controller Characteristics packet
+ */
+
+#define        mscp_version    mscp_un.mscp_setcntchar.Mscp_version
+#define        mscp_cntflgs    mscp_un.mscp_setcntchar.Mscp_cntflgs
+#define        mscp_hsttmo     mscp_un.mscp_setcntchar.Mscp_hsttmo
+#define        mscp_usefrac    mscp_un.mscp_setcntchar.Mscp_usefrac
+#define        mscp_time       mscp_un.mscp_setcntchar.Mscp_time
+
+/*
+ * Get Unit Status end packet
+ */
+
+#define        mscp_multunt    mscp_un.mscp_getunitsts.Mscp_multunt
+#define        mscp_unitflgs   mscp_un.mscp_getunitsts.Mscp_unitflgs
+#define        mscp_hostid     mscp_un.mscp_getunitsts.Mscp_hostid
+#define        mscp_unitid     mscp_un.mscp_getunitsts.Mscp_unitid
+#define        mscp_mediaid    mscp_un.mscp_getunitsts.Mscp_mediaid
+#define        mscp_shdwunt    mscp_un.mscp_getunitsts.Mscp_shdwunt
+#define        mscp_shdwsts    mscp_un.mscp_getunitsts.Mscp_shdwsts
+#define        mscp_track      mscp_un.mscp_getunitsts.Mscp_track
+#define        mscp_group      mscp_un.mscp_getunitsts.Mscp_group
+#define        mscp_cylinder   mscp_un.mscp_getunitsts.Mscp_cylinder
+#define        mscp_rctsize    mscp_un.mscp_getunitsts.Mscp_rctsize
+#define        mscp_rbns       mscp_un.mscp_getunitsts.Mscp_rbns
+#define        mscp_rctcpys    mscp_un.mscp_getunitsts.Mscp_rctcpys
+
+/*
+ * Online / Set Unit Characteristics end packet
+ */
+
+#define        mscp_untsize    mscp_dscptr
+#define        mscp_volser     mscp_sftwds[0]
+
+/*
+ * Set Controller Characteristics end packet
+ */
+
+#define        mscp_cnttmo     mscp_hsttmo
+#define        mscp_cntcmdl    mscp_usefrac
+#define        mscp_cntid      mscp_unitid
+
+
+/*
+ * Error Log message format codes
+ */
+#define        M_FM_CNTERR     0       /* Controller error */
+#define        M_FM_BUSADDR    1       /* Host memory access error */
+#define        M_FM_DISKTRN    2       /* Disk transfer error */
+#define        M_FM_SDI        3       /* SDI error */
+#define        M_FM_SMLDSK     4       /* Small disk error */
+
+/*
+ * Error Log message flags
+ */
+#define        M_LF_SUCC       0200    /* Operation successful */
+#define        M_LF_CONT       0100    /* Operation continuing */
+#define        M_LF_SQNRS      0001    /* Sequence number reset */
+
+/*
+ * MSCP Error Log packet
+ *
+ *     NOTE: MSCP packet must be padded to this size.
+ */
+
+struct mslg {
+       struct  mscp_header mslg_header;/* device specific header */
+       long    mslg_cmdref;            /* command reference number */
+       short   mslg_unit;              /* unit number */
+       short   mslg_seqnum;            /* sequence number */
+       u_char  mslg_format;            /* format */
+       u_char  mslg_flags;             /* error log message flags */
+       short   mslg_event;             /* event code */
+       quad    mslg_cntid;             /* controller id */
+       u_char  mslg_cntsvr;            /* controller software version */
+       u_char  mslg_cnthvr;            /* controller hardware version */
+       short   mslg_multunt;           /* multi-unit code */
+       quad    mslg_unitid;            /* unit id */
+       u_char  mslg_unitsvr;           /* unit software version */
+       u_char  mslg_unithvr;           /* unit hardware version */
+       short   mslg_group;             /* group; retry + level */
+       long    mslg_volser;            /* volume serial number */
+       long    mslg_hdr;               /* header */
+       char    mslg_sdistat[12];       /* SDI status information */
+};
+
+#define        mslg_busaddr    mslg_unitid.val[0]
+#define        mslg_sdecyl     mslg_group
diff --git a/usr/src/sys/vax/mtpr.h b/usr/src/sys/vax/mtpr.h
new file mode 100644 (file)
index 0000000..255e917
--- /dev/null
@@ -0,0 +1,65 @@
+/*     mtpr.h  6.1     83/07/29        */
+
+/*
+ * VAX processor register numbers
+ */
+
+#define        KSP     0x0             /* kernel stack pointer */
+#define        ESP     0x1             /* exec stack pointer */
+#define        SSP     0x2             /* supervisor stack pointer */
+#define        USP     0x3             /* user stack pointer */
+#define        ISP     0x4             /* interrupt stack pointer */
+#define        P0BR    0x8             /* p0 base register */
+#define        P0LR    0x9             /* p0 length register */
+#define        P1BR    0xa             /* p1 base register */
+#define        P1LR    0xb             /* p1 length register */
+#define        SBR     0xc             /* system segment base register */
+#define        SLR     0xd             /* system segment length register */
+#define        PCBB    0x10            /* process control block base */
+#define        SCBB    0x11            /* system control block base */
+#define        IPL     0x12            /* interrupt priority level */
+#define        ASTLVL  0x13            /* async. system trap level */
+#define        SIRR    0x14            /* software interrupt request */
+#define        SISR    0x15            /* software interrupt summary */
+#define        ICCS    0x18            /* interval clock control */
+#define        NICR    0x19            /* next interval count */
+#define        ICR     0x1a            /* interval count */
+#define        TODR    0x1b            /* time of year (day) */
+#define        RXCS    0x20            /* console receiver control and status */
+#define        RXDB    0x21            /* console receiver data buffer */
+#define        TXCS    0x22            /* console transmitter control and status */
+#define        TXDB    0x23            /* console transmitter data buffer */
+#define        MAPEN   0x38            /* memory management enable */
+#define        TBIA    0x39            /* translation buffer invalidate all */
+#define        TBIS    0x3a            /* translation buffer invalidate single */
+#define        PMR     0x3d            /* performance monitor enable */
+#define        SID     0x3e            /* system identification */
+
+#if defined(VAX780)
+#define        ACCS    0x28            /* accelerator control and status */
+#define        ACCR    0x29            /* accelerator maintenance */
+#define        WCSA    0x2c            /* WCS address */
+#define        WCSD    0x2d            /* WCS data */
+#define        SBIFS   0x30            /* SBI fault and status */
+#define        SBIS    0x31            /* SBI silo */
+#define        SBISC   0x32            /* SBI silo comparator */
+#define        SBIMT   0x33            /* SBI maintenance */
+#define        SBIER   0x34            /* SBI error register */
+#define        SBITA   0x35            /* SBI timeout address */
+#define        SBIQC   0x36            /* SBI quadword clear */
+#define        MBRK    0x3c            /* micro-program breakpoint */
+#endif
+
+#if defined(VAX750) || defined(VAX730)
+#define        MCSR    0x17            /* machine check status register */
+#define        CSRS    0x1c            /* console storage receive status register */
+#define        CSRD    0x1d            /* console storage receive data register */
+#define        CSTS    0x1e            /* console storage transmit status register */
+#define        CSTD    0x1f            /* console storage transmit data register */
+#define        TBDR    0x24            /* translation buffer disable register */
+#define        CADR    0x25            /* cache disable register */
+#define        MCESR   0x26            /* machine check error summary register */
+#define        CAER    0x27            /* cache error */
+#define        IUR     0x37            /* init unibus register */
+#define        TB      0x3b            /* translation buffer */
+#endif
diff --git a/usr/src/sys/vax/param.h b/usr/src/sys/vax/param.h
new file mode 100644 (file)
index 0000000..480ef26
--- /dev/null
@@ -0,0 +1,42 @@
+/*     param.h 6.1     83/07/29        */
+
+/*
+ * Machine dependent constants for vax.
+ */
+#define        NBPG    512             /* bytes/page */
+#define        PGOFSET (NBPG-1)        /* byte offset into page */
+#define        PGSHIFT 9               /* LOG2(NBPG) */
+
+#define        CLSIZE          2
+#define        CLSIZELOG2      1
+
+#define        SSIZE   4               /* initial stack size/NBPG */
+#define        SINCR   4               /* increment of stack/NBPG */
+
+#define        UPAGES  8               /* pages of u-area */
+
+/*
+ * Some macros for units conversion
+ */
+/* Core clicks (512 bytes) to segments and vice versa */
+#define        ctos(x) (x)
+#define        stoc(x) (x)
+
+/* Core clicks (512 bytes) to disk blocks */
+#define        ctod(x) (x)
+#define        dtoc(x) (x)
+#define        dtob(x) ((x)<<9)
+
+/* clicks to bytes */
+#define        ctob(x) ((x)<<9)
+
+/* bytes to clicks */
+#define        btoc(x) ((((unsigned)(x)+511)>>9))
+
+/*
+ * Macros to decode processor status word.
+ */
+#define        USERMODE(ps)    (((ps) & PSL_CURMOD) == PSL_CURMOD)
+#define        BASEPRI(ps)     (((ps) & PSL_IPL) == 0)
+
+#define        DELAY(n)        { register int N = (n); while (--N > 0); }
diff --git a/usr/src/sys/vax/pcb.h b/usr/src/sys/vax/pcb.h
new file mode 100644 (file)
index 0000000..309fef4
--- /dev/null
@@ -0,0 +1,63 @@
+/*     pcb.h   6.1     83/07/29        */
+
+/*
+ * VAX process control block
+ */
+
+struct pcb
+{
+       int     pcb_ksp;        /* kernel stack pointer */
+       int     pcb_esp;        /* exec stack pointer */
+       int     pcb_ssp;        /* supervisor stack pointer */
+       int     pcb_usp;        /* user stack pointer */
+       int     pcb_r0; 
+       int     pcb_r1; 
+       int     pcb_r2; 
+       int     pcb_r3; 
+       int     pcb_r4; 
+       int     pcb_r5; 
+       int     pcb_r6; 
+       int     pcb_r7; 
+       int     pcb_r8; 
+       int     pcb_r9; 
+       int     pcb_r10; 
+       int     pcb_r11; 
+       int     pcb_r12; 
+#define        pcb_ap pcb_r12
+       int     pcb_r13; 
+#define        pcb_fp pcb_r13
+       int     pcb_pc;         /* program counter */
+       int     pcb_psl;        /* program status longword */
+       struct  pte *pcb_p0br;  /* seg 0 base register */
+       int     pcb_p0lr;       /* seg 0 length register and astlevel */
+       struct  pte *pcb_p1br;  /* seg 1 base register */
+       int     pcb_p1lr;       /* seg 1 length register and pme */
+/*
+ * Software pcb (extension)
+ */
+       int     pcb_szpt;       /* number of pages of user page table */
+       int     pcb_cmap2;
+       int     *pcb_sswap;
+       int     pcb_sigc[4];
+};
+
+#define        AST_NONE        0x04000000      /* ast level */
+#define        AST_USER        0x03000000      /* ast for user mode */
+
+#define        ASTLVL_NONE     4
+#define        ASTLVL_USER     3
+
+#define        AST_CLR         0x07000000
+#define        PME_CLR         0x80000000
+
+#define        aston() \
+       { \
+               u.u_pcb.pcb_p0lr = (u.u_pcb.pcb_p0lr &~ AST_CLR) | AST_USER; \
+               mtpr(ASTLVL, ASTLVL_USER); \
+       }
+
+#define        astoff() \
+       { \
+               u.u_pcb.pcb_p0lr = (u.u_pcb.pcb_p0lr &~ AST_CLR) | AST_NONE; \
+               mtpr(ASTLVL, ASTLVL_NONE); \
+       }
diff --git a/usr/src/sys/vax/pcb.m b/usr/src/sys/vax/pcb.m
new file mode 100644 (file)
index 0000000..b17573f
--- /dev/null
@@ -0,0 +1,36 @@
+/*     pcb.m   6.1     83/07/29        */
+
+/*
+ * VAX process control block
+ */
+       .set    PCB_KSP,        0
+       .set    PCB_ESP,        4
+       .set    PCB_SSP,        8
+       .set    PCB_USP,        12
+       .set    PCB_R0,         16
+       .set    PCB_R1,         20
+       .set    PCB_R2,         24
+       .set    PCB_R3,         28
+       .set    PCB_R4,         32
+       .set    PCB_R5,         36
+       .set    PCB_R6,         40
+       .set    PCB_R7,         44
+       .set    PCB_R8,         48
+       .set    PCB_R9,         52
+       .set    PCB_R10,        56
+       .set    PCB_R11,        60
+       .set    PCB_R12,        64
+       .set    PCB_R13,        68
+       .set    PCB_PC,         72
+       .set    PCB_PSL,        76
+       .set    PCB_P0BR,       80
+       .set    PCB_P0LR,       84
+       .set    PCB_P1BR,       88
+       .set    PCB_P1LR,       92
+/*
+ * Software pcb extension
+ */
+       .set    PCB_SZPT,       96      /* number of user page table pages */
+       .set    PCB_CMAP2,      100     /* saved cmap2 across cswitch (ick) */
+       .set    PCB_SSWAP,      104     /* flag for non-local goto */
+       .set    PCB_SIGC,       108     /* signal trampoline code */
diff --git a/usr/src/sys/vax/psl.h b/usr/src/sys/vax/psl.h
new file mode 100644 (file)
index 0000000..8e5477e
--- /dev/null
@@ -0,0 +1,27 @@
+/*     psl.h   6.1     83/07/29        */
+
+/*
+ * VAX program status longword
+ */
+
+#define        PSL_C           0x00000001      /* carry bit */
+#define        PSL_V           0x00000002      /* overflow bit */
+#define        PSL_Z           0x00000004      /* zero bit */
+#define        PSL_N           0x00000008      /* negative bit */
+#define        PSL_ALLCC       0x0000000f      /* all cc bits - unlikely */
+#define        PSL_T           0x00000010      /* trace enable bit */
+#define        PSL_IV          0x00000020      /* integer overflow enable bit */
+#define        PSL_FU          0x00000040      /* floating point underflow enable */
+#define        PSL_DV          0x00000080      /* decimal overflow enable bit */
+#define        PSL_IPL         0x001f0000      /* interrupt priority level */
+#define        PSL_PRVMOD      0x00c00000      /* previous mode (all on is user) */
+#define        PSL_CURMOD      0x03000000      /* current mode (all on is user) */
+#define        PSL_IS          0x04000000      /* interrupt stack */
+#define        PSL_FPD         0x08000000      /* first part done */
+#define        PSL_TP          0x40000000      /* trace pending */
+#define        PSL_CM          0x80000000      /* compatibility mode */
+
+#define        PSL_MBZ         0x3020ff00      /* must be zero bits */
+
+#define        PSL_USERSET     (PSL_PRVMOD|PSL_CURMOD)
+#define        PSL_USERCLR     (PSL_IS|PSL_IPL|PSL_MBZ)
diff --git a/usr/src/sys/vax/pte.h b/usr/src/sys/vax/pte.h
new file mode 100644 (file)
index 0000000..800816e
--- /dev/null
@@ -0,0 +1,85 @@
+/*     pte.h   6.1     83/07/29        */
+
+/*
+ * VAX page table entry
+ *
+ * There are two major kinds of pte's: those which have ever existed (and are
+ * thus either now in core or on the swap device), and those which have
+ * never existed, but which will be filled on demand at first reference.
+ * There is a structure describing each.  There is also an ancillary
+ * structure used in page clustering.
+ */
+
+#ifndef LOCORE
+struct pte
+{
+unsigned int   pg_pfnum:21,            /* core page frame number or 0 */
+               :2,
+               pg_vreadm:1,            /* modified since vread (or with _m) */
+               pg_swapm:1,             /* have to write back to swap */
+               pg_fod:1,               /* is fill on demand (=0) */
+               pg_m:1,                 /* hardware maintained modified bit */
+               pg_prot:4,              /* access control */
+               pg_v:1;                 /* valid bit */
+};
+struct hpte
+{
+unsigned int   pg_pfnum:21,
+               :2,
+               pg_high:9;              /* special for clustering */
+};
+struct fpte
+{
+unsigned int   pg_blkno:20,            /* file system block number */
+               pg_fileno:5,            /* file mapped from or TEXT or ZERO */
+               pg_fod:1,               /* is fill on demand (=1) */
+               :1,
+               pg_prot:4,
+               pg_v:1;
+};
+#endif
+
+#define        PG_V            0x80000000
+#define        PG_PROT         0x78000000
+#define        PG_M            0x04000000
+#define        PG_FOD          0x02000000
+#define        PG_VREADM       0x00800000
+#define        PG_PFNUM        0x001fffff
+
+#define        PG_FZERO        (NOFILE)
+#define        PG_FTEXT        (NOFILE+1)
+#define        PG_FMAX         (PG_FTEXT)
+
+#define        PG_NOACC        0
+#define        PG_KW           0x10000000
+#define        PG_KR           0x18000000
+#define        PG_UW           0x20000000
+#define        PG_URKW         0x70000000
+#define        PG_URKR         0x78000000
+
+/*
+ * Pte related macros
+ */
+#define        dirty(pte)      ((pte)->pg_fod == 0 && (pte)->pg_pfnum && \
+                           ((pte)->pg_m || (pte)->pg_swapm))
+
+#ifndef LOCORE
+#ifdef KERNEL
+struct pte *vtopte();
+
+/* utilities defined in locore.s */
+extern struct pte Sysmap[];
+extern struct pte Usrptmap[];
+extern struct pte usrpt[];
+extern struct pte Swapmap[];
+extern struct pte Forkmap[];
+extern struct pte Xswapmap[];
+extern struct pte Xswap2map[];
+extern struct pte Pushmap[];
+extern struct pte Vfmap[];
+extern struct pte mmap[];
+extern struct pte msgbufmap[];
+extern struct pte camap[];
+extern struct pte Nexmap[][16];
+#endif
+#endif
diff --git a/usr/src/sys/vax/pup_cksum.c b/usr/src/sys/vax/pup_cksum.c
new file mode 100644 (file)
index 0000000..536b280
--- /dev/null
@@ -0,0 +1,64 @@
+/*     pup_cksum.c     6.1     83/07/29        */
+
+#include "../h/types.h"
+#include "../h/mbuf.h"
+
+/*
+ * Checksum routine for PUP-I Protocol family (VAX Version).
+ */
+pup_cksum(m, len)
+       register struct mbuf *m;
+       register int len;
+{
+       register u_short *w;
+       register int sum = 0;                   /* known to be r8 */
+       register int mlen = 0;
+
+       for (;;) {
+               /*
+                * Each trip around loop adds in
+                * words from one mbuf segment.
+                */
+               w = mtod(m, u_short *);
+               if (mlen == -1) {
+                       /*
+                        * There is a byte left from the last segment;
+                        * add it into the checksum. 
+                        */
+                       sum += *(u_char *)w << 8;
+                       asm("rotl $1,r8,r8");
+                       w = (u_short *)((char *)w + 1);
+                       mlen = m->m_len - 1;
+                       len--;
+               } else
+                       mlen = m->m_len;
+               m = m->m_next;
+               if (len < mlen)
+                       mlen = len;
+               len -= mlen;
+               while ((mlen -= 2) >= 0) {
+                       asm("addw2 (r9)+,r8; rotl $1,r8,r8;");
+               }
+               if (mlen == -1)
+                       sum += *(u_char *)w;
+               if (len == 0)
+                       break;
+               /*
+                * Locate the next block with some data.
+                * If there is a word split across a boundary we
+                * will wrap to the top with mlen == -1 and
+                * then add it in shifted appropriately.
+                */
+               for (;;) {
+                       if (m == 0) {
+                               printf("pup_cksum: out of data\n");
+                               goto done;
+                       }
+                       if (m->m_len)
+                               break;
+                       m = m->m_next;
+               }
+       }
+done:
+       return (sum);
+}
diff --git a/usr/src/sys/vax/reg.h b/usr/src/sys/vax/reg.h
new file mode 100644 (file)
index 0000000..fe22c5e
--- /dev/null
@@ -0,0 +1,26 @@
+/*     reg.h   6.1     83/07/29        */
+/*
+ * Location of the users' stored
+ * registers relative to R0.
+ * Usage is u.u_ar0[XX].
+ */
+#define        R0      (-18)
+#define        R1      (-17)
+#define        R2      (-16)
+#define        R3      (-15)
+#define        R4      (-14)
+#define        R5      (-13)
+#define        R6      (-12)
+#define        R7      (-11)
+#define        R8      (-10)
+#define        R9      (-9)
+#define        R10     (-8)
+#define        R11     (-7)
+#define        R12     (-21)
+#define        R13     (-20)
+
+#define AP     (-21)
+#define        FP      (-20)
+#define        SP      (-5)
+#define        PS      (-1)
+#define        PC      (-2)
diff --git a/usr/src/sys/vax/rpb.h b/usr/src/sys/vax/rpb.h
new file mode 100644 (file)
index 0000000..03185e4
--- /dev/null
@@ -0,0 +1,17 @@
+/*     rpb.h   6.1     83/07/29        */
+
+/*
+ * The restart parameter block, which is a page in (very) low
+ * core which runs after a crash.  Currently, the restart
+ * procedure takes a dump.
+ */
+struct rpb {
+       struct  rpb *rp_selfref;        /* self-reference */
+       int     (*rp_dumprout)();       /* routine to be called */
+       long    rp_checksum;            /* checksum of 31 words of dumprout */
+       long    rp_flag;                /* set to 1 when dumprout runs */
+/* the dump stack grows from the end of the rpb page not to reach here */
+};
+#ifdef KERNEL
+extern struct rpb rpb;
+#endif
diff --git a/usr/src/sys/vax/rsp.h b/usr/src/sys/vax/rsp.h
new file mode 100644 (file)
index 0000000..46e7254
--- /dev/null
@@ -0,0 +1,79 @@
+/*     rsp.h   6.1     83/07/29        */
+
+/*
+ * TU58 transfer protocol constants and data structures
+ */
+
+/*
+ * Structure of a command packet
+ */
+struct packet {
+       u_char  pk_flag;        /* indicates packet type (cmd, data, etc.) */
+       u_char  pk_mcount;      /* length of packet (bytes) */
+       u_char  pk_op;          /* operation to perform (read, write, etc.) */
+       u_char  pk_mod;         /* modifier for op or returned status */
+       u_char  pk_unit;        /* unit number */
+       u_char  pk_sw;          /* switches */
+       u_short pk_seq;         /* sequence number, always zero */
+       u_short pk_count;       /* requested byte count for read or write */
+       u_short pk_block;       /* block number for read, write, or seek */
+       u_short pk_chksum;      /* checksum, by words with end around carry */
+};
+
+/*
+ * States
+ */
+#define        TUS_INIT1       0       /* sending nulls */
+#define        TUS_INIT2       1       /* sending inits */
+#define        TUS_IDLE        2       /* initialized, no transfer in progress */
+#define        TUS_SENDH       3       /* sending header */
+#define        TUS_SENDD       4       /* sending data */
+#define        TUS_SENDC       5       /* sending checksum */
+#define        TUS_SENDR       6       /* sending read command packet */
+#define        TUS_SENDW       7       /* sending write command packet */
+#define        TUS_GETH        8       /* reading header */
+#define        TUS_GETD        9       /* reading data */
+#define        TUS_GETC        10      /* reading checksum */
+#define        TUS_GET         11      /* reading an entire packet */
+#define        TUS_WAIT        12      /* waiting for continue */
+#define        TUS_RCVERR      13      /* receiver error in pseudo DMA routine */
+#define        TUS_CHKERR      14      /* checksum error in pseudo DMA routine */
+
+#define        TUS_NSTATES     15
+
+#define        printstate(state) \
+       if ((state) < TUS_NSTATES) \
+               printf("%s", tustates[(state)]); \
+       else \
+               printf("%d", (state));
+
+/*
+ * Packet Flags
+ */
+#define        TUF_DATA        1               /* data packet */
+#define        TUF_CMD         2               /* command packet */
+#define        TUF_INITF       4               /* initialize */
+#define        TUF_CONT        020             /* continue */
+#define        TUF_XOFF        023             /* flow control */
+
+/*
+ * Op Codes
+ */
+#define        TUOP_NOOP       0               /* no operation */
+#define        TUOP_INIT       1               /* initialize */
+#define        TUOP_READ       2               /* read block */
+#define        TUOP_WRITE      3               /* write block */
+#define        TUOP_SEEK       5               /* seek to block */
+#define TUOP_DIAGNOSE  7               /* run micro-diagnostics */
+#define        TUOP_END        0100            /* end packet */
+
+/*
+ * Mod Flags
+ */
+#define TUMD_WRV        1               /* write with read verify */
+
+/*
+ * Switches
+ */
+#define        TUSW_MRSP       010             /* use Modified RSP */
+
diff --git a/usr/src/sys/vax/sys_machdep.c b/usr/src/sys/vax/sys_machdep.c
new file mode 100644 (file)
index 0000000..d3e11d2
--- /dev/null
@@ -0,0 +1,142 @@
+/*     sys_machdep.c   6.1     83/07/29        */
+
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/ioctl.h"
+#include "../h/file.h"
+#include "../h/proc.h"
+#include "../h/uio.h"
+#include "../h/kernel.h"
+#include "../h/mtio.h"
+#include "../h/buf.h"
+
+#include "../vax/dkio.h"
+#include "../vax/pte.h"
+#include "../vaxuba/ubareg.h"
+#include "../vaxuba/ubavar.h"
+
+resuba()
+{
+
+       if (suser())
+       if (u.u_arg[0] < numuba)
+               ubareset(u.u_arg[0]);
+}
+
+#ifdef TRACE
+int    nvualarm;
+
+vtrace()
+{
+       register struct a {
+               int     request;
+               int     value;
+       } *uap;
+       int vdoualarm();
+
+       uap = (struct a *)u.u_ap;
+       switch (uap->request) {
+
+       case VTR_DISABLE:               /* disable a trace point */
+       case VTR_ENABLE:                /* enable a trace point */
+               if (uap->value < 0 || uap->value >= TR_NFLAGS)
+                       u.u_error = EINVAL;
+               else {
+                       u.u_r.r_val1 = traceflags[uap->value];
+                       traceflags[uap->value] = uap->request;
+               }
+               break;
+
+       case VTR_VALUE:         /* return a trace point setting */
+               if (uap->value < 0 || uap->value >= TR_NFLAGS)
+                       u.u_error = EINVAL;
+               else
+                       u.u_r.r_val1 = traceflags[uap->value];
+               break;
+
+       case VTR_UALARM:        /* set a real-time ualarm, less than 1 min */
+               if (uap->value <= 0 || uap->value > 60 * hz ||
+                   nvualarm > 5)
+                       u.u_error = EINVAL;
+               else {
+                       nvualarm++;
+                       timeout(vdoualarm, (caddr_t)u.u_procp->p_pid,
+                           uap->value);
+               }
+               break;
+
+       case VTR_STAMP:
+               trace(TR_STAMP, uap->value, u.u_procp->p_pid);
+               break;
+       }
+}
+
+vdoualarm(arg)
+       int arg;
+{
+       register struct proc *p;
+
+       p = pfind(arg);
+       if (p)
+               psignal(p, 16);
+       nvualarm--;
+}
+#endif
+
+#ifdef COMPAT
+/*
+ * Note: these tables are sorted by
+ * ioctl "code" (in ascending order).
+ */
+int dctls[] = { DKIOCHDR, 0 };
+int fctls[] = { FIOCLEX, FIONCLEX, FIOASYNC, FIONBIO, FIONREAD, 0 };
+int mctls[] = { MTIOCTOP, MTIOCGET, 0 };
+int tctls[] = {
+       TIOCGETD, TIOCSETD, TIOCHPCL, TIOCMODG, TIOCMODS,
+       TIOCGETP, TIOCSETP, TIOCSETN, TIOCEXCL, TIOCNXCL,
+       TIOCFLUSH,TIOCSETC, TIOCGETC, TIOCREMOTE,TIOCMGET,
+       TIOCMBIC, TIOCMBIS, TIOCMSET, TIOCSTART,TIOCSTOP,
+       TIOCPKT,  TIOCNOTTY,TIOCSTI,  TIOCOUTQ, TIOCGLTC,
+       TIOCSLTC, TIOCSPGRP,TIOCGPGRP,TIOCCDTR, TIOCSDTR,
+       TIOCCBRK, TIOCSBRK, TIOCLGET, TIOCLSET, TIOCLBIC,
+       TIOCLBIS, 0
+};
+
+/*
+ * Map an old style ioctl command to new.
+ */
+mapioctl(cmd)
+       int cmd;
+{
+       register int *map, c;
+
+       switch ((cmd >> 8) & 0xff) {
+
+       case 'd':
+               map = dctls;
+               break;
+
+       case 'f':
+               map = fctls;
+               break;
+
+       case 'm':
+               map = mctls;
+               break;
+
+       case 't':
+               map = tctls;
+               break;
+
+       default:
+               return (0);
+       }
+       while ((c = *map) && (c&0xff) < (cmd&0xff))
+               map++;
+       if (c && (c&0xff) == (cmd&0xff))
+               return (c);
+       return (0);
+}
+#endif
diff --git a/usr/src/sys/vax/trap.h b/usr/src/sys/vax/trap.h
new file mode 100644 (file)
index 0000000..2ec1e64
--- /dev/null
@@ -0,0 +1,22 @@
+/*     trap.h  6.1     83/07/29        */
+
+/*
+ * Trap type values
+ */
+
+/* The first three constant values are known to the real world <signal.h> */
+#define        T_RESADFLT      0               /* reserved addressing fault */
+#define        T_PRIVINFLT     1               /* privileged instruction fault */
+#define        T_RESOPFLT      2               /* reserved operand fault */
+/* End of known constants */
+#define        T_BPTFLT        3               /* bpt instruction fault */
+#define        T_XFCFLT        4               /* xfc instruction fault */
+#define        T_SYSCALL       5               /* chmk instruction (syscall trap) */
+#define        T_ARITHTRAP     6               /* arithmetic trap */
+#define        T_ASTFLT        7               /* software level 2 trap (ast deliv) */
+#define        T_SEGFLT        8               /* segmentation fault */
+#define        T_PROTFLT       9               /* protection fault */
+#define        T_TRCTRAP       10              /* trace trap */
+#define        T_COMPATFLT     11              /* compatibility mode fault */
+#define        T_PAGEFLT       12              /* page fault */
+#define        T_TABLEFLT      13              /* page table fault */
diff --git a/usr/src/sys/vax/udiv.s b/usr/src/sys/vax/udiv.s
new file mode 100644 (file)
index 0000000..fe284eb
--- /dev/null
@@ -0,0 +1,38 @@
+#      udiv.s  6.1     83/07/29
+#
+#      udiv - unsigned division for vax-11
+#
+#      arguments: dividend, divisor.
+#      result: quotient.
+#      uses r0-r2
+#
+#      If 1 < divisor <= 2147483647, zero-extend the dividend
+#      to 64 bits and let ediv do the work.  If the divisor is 1,
+#      ediv will overflow if bit 31 of the dividend is on, so
+#      just return the dividend unchanged.  If the divisor is 0,
+#      do the ediv also, so it will generate the proper exception.
+#      All other values of the divisor have bit 31 on: in this case
+#      the quotient must be 0 if divisor > dividend, and 1 otherwise,
+#      provided that the comparison is made as unsigned.
+#
+       .text
+       .align  1
+       .globl  udiv
+udiv:  .word   0x0000
+       movl    4(ap),r0        # Dividend
+       movl    8(ap),r2        # Divisor
+       jeql    div             # If divisor=0, force exception
+       cmpl    r2,$1           # If divisor <= 1 (signed),
+       jleq    nodiv           #  no division is necessary
+div:   clrl    r1              # Zero-extend the dividend
+       ediv    r2,r0,r0,r2     # Divide.  q->r0, r->r2 (discarded)
+       ret
+nodiv: jeql    retn            # If divisor=1, return dividend
+       cmpl    r0,r2           # Unsigned comparison between
+       jgequ   one             #  dividend and divisor
+       clrl    r0              # Dividend < divisor, return 0
+       ret
+one:   movl    $1,r0           # Dividend >= divisor, return 1
+retn:  ret
+
+
diff --git a/usr/src/sys/vax/ufs_machdep.c b/usr/src/sys/vax/ufs_machdep.c
new file mode 100644 (file)
index 0000000..1f76a71
--- /dev/null
@@ -0,0 +1,95 @@
+/*     ufs_machdep.c   6.1     83/07/29        */
+
+#include "../machine/pte.h"
+
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/buf.h"
+#include "../h/conf.h"
+#include "../h/proc.h"
+#include "../h/seg.h"
+#include "../h/vm.h"
+
+/*
+ * Machine dependent handling of the buffer cache.
+ */
+
+/*
+ * Expand or contract the actual memory allocated to a buffer.
+ * If no memory is available, release buffer and take error exit
+ */
+allocbuf(tp, size)
+       register struct buf *tp;
+       int size;
+{
+       register struct buf *bp, *ep;
+       int sizealloc, take;
+
+       sizealloc = roundup(size, CLBYTES);
+       /*
+        * Buffer size does not change
+        */
+       if (sizealloc == tp->b_bufsize)
+               goto out;
+       /*
+        * Buffer size is shrinking.
+        * Place excess space in a buffer header taken from the
+        * BQ_EMPTY buffer list and placed on the "most free" list.
+        * If no extra buffer headers are available, leave the
+        * extra space in the present buffer.
+        */
+       if (sizealloc < tp->b_bufsize) {
+               ep = bfreelist[BQ_EMPTY].av_forw;
+               if (ep == &bfreelist[BQ_EMPTY])
+                       goto out;
+               notavail(ep);
+               pagemove(tp->b_un.b_addr + sizealloc, ep->b_un.b_addr,
+                   (int)tp->b_bufsize - sizealloc);
+               ep->b_bufsize = tp->b_bufsize - sizealloc;
+               tp->b_bufsize = sizealloc;
+               ep->b_flags |= B_INVAL;
+               ep->b_bcount = 0;
+               brelse(ep);
+               goto out;
+       }
+       /*
+        * More buffer space is needed. Get it out of buffers on
+        * the "most free" list, placing the empty headers on the
+        * BQ_EMPTY buffer header list.
+        */
+       while (tp->b_bufsize < sizealloc) {
+               take = sizealloc - tp->b_bufsize;
+               bp = getnewbuf();
+               if (take >= bp->b_bufsize)
+                       take = bp->b_bufsize;
+               pagemove(&bp->b_un.b_addr[bp->b_bufsize - take],
+                   &tp->b_un.b_addr[tp->b_bufsize], take);
+               tp->b_bufsize += take;
+               bp->b_bufsize = bp->b_bufsize - take;
+               if (bp->b_bcount > bp->b_bufsize)
+                       bp->b_bcount = bp->b_bufsize;
+               if (bp->b_bufsize <= 0) {
+                       bremhash(bp);
+                       binshash(bp, &bfreelist[BQ_EMPTY]);
+                       bp->b_dev = (dev_t)NODEV;
+                       bp->b_error = 0;
+                       bp->b_flags |= B_INVAL;
+               }
+               brelse(bp);
+       }
+out:
+       tp->b_bcount = size;
+       return (1);
+}
+
+/*
+ * Release space associated with a buffer.
+ */
+bfree(bp)
+       struct buf *bp;
+{
+
+       bp->b_bcount = 0;
+}
diff --git a/usr/src/sys/vax/urem.s b/usr/src/sys/vax/urem.s
new file mode 100644 (file)
index 0000000..b7e755a
--- /dev/null
@@ -0,0 +1,38 @@
+#      urem.s  6.1     83/07/29
+#
+#      urem - unsigned remainder for vax-11
+#
+#      arguments: dividend, divisor
+#      result: remainder
+#      uses r0-r2
+#
+#      if 1 < divisor <= 2147483647, zero-extend the dividend
+#      to 64 bits and let ediv do the work.  If the divisor is 1,
+#      ediv will overflow if bit 31 of the dividend is on, so
+#      just return 0.  If the divisor is 0, do the ediv also,
+#      so it will generate the proper exception.  All other values
+#      of the divisor have bit 31 on: in this case the remainder
+#      must be the dividend if divisor > dividend, and the dividend
+#      minus the divisor otherwise.  The comparison must be unsigned.
+#
+       .text
+       .align  1
+       .globl  urem
+urem:  .word   0x0000
+       movl    4(ap),r0        # Dividend
+       movl    8(ap),r2        # Divisor
+       jeql    div             # If divisor=0, force exception
+       cmpl    r2,$1           # If divisor <= 1 (signed),
+       jleq    nodiv           #  no division is necessary
+div:   clrl    r1              # Zero-extend the dividend
+       ediv    r2,r0,r2,r0     # Divide.  q->r2 (discarded), r->r0
+       ret
+nodiv: jneq    nzero           # If divisor=1, return 0
+       clrl    r0              #  (because doing the divide will overflow
+       ret                     #  if the dividend has its high bit on)
+nzero: cmpl    r0,r2           # If dividend < divisor (unsigned)
+       jlssu   retn            #  remainder is dividend
+       subl2   r2,r0           #  else remainder is dividend - divisor
+retn:  ret
+
+
diff --git a/usr/src/sys/vax/vm_machdep.c b/usr/src/sys/vax/vm_machdep.c
new file mode 100644 (file)
index 0000000..882311d
--- /dev/null
@@ -0,0 +1,226 @@
+/*     vm_machdep.c    6.1     83/07/29        */
+
+#include "../machine/pte.h"
+
+#include "../h/param.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/proc.h"
+#include "../h/cmap.h"
+#include "../h/mount.h"
+#include "../h/vm.h"
+#include "../h/text.h"
+
+#include "../vax/mtpr.h"
+
+/*
+ * Set a red zone in the kernel stack after the u. area.
+ */
+setredzone(pte, vaddr)
+       register struct pte *pte;
+       caddr_t vaddr;
+{
+
+       pte += (sizeof (struct user) + NBPG - 1) / NBPG;
+       *(int *)pte &= ~PG_PROT;
+       *(int *)pte |= PG_URKR;
+       if (vaddr)
+               mtpr(TBIS, vaddr + sizeof (struct user));
+}
+
+#ifndef mapin
+mapin(pte, v, pfnum, count, prot)
+       struct pte *pte;
+       u_int v, pfnum;
+       int count, prot;
+{
+
+       while (count > 0) {
+               *(int *)pte++ = pfnum | prot;
+               mtpr(TBIS, ptob(v));
+               v++;
+               pfnum++;
+               count--;
+       }
+}
+#endif
+
+#ifdef notdef
+/*ARGSUSED*/
+mapout(pte, size)
+       register struct pte *pte;
+       int size;
+{
+
+       panic("mapout");
+}
+#endif
+
+/*
+ * Check for valid program size
+ */
+chksize(ts, ds, ss)
+       register unsigned ts, ds, ss;
+{
+       static int maxdmap = 0;
+
+       if (ts > MAXTSIZ || ds > MAXDSIZ || ss > MAXSSIZ) {
+               u.u_error = ENOMEM;
+               return (1);
+       }
+       /* check for swap map overflow */
+       if (maxdmap == 0) {
+               register int i, blk;
+
+               blk = dmmin;
+               for (i = 0; i < NDMAP; i++) {
+                       maxdmap += blk;
+                       if (blk < dmmax)
+                               blk *= 2;
+               }
+       }
+       if (ctod(ts) > NXDAD * dmtext ||
+           ctod(ds) > maxdmap || ctod(ss) > maxdmap) {
+               u.u_error = ENOMEM;
+               return (1);
+       }
+       /*
+        * Make sure the process isn't bigger than our
+        * virtual memory limit.
+        *
+        * THERE SHOULD BE A CONSTANT FOR THIS.
+        */
+       if (ts + ds + ss + LOWPAGES + HIGHPAGES > btoc(USRSTACK)) {
+               u.u_error = ENOMEM;
+               return (1);
+       }
+       return (0);
+}
+
+/*ARGSUSED*/
+newptes(pte, v, size)
+       register struct pte *pte;
+       u_int v;
+       register int size;
+{
+       register caddr_t a = ptob(v);
+
+#ifdef lint
+       pte = pte;
+#endif
+       if (size >= 8) {
+               mtpr(TBIA, 0);
+               return;
+       }
+       while (size > 0) {
+               mtpr(TBIS, a);
+               a += NBPG;
+               size--;
+       }
+}
+
+/*
+ * Change protection codes of text segment.
+ * Have to flush translation buffer since this
+ * affect virtual memory mapping of current process.
+ */
+chgprot(addr, tprot)
+       caddr_t addr;
+       long tprot;
+{
+       unsigned v;
+       int tp;
+       register struct pte *pte;
+       register struct cmap *c;
+
+       v = clbase(btop(addr));
+       if (!isatsv(u.u_procp, v)) {
+               u.u_error = EFAULT;
+               return (0);
+       }
+       tp = vtotp(u.u_procp, v);
+       pte = tptopte(u.u_procp, tp);
+       if (pte->pg_fod == 0 && pte->pg_pfnum) {
+               c = &cmap[pgtocm(pte->pg_pfnum)];
+               if (c->c_blkno && c->c_mdev != MSWAPX)
+                       munhash(mount[c->c_mdev].m_dev,
+                           (daddr_t)(u_long)c->c_blkno);
+       }
+       *(int *)pte &= ~PG_PROT;
+       *(int *)pte |= tprot;
+       distcl(pte);
+       tbiscl(v);
+       return (1);
+}
+
+settprot(tprot)
+       long tprot;
+{
+       register int *ptaddr, i;
+
+       ptaddr = (int *)mfpr(P0BR);
+       for (i = 0; i < u.u_tsize; i++) {
+               ptaddr[i] &= ~PG_PROT;
+               ptaddr[i] |= tprot;
+       }
+       mtpr(TBIA, 0);
+}
+
+/*
+ * Rest are machine-dependent
+ */
+
+getmemc(addr)
+       caddr_t addr;
+{
+       register int c;
+       struct pte savemap;
+
+       savemap = mmap[0];
+       *(int *)mmap = PG_V | PG_KR | btop(addr);
+       mtpr(TBIS, vmmap);
+       c = *(char *)&vmmap[(int)addr & PGOFSET];
+       mmap[0] = savemap;
+       mtpr(TBIS, vmmap);
+       return (c & 0377);
+}
+
+putmemc(addr, val)
+       caddr_t addr;
+{
+       struct pte savemap;
+
+       savemap = mmap[0];
+       *(int *)mmap = PG_V | PG_KW | btop(addr);
+       mtpr(TBIS, vmmap);
+       *(char *)&vmmap[(int)addr & PGOFSET] = val;
+       mmap[0] = savemap;
+       mtpr(TBIS, vmmap);
+}
+
+/*
+ * Move pages from one kernel virtual address to another.
+ * Both addresses are assumed to reside in the Sysmap,
+ * and size must be a multiple of CLSIZE.
+ */
+pagemove(from, to, size)
+       register caddr_t from, to;
+       int size;
+{
+       register struct pte *fpte, *tpte;
+
+       if (size % CLBYTES)
+               panic("pagemove");
+       fpte = &Sysmap[btop(from - 0x80000000)];
+       tpte = &Sysmap[btop(to - 0x80000000)];
+       while (size > 0) {
+               *tpte++ = *fpte;
+               *(int *)fpte++ = 0;
+               mtpr(TBIS, from);
+               mtpr(TBIS, to);
+               from += NBPG;
+               to += NBPG;
+               size -= NBPG;
+       }
+}
diff --git a/usr/src/sys/vax/vmparam.h b/usr/src/sys/vax/vmparam.h
new file mode 100644 (file)
index 0000000..3a5a0d3
--- /dev/null
@@ -0,0 +1,121 @@
+/*     vmparam.h       6.1     83/07/29        */
+
+/*
+ * Machine dependent constants for VAX
+ */
+/*
+ * USRTEXT is the start of the user text/data space, while USRSTACK
+ * is the top (end) of the user stack.  LOWPAGES and HIGHPAGES are
+ * the number of pages from the beginning of the P0 region to the
+ * beginning of the text and from the beginning of the P1 region to the
+ * beginning of the stack respectively.
+ */
+                                       /* number of ptes per page */
+#define        USRTEXT         0
+#define        USRSTACK        (0x80000000-UPAGES*NBPG)
+                                       /* Start of user stack */
+#define        P1PAGES         0x200000        /* number of pages in P1 region */
+#define        LOWPAGES        0
+#define        HIGHPAGES       UPAGES
+
+/*
+ * Virtual memory related constants
+ */
+#define        SLOP    32
+#define        MAXTSIZ         (6*2048-SLOP)           /* max text size (clicks) */
+#ifndef MAXDSIZ
+#define        MAXDSIZ         (12*1024-32-SLOP)       /* max data size (clicks) */
+#endif
+#define        MAXSSIZ         (12*1024-32-SLOP)       /* max stack size (clicks) */
+
+/*
+ * Sizes of the system and user portions of the system page table.
+ */
+/* SYSPTSIZE IS SILLY; IT SHOULD BE COMPUTED AT BOOT TIME */
+#define        SYSPTSIZE       ((20+MAXUSERS)*NPTEPG)
+#define        USRPTSIZE       (8*NPTEPG)
+
+/*
+ * The size of the clock loop.
+ */
+#define        LOOPPAGES       (maxfree - firstfree)
+
+/*
+ * The time for a process to be blocked before being very swappable.
+ * This is a number of seconds which the system takes as being a non-trivial
+ * amount of real time.  You probably shouldn't change this;
+ * it is used in subtle ways (fractions and multiples of it are, that is, like
+ * half of a ``long time'', almost a long time, etc.)
+ * It is related to human patience and other factors which don't really
+ * change over time.
+ */
+#define        MAXSLP          20
+
+/*
+ * A swapped in process is given a small amount of core without being bothered
+ * by the page replacement algorithm.  Basically this says that if you are
+ * swapped in you deserve some resources.  We protect the last SAFERSS
+ * pages against paging and will just swap you out rather than paging you.
+ * Note that each process has at least UPAGES+CLSIZE pages which are not
+ * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this
+ * number just means a swapped in process is given around 25k bytes.
+ * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81),
+ * so we loan each swapped in process memory worth 100$, or just admit
+ * that we don't consider it worthwhile and swap it out to disk which costs
+ * $30/mb or about $0.75.
+ */
+#define        SAFERSS         32              /* nominal ``small'' resident set size
+                                          protected against replacement */
+
+/*
+ * DISKRPM is used to estimate the number of paging i/o operations
+ * which one can expect from a single disk controller.
+ */
+#define        DISKRPM         60
+
+/*
+ * Klustering constants.  Klustering is the gathering
+ * of pages together for pagein/pageout, while clustering
+ * is the treatment of hardware page size as though it were
+ * larger than it really is.
+ *
+ * KLMAX gives maximum cluster size in CLSIZE page (cluster-page)
+ * units.  Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h.
+ */
+
+#define        KLMAX   (32/CLSIZE)
+#define        KLSEQL  (16/CLSIZE)             /* in klust if vadvise(VA_SEQL) */
+#define        KLIN    (8/CLSIZE)              /* default data/stack in klust */
+#define        KLTXT   (4/CLSIZE)              /* default text in klust */
+#define        KLOUT   (32/CLSIZE)
+
+/*
+ * KLSDIST is the advance or retard of the fifo reclaim for sequential
+ * processes data space.
+ */
+#define        KLSDIST 3               /* klusters advance/retard for seq. fifo */
+
+/*
+ * Paging thresholds (see vm_sched.c).
+ * Strategy of 4/22/81:
+ *     lotsfree is 1/4 of memory free.
+ *     desfree is 200k bytes, but at most 1/8 of memory
+ *     minfree is 64k bytes, but at most 1/2 of desfree
+ */
+#define        LOTSFREEFRACT   4
+#define        DESFREE         (200 * 1024)
+#define        DESFREEFRACT    8
+#define        MINFREE         (64 * 1024)
+#define        MINFREEFRACT    2
+
+/*
+ * Believed threshold (in megabytes) for which interleaved
+ * swapping area is desirable.
+ */
+#define        LOTSOFMEM       2
+
+/*
+ * BEWARE THIS DEFINITION WORKS ONLY WITH COUNT OF 1
+ */
+#define        mapin(pte, v, pfnum, count, prot) \
+       (*(int *)(pte) = (pfnum) | (prot), mtpr(TBIS, ptob(v)))