1: /*
   2:  *	SCCS id	@(#)dn.c	2.3 (2.11BSD GTE) 1997/1/18
   3:  */
   4: 
   5: /*
   6:  * DN-11 ACU interface
   7:  */
   8: 
   9: #include "dn.h"
  10: 
  11: #if NDN > 0
  12: #include "param.h"
  13: #include "user.h"
  14: #include "uio.h"
  15: #include "kernel.h"
  16: #include "dnreg.h"
  17: 
  18: #define DNPRI   (PZERO+5)
  19: 
  20: struct  dndevice *dn_addr[NDN];
  21: 
  22: dnattach(addr, unit)
  23: struct dndevice *addr;
  24: {
  25:     if ((unsigned)unit >= NDN)
  26:         return 0;
  27:     dn_addr[unit] = addr;
  28:     return 1;
  29: }
  30: 
  31: /*ARGSUSED*/
  32: dnopen(dev, flag)
  33: register dev_t  dev;
  34: {
  35:     register struct dndevice *dp;
  36: 
  37:     dev = minor(dev);
  38:     if (dev >= NDN << 2 || (dp = dn_addr[dev >> 2]) == NULL
  39:         || (dp->dnisr[dev & 03] & (DN_PWI | DN_FDLO | DN_FCRQ)))
  40:         return(ENXIO);
  41:     else {
  42:         dp->dnisr[0] |= DN_MINAB;
  43:         dp->dnisr[dev & 03] = DN_INTENB | DN_MINAB | DN_FCRQ;
  44:     }
  45:     return(0);
  46: }
  47: 
  48: dnclose(dev, flag)
  49: register dev_t  dev;
  50: {
  51:     dev = minor(dev);
  52:     dn_addr[dev >> 2]->dnisr[dev & 03] = DN_MINAB;
  53:     return(0);
  54: }
  55: 
  56: dnwrite(dev, uio, flag)
  57: register dev_t  dev;
  58: register struct uio *uio;
  59:     int flag;
  60: {
  61:     register int c, *dp;
  62:     int s;
  63: 
  64:     dev = minor(dev);
  65:     dp = (int *)&(dn_addr[dev >> 2]->dnisr[dev & 03]);
  66:     while ((*dp & (DN_PWI | DN_ACR | DN_DSS)) == 0) {
  67:         s = spl4();
  68:         if ((*dp & DN_FPND) == 0 || !uio->uio_resid || (c = uwritec(uio)) < 0)
  69:             sleep((caddr_t) dp, DNPRI);
  70:         else if (c == '-') {
  71:             sleep((caddr_t) &lbolt, DNPRI);
  72:             sleep((caddr_t) &lbolt, DNPRI);
  73:         } else
  74:             {
  75:             *dp = (c << 8) | DN_INTENB|DN_MINAB|DN_FDPR|DN_FCRQ;
  76:             sleep((caddr_t) dp, DNPRI);
  77:         }
  78:         splx(s);
  79:     }
  80:     if (*dp & (DN_PWI | DN_ACR))
  81:         return(EIO);
  82:     return(0);
  83: }
  84: 
  85: dnint(dn11)
  86: {
  87:     register int *dp, *ep;
  88: 
  89:     dp = (int *)&(dn_addr[dn11]->dnisr[0]);
  90:     *dp &= ~DN_MINAB;
  91:     for (ep = dp; ep < dp + 4; ep++)
  92:         if (*ep & DN_DONE) {
  93:             *ep &= ~DN_DONE;
  94:             wakeup((caddr_t)ep);
  95:         }
  96:     *dp |= DN_MINAB;
  97: }
  98: #endif /* NDN */

Defined functions

dnattach defined in line 22; never used
dnclose defined in line 48; never used
dnint defined in line 85; used 1 times
dnopen defined in line 32; never used
dnwrite defined in line 56; never used

Defined variables

dn_addr defined in line 20; used 5 times

Defined macros

DNPRI defined in line 18; used 4 times
Last modified: 1997-01-19
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3174
Valid CSS Valid XHTML 1.0 Strict