1: /*
   2:  *	DM-BB driver
   3:  */
   4: #include "param.h"
   5: #include <sys/tty.h>
   6: #include <sys/file.h>
   7: #include <sys/conf.h>
   8: 
   9: /*
  10:  *	SCCS id	@(#)dhdm.c	2.1 (Berkeley)	8/5/83
  11:  */
  12: 
  13: #define DMADDR  ((struct device *)0170500)
  14: 
  15: struct  tty dh11[];
  16: 
  17: int dhlowdm;    /* minor device of first line with DM11-BB */
  18: int dhndm;      /* number of lines with DM11-BB (both set in dh.c) */
  19: 
  20: #define DONE    0200
  21: #define SCENABL 040
  22: #define CLSCAN  01000
  23: #define TURNON  03  /* CD lead, line enable */
  24: #define SECX    010 /* secondary xmit */
  25: #define RQS 04  /* request to send */
  26: #define TURNOFF 1   /* line enable only */
  27: #define CARRIER 0100
  28: #define CLS 040 /* clear to send */
  29: #define SECR    020 /* secondary receive */
  30: 
  31: struct device
  32: {
  33:     int dmcsr;
  34:     int dmlstat;
  35:     int junk[2];
  36: };
  37: 
  38: #define B1200   9
  39: #define B300    7
  40: 
  41: /*
  42:  * Turn on the line associated with the (DH) device dev.
  43:  */
  44: dmopen(dev)
  45: {
  46:     register struct tty *tp;
  47:     register struct device *addr;
  48:     register d;
  49: 
  50:     d = minor(dev);
  51:     tp = &dh11[d];
  52:     if(d < dhlowdm || d >= dhlowdm+dhndm) {
  53:         tp->t_state |= CARR_ON;
  54:         return;
  55:     }
  56:     addr = DMADDR;
  57:     addr += (d - dhlowdm) >> 4;
  58:     (void) _spl5();
  59:     addr->dmcsr = d&017;
  60:     addr->dmlstat = TURNON;
  61:     if (addr->dmlstat&CARRIER) {
  62:         tp->t_state |= CARR_ON;
  63:     }
  64:     addr->dmcsr = IENABLE|SCENABL;
  65:     while ((tp->t_state&CARR_ON)==0)
  66:         sleep((caddr_t)&tp->t_rawq, TTIPRI);
  67:     addr->dmcsr = d&017;
  68:     if (addr->dmlstat&SECR) {
  69:         tp->t_ispeed = B1200;
  70:         tp->t_ospeed = B1200;
  71:         dhparam(dev);
  72:     }
  73:     addr->dmcsr = IENABLE|SCENABL;
  74:     (void) _spl0();
  75: }
  76: 
  77: /*
  78:  * Dump control bits into the DM registers.
  79:  */
  80: dmctl(dev, bits)
  81: {
  82:     register struct device *addr;
  83:     register d, s;
  84: 
  85:     d = minor(dev);
  86:     if(d < dhlowdm || d >= dhlowdm+dhndm)
  87:         return;
  88:     addr = DMADDR;
  89:     addr += (d - dhlowdm) >> 4;
  90:     s = spl5();
  91:     addr->dmcsr = d&017;
  92:     addr->dmlstat = bits;
  93:     addr->dmcsr = IENABLE|SCENABL;
  94:     splx(s);
  95: }
  96: 
  97: /*
  98:  * DM11 interrupt.
  99:  * Mainly, deal with carrier transitions.
 100:  */
 101: dmint(dev)
 102: {
 103:     register struct tty *tp;
 104:     register struct device *addr;
 105:     register d;
 106: 
 107:     d = minor(dev);
 108:     addr = DMADDR;
 109:     addr += d;
 110:     if (addr->dmcsr&DONE) {
 111:         tp = &dh11[(d<<4)+(addr->dmcsr&017)];
 112:         tp += dhlowdm;
 113:         if (tp < &dh11[dhlowdm+dhndm]) {
 114:             wakeup((caddr_t)&tp->t_rawq);
 115:             if ((addr->dmlstat&CARRIER)==0) {
 116:                 if ((tp->t_state&WOPEN)==0 &&
 117:                      (tp->t_local&LNOHANG)==0) {
 118:                     gsignal(tp->t_pgrp, SIGHUP);
 119:                     addr->dmlstat = 0;
 120:                     flushtty(tp, FREAD|FWRITE);
 121:                 }
 122:                 tp->t_state &= ~CARR_ON;
 123:             } else {
 124:                 tp->t_state |= CARR_ON;
 125:             }
 126:         }
 127:         addr->dmcsr = IENABLE|SCENABL;
 128:     }
 129: }

Defined functions

dmctl defined in line 80; never used
dmint defined in line 101; never used
dmopen defined in line 44; never used

Defined variables

dh11 defined in line 15; used 3 times
dhlowdm defined in line 17; used 8 times
dhndm defined in line 18; used 3 times

Defined struct's

device defined in line 31; used 6 times

Defined macros

B1200 defined in line 38; used 2 times
B300 defined in line 39; never used
CARRIER defined in line 27; used 2 times
CLS defined in line 28; never used
CLSCAN defined in line 22; never used
DMADDR defined in line 13; used 3 times
DONE defined in line 20; used 1 times
RQS defined in line 25; never used
SCENABL defined in line 21; used 4 times
SECR defined in line 29; used 1 times
  • in line 68
SECX defined in line 24; never used
TURNOFF defined in line 26; never used
TURNON defined in line 23; used 1 times
  • in line 60
Last modified: 1983-08-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 949
Valid CSS Valid XHTML 1.0 Strict