KA88 console support.

This commit is contained in:
ragge 2000-07-26 11:50:16 +00:00
parent 0aeb2853f9
commit 3a73106b1b
2 changed files with 101 additions and 110 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: conf.c,v 1.47 2000/06/12 11:13:15 ragge Exp $ */ /* $NetBSD: conf.c,v 1.48 2000/07/26 11:50:16 ragge Exp $ */
/*- /*-
* Copyright (c) 1982, 1986 The Regents of the University of California. * Copyright (c) 1982, 1986 The Regents of the University of California.
@ -175,7 +175,7 @@ cons_decl(smg);
struct consdev constab[]={ struct consdev constab[]={
#if VAX8600 || VAX8200 || VAX780 || VAX750 || VAX650 || VAX630 || VAX660 || \ #if VAX8600 || VAX8200 || VAX780 || VAX750 || VAX650 || VAX630 || VAX660 || \
VAX670 || VAX680 VAX670 || VAX680 || VAX8800
#define NGEN 1 #define NGEN 1
cons_init(gen), /* Generic console type; mtpr/mfpr */ cons_init(gen), /* Generic console type; mtpr/mfpr */
#else #else

View File

@ -1,4 +1,4 @@
/* $NetBSD: gencons.c,v 1.25 2000/07/06 17:36:22 ragge Exp $ */ /* $NetBSD: gencons.c,v 1.26 2000/07/26 11:50:16 ragge Exp $ */
/* /*
* Copyright (c) 1994 Gordon W. Ross * Copyright (c) 1994 Gordon W. Ross
@ -36,6 +36,7 @@
/* All bugs are subject to removal without further notice */ /* All bugs are subject to removal without further notice */
#include "opt_ddb.h" #include "opt_ddb.h"
#include "opt_cputype.h"
#include <sys/param.h> #include <sys/param.h>
#include <sys/proc.h> #include <sys/proc.h>
@ -66,28 +67,19 @@ static int pr_txdb[4] = {PR_TXDB, PR_TXDB1, PR_TXDB2, PR_TXDB3};
static int pr_rxdb[4] = {PR_RXDB, PR_RXDB1, PR_RXDB2, PR_RXDB3}; static int pr_rxdb[4] = {PR_RXDB, PR_RXDB1, PR_RXDB2, PR_RXDB3};
cons_decl(gen); cons_decl(gen);
#ifdef DYNAMIC_DEVSW
bcdev_decl(gencn);
#else
cdev_decl(gencn); cdev_decl(gencn);
#endif
static int gencnparam __P((struct tty *, struct termios *)); static int gencnparam __P((struct tty *, struct termios *));
static void gencnstart __P((struct tty *)); static void gencnstart __P((struct tty *));
void gencnrint __P((void *));
void gencntint __P((void *));
int int
gencnopen(dev, flag, mode, p) gencnopen(dev_t dev, int flag, int mode, struct proc *p)
dev_t dev;
int flag, mode;
struct proc *p;
{ {
int unit; int unit;
struct tty *tp; struct tty *tp;
unit = minor(dev); unit = minor(dev);
if (unit >= maxttys) if (unit >= maxttys)
return ENXIO; return ENXIO;
if (gencn_tty[unit] == NULL) if (gencn_tty[unit] == NULL)
@ -95,108 +87,92 @@ gencnopen(dev, flag, mode, p)
tp = gencn_tty[unit]; tp = gencn_tty[unit];
tp->t_oproc = gencnstart; tp->t_oproc = gencnstart;
tp->t_param = gencnparam; tp->t_param = gencnparam;
tp->t_dev = dev; tp->t_dev = dev;
if ((tp->t_state & TS_ISOPEN) == 0) { if ((tp->t_state & TS_ISOPEN) == 0) {
ttychars(tp); ttychars(tp);
tp->t_iflag = TTYDEF_IFLAG; tp->t_iflag = TTYDEF_IFLAG;
tp->t_oflag = TTYDEF_OFLAG; tp->t_oflag = TTYDEF_OFLAG;
tp->t_cflag = TTYDEF_CFLAG; tp->t_cflag = TTYDEF_CFLAG;
tp->t_lflag = TTYDEF_LFLAG; tp->t_lflag = TTYDEF_LFLAG;
tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
gencnparam(tp, &tp->t_termios); gencnparam(tp, &tp->t_termios);
ttsetwater(tp); ttsetwater(tp);
} else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) } else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0)
return EBUSY; return EBUSY;
tp->t_state |= TS_CARR_ON; tp->t_state |= TS_CARR_ON;
if (unit == 0) if (unit == 0)
consopened = 1; consopened = 1;
mtpr(GC_RIE, pr_rxcs[unit]); /* Turn on interrupts */ mtpr(GC_RIE, pr_rxcs[unit]); /* Turn on interrupts */
mtpr(GC_TIE, pr_txcs[unit]); mtpr(GC_TIE, pr_txcs[unit]);
return ((*linesw[tp->t_line].l_open)(dev, tp)); return ((*linesw[tp->t_line].l_open)(dev, tp));
} }
int int
gencnclose(dev, flag, mode, p) gencnclose(dev_t dev, int flag, int mode, struct proc *p)
dev_t dev;
int flag, mode;
struct proc *p;
{ {
struct tty *tp = gencn_tty[minor(dev)]; struct tty *tp = gencn_tty[minor(dev)];
if (minor(dev) == 0) if (minor(dev) == 0)
consopened = 0; consopened = 0;
(*linesw[tp->t_line].l_close)(tp, flag); (*linesw[tp->t_line].l_close)(tp, flag);
ttyclose(tp); ttyclose(tp);
return (0); return (0);
} }
struct tty * struct tty *
gencntty(dev) gencntty(dev_t dev)
dev_t dev;
{ {
return gencn_tty[minor(dev)]; return gencn_tty[minor(dev)];
} }
int int
gencnread(dev, uio, flag) gencnread(dev_t dev, struct uio *uio, int flag)
dev_t dev;
struct uio *uio;
int flag;
{ {
struct tty *tp = gencn_tty[minor(dev)]; struct tty *tp = gencn_tty[minor(dev)];
return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
} }
int int
gencnwrite(dev, uio, flag) gencnwrite(dev_t dev, struct uio *uio, int flag)
dev_t dev;
struct uio *uio;
int flag;
{ {
struct tty *tp = gencn_tty[minor(dev)]; struct tty *tp = gencn_tty[minor(dev)];
return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
} }
int int
gencnioctl(dev, cmd, data, flag, p) gencnioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
dev_t dev;
u_long cmd;
caddr_t data;
int flag;
struct proc *p;
{ {
struct tty *tp = gencn_tty[minor(dev)]; struct tty *tp = gencn_tty[minor(dev)];
int error; int error;
error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p);
if (error >= 0) if (error >= 0)
return error; return error;
error = ttioctl(tp, cmd, data, flag, p); error = ttioctl(tp, cmd, data, flag, p);
if (error >= 0) if (error >= 0)
return error; return error;
return ENOTTY; return ENOTTY;
} }
void void
gencnstart(tp) gencnstart(struct tty *tp)
struct tty *tp;
{ {
struct clist *cl; struct clist *cl;
int s, ch; int s, ch;
s = spltty(); s = spltty();
if (tp->t_state & (TS_BUSY|TS_TTSTOP|TS_TIMEOUT)) if (tp->t_state & (TS_BUSY|TS_TTSTOP|TS_TIMEOUT))
goto out; goto out;
cl = &tp->t_outq; cl = &tp->t_outq;
if(cl->c_cc){ if(cl->c_cc){
tp->t_state |= TS_BUSY; tp->t_state |= TS_BUSY;
ch = getc(cl); ch = getc(cl);
mtpr(ch, pr_txdb[minor(tp->t_dev)]); mtpr(ch, pr_txdb[minor(tp->t_dev)]);
} else { } else {
@ -210,14 +186,15 @@ gencnstart(tp)
out: splx(s); out: splx(s);
} }
void static void
gencnrint(arg) gencnrint(void *arg)
void *arg;
{ {
struct tty *tp = *(struct tty **) arg; struct tty *tp = *(struct tty **) arg;
int unit = (struct tty **) arg - gencn_tty; int unit = (struct tty **) arg - gencn_tty;
int i; int i;
printf("gencnrint: %x\n", mfpr(PR_RXDB));
return;
i = mfpr(pr_rxdb[unit]) & 0377; /* Mask status flags etc... */ i = mfpr(pr_rxdb[unit]) & 0377; /* Mask status flags etc... */
#ifdef DDB #ifdef DDB
@ -237,15 +214,12 @@ gencnrint(arg)
} }
void void
gencnstop(tp, flag) gencnstop(struct tty *tp, int flag)
struct tty *tp;
int flag;
{ {
} }
void static void
gencntint(arg) gencntint(void *arg)
void *arg;
{ {
struct tty *tp = *(struct tty **) arg; struct tty *tp = *(struct tty **) arg;
@ -255,20 +229,17 @@ gencntint(arg)
} }
int int
gencnparam(tp, t) gencnparam(struct tty *tp, struct termios *t)
struct tty *tp;
struct termios *t;
{ {
/* XXX - These are ignored... */ /* XXX - These are ignored... */
tp->t_ispeed = t->c_ispeed; tp->t_ispeed = t->c_ispeed;
tp->t_ospeed = t->c_ospeed; tp->t_ospeed = t->c_ospeed;
tp->t_cflag = t->c_cflag; tp->t_cflag = t->c_cflag;
return 0; return 0;
} }
void void
gencnprobe(cndev) gencnprobe(struct consdev *cndev)
struct consdev *cndev;
{ {
if ((vax_cputype < VAX_TYP_UV1) || /* All older has MTPR console */ if ((vax_cputype < VAX_TYP_UV1) || /* All older has MTPR console */
(vax_boardtype == VAX_BTYP_9RR) || (vax_boardtype == VAX_BTYP_9RR) ||
@ -283,8 +254,7 @@ gencnprobe(cndev)
} }
void void
gencninit(cndev) gencninit(struct consdev *cndev)
struct consdev *cndev;
{ {
/* Allocate interrupt vectors */ /* Allocate interrupt vectors */
@ -302,14 +272,38 @@ gencninit(cndev)
scb_vecalloc(SCB_G3R, gencnrint, &gencn_tty[3], SCB_ISTACK, NULL); scb_vecalloc(SCB_G3R, gencnrint, &gencn_tty[3], SCB_ISTACK, NULL);
scb_vecalloc(SCB_G3T, gencntint, &gencn_tty[3], SCB_ISTACK, NULL); scb_vecalloc(SCB_G3T, gencntint, &gencn_tty[3], SCB_ISTACK, NULL);
} }
mtpr(0, PR_RXCS);
mtpr(0, PR_TXCS);
mtpr(0, PR_TBIA); /* ??? */ mtpr(0, PR_TBIA); /* ??? */
} }
void void
gencnputc(dev,ch) gencnputc(dev_t dev, int ch)
dev_t dev;
int ch;
{ {
#ifdef VAX8800
/*
* On KA88 we may get C-S/C-Q from the console.
* XXX - this will cause a loop at spltty() in kernel and will
* interfere with other console communication. Fortunately
* kernel printf's are uncommon.
*/
if (vax_cputype == VAX_TYP_8NN) {
int s = spltty();
while (mfpr(PR_RXCS) & GC_DON) {
if ((mfpr(PR_RXDB) & 0x7f) == 19) {
while (1) {
while ((mfpr(PR_RXCS) & GC_DON) == 0)
;
if ((mfpr(PR_RXDB) & 0x7f) == 17)
break;
}
}
}
splx(s);
}
#endif
while ((mfpr(PR_TXCS) & GC_RDY) == 0) /* Wait until xmit ready */ while ((mfpr(PR_TXCS) & GC_RDY) == 0) /* Wait until xmit ready */
; ;
mtpr(ch, PR_TXDB); /* xmit character */ mtpr(ch, PR_TXDB); /* xmit character */
@ -319,8 +313,7 @@ gencnputc(dev,ch)
} }
int int
gencngetc(dev) gencngetc(dev_t dev)
dev_t dev;
{ {
int i; int i;
@ -333,15 +326,13 @@ gencngetc(dev)
} }
void void
gencnpollc(dev, pollflag) gencnpollc(dev_t dev, int pollflag)
dev_t dev;
int pollflag;
{ {
if (pollflag) { if (pollflag) {
mtpr(0, PR_RXCS); mtpr(0, PR_RXCS);
mtpr(0, PR_TXCS); mtpr(0, PR_TXCS);
} else if (consopened) { } else if (consopened) {
mtpr(GC_RIE, PR_RXCS); mtpr(GC_RIE, PR_RXCS);
mtpr(GC_TIE, PR_TXCS); mtpr(GC_TIE, PR_TXCS);
} }
} }