1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36#include <sys/param.h>
37#include <sys/systm.h>
38#include <sys/conf.h>
39#include <sys/ioctl.h>
40#include <sys/tty.h>
41#include <sys/proc.h>
42#include <sys/uio.h>
43
44struct tty cons;
45struct tty *constty;
46
47int cnopen(__unused dev_t dev, int flag, int devtype, struct proc *pp);
48int cnclose(__unused dev_t dev, int flag, int mode, struct proc *pp);
49int cnread(__unused dev_t dev, struct uio *uio, int ioflag);
50int cnwrite(__unused dev_t dev, struct uio *uio, int ioflag);
51int cnioctl(__unused dev_t dev, int cmd, caddr_t addr, int flg, struct proc *p);
52int cnselect(__unused dev_t dev, int flag, void * wql, struct proc *p);
53
54void slave_cnenable(void);
55
56int alert(
57 __unused int width,
58 __unused int height,
59 __unused const char *title,
60 const char *msg,
61 int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8);
62int alert_done(void);
63
64
65int
66cnopen(__unused dev_t dev, int flag, int devtype, struct proc *pp)
67{
68 dev_t device;
69 boolean_t funnel_state;
70 int error;
71
72 funnel_state = thread_funnel_set(kernel_flock, TRUE);
73
74 if (constty)
75 device = constty->t_dev;
76 else
77 device = cons.t_dev;
78 error = (*cdevsw[major(device)].d_open)(device, flag, devtype, pp);
79 thread_funnel_set(kernel_flock, funnel_state);
80
81 return(error);
82}
83
84
85int
86cnclose(__unused dev_t dev, int flag, int mode, struct proc *pp)
87{
88 dev_t device;
89 boolean_t funnel_state;
90 int error;
91
92 funnel_state = thread_funnel_set(kernel_flock, TRUE);
93 if (constty)
94 device = constty->t_dev;
95 else
96 device = cons.t_dev;
97 error = (*cdevsw[major(device)].d_close)(device, flag, mode, pp);
98 thread_funnel_set(kernel_flock, funnel_state);
99
100 return(error);
101
102
103}
104
105
106int
107cnread(__unused dev_t dev, struct uio *uio, int ioflag)
108{
109 dev_t device;
110 boolean_t funnel_state;
111 int error;
112
113 funnel_state = thread_funnel_set(kernel_flock, TRUE);
114 if (constty)
115 device = constty->t_dev;
116 else
117 device = cons.t_dev;
118 error = (*cdevsw[major(device)].d_read)(device, uio, ioflag);
119 thread_funnel_set(kernel_flock, funnel_state);
120
121 return(error);
122}
123
124
125int
126cnwrite(__unused dev_t dev, struct uio *uio, int ioflag)
127{
128 dev_t device;
129 boolean_t funnel_state;
130 int error;
131
132 funnel_state = thread_funnel_set(kernel_flock, TRUE);
133 if (constty)
134 device = constty->t_dev;
135 else
136 device = cons.t_dev;
137 error = (*cdevsw[major(device)].d_write)(device, uio, ioflag);
138 thread_funnel_set(kernel_flock, funnel_state);
139
140 return(error);
141}
142
143
144int
145cnioctl(__unused dev_t dev, int cmd, caddr_t addr, int flag, struct proc *p)
146{
147 dev_t device;
148 boolean_t funnel_state;
149 int error;
150
151 funnel_state = thread_funnel_set(kernel_flock, TRUE);
152
153 if (constty)
154 device = constty->t_dev;
155 else
156 device = cons.t_dev;
157
158
159
160
161 if ((unsigned) cmd == TIOCCONS && constty) {
162 error = proc_suser(p);
163 if (error) {
164 goto out;
165 }
166 constty = NULL;
167 error = 0;
168 goto out;
169 }
170 error = (*cdevsw[major(device)].d_ioctl)(device, cmd, addr, flag, p);
171out:
172 thread_funnel_set(kernel_flock, funnel_state);
173
174 return(error);
175}
176
177
178
179int
180cnselect(__unused dev_t dev, int flag, void * wql, struct proc *p)
181{
182 dev_t device;
183
184 if (constty)
185 device = constty->t_dev;
186 else
187 device = cons.t_dev;
188 return ((*cdevsw[major(device)].d_select)(device, flag, wql, p));
189}
190
191#if 0
192int
193cngetc()
194{
195 dev_t device;
196 boolean_t funnel_state;
197 int error;
198
199 funnel_state = thread_funnel_set(kernel_flock, TRUE);
200 if (constty)
201 device = constty->t_dev;
202 else
203 device = cons.t_dev;
204 error = (*cdevsw[major(device)].d_getc)(device);
205 thread_funnel_set(kernel_flock, funnel_state);
206
207 return(error);
208}
209
210
211int
212cnputc(c)
213 char c;
214{
215 dev_t device;
216 boolean_t funnel_state;
217 int error;
218
219 funnel_state = thread_funnel_set(kernel_flock, TRUE);
220 if (constty)
221 device = constty->t_dev;
222 else
223 device = cons.t_dev;
224 error = (*cdevsw[major(device)].d_putc)(device, c);
225 thread_funnel_set(kernel_flock, funnel_state);
226
227 return(error);
228}
229#endif
230
231void
232slave_cnenable(void)
233{
234
235}
236
237#if 0
238void
239kprintf( const char *format, ...)
240{
241
242
243
244}
245#endif
246
247
248
249
250
251
252
253int
254alert(
255 __unused int width,
256 __unused int height,
257 __unused const char *title,
258 const char *msg,
259 int p1,
260 int p2,
261 int p3,
262 int p4,
263 int p5,
264 int p6,
265 int p7,
266 int p8)
267{
268 char smsg[200];
269
270 sprintf(smsg, msg, p1, p2, p3, p4, p5, p6, p7, p8);
271#if FIXME
272
273#else
274 printf("%s\n",smsg);
275#endif
276
277 return 0;
278}
279
280int
281alert_done(void)
282{
283
284 return 0;
285}
286
287