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