1 /* $NetBSD: rcons_kern.c,v 1.21 2007/11/19 18:51:50 ad Exp $ */
4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This software was developed by the Computer Systems Engineering group
8 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
9 * contributed to Berkeley.
11 * All advertising materials mentioning features or use of this software
12 * must display the following acknowledgement:
13 * This product includes software developed by the University of
14 * California, Lawrence Berkeley Laboratory.
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions
19 * 1. Redistributions of source code must retain the above copyright
20 * notice, this list of conditions and the following disclaimer.
21 * 2. Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 * 3. Neither the name of the University nor the names of its contributors
25 * may be used to endorse or promote products derived from this software
26 * without specific prior written permission.
28 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
29 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
37 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * @(#)rcons_kern.c 8.1 (Berkeley) 6/11/93
43 #include <sys/cdefs.h>
44 __KERNEL_RCSID(0, "$NetBSD: rcons_kern.c,v 1.21 2007/11/19 18:51:50 ad Exp $");
46 #include <sys/param.h>
47 #include <sys/device.h>
48 #include <sys/kernel.h>
49 #include <sys/systm.h>
50 #include <sys/ioctl.h>
54 #include <dev/rcons/raster.h>
55 #include <dev/rcons/rcons.h>
57 static void rcons_belltmr(void *);
59 static struct rconsole
*mydevicep
; /* XXX */
60 static void rcons_output(struct tty
*);
68 /* Swap in kernel attribute */
69 attr
= mydevicep
->rc_attr
;
70 mydevicep
->rc_attr
= mydevicep
->rc_kern_attr
;
73 rcons_puts(mydevicep
, "\r\n", 2);
76 rcons_puts(mydevicep
, buf
, 1);
79 /* Swap out kernel attribute */
80 mydevicep
->rc_attr
= attr
;
84 rcons_output(struct tty
*tp
)
90 if (tp
->t_state
& (TS_TIMEOUT
| TS_BUSY
| TS_TTSTOP
)) {
94 tp
->t_state
|= TS_BUSY
;
96 n
= q_to_b(&tp
->t_outq
, buf
, sizeof(buf
));
97 rcons_puts(mydevicep
, buf
, n
);
100 tp
->t_state
&= ~TS_BUSY
;
101 /* Come back if there's more to do */
103 tp
->t_state
|= TS_TIMEOUT
;
104 callout_schedule(&tp
->t_rstrt_ch
, 1);
109 /* Ring the console bell */
111 rcons_bell(struct rconsole
*rc
)
115 if (rc
->rc_bits
& FB_VISBELL
) {
116 /* invert the screen twice */
117 i
= ((rc
->rc_bits
& FB_INVERT
) == 0);
119 rcons_invert(rc
, i
^ 1);
123 if (rc
->rc_belldepth
++) {
124 if (rc
->rc_belldepth
> 3)
125 rc
->rc_belldepth
= 3;
131 /* XXX Chris doesn't like the following divide */
132 callout_reset(&rc
->rc_belltmr_ch
, hz
/ 10,
137 /* Bell timer service routine */
139 rcons_belltmr(void *p
)
141 struct rconsole
*rc
= p
;
142 int s
= splhigh(), i
;
144 if (rc
->rc_ringing
) {
146 i
= --rc
->rc_belldepth
;
150 /* XXX Chris doesn't like the following divide */
151 callout_reset(&rc
->rc_belltmr_ch
, hz
/ 30,
157 callout_reset(&rc
->rc_belltmr_ch
, hz
/ 10,
163 rcons_init(struct rconsole
*rc
, int clear
)
167 callout_init(&rc
->rc_belltmr_ch
, 0);
169 /* Initialize operations set, clear screen and turn cursor on */
180 rcons_ttyinit(struct tty
*tp
)
182 /* XXX this should go away */
183 struct rconsole
*rc
= mydevicep
;
189 /* Let the system know how big the console is */
191 ws
->ws_row
= rc
->rc_maxrow
;
192 ws
->ws_col
= rc
->rc_maxcol
;
193 ws
->ws_xpixel
= rc
->rc_width
;
194 ws
->ws_ypixel
= rc
->rc_height
;
196 /* Initialization done; hook us up */
197 tp
->t_oproc
= rcons_output
;
198 /*tp->t_stop = (void (*)()) nullop;*/