|
|
1.1 root 1: /*
2: * DN-11 ACU interface
3: * Minor devices < <128 are standard 801's
4: * Minor devices >= 128 are Parker shared
5: * units in which the 1st digit selects a line.
6: * The only interface difference is that DLO
7: * can appear some time after the line is selected
8: * to indicate that the line is busy or out of service.
9: *
10: * If the system has an accessible DR-11C, allow some of
11: * its bits to be fiddled.
12: */
13:
14: #include "dn.h"
15: #if NDN > 0
16: #include "dr.h"
17: #include "../h/param.h"
18: #include "../h/dir.h"
19: #include "../h/user.h"
20: #include "../h/conf.h"
21: #include "../h/inode.h"
22: #include "../h/file.h"
23: #include "../h/systm.h"
24: #include "../h/pte.h"
25: #include "../h/buf.h"
26: #include "../h/ubareg.h"
27: #include "../h/ubavar.h"
28:
29: struct device {
30: u_short dn_reg[4];
31: };
32:
33: #define PWI 0100000
34: #define ACR 040000
35: #define DLO 010000
36: #define DONE 0200
37: #define IENABLE 0100
38: #define DSS 040
39: #define PND 020
40: #define MAINT 010
41: #define MENABLE 04
42: #define DPR 02
43: #define CRQ 01
44:
45: #define DNPRI (PZERO+5)
46:
47: int dnattach(), dnprobe();
48: struct uba_device *dninfo[NDN];
49: u_short dnstd[] = { 0 };
50: struct uba_driver dndriver =
51: { dnprobe, 0, dnattach, 0, dnstd, "dn", dninfo };
52:
53: dnprobe(reg)
54: caddr_t reg;
55: {
56: register int br, cvec;
57: register struct device *dnaddr = (struct device *)reg;
58:
59: dnaddr->dn_reg[0] = MENABLE|IENABLE|MAINT;
60: dnaddr->dn_reg[0] |= CRQ;
61: dnaddr->dn_reg[0] |= 1<<8; /* digit 0 loop to PND */
62: DELAY(10000);
63: dnaddr->dn_reg[0] = MENABLE;
64: return(1);
65: }
66:
67: dnattach()
68: {
69: }
70:
71: dnopen(dev)
72: register dev;
73: {
74: register struct device *dp;
75: register unit;
76:
77: dev = minor(dev) & 0177;
78: unit = dev>>2;
79: dp = (struct device *)dninfo[unit]->ui_addr;
80: if (unit >= NDN ||
81: dninfo[unit]->ui_alive == 0 ||
82: dp->dn_reg[dev&03]&(PWI|DLO|CRQ))
83: u.u_error = ENXIO;
84: else {
85: dp->dn_reg[0] |= MENABLE;
86: dp->dn_reg[dev&03] = IENABLE|MENABLE|CRQ;
87: }
88: }
89:
90: dnclose(dev)
91: {
92: dev = minor(dev) & 0177;
93: ((struct device *)dninfo[dev>>2]->ui_addr)->dn_reg[dev&03] = MENABLE;
94: }
95:
96: dnwrite(dev)
97: {
98: register c;
99: register u_short *dp;
100: register first;
101: extern lbolt;
102: int ldlo;
103: register int setspeed = -1;
104: register k;
105:
106: ldlo = 0;
107: if (dev & 0200)
108: ldlo = DLO;
109: dev = minor(dev) & 0177;
110: dp = & ((struct device *)dninfo[dev>>2]->ui_addr)->dn_reg[dev&03];
111: if (*dp & DLO) {
112: u.u_error = EIO;
113: return;
114: }
115: *dp |= CRQ;
116: first = 0;
117: while ((*dp & (PWI|ACR|DSS|ldlo)) == 0) {
118: spl4();
119: if ((*dp&PND) == 0 || u.u_count == 0 || (c=cpass()) < 0)
120: sleep((caddr_t)dp, DNPRI);
121: else if (c == '-') {
122: sleep((caddr_t)&lbolt, DNPRI);
123: sleep((caddr_t)&lbolt, DNPRI);
124: #if NDR > 0
125: } else if ((k = dnindex (c, "abcdefghABCDEFGH")) >= 0) {
126: setspeed = k;
127: #endif
128: } else {
129: *dp = (c<<8)|IENABLE|MENABLE|DPR|CRQ;
130: if (first == 0) {
131: while (first < 800)
132: first++;
133: if (*dp&ldlo) {
134: *dp = MENABLE;
135: break;
136: }
137: ldlo = 0;
138: }
139: sleep((caddr_t)dp, DNPRI);
140: }
141: spl0();
142: }
143: if (*dp&(PWI|ACR|ldlo))
144: u.u_error = EIO;
145: else if (setspeed >= 0)
146: drsetbit (setspeed % 8, setspeed >= 8);
147: }
148:
149: /*
150: * interrupt-- "dev" applies to
151: * system unit number, not minor device
152: */
153: dnint(dev)
154: {
155: register u_short *ep;
156: register struct device *dp;
157:
158: dp = (struct device *)dninfo[dev]->ui_addr;
159: dp->dn_reg[0] &= ~MENABLE;
160: for (ep = &dp->dn_reg[0]; ep < &dp->dn_reg[4]; ep++)
161: if (*ep&DONE) {
162: *ep &= ~DONE;
163: wakeup((caddr_t)ep);
164: }
165: dp->dn_reg[0] |= MENABLE;
166: }
167:
168: static int
169: dnindex (c, s)
170: register char c, *s;
171: {
172: register char *p;
173:
174: p = s;
175: while (*p) {
176: if (c == *p)
177: return p - s;
178: p++;
179: }
180: return -1;
181: }
182: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.