home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / sys / dev / dhdm.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-03  |  2.0 KB  |  115 lines

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