|
|
1.1 ! root 1: /* %M% %I% %G% */ ! 2: ! 3: /* ! 4: * KL/DL-11 driver ! 5: */ ! 6: #include "../h/param.h" ! 7: #include "../h/conf.h" ! 8: #include "../h/dir.h" ! 9: #include "../h/user.h" ! 10: #include "../h/tty.h" ! 11: #include "../h/systm.h" ! 12: #include "../h/map.h" ! 13: #include "../h/pte.h" ! 14: #include "../h/uba.h" ! 15: ! 16: /* base address */ ! 17: #define KLBASE ((struct device *)(UBA0_DEV+0176500)) /* kl and dl11-a */ ! 18: #define DLBASE ((struct device *)(UBA0_DEV+0175610)) /* dl-e */ ! 19: #define NKL11 8 ! 20: #define NDL11 0 ! 21: #define DSRDY 02 ! 22: #define RDRENB 01 ! 23: #define DLDELAY 4 /* Extra delay for DL's (double buff) */ ! 24: ! 25: #define NL1 000400 ! 26: #define NL2 001000 ! 27: #define CR2 020000 ! 28: #define FF1 040000 ! 29: #define TAB1 002000 ! 30: ! 31: struct tty kl_tty[NKL11+NDL11]; ! 32: int klstart(); ! 33: int ttrstrt(); ! 34: char partab[]; ! 35: ! 36: struct device { ! 37: short rcsr; ! 38: short rbuf; ! 39: short tcsr; ! 40: short tbuf; ! 41: }; ! 42: ! 43: /*ARGSUSED*/ ! 44: klopen(dev, flag) ! 45: dev_t dev; ! 46: { ! 47: register struct device *addr; ! 48: register struct tty *tp; ! 49: register d; ! 50: ! 51: d = minor(dev); ! 52: if(d >= NKL11+NDL11) { ! 53: u.u_error = ENXIO; ! 54: return; ! 55: } ! 56: tp = &kl_tty[d]; ! 57: /* ! 58: * set up minor 0 thru NKL11-1 to address from KLBASE ! 59: * set up minor NKL11 on to address from DLBASE ! 60: */ ! 61: if(d<NKL11) ! 62: addr = KLBASE + d; ! 63: else ! 64: addr = DLBASE + (d-NKL11); ! 65: tp->t_addr = (caddr_t)addr; ! 66: tp->t_oproc = klstart; ! 67: if ((tp->t_state&ISOPEN) == 0) { ! 68: tp->t_state = ISOPEN|CARR_ON; ! 69: tp->t_flags = EVENP|LCASE|ECHO|XTABS|CRMOD|CR2; ! 70: ttychars(tp); ! 71: } ! 72: addr->rcsr |= IENABLE|DSRDY|RDRENB; ! 73: addr->tcsr |= IENABLE; ! 74: (*linesw[tp->t_line].l_open)(dev, tp); ! 75: } ! 76: ! 77: klclose(dev) ! 78: dev_t dev; ! 79: { ! 80: register struct tty *tp; ! 81: ! 82: tp = &kl_tty[minor(dev)]; ! 83: (*linesw[tp->t_line].l_close)(tp); ! 84: ttyclose(tp); ! 85: } ! 86: ! 87: klread(dev) ! 88: dev_t dev; ! 89: { ! 90: register struct tty *tp; ! 91: ! 92: tp = &kl_tty[minor(dev)]; ! 93: (*linesw[tp->t_line].l_read)(tp); ! 94: } ! 95: ! 96: klwrite(dev) ! 97: dev_t dev; ! 98: { ! 99: register struct tty *tp; ! 100: ! 101: tp = &kl_tty[minor(dev)]; ! 102: (*linesw[tp->t_line].l_write)(tp); ! 103: } ! 104: ! 105: klxint(dev) ! 106: dev_t dev; ! 107: { ! 108: register struct tty *tp; ! 109: ! 110: tp = &kl_tty[minor(dev)]; ! 111: if (tp->t_line) ! 112: (*linesw[tp->t_line].l_start)(tp); ! 113: else ! 114: ttstart(tp); ! 115: if ((tp->t_state&ASLEEP) && tp->t_outq.c_cc<=TTLOWAT(tp)) ! 116: if (tp->t_chan) ! 117: mcstart(tp->t_chan, (caddr_t)&tp->t_outq); ! 118: else ! 119: wakeup((caddr_t)&tp->t_outq); ! 120: } ! 121: ! 122: klrint(dev) ! 123: dev_t dev; ! 124: { ! 125: register int c; ! 126: register struct device *addr; ! 127: register struct tty *tp; ! 128: ! 129: tp = &kl_tty[minor(dev)]; ! 130: addr = (struct device *)tp->t_addr; ! 131: c = addr->rbuf; ! 132: addr->rcsr |= RDRENB; ! 133: (*linesw[tp->t_line].l_rint)(c, tp); ! 134: } ! 135: ! 136: /*ARGSUSED*/ ! 137: klioctl(dev, cmd, addr, flag) ! 138: caddr_t addr; ! 139: dev_t dev; ! 140: { ! 141: if (ttioccomm(cmd, &kl_tty[minor(dev)], addr, dev, flag)==0) ! 142: u.u_error = ENOTTY; ! 143: } ! 144: ! 145: klstart(tp) ! 146: register struct tty *tp; ! 147: { ! 148: register c; ! 149: register struct device *addr; ! 150: ! 151: addr = (struct device *)tp->t_addr; ! 152: if ((addr->tcsr&DONE) == 0) ! 153: return; ! 154: if ((c=getc(&tp->t_outq)) >= 0) { ! 155: if (tp->t_flags&RAW) ! 156: addr->tbuf = c; ! 157: else if (c<=0177) ! 158: addr->tbuf = c | (partab[c]&0200); ! 159: else { ! 160: timeout(ttrstrt, (caddr_t)tp, (c&0177) + DLDELAY); ! 161: tp->t_state |= TIMEOUT; ! 162: } ! 163: } ! 164: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.