1: /*
2: * SCCS id @(#)dj.c 2.1 (Berkeley) 8/5/83
3: */
4:
5: #include "dj.h"
6: #if NDJ > 0
7: #include "param.h"
8: #include <sys/conf.h>
9: #include <sys/dir.h>
10: #include <sys/user.h>
11: #include <sys/tty.h>
12: #include <sys/djreg.h>
13:
14: struct tty dj11[NDJ];
15: extern struct djdevice *dj_addr[];
16:
17: /*ARGSUSED*/
18: djopen(dev, flag)
19: dev_t dev;
20: {
21: register d;
22: register struct tty *tp;
23: register struct djdevice *djaddr;
24: extern djstart();
25:
26: d = minor(dev);
27: if (d >= NDJ) {
28: u.u_error = ENXIO;
29: return;
30: }
31: tp = &dj11[d];
32: if ((tp->t_state & XCLUDE) && (u.u_uid != 0)) {
33: u.u_error = EBUSY;
34: return;
35: }
36: tp->t_oproc = djstart;
37: tp->t_iproc = NULL;
38: tp->t_state |= WOPEN | CARR_ON;
39: djaddr = dj_addr[d >> 4];
40: djaddr->djcsr |= DJ_TIE | DJ_MTSE | DJ_RIE | DJ_RE;
41: if ((tp->t_state & ISOPEN) == 0) {
42: ttychars(tp);
43: tp->t_ispeed = B300;
44: tp->t_ospeed = B300;
45: tp->t_flags = ODDP | EVENP | ECHO;
46: }
47: (*linesw[tp->t_line].l_open)(dev, tp);
48: }
49:
50: djclose(dev)
51: dev_t dev;
52: {
53: register struct tty *tp;
54:
55: tp = &dj11[minor(dev)];
56: ttyclose(tp);
57: }
58:
59: djread(dev)
60: dev_t dev;
61: {
62: register struct tty *tp;
63:
64: tp = &dj11[minor(dev)];
65: (*linesw[tp->t_line].l_read)(tp);
66: }
67:
68: djwrite(dev)
69: dev_t dev;
70: {
71: register struct tty *tp;
72:
73: tp = &dj11[minor(dev)];
74: (*linesw[tp->t_line].l_write)(tp);
75: }
76:
77: djioctl(dev, cmd, addr, flag)
78: dev_t dev;
79: caddr_t addr;
80: {
81: register struct tty *tp;
82:
83: tp = &dj11[minor(dev)];
84: if (ttioctl(cmd, tp, addr, dev, flag) == 0)
85: u.u_error = ENOTTY;
86: }
87:
88: djrint(unit)
89: {
90: register struct tty *tp;
91: register struct djdevice *djaddr;
92: register c;
93: struct tty *tp0;
94:
95: djaddr = dj_addr[unit];
96: tp0 = &dj11[unit << 4];
97: while ((c = djaddr->djrbuf) < 0) {
98: tp = tp0 + ((c >> 8) & 017);
99: if (tp >= &dj11[NDJ])
100: continue;
101: if ((tp->t_state & ISOPEN) == 0) {
102: wakeup((caddr_t) tp);
103: continue;
104: }
105: if (c & DJRBUF_RDPE)
106: if ((tp->t_flags & (EVENP | ODDP)) == EVENP ||
107: (tp->t_flags & (EVENP | ODDP)) == ODDP)
108: continue;
109: if (c & DJRBUF_FE)
110: if (tp->t_flags & RAW)
111: c = 0;
112: else
113: c = 0177;
114: (*linesw[tp->t_line].l_input)(c, tp);
115: }
116: }
117:
118: djxint(unit)
119: {
120: register struct tty *tp, *tp0;
121: register struct djdevice *djaddr;
122:
123: djaddr = dj_addr[unit];
124: tp0 = &dj11[unit << 4];
125: while (djaddr->djcsr < 0) {
126: tp = &tp0[djaddr->dj_un.djtbufh];
127: djaddr->dj_un.djtbufl = tp->t_char;
128: tp->t_state &= ~BUSY;
129: djstart(tp);
130: }
131: }
132:
133: djstart(tp)
134: register struct tty *tp;
135: {
136: register struct djdevice *djaddr;
137: register unit;
138: int c, s;
139: extern ttrstrt();
140:
141: unit = tp - dj11;
142: djaddr = dj_addr[unit >> 4];
143: unit = 1 << (unit & 017);
144: s = spl5();
145: if (tp->t_state & (TIMEOUT | BUSY)) {
146: splx(s);
147: return;
148: }
149: if (tp->t_state & TTSTOP) {
150: djaddr->djtcr &= ~unit;
151: splx(s);
152: return;
153: }
154: if ((c = getc(&tp->t_outq)) >= 0) {
155: if (c >= 0200 && ((tp->t_flags & RAW) == 0)) {
156: djaddr->djtcr &= ~unit;
157: tp->t_state |= TIMEOUT;
158: timeout(ttrstrt, (caddr_t) tp, (c & 0177) + 6);
159: } else
160: {
161: tp->t_char = c;
162: tp->t_state |= BUSY;
163: djaddr->djtcr |= unit;
164: }
165: if ((tp->t_outq.c_cc <= TTLOWAT(tp)) && (tp->t_state & ASLEEP)) {
166: tp->t_state &= ~ASLEEP;
167: #ifdef MPX_FILS
168: if (tp->t_chan)
169: mcstart(tp->t_chan, (caddr_t) &tp->t_outq);
170: else
171: #endif
172: wakeup((caddr_t) &tp->t_outq);
173: }
174: } else
175: djaddr->djtcr &= ~unit;
176: splx(s);
177: }
178: #endif NDJ
Defined functions
Defined variables
dj11
defined in line
14; used 9 times