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

1.1       root        1: /*
                      2:  * machine-specific hardware routines,
                      3:  * these for nautilus
                      4:  */
                      5: 
                      6: #include "sys/mtpr.h"
                      7: #include "sys/cons.h"
                      8: 
                      9: int delayfact = 5;     /* for DELAY macro */
                     10: 
                     11: #define        NICTRL  0x80    /* nmi interrupt enables: */
                     12: #define        MEMENB  0x20    /* memory/fault */
                     13: #define        NB1ENB  0x40    /* device 1 */
                     14: #define        NB0ENB  0x80    /* device 0 */
                     15: #define        COR     0x85    /* cache on */
                     16: 
                     17: static int nmienable = MEMENB;
                     18: 
                     19: /*
                     20:  * adjust physical top of memory to useful top of memory
                     21:  * (some vaxes put important console stuff there)
                     22:  * called with mapping off
                     23:  */
                     24: machmem(hi)
                     25: int hi;
                     26: {
                     27:        return (hi);
                     28: }
                     29: 
                     30: /*
                     31:  * miscellaneous machine-dependent initialization
                     32:  * called just after mapping turned on
                     33:  */
                     34: machinit()
                     35: {
                     36: 
                     37:        mtpr(COR, 1);           /* turn on the cache */
                     38:        mcrinit();
                     39:        mtpr(NICTRL, nmienable);
                     40: }
                     41: 
                     42: /*
                     43:  * enable interrupts from one of the NBIAs
                     44:  */
                     45: 
                     46: setnmi(dev)
                     47: int dev;
                     48: {
                     49:        nmienable |= dev ? NB1ENB : NB0ENB;
                     50:        mtpr(NICTRL, nmienable);        
                     51: }
                     52: 
                     53: /*
                     54:  * stray interrupt handling:
                     55:  * just decrypt it and return
                     56:  */
                     57: 
                     58: long passintr;
                     59: 
                     60: strayintr(v)
                     61: int v;
                     62: {
                     63:        if ((v & 0x1ff) == 0) {
                     64:                passintr++;
                     65:                return;
                     66:        }
                     67:        printf("stray interrupt at 0x%x == 0%o\n", v, v);       /* temp */
                     68: }
                     69: 
                     70: /*
                     71:  * read the time-of-year clock, which is buried in the wretched console
                     72:  */
                     73: 
                     74: #define        CMDID   0xf
                     75: #define        READTOY 0x8
                     76: #define        WRITTOY 0x9
                     77: #define        RTOYID  0xd
                     78: #define        WTOYID  0xd
                     79: 
                     80: int *cniread(), *cniwrite();
                     81: static char rtbusy, wtbusy;
                     82: long
                     83: gettodr()
                     84: {
                     85:        register int i;
                     86:        register int *p;
                     87:        static char rtoy = READTOY;
                     88:        static long toy;
                     89: 
                     90:        if (rtbusy)
                     91:                return (0);
                     92:        rtbusy++;
                     93:        for (i = 0; i < 2; i++) {
                     94:                p = cniread(RTOYID, (char *)&toy, 4);
                     95:                cniwrite(CMDID, &rtoy, 1);
                     96:                if (cniwait(p, 2) == 0) {
                     97:                        rtbusy = 0;
                     98:                        return (toy);
                     99:                }
                    100:        }
                    101:        rtbusy = 0;
                    102:        return (0);
                    103: }
                    104: 
                    105: /*
                    106:  * set time-of-year clock
                    107:  * 10% of the time, it is mysteriously set wrong;
                    108:  * try a couple of times
                    109:  */
                    110: 
                    111: settodr(toy)
                    112: unsigned long toy;
                    113: {
                    114:        register int i;
                    115:        register unsigned long ntoy;
                    116: 
                    117:        if (wtbusy)
                    118:                return;
                    119:        wtbusy++;
                    120:        for (i = 0; i < 4; i++) {
                    121:                csettodr(toy);
                    122:                ntoy = gettodr();
                    123:                if (ntoy >= toy && ntoy < toy + 100)
                    124:                        break;
                    125:        }
                    126:        wtbusy = 0;
                    127: }
                    128: 
                    129: csettodr(toy)
                    130: long toy;
                    131: {
                    132:        static char wtoy = WRITTOY;
                    133:        static long tbuf;
                    134: 
                    135:        if (cniwait(cniwrite(CMDID, &wtoy, 1), 2))
                    136:                return;
                    137:        tbuf = toy;
                    138:        cniwait(cniwrite(WTOYID, (char *)&tbuf, 4));
                    139: }

unix.superglobalmegacorp.com

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