8000: # 8001: /* KL/DL-11 driver */ 8002: #include "../param.h" 8003: #include "../conf.h" 8004: #include "../user.h" 8005: #include "../tty.h" 8006: #include "../proc.h" 8007: /* base address */ 8008: #define KLADDR 0177560 /* console */ 8009: #define KLBASE 0176500 /* kl and dl11-a */ 8010: #define DLBASE 0175610 /* dl-e */ 8011: #define NKL11 1 8012: #define NDL11 0 8013: #define DSRDY 02 8014: #define RDRENB 01 8015: struct tty kl11[NKL11+NDL11]; 8016: struct klregs { 8017: int klrcsr; 8018: int klrbuf; 8019: int kltcsr; 8020: int kltbuf; 8021: } 8022: /* --------------------------- */ 8023: klopen(dev, flag) 8024: { register char *addr; 8025: register struct tty *tp; 8026: if(dev.d_minor >= NKL11+NDL11) { 8027: u.u_error = ENXIO; 8028: return; 8029: } 8030: tp = &kl11[dev.d_minor]; 8031: if (u.u_procp->p_ttyp == 0) { 8032: u.u_procp->p_ttyp = tp; 8033: tp->t_dev = dev; 8034: } 8035: /* set up minor 0 to address KLADDR 8036: * set up minor 1 thru NKL11-1 to address from KLBASE 8037: * set up minor NKL11 on to address from DLBASE 8038: */ 8039: addr = KLADDR + 8*dev.d_minor; 8040: if(dev.d_minor) 8041: addr =+ KLBASE-KLADDR-8; 8042: if(dev.d_minor >= NKL11) 8043: addr =+ DLBASE-KLBASE-8*NKL11+8; 8044: tp->t_addr = addr; 8045: if ((tp->t_state&ISOPEN) == 0) { 8046: tp->t_state = ISOPEN|CARR_ON; 8047: tp->t_flags = XTABS|LCASE|ECHO|CRMOD; 8048: tp->t_erase = CERASE; 8049: tp->t_kill = CKILL; 8050: } 8051: addr->klrcsr =| IENABLE|DSRDY|RDRENB; 8052: addr->kltcsr =| IENABLE; 8053: } 8054: /* --------------------------- */ 8055: klclose(dev) 8056: { register struct tty *tp; 8057: tp = &kl11[dev.d_minor]; 8058: wflushtty(tp); 8059: tp->t_state = 0; 8060: } 8061: /* --------------------------- */ 8062: klread(dev) 8063: { ttread(&kl11[dev.d_minor]); 8064: } 8065: /* --------------------------- */ 8066: klwrite(dev) 8067: { ttwrite(&kl11[dev.d_minor]); 8068: } 8069: /* --------------------------- */ 8070: klxint(dev) 8071: { register struct tty *tp; 8072: tp = &kl11[dev.d_minor]; 8073: ttstart(tp); 8074: if (tp->t_outq.c_cc == 0 || tp->t_outq.c_cc == TTLOWAT) 8075: wakeup(&tp->t_outq); 8076: } 8077: /* --------------------------- */ 8078: klrint(dev) 8079: { register int c, *addr; 8080: register struct tty *tp; 8081: tp = &kl11[dev.d_minor]; 8082: addr = tp->t_addr; 8083: c = addr->klrbuf; 8084: addr->klrcsr =| RDRENB; 8085: if ((c&0177)==0) 8086: addr->kltbuf = c; /* hardware botch */ 8087: ttyinput(c, tp); 8088: } 8089: /* --------------------------- */ 8090: klsgtty(dev, v) 8091: int *v; 8092: { register struct tty *tp; 8093: tp = &kl11[dev.d_minor]; 8094: ttystty(tp, v); 8095: } 8096: /* --------------------------- */