Annotation of researchv10dc/sys/md/machmfair.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * machine-specific hardware routines,
                      3:  * these for MicroVAX III
                      4:  */
                      5: 
                      6: #include "sys/param.h"
                      7: #include "sys/pte.h"
                      8: #include "sys/mtpr.h"
                      9: #include "sys/vm.h"
                     10: #include "sys/qbio.h"
                     11: #include "sys/clock.h"
                     12: 
                     13: #define        CADR    37              /* first-level cache control */
                     14: #define        IORESET 55              /* reset all IO connections */
                     15: #define        CEN     020             /* cacr: cache enable */
                     16: #define        CAEN    0360            /* CADR: enable both halves, both I and D */
                     17: 
                     18: /*
                     19:  * bits in console mailbox
                     20:  */
                     21: 
                     22: #define        HALTACT 03      /* halt action */
                     23: #define        HMRBOOT 0       /* halt: restart, then boot (if halts disabled!) */
                     24: #define        HMRST   01      /* halt: restart regardless (but never boot) */
                     25: #define        HMBOOT  02      /* halt: boot */
                     26: #define        BOOTIH  04      /* boot inhibit */
                     27: #define        RSTIH   010     /* restart inhibit */
                     28: 
                     29: char *iospace;
                     30: int delayfact = 3;             /* factor for DELAY macro */
                     31: 
                     32: /*
                     33:  * adjust physical top of memory to useful top of memory:
                     34:  * preserve memory bitmap (one bit per 512-byte page)
                     35:  * and Q-bus map, which steals memory as well
                     36:  * the console is meant to have left it all at the top
                     37:  * but we may not have found the top, if intermediate bits are broken
                     38:  */
                     39: machmem(hi)
                     40: register int hi;
                     41: {
                     42:        register int qm;
                     43: 
                     44:        qm = *(int *)0x20080010;        /* addr of Q-bus map in mem */
                     45:        qm -= qm/(NBPG*NBBY);           /* bitmap */
                     46:        if (hi < qm)                    /* in case memory has holes */
                     47:                return (hi);
                     48:        return (qm);
                     49: }
                     50: 
                     51: /*
                     52:  * miscellaneous machine-dependent initialization
                     53:  * called just after mapping turned on
                     54:  *
                     55:  * - make instruction emulation code accessible from user space
                     56:  * - reset and enable IO
                     57:  * - enable caches
                     58:  *
                     59:  * eventually some of the init stuff moves to machreset
                     60:  */
                     61: machinit()
                     62: {
                     63:        register int *p;                /* pun; really struct pte */
                     64:        register char *e;
                     65:        register struct iomfair *q;
                     66:        register int i;
                     67:        extern char _emulbeg, _emulend;
                     68: 
                     69:        e = &_emulbeg;
                     70:        p = (int *)&Sysmap[btop((int)e & ~KSTART)];
                     71:        do {
                     72:                *p = (*p &~ PG_PROT) | PG_URKR;
                     73:                p++;
                     74:                e += NBPG;
                     75:        } while (e < &_emulend);
                     76:        mtpr(IORESET, 0);
                     77:        q = (struct iomfair *)iospace;
                     78:        for (i = 0; i < CACHESIZE; i++)
                     79:                q->d.cd[i] = 0;         /* flush second-level cache */
                     80:        q->d.cacr |= CEN;       /* and enable it */
                     81:        mtpr(CADR, mfpr(CADR)|CAEN);
                     82:        machreset();
                     83:        mcrinit();
                     84: }
                     85: 
                     86: /*
                     87:  * stray interrupt handling:
                     88:  * just decrypt it and return
                     89:  */
                     90: strayintr(v)
                     91: int v;
                     92: {
                     93:        if (v < 0x200)
                     94:                printf("stray interrupt at 0x%x\n", v);
                     95:        else
                     96:                printf("stray Q-bus interrupt at 0%o\n", v-0x200);
                     97: }
                     98: 
                     99: /*
                    100:  * how big is io space?
                    101:  */
                    102: 
                    103: mchiopsize()
                    104: {
                    105:        return (sizeof(struct iomfair));
                    106: }
                    107: 
                    108: /*
                    109:  * set up the page tables for iospace
                    110:  * called while the system page table is being assembled;
                    111:  * memory mapping is off
                    112:  * pt is the first page table of an area
                    113:  * mapping what mchiopsize returned
                    114:  */
                    115: 
                    116: mchiopinit(pt)
                    117: struct pte *pt;
                    118: {
                    119:        register long *p;       /* pun, for efficiency */
                    120:        register long b;
                    121:        register int i;
                    122: 
                    123:        p = (long *)pt;
                    124:        *p++ = PG_V|PG_KW|btop(0x20080000);     /* cpu regs */
                    125:        *p++ = PG_V|PG_KW|btop(0x20140400);     /* NVRAM */
                    126:        *p++ = PG_V|PG_KW|btop(0x20084000);     /* cache register */
                    127:        b = btop(0x10000000);                   /* cache diagnostic space */
                    128:        for (i = 0; i < btop(CACHESIZE*sizeof(long)); i++)
                    129:                *p++ = PG_V|PG_KW|b++;
                    130:        b = btop(0x20088000);                   /* Q-bus map */
                    131:        for (i = 0; i < btop(NQMREG*sizeof(long)); i++)
                    132:                *p++ = PG_V|PG_KW|b++;
                    133:        b = btop(0x20000000);                   /* Q-bus io regs */
                    134:        for (i = 0; i < btop(8192); i++)
                    135:                *p++ = PG_V|PG_KW|b++;
                    136: }
                    137: 
                    138: /*
                    139:  * return the IO regs for a Q-bus adapter
                    140:  * (there's really only one, but only this code knows that)
                    141:  */
                    142: 
                    143: caddr_t
                    144: qbaaddr(u)
                    145: int u;
                    146: {
                    147:        if (u != 0)
                    148:                return (0);
                    149:        return ((caddr_t)&((struct iomfair *)iospace)->u[u]);
                    150: }
                    151: 
                    152: /*
                    153:  * arrange for a restart on halt
                    154:  * -- it would be slightly preferable
                    155:  * to fall back to a boot if the restart fails;
                    156:  * alas, to do that on MicroVAX II or III,
                    157:  * you must disable console halts
                    158:  */
                    159: 
                    160: setrestart()
                    161: {
                    162:        register short *p;
                    163: 
                    164:        p = &((struct iomfair *)iospace)->w.cpmbx;
                    165:        *p &=~ (BOOTIH|RSTIH|HALTACT);
                    166:        *p |= HMRST;            /* always just restart */
                    167: }
                    168: 
                    169: /*
                    170:  * arrange for a boot, now or on next halt
                    171:  * -- sometimes called with mapping disabled
                    172:  */
                    173: 
                    174: setboot()
                    175: {
                    176:        register short *p;
                    177: 
                    178:        if (mfpr(MAPEN))
                    179:                p = &((struct iomfair *)iospace)->w.cpmbx;
                    180:        else
                    181:                p = (short *)0x20140400;
                    182:        *p &=~ (BOOTIH|RSTIH|HALTACT);
                    183:        *p |= HMBOOT;           /* halt mode `boot' */
                    184: }
                    185: 
                    186: /*
                    187:  * fetch/set time-of-year clock
                    188:  */
                    189: 
                    190: gettodr()
                    191: {
                    192:        return (mfpr(TODR));
                    193: }
                    194: 
                    195: settodr(t)
                    196: long t;
                    197: {
                    198:        mtpr(TODR, t);
                    199: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.