1: # 2: /* 3: */ 4: 5: /* 6: * VT01 driver via DR11C to 11/20 7: */ 8: 9: #include "../param.h" 10: #include "../user.h" 11: 12: int vtflag; 13: 14: struct vtreg { 15: int csr; 16: int buf; 17: }; 18: 19: #define VTADDR 0167770 20: #define RQINT 01 21: #define BIENABL 040 22: #define SEOF 0100000 23: #define VTPRI 8 24: 25: vtopen(dev, flag) 26: { 27: if (!flag) 28: u.u_error = ENXIO; 29: else 30: VTADDR->csr = BIENABL; 31: } 32: 33: vtclose() 34: { 35: VTADDR->buf = SEOF; 36: VTADDR->csr =| RQINT; 37: } 38: 39: vtwrite() 40: { 41: register int c; 42: int register count; 43: 44: while ((c=cpass()) >= 0) { 45: retry: 46: for (count=0; count<10; count++) 47: if ((VTADDR->csr&RQINT)==0) { 48: VTADDR->buf = c&0377; 49: VTADDR->csr =| RQINT; 50: goto contin; 51: } 52: spl5(); 53: if (VTADDR->csr&RQINT) { 54: vtflag++; 55: sleep(VTADDR, VTPRI); 56: } 57: spl0(); 58: goto retry; 59: contin:; 60: } 61: } 62: 63: vtintr() 64: { 65: VTADDR->csr =& ~RQINT; 66: if (vtflag) { 67: vtflag = 0; 68: wakeup(VTADDR); 69: } 70: }