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

Defined functions

dnattach defined in line 20; never used
dnclose defined in line 47; never used
dnint defined in line 82; never used
dnopen defined in line 30; never used
dnwrite defined in line 54; never used

Defined variables

dn_addr defined in line 18; used 5 times

Defined macros

DNPRI defined in line 16; used 4 times
Last modified: 1983-08-06
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 836
Valid CSS Valid XHTML 1.0 Strict