1: # 2: /* 3: */ 4: 5: /* 6: * DM-BB driver 7: */ 8: #include "../param.h" 9: #include "../tty.h" 10: #include "../conf.h" 11: 12: #define DMADDR 0170500 13: 14: struct tty dh11[]; 15: int ndh11; /* Set by dh.c to number of lines */ 16: 17: #define DONE 0200 18: #define SCENABL 040 19: #define CLSCAN 01000 20: #define TURNON 07 /* RQ send, CD lead, line enable */ 21: #define TURNOFF 1 /* line enable only */ 22: #define CARRIER 0100 23: 24: struct dmregs { 25: int dmcsr; 26: int dmlstat; 27: }; 28: 29: /* 30: * Turn on the line associated with the (DH) device dev. 31: */ 32: dmopen(dev) 33: { 34: register struct tty *tp; 35: 36: tp = &dh11[dev.d_minor]; 37: DMADDR->dmcsr = dev.d_minor; 38: DMADDR->dmlstat = TURNON; 39: if (DMADDR->dmlstat&CARRIER) 40: tp->t_state =| CARR_ON; 41: DMADDR->dmcsr = IENABLE|SCENABL; 42: spl5(); 43: while ((tp->t_state&CARR_ON)==0) 44: sleep(&tp->t_rawq, TTIPRI); 45: spl0(); 46: } 47: 48: /* 49: * If a DH line has the HUPCL mode, 50: * turn off carrier when it is closed. 51: */ 52: dmclose(dev) 53: { 54: register struct tty *tp; 55: 56: tp = &dh11[dev.d_minor]; 57: if (tp->t_flags&HUPCL) { 58: DMADDR->dmcsr = dev.d_minor; 59: DMADDR->dmlstat = TURNOFF; 60: DMADDR->dmcsr = IENABLE|SCENABL; 61: } 62: } 63: 64: /* 65: * DM11 interrupt. 66: * Mainly, deal with carrier transitions. 67: */ 68: dmint() 69: { 70: register struct tty *tp; 71: 72: if (DMADDR->dmcsr&DONE) { 73: tp = &dh11[DMADDR->dmcsr&017]; 74: if (tp < &dh11[ndh11]) { 75: wakeup(tp); 76: if ((DMADDR->dmlstat&CARRIER)==0) { 77: if ((tp->t_state&WOPEN)==0) { 78: signal(tp, SIGHUP); 79: DMADDR->dmlstat = 0; 80: flushtty(tp); 81: } 82: tp->t_state =& ~CARR_ON; 83: } else 84: tp->t_state =| CARR_ON; 85: } 86: DMADDR->dmcsr = IENABLE|SCENABL; 87: } 88: }