1: # 2: /* 3: */ 4: 5: /* 6: * Screw Works interface via DC-11 7: */ 8: 9: #include "../tty.h" 10: 11: #define VSADDR 0174150 12: #define CDLEAD 01 13: #define B1200 030 14: #define STOP1 0400 15: #define CLSEND 02 16: #define RQSEND 01 17: 18: #define MAGIC_MAP 0377 19: 20: struct { 21: int vsrcsr; 22: int vsrbuf; 23: int vsxcsr; 24: int vsxbuf; 25: }; 26: 27: struct { 28: struct clist iq; 29: struct clist oq; 30: } vs; 31: 32: vsopen(dev) 33: { 34: VSADDR->vsrcsr = IENABLE|B1200|CDLEAD; 35: VSADDR->vsxcsr = STOP1|IENABLE|B1200; 36: vschar(0); 37: } 38: 39: vsclose(dev) 40: { 41: vschar(0); 42: VSADDR->vsrcsr =& ~IENABLE; 43: while (getc(&vs.iq) >= 0); 44: } 45: 46: vswrite(dev) 47: { 48: register int count, c; 49: 50: count = 0; 51: while ((c=cpass()) >= 0) { 52: if (--count <= 0) { 53: count = 60; 54: vschar(0); 55: } 56: vschar(c); 57: } 58: vschar(0); 59: } 60: 61: vschar(c) 62: { 63: 64: c =^ MAGIC_MAP; 65: spl5(); 66: while (vs.oq.c_cc > 60) { 67: vsxintr(); 68: sleep(&vs.oq, TTIPRI); 69: } 70: putc(c, &vs.oq); 71: vsxintr(); 72: spl0(); 73: } 74: 75: vsxintr() 76: { 77: static lchar; 78: register c; 79: register int *xcsr; 80: 81: xcsr = &VSADDR->vsxcsr; 82: if (*xcsr&DONE) { 83: if (lchar==MAGIC_MAP) { 84: *xcsr =& ~RQSEND; 85: lchar = 0; 86: if (vs.oq.c_cc==0) 87: goto wake; 88: } 89: if ((*xcsr&CLSEND) == 0) { 90: *xcsr =& ~RQSEND; 91: *xcsr =| RQSEND; 92: if ((*xcsr&CLSEND) == 0) 93: goto wake; 94: } 95: if ((c = getc(&vs.oq)) >= 0) 96: VSADDR->vsxbuf = lchar = c; 97: if (vs.oq.c_cc <= 15) 98: wake: 99: wakeup(&vs.oq); 100: } 101: } 102: 103: vsread(dev) 104: { 105: register int c; 106: 107: spl5(); 108: while ((c = getc(&vs.iq)) < 0) 109: sleep(&vs.iq, TTIPRI); 110: spl0(); 111: passc("?0*#?546?213?879?"[c&017]); 112: } 113: 114: vsrintr() 115: { 116: register int c; 117: 118: c = VSADDR->vsrbuf; 119: if (vs.iq.c_cc<=10) 120: putc(c, &vs.iq); 121: wakeup(&vs.iq); 122: }