Commit | Line | Data |
---|---|---|
a79d1f50 DR |
1 | # |
2 | /* | |
3 | * Screw Works interface via DC-11 | |
4 | */ | |
5 | ||
6 | #include "/sys/nsys/tty.h" | |
7 | ||
8 | #define VSADDR 0174150 | |
9 | #define CDLEAD 01 | |
10 | #define B1200 030 | |
11 | #define STOP1 0400 | |
12 | #define CLSEND 02 | |
13 | #define RQSEND 01 | |
14 | ||
15 | struct { | |
16 | int vsrcsr; | |
17 | int vsrbuf; | |
18 | int vsxcsr; | |
19 | int vsxbuf; | |
20 | }; | |
21 | ||
22 | struct { | |
23 | struct clist iq; | |
24 | struct clist oq; | |
25 | } vs; | |
26 | ||
27 | char vsmap[] "?0*#?546?213?879?"; | |
28 | ||
29 | vsopen(dev) | |
30 | { | |
31 | VSADDR->vsrcsr = IENABLE|B1200|CDLEAD; | |
32 | VSADDR->vsxcsr = STOP1|IENABLE|B1200; | |
33 | vschar(0); | |
34 | } | |
35 | ||
36 | vsclose(dev) | |
37 | { | |
38 | VSADDR->vsrcsr =& ~IENABLE; | |
39 | while (getc(&vs.iq) >= 0); | |
40 | while (getc(&vs.oq) >= 0); | |
41 | } | |
42 | ||
43 | vswrite(dev) | |
44 | { | |
45 | int count, c; | |
46 | ||
47 | count = 0; | |
48 | while (cpass(&c) >= 0) { | |
49 | if (--count <= 0) { | |
50 | count = 60; | |
51 | vschar(0); | |
52 | } | |
53 | vschar(c); | |
54 | } | |
55 | vschar(0); | |
56 | } | |
57 | ||
58 | vschar(c) | |
59 | { | |
60 | ||
61 | c =^ 0277; /* magic map */ | |
62 | spl5(); | |
63 | while (vs.oq.c_cc > 60) { | |
64 | vsxintr(); | |
65 | sleep(&vs.oq, TTIPRI); | |
66 | } | |
67 | putc(c, &vs.oq); | |
68 | vsxintr(); | |
69 | spl0(); | |
70 | } | |
71 | ||
72 | vsxintr() | |
73 | { | |
74 | static lchar; | |
75 | register c; | |
76 | register int *xcsr; | |
77 | ||
78 | xcsr = &VSADDR->vsxcsr; | |
79 | if (*xcsr&DONE) { | |
80 | if (lchar==0277) { | |
81 | *xcsr =& ~RQSEND; | |
82 | lchar = 0; | |
83 | if (vs.oq.c_cc==0) | |
84 | goto wake; | |
85 | } | |
86 | if ((*xcsr&CLSEND) == 0) { | |
87 | *xcsr =& ~RQSEND; | |
88 | *xcsr =| RQSEND; | |
89 | if ((*xcsr&CLSEND) == 0) | |
90 | goto wake; | |
91 | } | |
92 | if ((c = getc(&vs.oq)) >= 0) | |
93 | VSADDR->vsxbuf = lchar = c; | |
94 | if (vs.oq.c_cc <= 15) | |
95 | wake: | |
96 | wakeup(&vs.oq); | |
97 | } | |
98 | } | |
99 | ||
100 | vsread(dev) | |
101 | { | |
102 | register int c; | |
103 | ||
104 | spl5(); | |
105 | while ((c = getc(&vs.iq)) < 0) | |
106 | sleep(&vs.iq, TTIPRI); | |
107 | spl0(); | |
108 | passc(vsmap[c&017]); | |
109 | } | |
110 | ||
111 | vsrintr() | |
112 | { | |
113 | register int c; | |
114 | ||
115 | c = VSADDR->vsrbuf; | |
116 | if (vs.iq.c_cc<=10) | |
117 | putc(c, &vs.iq); | |
118 | wakeup(&vs.iq); | |
119 | } |