* Copyright (c) 1991 The Regents of the University of California.
* This software was developed by the Computer Systems Engineering group
* at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
* contributed to Berkeley.
* All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Lawrence Berkeley Laboratories.
* %sccs.include.redist.c%
* @(#)rcons_kern.c 7.3 (Berkeley) %G%
* from: $Header: rcons_kern.c,v 1.26 92/07/09 08:01:28 torek Exp $
#include <machine/fbvar.h>
#include <machine/autoconf.h>
#include <sparc/dev/kbd.h>
#include <sparc/rcons/raster.h>
extern struct tty
*fbconstty
;
static void rcons_belltmr(void *);
extern void rcons_puts(struct fbdevice
*, char *, int);
extern void rcons_font(struct fbdevice
*);
extern void ttrstrt(void *);
static struct fbdevice
*myfbdevicep
;
rcons_puts(myfbdevicep
, "\r\n", 2);
rcons_puts(myfbdevicep
, buf
, 1);
if (tp
->t_state
& (TS_TIMEOUT
| TS_BUSY
| TS_TTSTOP
)) {
n
= q_to_b(&tp
->t_outq
, buf
, sizeof(buf
));
buf
[i
] &= 0177; /* strip parity (argh) */
rcons_puts(myfbdevicep
, buf
, n
);
/* Come back if there's more to do */
tp
->t_state
|= TS_TIMEOUT
;
if (tp
->t_outq
.c_cc
<= tp
->t_lowat
) {
if (tp
->t_state
&TS_ASLEEP
) {
tp
->t_state
&= ~TS_ASLEEP
;
wakeup((caddr_t
)&tp
->t_outq
);
/* Ring the console bell */
register struct fbdevice
*fb
;
if (fb
->fb_bits
& FB_VISBELL
) {
/* invert the screen twice */
raster_op(fb
->fb_sp
, 0, 0,
fb
->fb_sp
->width
, fb
->fb_sp
->height
,
RAS_INVERT
, (struct raster
*) 0, 0, 0);
if (fb
->fb_belldepth
++) {
if (fb
->fb_belldepth
> 3)
(void) kbd_docmd(KBD_CMD_BELL
, 0);
/* XXX Chris doesn't like the following divide */
timeout(rcons_belltmr
, fb
, hz
/10);
/* Bell timer service routine */
register struct fbdevice
*fb
= p
;
register int s
= splhigh(), i
;
(void) kbd_docmd(KBD_CMD_NOBELL
, 0);
/* XXX Chris doesn't like the following divide */
timeout(rcons_belltmr
, fb
, hz
/30);
(void) kbd_docmd(KBD_CMD_BELL
, 0);
timeout(rcons_belltmr
, fb
, hz
/10);
i
= i
* 10 + *cp
++ - '0';
register struct fbdevice
*fb
;
/* XXX this should go away */
static struct raster xxxraster
;
register struct raster
*rp
= fb
->fb_sp
= &xxxraster
;
register struct fbtype
*ft
= &fb
->fb_type
;
register struct winsize
*ws
;
rcons_a2int(getpropstring(optionsnode
, "screen-#columns"), 80);
rcons_a2int(getpropstring(optionsnode
, "screen-#rows"), 34);
/* XXX mostly duplicates of data in other places */
rp
->width
= ft
->fb_width
;
rp
->height
= ft
->fb_height
;
rp
->depth
= ft
->fb_depth
;
if (fb
->fb_linebytes
& 0x3) {
printf("rcons_init: linebytes assumption botched (0x%x)\n",
rp
->linelongs
= fb
->fb_linebytes
>> 2;
rp
->pixels
= (u_long
*)fb
->fb_pixels
;
fb
->fb_ras_blank
= RAS_CLEAR
;
/* Setup the static font */
/* Impose upper bounds on fb_max{row,col} */
i
= ft
->fb_height
/ fb
->fb_font
->height
;
i
= ft
->fb_width
/ fb
->fb_font
->width
;
/* Let the system know how big the console is */
ws
= &fbconstty
->t_winsize
;
ws
->ws_row
= fb
->fb_maxrow
;
ws
->ws_col
= fb
->fb_maxcol
;
ws
->ws_xpixel
= ft
->fb_width
;
ws
->ws_ypixel
= ft
->fb_height
;
/* Center emulator screen (but align x origin to 32 bits) */
((ft
->fb_width
- fb
->fb_maxcol
* fb
->fb_font
->width
) / 2) & ~0x1f;
(ft
->fb_height
- fb
->fb_maxrow
* fb
->fb_font
->height
) / 2;
/* Emulator width and height used for scrolling */
fb
->fb_emuwidth
= fb
->fb_maxcol
* fb
->fb_font
->width
;
if (fb
->fb_emuwidth
& 0x1f) {
i
= (fb
->fb_emuwidth
+ 0x1f) & ~0x1f;
/* Make sure emulator width isn't too wide */
if (fb
->fb_xorigin
+ i
<= ft
->fb_width
)
fb
->fb_emuheight
= fb
->fb_maxrow
* fb
->fb_font
->height
;
/* Determine addresses of prom emulator row and column */
fb
->fb_row
= fb
->fb_col
= NULL
;
sprintf(buf
, "' line# >body >user %x !", &fb
->fb_row
);
sprintf(buf
, "' column# >body >user %x !", &fb
->fb_col
);
if (fb
->fb_row
== NULL
|| fb
->fb_col
== NULL
) {
/* Can't find addresses; use private copies */
rcons_clear2eop(fb
); /* clear the display */
rcons_cursor(fb
); /* and draw the initial cursor */
/* Prom emulator cursor is currently visible */
fb
->fb_bits
|= FB_CURSOR
;
/* Initialization done; hook us up */
v_putc
= (int (*)())rcons_cnputc
;
fbconstty
->t_oproc
= rcons_output
;
fbconstty
->t_stop
= (void (*)()) nullop
;