ttycons.c revision 1.5.6.1 1 1.5.6.1 mrg /* $NetBSD: ttycons.c,v 1.5.6.1 2012/02/18 07:33:23 mrg Exp $ */
2 1.1 jmcneill
3 1.1 jmcneill /*-
4 1.1 jmcneill * Copyright (c) 2007 Jared D. McNeill <jmcneill (at) invisible.ca>
5 1.1 jmcneill * All rights reserved.
6 1.1 jmcneill *
7 1.1 jmcneill * Redistribution and use in source and binary forms, with or without
8 1.1 jmcneill * modification, are permitted provided that the following conditions
9 1.1 jmcneill * are met:
10 1.1 jmcneill * 1. Redistributions of source code must retain the above copyright
11 1.1 jmcneill * notice, this list of conditions and the following disclaimer.
12 1.1 jmcneill * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 jmcneill * notice, this list of conditions and the following disclaimer in the
14 1.1 jmcneill * documentation and/or other materials provided with the distribution.
15 1.1 jmcneill *
16 1.1 jmcneill * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1 jmcneill * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1 jmcneill * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1 jmcneill * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1 jmcneill * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1 jmcneill * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1 jmcneill * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1 jmcneill * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1 jmcneill * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1 jmcneill * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1 jmcneill * POSSIBILITY OF SUCH DAMAGE.
27 1.1 jmcneill */
28 1.1 jmcneill
29 1.1 jmcneill #include <sys/cdefs.h>
30 1.5.6.1 mrg __KERNEL_RCSID(0, "$NetBSD: ttycons.c,v 1.5.6.1 2012/02/18 07:33:23 mrg Exp $");
31 1.1 jmcneill
32 1.1 jmcneill #include <sys/param.h>
33 1.5.6.1 mrg #include <sys/conf.h>
34 1.1 jmcneill #include <sys/proc.h>
35 1.1 jmcneill #include <sys/systm.h>
36 1.1 jmcneill #include <sys/device.h>
37 1.5.6.1 mrg #include <sys/kauth.h>
38 1.5 jmcneill #include <sys/termios.h>
39 1.5.6.1 mrg #include <sys/tty.h>
40 1.1 jmcneill
41 1.1 jmcneill #include <dev/cons.h>
42 1.1 jmcneill
43 1.1 jmcneill #include <machine/mainbus.h>
44 1.4 jmcneill #include <machine/thunk.h>
45 1.1 jmcneill
46 1.1 jmcneill static int ttycons_match(device_t, cfdata_t, void *);
47 1.1 jmcneill static void ttycons_attach(device_t, device_t, void *);
48 1.1 jmcneill
49 1.1 jmcneill void ttycons_consinit(void);
50 1.1 jmcneill
51 1.5.6.1 mrg struct ttycons_softc {
52 1.1 jmcneill device_t sc_dev;
53 1.5.6.1 mrg struct tty *sc_tty;
54 1.5.6.1 mrg void *sc_rd_sih;
55 1.5.6.1 mrg void *sc_ctrlc_sih;
56 1.5.6.1 mrg void *sc_ctrlz_sih;
57 1.5.6.1 mrg u_char sc_buf[1024];
58 1.5.6.1 mrg };
59 1.1 jmcneill
60 1.1 jmcneill dev_type_cngetc(ttycons_cngetc);
61 1.1 jmcneill dev_type_cnputc(ttycons_cnputc);
62 1.1 jmcneill dev_type_cnpollc(ttycons_cnpollc);
63 1.1 jmcneill
64 1.1 jmcneill static struct cnm_state ttycons_cnm_state;
65 1.1 jmcneill struct consdev ttycons_consdev = {
66 1.1 jmcneill .cn_getc = ttycons_cngetc,
67 1.1 jmcneill .cn_putc = ttycons_cnputc,
68 1.1 jmcneill .cn_pollc = ttycons_cnpollc,
69 1.5.6.1 mrg .cn_dev = NODEV,
70 1.5.6.1 mrg .cn_pri = CN_NORMAL,
71 1.1 jmcneill };
72 1.1 jmcneill
73 1.5.6.1 mrg CFATTACH_DECL_NEW(ttycons, sizeof(struct ttycons_softc),
74 1.1 jmcneill ttycons_match, ttycons_attach, NULL, NULL);
75 1.1 jmcneill
76 1.5.6.1 mrg extern struct cfdriver ttycons_cd;
77 1.5.6.1 mrg
78 1.5.6.1 mrg dev_type_open(ttycons_open);
79 1.5.6.1 mrg dev_type_close(ttycons_close);
80 1.5.6.1 mrg dev_type_read(ttycons_read);
81 1.5.6.1 mrg dev_type_write(ttycons_write);
82 1.5.6.1 mrg dev_type_ioctl(ttycons_ioctl);
83 1.5.6.1 mrg dev_type_stop(ttycons_stop);
84 1.5.6.1 mrg dev_type_tty(ttycons_tty);
85 1.5.6.1 mrg dev_type_poll(ttycons_poll);
86 1.5.6.1 mrg
87 1.5.6.1 mrg const struct cdevsw ttycons_cdevsw = {
88 1.5.6.1 mrg .d_open = ttycons_open,
89 1.5.6.1 mrg .d_close = ttycons_close,
90 1.5.6.1 mrg .d_read = ttycons_read,
91 1.5.6.1 mrg .d_write = ttycons_write,
92 1.5.6.1 mrg .d_ioctl = ttycons_ioctl,
93 1.5.6.1 mrg .d_stop = ttycons_stop,
94 1.5.6.1 mrg .d_tty = ttycons_tty,
95 1.5.6.1 mrg .d_poll = ttycons_poll,
96 1.5.6.1 mrg .d_kqfilter = ttykqfilter,
97 1.5.6.1 mrg .d_flag = D_TTY,
98 1.5.6.1 mrg };
99 1.5.6.1 mrg
100 1.5.6.1 mrg static void ttycons_start(struct tty *);
101 1.5.6.1 mrg static int ttycons_param(struct tty *, struct termios *);
102 1.5.6.1 mrg
103 1.5.6.1 mrg static int ttycons_intr(void *);
104 1.5.6.1 mrg static void ttycons_softintr(void *);
105 1.5.6.1 mrg
106 1.5.6.1 mrg static sigfunc_t ttycons_ctrlc;
107 1.5.6.1 mrg static void ttycons_softctrlc(void *);
108 1.5.6.1 mrg static sigfunc_t ttycons_ctrlz;
109 1.5.6.1 mrg static void ttycons_softctrlz(void *);
110 1.5.6.1 mrg
111 1.1 jmcneill static int
112 1.1 jmcneill ttycons_match(device_t parent, cfdata_t match, void *opaque)
113 1.1 jmcneill {
114 1.1 jmcneill struct thunkbus_attach_args *taa = opaque;
115 1.1 jmcneill
116 1.1 jmcneill if (taa->taa_type != THUNKBUS_TYPE_TTYCONS)
117 1.1 jmcneill return 0;
118 1.1 jmcneill
119 1.1 jmcneill return 1;
120 1.1 jmcneill }
121 1.1 jmcneill
122 1.1 jmcneill static void
123 1.1 jmcneill ttycons_attach(device_t parent, device_t self, void *opaque)
124 1.1 jmcneill {
125 1.5.6.1 mrg struct ttycons_softc *sc = device_private(self);
126 1.5.6.1 mrg int maj;
127 1.1 jmcneill
128 1.1 jmcneill aprint_naive("\n");
129 1.1 jmcneill aprint_normal(": console\n");
130 1.1 jmcneill
131 1.1 jmcneill sc->sc_dev = self;
132 1.5.6.1 mrg sc->sc_tty = tty_alloc();
133 1.5.6.1 mrg tty_attach(sc->sc_tty);
134 1.5.6.1 mrg sc->sc_tty->t_oproc = ttycons_start;
135 1.5.6.1 mrg sc->sc_tty->t_param = ttycons_param;
136 1.5.6.1 mrg sc->sc_tty->t_sc = sc;
137 1.5.6.1 mrg
138 1.5.6.1 mrg maj = cdevsw_lookup_major(&ttycons_cdevsw);
139 1.5.6.1 mrg cn_tab->cn_dev = makedev(maj, device_unit(self));
140 1.5.6.1 mrg sc->sc_tty->t_dev = cn_tab->cn_dev;
141 1.5.6.1 mrg
142 1.5.6.1 mrg sc->sc_rd_sih = softint_establish(SOFTINT_SERIAL,
143 1.5.6.1 mrg ttycons_softintr, sc);
144 1.5.6.1 mrg if (sc->sc_rd_sih == NULL)
145 1.5.6.1 mrg panic("couldn't establish ttycons intr handler\n");
146 1.5.6.1 mrg
147 1.5.6.1 mrg sc->sc_ctrlc_sih = softint_establish(SOFTINT_SERIAL,
148 1.5.6.1 mrg ttycons_softctrlc, sc);
149 1.5.6.1 mrg if (sc->sc_ctrlc_sih == NULL)
150 1.5.6.1 mrg panic("couldn't establish ttycons ctrlc handler\n");
151 1.5.6.1 mrg sc->sc_ctrlz_sih = softint_establish(SOFTINT_SERIAL,
152 1.5.6.1 mrg ttycons_softctrlz, sc);
153 1.5.6.1 mrg if (sc->sc_ctrlz_sih == NULL)
154 1.5.6.1 mrg panic("couldn't establish ttycons ctrlz handler\n");
155 1.5.6.1 mrg
156 1.5.6.1 mrg sigio_intr_establish(ttycons_intr, sc);
157 1.5.6.1 mrg signal_intr_establish(SIGINT, ttycons_ctrlc);
158 1.5.6.1 mrg signal_intr_establish(SIGTSTP, ttycons_ctrlz);
159 1.5.6.1 mrg
160 1.5.6.1 mrg if (thunk_set_stdin_sigio(true) != 0)
161 1.5.6.1 mrg panic("couldn't enable stdin async mode");
162 1.1 jmcneill }
163 1.1 jmcneill
164 1.1 jmcneill void
165 1.1 jmcneill ttycons_consinit(void)
166 1.1 jmcneill {
167 1.5 jmcneill struct thunk_termios t;
168 1.5 jmcneill
169 1.5 jmcneill thunk_tcgetattr(0, &t);
170 1.5 jmcneill t.c_lflag &= ~(ECHO|ICANON);
171 1.5 jmcneill t.c_cc[VTIME] = 0;
172 1.5 jmcneill t.c_cc[VMIN] = 1;
173 1.5 jmcneill thunk_tcsetattr(0, TCSANOW, &t);
174 1.5 jmcneill
175 1.1 jmcneill cn_tab = &ttycons_consdev;
176 1.1 jmcneill cn_init_magic(&ttycons_cnm_state);
177 1.1 jmcneill cn_set_magic("\047\001");
178 1.1 jmcneill }
179 1.1 jmcneill
180 1.1 jmcneill int
181 1.1 jmcneill ttycons_cngetc(dev_t dev)
182 1.1 jmcneill {
183 1.4 jmcneill return thunk_getchar();
184 1.1 jmcneill }
185 1.1 jmcneill
186 1.1 jmcneill void
187 1.1 jmcneill ttycons_cnputc(dev_t dev, int c)
188 1.1 jmcneill {
189 1.4 jmcneill thunk_putchar(c);
190 1.1 jmcneill }
191 1.1 jmcneill
192 1.1 jmcneill void
193 1.1 jmcneill ttycons_cnpollc(dev_t dev, int on)
194 1.1 jmcneill {
195 1.1 jmcneill }
196 1.5.6.1 mrg
197 1.5.6.1 mrg int
198 1.5.6.1 mrg ttycons_open(dev_t dev, int flag, int mode, lwp_t *l)
199 1.5.6.1 mrg {
200 1.5.6.1 mrg struct ttycons_softc *sc;
201 1.5.6.1 mrg struct tty *t;
202 1.5.6.1 mrg
203 1.5.6.1 mrg sc = device_lookup_private(&ttycons_cd, minor(dev));
204 1.5.6.1 mrg if (sc == NULL)
205 1.5.6.1 mrg return ENXIO;
206 1.5.6.1 mrg t = sc->sc_tty;
207 1.5.6.1 mrg
208 1.5.6.1 mrg if (kauth_authorize_device_tty(l->l_cred, KAUTH_DEVICE_TTY_OPEN, t))
209 1.5.6.1 mrg return EBUSY;
210 1.5.6.1 mrg
211 1.5.6.1 mrg if ((t->t_state & TS_ISOPEN) == 0 && t->t_wopen == 0) {
212 1.5.6.1 mrg t->t_dev = dev;
213 1.5.6.1 mrg ttychars(t);
214 1.5.6.1 mrg t->t_iflag = TTYDEF_IFLAG;
215 1.5.6.1 mrg t->t_oflag = TTYDEF_OFLAG;
216 1.5.6.1 mrg t->t_cflag = TTYDEF_CFLAG;
217 1.5.6.1 mrg t->t_lflag = TTYDEF_LFLAG;
218 1.5.6.1 mrg t->t_ispeed = t->t_ospeed = TTYDEF_SPEED;
219 1.5.6.1 mrg ttycons_param(t, &t->t_termios);
220 1.5.6.1 mrg ttsetwater(t);
221 1.5.6.1 mrg }
222 1.5.6.1 mrg t->t_state |= TS_CARR_ON;
223 1.5.6.1 mrg
224 1.5.6.1 mrg return t->t_linesw->l_open(dev, t);
225 1.5.6.1 mrg }
226 1.5.6.1 mrg
227 1.5.6.1 mrg int
228 1.5.6.1 mrg ttycons_close(dev_t dev, int flag, int mode, lwp_t *l)
229 1.5.6.1 mrg {
230 1.5.6.1 mrg struct ttycons_softc *sc;
231 1.5.6.1 mrg struct tty *t;
232 1.5.6.1 mrg
233 1.5.6.1 mrg sc = device_lookup_private(&ttycons_cd, minor(dev));
234 1.5.6.1 mrg t = sc->sc_tty;
235 1.5.6.1 mrg
236 1.5.6.1 mrg if (t == NULL)
237 1.5.6.1 mrg return 0;
238 1.5.6.1 mrg
239 1.5.6.1 mrg t->t_linesw->l_close(t, flag);
240 1.5.6.1 mrg ttyclose(t);
241 1.5.6.1 mrg
242 1.5.6.1 mrg return 0;
243 1.5.6.1 mrg }
244 1.5.6.1 mrg
245 1.5.6.1 mrg int
246 1.5.6.1 mrg ttycons_read(dev_t dev, struct uio *uio, int flag)
247 1.5.6.1 mrg {
248 1.5.6.1 mrg struct ttycons_softc *sc;
249 1.5.6.1 mrg struct tty *t;
250 1.5.6.1 mrg
251 1.5.6.1 mrg sc = device_lookup_private(&ttycons_cd, minor(dev));
252 1.5.6.1 mrg t = sc->sc_tty;
253 1.5.6.1 mrg
254 1.5.6.1 mrg return t->t_linesw->l_read(t, uio, flag);
255 1.5.6.1 mrg }
256 1.5.6.1 mrg
257 1.5.6.1 mrg int
258 1.5.6.1 mrg ttycons_write(dev_t dev, struct uio *uio, int flag)
259 1.5.6.1 mrg {
260 1.5.6.1 mrg struct ttycons_softc *sc;
261 1.5.6.1 mrg struct tty *t;
262 1.5.6.1 mrg
263 1.5.6.1 mrg sc = device_lookup_private(&ttycons_cd, minor(dev));
264 1.5.6.1 mrg t = sc->sc_tty;
265 1.5.6.1 mrg
266 1.5.6.1 mrg return t->t_linesw->l_write(t, uio, flag);
267 1.5.6.1 mrg }
268 1.5.6.1 mrg
269 1.5.6.1 mrg int
270 1.5.6.1 mrg ttycons_poll(dev_t dev, int events, lwp_t *l)
271 1.5.6.1 mrg {
272 1.5.6.1 mrg struct ttycons_softc *sc;
273 1.5.6.1 mrg struct tty *t;
274 1.5.6.1 mrg
275 1.5.6.1 mrg sc = device_lookup_private(&ttycons_cd, minor(dev));
276 1.5.6.1 mrg t = sc->sc_tty;
277 1.5.6.1 mrg
278 1.5.6.1 mrg return t->t_linesw->l_poll(t, events, l);
279 1.5.6.1 mrg }
280 1.5.6.1 mrg
281 1.5.6.1 mrg struct tty *
282 1.5.6.1 mrg ttycons_tty(dev_t dev)
283 1.5.6.1 mrg {
284 1.5.6.1 mrg struct ttycons_softc *sc;
285 1.5.6.1 mrg
286 1.5.6.1 mrg sc = device_lookup_private(&ttycons_cd, minor(dev));
287 1.5.6.1 mrg
288 1.5.6.1 mrg return sc->sc_tty;
289 1.5.6.1 mrg }
290 1.5.6.1 mrg
291 1.5.6.1 mrg int
292 1.5.6.1 mrg ttycons_ioctl(dev_t dev, u_long cmd, void *data, int flag, lwp_t *l)
293 1.5.6.1 mrg {
294 1.5.6.1 mrg struct ttycons_softc *sc;
295 1.5.6.1 mrg struct tty *t;
296 1.5.6.1 mrg int error;
297 1.5.6.1 mrg
298 1.5.6.1 mrg sc = device_lookup_private(&ttycons_cd, minor(dev));
299 1.5.6.1 mrg t = sc->sc_tty;
300 1.5.6.1 mrg
301 1.5.6.1 mrg error = t->t_linesw->l_ioctl(t, cmd, data, flag, l);
302 1.5.6.1 mrg if (error != EPASSTHROUGH)
303 1.5.6.1 mrg return error;
304 1.5.6.1 mrg
305 1.5.6.1 mrg error = ttioctl(t, cmd, data, flag, l);
306 1.5.6.1 mrg if (error != EPASSTHROUGH)
307 1.5.6.1 mrg return error;
308 1.5.6.1 mrg
309 1.5.6.1 mrg return EPASSTHROUGH;
310 1.5.6.1 mrg }
311 1.5.6.1 mrg
312 1.5.6.1 mrg static void
313 1.5.6.1 mrg ttycons_start(struct tty *t)
314 1.5.6.1 mrg {
315 1.5.6.1 mrg struct ttycons_softc *sc = t->t_sc;
316 1.5.6.1 mrg u_char *p = sc->sc_buf;
317 1.5.6.1 mrg int s, len, brem;
318 1.5.6.1 mrg
319 1.5.6.1 mrg s = spltty();
320 1.5.6.1 mrg if (t->t_state & (TS_TIMEOUT|TS_BUSY|TS_TTSTOP)) {
321 1.5.6.1 mrg splx(s);
322 1.5.6.1 mrg return;
323 1.5.6.1 mrg }
324 1.5.6.1 mrg t->t_state |= TS_BUSY;
325 1.5.6.1 mrg splx(s);
326 1.5.6.1 mrg
327 1.5.6.1 mrg brem = q_to_b(&t->t_outq, sc->sc_buf, sizeof(sc->sc_buf));
328 1.5.6.1 mrg
329 1.5.6.1 mrg while (brem > 0) {
330 1.5.6.1 mrg len = thunk_write(1, p, brem);
331 1.5.6.1 mrg if (len > 0) {
332 1.5.6.1 mrg p += len;
333 1.5.6.1 mrg brem -= len;
334 1.5.6.1 mrg }
335 1.5.6.1 mrg }
336 1.5.6.1 mrg
337 1.5.6.1 mrg s = spltty();
338 1.5.6.1 mrg t->t_state &= ~TS_BUSY;
339 1.5.6.1 mrg if (ttypull(t)) {
340 1.5.6.1 mrg t->t_state |= TS_TIMEOUT;
341 1.5.6.1 mrg callout_schedule(&t->t_rstrt_ch, 1);
342 1.5.6.1 mrg }
343 1.5.6.1 mrg splx(s);
344 1.5.6.1 mrg }
345 1.5.6.1 mrg
346 1.5.6.1 mrg void
347 1.5.6.1 mrg ttycons_stop(struct tty *t, int flag)
348 1.5.6.1 mrg {
349 1.5.6.1 mrg }
350 1.5.6.1 mrg
351 1.5.6.1 mrg static int
352 1.5.6.1 mrg ttycons_param(struct tty *t, struct termios *c)
353 1.5.6.1 mrg {
354 1.5.6.1 mrg t->t_ispeed = c->c_ispeed;
355 1.5.6.1 mrg t->t_ospeed = c->c_ospeed;
356 1.5.6.1 mrg t->t_cflag = c->c_cflag;
357 1.5.6.1 mrg return 0;
358 1.5.6.1 mrg }
359 1.5.6.1 mrg
360 1.5.6.1 mrg static int
361 1.5.6.1 mrg ttycons_intr(void *priv)
362 1.5.6.1 mrg {
363 1.5.6.1 mrg struct ttycons_softc *sc = priv;
364 1.5.6.1 mrg
365 1.5.6.1 mrg softint_schedule(sc->sc_rd_sih);
366 1.5.6.1 mrg
367 1.5.6.1 mrg return 0;
368 1.5.6.1 mrg }
369 1.5.6.1 mrg
370 1.5.6.1 mrg static void
371 1.5.6.1 mrg ttycons_softintr(void *priv)
372 1.5.6.1 mrg {
373 1.5.6.1 mrg struct ttycons_softc *sc = priv;
374 1.5.6.1 mrg struct tty *t = sc->sc_tty;
375 1.5.6.1 mrg unsigned char ch;
376 1.5.6.1 mrg int c;
377 1.5.6.1 mrg
378 1.5.6.1 mrg while ((c = thunk_pollchar()) >= 0) {
379 1.5.6.1 mrg ch = (unsigned char)c;
380 1.5.6.1 mrg cn_check_magic(t->t_dev, ch, ttycons_cnm_state);
381 1.5.6.1 mrg t->t_linesw->l_rint(ch, t);
382 1.5.6.1 mrg }
383 1.5.6.1 mrg }
384 1.5.6.1 mrg
385 1.5.6.1 mrg
386 1.5.6.1 mrg /*
387 1.5.6.1 mrg * handle SIGINT signal from trap.c
388 1.5.6.1 mrg *
389 1.5.6.1 mrg * argument 'pc' and 'va' are not used.
390 1.5.6.1 mrg */
391 1.5.6.1 mrg static void
392 1.5.6.1 mrg ttycons_ctrlc(vaddr_t from_userland, vaddr_t pc, vaddr_t va)
393 1.5.6.1 mrg {
394 1.5.6.1 mrg struct ttycons_softc *sc;
395 1.5.6.1 mrg
396 1.5.6.1 mrg sc = device_lookup_private(&ttycons_cd, minor(cn_tab->cn_dev));
397 1.5.6.1 mrg if (sc)
398 1.5.6.1 mrg softint_schedule(sc->sc_ctrlc_sih);
399 1.5.6.1 mrg
400 1.5.6.1 mrg }
401 1.5.6.1 mrg
402 1.5.6.1 mrg static void
403 1.5.6.1 mrg ttycons_softctrlc(void *priv)
404 1.5.6.1 mrg {
405 1.5.6.1 mrg struct ttycons_softc *sc = priv;
406 1.5.6.1 mrg struct tty *t = sc->sc_tty;
407 1.5.6.1 mrg unsigned char ch = 3; /* ETX */
408 1.5.6.1 mrg
409 1.5.6.1 mrg cn_check_magic(t->t_dev, ch, ttycons_cnm_state);
410 1.5.6.1 mrg t->t_linesw->l_rint(ch, t);
411 1.5.6.1 mrg }
412 1.5.6.1 mrg
413 1.5.6.1 mrg /*
414 1.5.6.1 mrg * handle SIGTSTP signal from trap.c
415 1.5.6.1 mrg *
416 1.5.6.1 mrg * argument 'pc' and 'va' are not used.
417 1.5.6.1 mrg */
418 1.5.6.1 mrg static void
419 1.5.6.1 mrg ttycons_ctrlz(vaddr_t from_userland, vaddr_t pc, vaddr_t va)
420 1.5.6.1 mrg {
421 1.5.6.1 mrg struct ttycons_softc *sc;
422 1.5.6.1 mrg
423 1.5.6.1 mrg sc = device_lookup_private(&ttycons_cd, minor(cn_tab->cn_dev));
424 1.5.6.1 mrg if (sc)
425 1.5.6.1 mrg softint_schedule(sc->sc_ctrlz_sih);
426 1.5.6.1 mrg }
427 1.5.6.1 mrg
428 1.5.6.1 mrg static void
429 1.5.6.1 mrg ttycons_softctrlz(void *priv)
430 1.5.6.1 mrg {
431 1.5.6.1 mrg struct ttycons_softc *sc = priv;
432 1.5.6.1 mrg struct tty *t = sc->sc_tty;
433 1.5.6.1 mrg unsigned char ch = 26; /* SUB */
434 1.5.6.1 mrg
435 1.5.6.1 mrg cn_check_magic(t->t_dev, ch, ttycons_cnm_state);
436 1.5.6.1 mrg t->t_linesw->l_rint(ch, t);
437 1.5.6.1 mrg }
438