* Copyright (c) 1982, 1986 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
* @(#)cons.c 7.12 (Berkeley) 5/16/91
* VAX console driver (and floppy interface)
#include "../include/cpu.h"
#include "../include/mtpr.h"
* On some machines (e.g. MicroVAX), a secondary console
* such as a display may supercede the standard serial console.
* On such machines, consops will be set to point to the cdevsw
* entry for the secondary console, and the standard console device
* (minor number 0) will be redirected. Other minor numbers still
* refer to the standard console serial line.
* Also, console output may be redirected to another tty
* (e.g. a window); if so, constty will point to the current
struct cdevsw
*consops
= 0;
register struct tty
*tp
= &cons
;
if (consops
&& minor(dev
) == 0)
return ((*consops
->d_open
)(dev
, flag
));
if ((tp
->t_state
&TS_ISOPEN
) == 0) {
tp
->t_iflag
= TTYDEF_IFLAG
|ICRNL
;
tp
->t_oflag
= TTYDEF_OFLAG
|OPOST
|ONLCR
;
tp
->t_lflag
= TTYDEF_LFLAG
;
tp
->t_ispeed
= tp
->t_ospeed
= TTYDEF_SPEED
;
tp
->t_state
= TS_ISOPEN
|TS_CARR_ON
;
if (tp
->t_state
&TS_XCLUDE
&& u
.u_uid
!= 0)
mtpr(RXCS
, mfpr(RXCS
)|RXCS_IE
);
mtpr(TXCS
, mfpr(TXCS
)|TXCS_IE
);
return ((*linesw
[tp
->t_line
].l_open
)(dev
, tp
));
cnclose(dev
, flag
, mode
, p
)
register struct tty
*tp
= &cons
;
if (consops
&& minor(dev
) == 0)
return ((*consops
->d_close
)(dev
, flag
, mode
, p
));
(*linesw
[tp
->t_line
].l_close
)(tp
, flag
);
register struct tty
*tp
= &cons
;
if (consops
&& minor(dev
) == 0)
return ((*consops
->d_read
)(dev
, uio
, flag
));
return ((*linesw
[tp
->t_line
].l_read
)(tp
, uio
, flag
));
register struct tty
*tp
= &cons
;
if (constty
&& (constty
->t_state
& (TS_CARR_ON
| TS_ISOPEN
)) ==
(TS_CARR_ON
| TS_ISOPEN
))
return ((*consops
->d_write
)(dev
, uio
, flag
));
return ((*linesw
[tp
->t_line
].l_write
)(tp
, uio
, flag
));
static int cnpolling
= 0;
* Got a level-20 receive interrupt -
* the LSI wants to give us a character.
* Catch the character, and see who it goes to.
if ((tp
->t_cflag
&CSIZE
) == CS7
) {
if (tp
->t_cflag
&PARENB
) {
if ((tp
->t_cflag
&PARODD
) &&
(partab
[c
&0177]&0200) == (c
&0200))
else if ((partab
[c
&0177]&0200) != (c
&0200))
(*linesw
[tp
->t_line
].l_rint
)(c
, tp
);
cnioctl(dev
, cmd
, addr
, flag
)
register struct tty
*tp
= &cons
;
if (consops
&& minor(dev
) == 0)
return ((*consops
->d_ioctl
)(dev
, cmd
, addr
, flag
));
error
= (*linesw
[tp
->t_line
].l_ioctl
)(tp
, cmd
, addr
);
error
= ttioctl(tp
, cmd
, addr
, flag
);
* Got a level-20 transmission interrupt -
* the LSI wants another character. First,
* see if we can send something to the typewriter.
* If not, try the floppy.
register struct tty
*tp
= &cons
;
(*linesw
[tp
->t_line
].l_start
)(tp
);
if (cpu
==VAX_780
&& (tp
->t_state
& TS_BUSY
) == 0)
if (tp
->t_state
& (TS_TIMEOUT
|TS_BUSY
|TS_TTSTOP
))
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
);
selwakeup(tp
->t_wsel
, tp
->t_state
& TS_WCOLL
);
tp
->t_state
&= ~TS_WCOLL
;
if (tp
->t_outq
.c_cc
== 0)
c
= getc(&tp
->t_outq
) & 0xff;
if (tp
->t_cflag
&PARENB
&& ((tp
->t_cflag
&CSIZE
)==CS7
)) {
c
|= (tp
->t_cflag
&PARODD
? ~partab
[c
] : partab
[c
]) & 0200;
if ((tp
->t_cflag
&CSIZE
) == CS7
) {
if (tp
->t_cflag
&PARENB
) {
c
= (~(partab
[c
&0177])&0200)|(c
&0177);
c
= (partab
[c
&0177]&0200)|(c
&0177);
* Print a character on console.
* Attempts to save and restore device
* Try waiting for the console tty to come ready,
* otherwise give up after a reasonable time.
while ((mfpr(TXCS
)&TXCS_RDY
) == 0)
#if (defined(KADB) || defined(GENERIC)) && !defined(lint)
* Get character from console.
while ((mfpr(RXCS
)&RXCS_DONE
) == 0 || (c
= mfpr(RXDB
)&0177) <= 0)