* Copyright (c) 1988 University of Utah.
* Copyright (c) 1990 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* the Systems Programming Group of the University of Utah Computer
* %sccs.include.redist.c%
* from: Utah $Hdr: ite.c 1.1 90/07/09$
* @(#)ite.c 7.6 (Berkeley) %G%
* Bit-mapped display terminal emulator machine independent code.
* This is a very rudimentary. Much more can be abstracted out of
* the hardware dependent routines.
#define set_attr(ip, attr) ((ip)->attribute |= (attr))
#define clr_attr(ip, attr) ((ip)->attribute &= ~(attr))
int topcat_scroll(), topcat_init(), topcat_deinit();
int topcat_clear(), topcat_putc(), topcat_cursor();
int gatorbox_scroll(), gatorbox_init(), gatorbox_deinit();
int gatorbox_clear(), gatorbox_putc(), gatorbox_cursor();
int rbox_scroll(), rbox_init(), rbox_deinit();
int rbox_clear(), rbox_putc(), rbox_cursor();
int dvbox_scroll(), dvbox_init(), dvbox_deinit();
int dvbox_clear(), dvbox_putc(), dvbox_cursor();
topcat_init
, topcat_deinit
, topcat_clear
,
topcat_putc
, topcat_cursor
, topcat_scroll
,
gatorbox_init
, gatorbox_deinit
, gatorbox_clear
,
gatorbox_putc
, gatorbox_cursor
, gatorbox_scroll
,
rbox_init
, rbox_deinit
, rbox_clear
,
rbox_putc
, rbox_cursor
, rbox_scroll
,
dvbox_init
, dvbox_deinit
, dvbox_clear
,
dvbox_putc
, dvbox_cursor
, dvbox_scroll
,
* # of chars are output in a single itestart() call.
* If this is too big, user processes will be blocked out for
* long periods of time while we are emptying the queue in itestart().
* If it is too small, console output will be very ragged.
struct tty
*kbd_tty
= NULL
;
struct tty ite_tty
[NITE
];
struct ite_softc ite_softc
[NITE
];
extern struct tty
*constty
;
* Primary attribute buffer to be used by the first bitmapped console
* found. Secondary displays alloc the attribute buffer as needed.
* Size is based on a 68x128 display, which is currently our largest.
u_char console_attributes
[0x2200];
* Perform functions necessary to setup device as a terminal emulator.
struct tty
*tp
= &ite_tty
[unit
];
struct ite_softc
*ip
= &ite_softc
[unit
];
if (unit
< 0 || unit
>= NITE
|| (ip
->flags
&ITE_ALIVE
) == 0)
/* force ite active, overriding graphics mode */
ip
->flags
&= ~(ITE_INGRF
|ITE_INITED
);
/* leave graphics mode */
if ((ip
->flags
& ITE_ACTIVE
) == 0)
if (ip
->flags
& ITE_INGRF
)
if (kbd_tty
== NULL
|| kbd_tty
== tp
) {
struct ite_softc
*ip
= &ite_softc
[unit
];
if (ip
->flags
& ITE_INITED
)
(*itesw
[ip
->type
].ite_init
)(ip
);
(*itesw
[ip
->type
].ite_cursor
)(ip
, DRAW_CURSOR
);
malloc(ip
->rows
* ip
->cols
, M_DEVBUF
, M_WAITOK
);
bzero(ip
->attrbuf
, (ip
->rows
* ip
->cols
));
* "Shut down" device as terminal emulator.
* Note that we do not deinit the console device unless forced.
* Deinit'ing the console every time leads to a very active
* screen when processing /etc/rc.
register struct ite_softc
*ip
= &ite_softc
[UNIT(dev
)];
if ((ip
->flags
& ITE_ACTIVE
) == 0)
(ip
->flags
& (ITE_INGRF
|ITE_ISCONS
|ITE_INITED
)) == ITE_INITED
)
(*itesw
[ip
->type
].ite_deinit
)(ip
);
ip
->flags
&= ~ITE_ACTIVE
;
iteopen(dev_t dev
, int mode
, int devtype
, struct proc
*p
)
iteopen(dev
, mode
, devtype
, p
)
register struct tty
*tp
= &ite_tty
[unit
];
register struct ite_softc
*ip
= &ite_softc
[unit
];
if ((tp
->t_state
&(TS_ISOPEN
|TS_XCLUDE
)) == (TS_ISOPEN
|TS_XCLUDE
)
&& p
->p_ucred
->cr_uid
!= 0)
if ((ip
->flags
& ITE_ACTIVE
) == 0) {
if ((tp
->t_state
&TS_ISOPEN
) == 0) {
tp
->t_iflag
= TTYDEF_IFLAG
;
tp
->t_oflag
= TTYDEF_OFLAG
;
tp
->t_lflag
= TTYDEF_LFLAG
;
tp
->t_ispeed
= tp
->t_ospeed
= TTYDEF_SPEED
;
tp
->t_state
= TS_ISOPEN
|TS_CARR_ON
;
error
= (*linesw
[tp
->t_line
].l_open
)(dev
, tp
);
tp
->t_winsize
.ws_row
= ip
->rows
;
tp
->t_winsize
.ws_col
= ip
->cols
;
iteclose(dev
, flag
, mode
, p
)
register struct tty
*tp
= &ite_tty
[UNIT(dev
)];
(*linesw
[tp
->t_line
].l_close
)(tp
, flag
);
register struct tty
*tp
= &ite_tty
[UNIT(dev
)];
return ((*linesw
[tp
->t_line
].l_read
)(tp
, uio
, flag
));
register struct tty
*tp
= &ite_tty
[unit
];
if ((ite_softc
[unit
].flags
& ITE_ISCONS
) && constty
&&
(constty
->t_state
&(TS_CARR_ON
|TS_ISOPEN
))==(TS_CARR_ON
|TS_ISOPEN
))
return ((*linesw
[tp
->t_line
].l_write
)(tp
, uio
, flag
));
iteioctl(dev
, cmd
, addr
, flag
)
register struct tty
*tp
= &ite_tty
[UNIT(dev
)];
error
= (*linesw
[tp
->t_line
].l_ioctl
)(tp
, cmd
, addr
, flag
);
error
= ttioctl(tp
, cmd
, addr
, flag
);
if (tp
->t_state
& (TS_TIMEOUT
|TS_BUSY
|TS_TTSTOP
)) {
if (tp
->t_state
& TS_ASLEEP
) {
tp
->t_state
&= ~TS_ASLEEP
;
selwakeup(tp
->t_wsel
, tp
->t_state
& TS_WCOLL
);
tp
->t_state
&= ~TS_WCOLL
;
* Limit the amount of output we do in one burst
* to prevent hogging the CPU.
* iteputchar() may take a long time and we don't want to
* block all interrupts for long periods of time. Since
* there is no need to stay at high priority while outputing
* the character (since we don't have to worry about
* interrupts), we don't. We just need to make sure that
* we don't reenter iteputchar, which is guarenteed by the
* earlier setting of TS_BUSY.
iteputchar(c
, tp
->t_dev
);
tp
->t_state
|= TS_TIMEOUT
;
register char code
, *str
;
switch ((stat
>>KBD_SSHIFT
) & KBD_SMASK
) {
code
= kbd_ctrlshiftmap
[c
];
if (code
== NULL
&& (str
= kbd_stringmap
[c
]) != NULL
) {
(*linesw
[kbd_tty
->t_line
].l_rint
)(*str
++, kbd_tty
);
(*linesw
[kbd_tty
->t_line
].l_rint
)(code
, kbd_tty
);
register struct ite_softc
*ip
= &ite_softc
[unit
];
register struct itesw
*sp
= &itesw
[ip
->type
];
if ((ip
->flags
& (ITE_ACTIVE
|ITE_INGRF
)) != ITE_ACTIVE
)
case '&': /* Next can be a,d, or s */
case 'a': /* cursor change */
case 'Y': /* Only y coord. */
ip
->cury
= MIN(ip
->pos
, ip
->rows
-1);
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
case 'y': /* y coord first */
ip
->cury
= MIN(ip
->pos
, ip
->rows
-1);
ip
->curx
= MIN(ip
->pos
, ip
->cols
-1);
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
default: /* Possibly a 3 digit number. */
if (c
>= '0' && c
<= '9' && ip
->fpd
< 3) {
ip
->pos
= ip
->pos
* 10 + (c
- '0');
case 'd': /* attribute change */
/* XXX: we don't do anything for underline */
case 's': /* keypad control */
if (ip
->curx
> TABSIZE
) {
n
= ip
->curx
- (ip
->curx
& (TABSIZE
- 1));
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
case '3': /* clear all tabs */
case 'K': /* clear_eol */
ite_clrtoeol(ip
, sp
, ip
->cury
, ip
->curx
);
case 'J': /* clear_eos */
case 'B': /* cursor down 1 line */
if (++ip
->cury
== ip
->rows
) {
(*sp
->ite_scroll
)(ip
, 1, 0, 1, SCROLL_UP
);
ite_clrtoeol(ip
, sp
, ip
->cury
, 0);
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
case 'C': /* cursor forward 1 char */
case 'A': /* cursor up 1 line */
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
case 'P': /* delete character */
case 'M': /* delete line */
case 'Q': /* enter insert mode */
case 'R': /* exit insert mode */
case 'L': /* insert blank line */
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
case 'D': /* left arrow key */
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
case '1': /* set tab in all rows */
if ((ip
->escape
= c
) == ESC
)
if (++ip
->cury
== ip
->rows
) {
(*sp
->ite_scroll
)(ip
, 1, 0, 1, SCROLL_UP
);
ite_clrtoeol(ip
, sp
, ip
->cury
, 0);
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
if (ip
->curx
< TABEND(unit
)) {
n
= TABSIZE
- (ip
->curx
& (TABSIZE
- 1));
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
if (&ite_tty
[unit
] == kbd_tty
)
if ((ip
->attribute
& ATTR_INV
) || attrtest(ip
, ATTR_INV
)) {
(*sp
->ite_putc
)(ip
, c
, ip
->cury
, ip
->curx
, ATTR_INV
);
(*sp
->ite_putc
)(ip
, c
, ip
->cury
, ip
->curx
, ATTR_NOR
);
(*sp
->ite_cursor
)(ip
, DRAW_CURSOR
);
register struct ite_softc
*ip
;
register struct itesw
*sp
;
if (++ip
->curx
== ip
->cols
) {
if (++ip
->cury
== ip
->rows
) {
(*sp
->ite_scroll
)(ip
, 1, 0, 1, SCROLL_UP
);
ite_clrtoeol(ip
, sp
, ip
->cury
, 0);
(*sp
->ite_cursor
)(ip
, MOVE_CURSOR
);
register struct ite_softc
*ip
;
register struct itesw
*sp
;
(*sp
->ite_scroll
)(ip
, ip
->cury
, ip
->curx
+ 1, 1, SCROLL_LEFT
);
attrmov(ip
, ip
->cury
, ip
->curx
+ 1, ip
->cury
, ip
->curx
,
1, ip
->cols
- ip
->curx
- 1);
attrclr(ip
, ip
->cury
, ip
->cols
- 1, 1, 1);
(*sp
->ite_putc
)(ip
, ' ', ip
->cury
, ip
->cols
- 1, ATTR_NOR
);
(*sp
->ite_cursor
)(ip
, DRAW_CURSOR
);
register struct ite_softc
*ip
;
register struct itesw
*sp
;
(*sp
->ite_scroll
)(ip
, ip
->cury
, ip
->curx
, 1, SCROLL_RIGHT
);
attrmov(ip
, ip
->cury
, ip
->curx
, ip
->cury
, ip
->curx
+ 1,
1, ip
->cols
- ip
->curx
- 1);
attrclr(ip
, ip
->cury
, ip
->curx
, 1, 1);
(*sp
->ite_putc
)(ip
, ' ', ip
->cury
, ip
->curx
, ATTR_NOR
);
(*sp
->ite_cursor
)(ip
, DRAW_CURSOR
);
register struct ite_softc
*ip
;
register struct itesw
*sp
;
(*sp
->ite_scroll
)(ip
, ip
->cury
+ 1, 0, 1, SCROLL_UP
);
attrmov(ip
, ip
->cury
+ 1, 0, ip
->cury
, 0,
ip
->rows
- ip
->cury
- 1, ip
->cols
);
ite_clrtoeol(ip
, sp
, ip
->rows
- 1, 0);
register struct ite_softc
*ip
;
register struct itesw
*sp
;
(*sp
->ite_scroll
)(ip
, ip
->cury
, 0, 1, SCROLL_DOWN
);
attrmov(ip
, ip
->cury
, 0, ip
->cury
+ 1, 0,
ip
->rows
- ip
->cury
- 1, ip
->cols
);
ite_clrtoeol(ip
, sp
, ip
->cury
, 0);
ite_clrtoeol(ip
, sp
, y
, x
)
register struct ite_softc
*ip
;
register struct itesw
*sp
;
(*sp
->ite_clear
)(ip
, y
, x
, 1, ip
->cols
- x
);
attrclr(ip
, y
, x
, 1, ip
->cols
- x
);
(*sp
->ite_cursor
)(ip
, DRAW_CURSOR
);
register struct ite_softc
*ip
;
register struct itesw
*sp
;
(*sp
->ite_clear
)(ip
, ip
->cury
, 0, ip
->rows
- ip
->cury
, ip
->cols
);
attrclr(ip
, ip
->cury
, 0, ip
->rows
- ip
->cury
, ip
->cols
);
(*sp
->ite_cursor
)(ip
, DRAW_CURSOR
);
#include "../hp300/cons.h"
* Minimum ITE number at which to start looking for a console.
* Setting to 0 will do normal search, 1 will skip first ITE device,
* NITE will skip ITEs and use serial port.
register struct ite_softc
*ip
;
/* locate the major number */
for (maj
= 0; maj
< nchrdev
; maj
++)
if (cdevsw
[maj
].d_open
== iteopen
)
/* check all the individual displays and find the best */
for (i
= 0; i
< NITE
; i
++) {
struct grf_softc
*gp
= &grf_softc
[i
];
if ((gp
->g_flags
& GF_ALIVE
) == 0)
ip
->flags
= (ITE_ALIVE
|ITE_CONSOLE
);
/* XXX - we need to do something about mapping these */
ip
->type
= ITE_RENAISSANCE
;
if ((int)gp
->g_display
.gd_regaddr
== GRFIADDR
) {
/* initialize required fields */
cp
->cn_dev
= makedev(maj
, unit
);
cp
->cn_tp
= &ite_tty
[unit
];
int unit
= UNIT(cp
->cn_dev
);
struct ite_softc
*ip
= &ite_softc
[unit
];
ip
->attrbuf
= console_attributes
;
ip
->flags
|= (ITE_ACTIVE
|ITE_ISCONS
);
kbd_tty
= &ite_tty
[unit
];
switch ((stat
>> KBD_SSHIFT
) & KBD_SMASK
) {
c
= kbd_shiftmap
[c
& KBD_CHARMASK
];
c
= kbd_ctrlmap
[c
& KBD_CHARMASK
];
c
= kbd_keymap
[c
& KBD_CHARMASK
];
struct ite_softc
*ip
= &ite_softc
[UNIT(dev
)];
if (panicstr
&& !paniced
&&
(ip
->flags
& (ITE_ACTIVE
|ITE_INGRF
)) != ITE_ACTIVE
) {