From 3a73106b1b913a6cbab8a64b5b01916788651238 Mon Sep 17 00:00:00 2001 From: ragge Date: Wed, 26 Jul 2000 11:50:16 +0000 Subject: [PATCH] KA88 console support. --- sys/arch/vax/vax/conf.c | 4 +- sys/arch/vax/vax/gencons.c | 207 ++++++++++++++++++------------------- 2 files changed, 101 insertions(+), 110 deletions(-) diff --git a/sys/arch/vax/vax/conf.c b/sys/arch/vax/vax/conf.c index 5db619fac9f3..d775478c9e9c 100644 --- a/sys/arch/vax/vax/conf.c +++ b/sys/arch/vax/vax/conf.c @@ -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. @@ -175,7 +175,7 @@ cons_decl(smg); struct consdev constab[]={ #if VAX8600 || VAX8200 || VAX780 || VAX750 || VAX650 || VAX630 || VAX660 || \ - VAX670 || VAX680 + VAX670 || VAX680 || VAX8800 #define NGEN 1 cons_init(gen), /* Generic console type; mtpr/mfpr */ #else diff --git a/sys/arch/vax/vax/gencons.c b/sys/arch/vax/vax/gencons.c index ee67d87dac29..916e68a04136 100644 --- a/sys/arch/vax/vax/gencons.c +++ b/sys/arch/vax/vax/gencons.c @@ -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 @@ -36,6 +36,7 @@ /* All bugs are subject to removal without further notice */ #include "opt_ddb.h" +#include "opt_cputype.h" #include #include @@ -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}; cons_decl(gen); -#ifdef DYNAMIC_DEVSW -bcdev_decl(gencn); -#else cdev_decl(gencn); -#endif static int gencnparam __P((struct tty *, struct termios *)); static void gencnstart __P((struct tty *)); -void gencnrint __P((void *)); -void gencntint __P((void *)); int -gencnopen(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; +gencnopen(dev_t dev, int flag, int mode, struct proc *p) { - int unit; - struct tty *tp; + int unit; + struct tty *tp; - unit = minor(dev); - if (unit >= maxttys) + unit = minor(dev); + if (unit >= maxttys) return ENXIO; if (gencn_tty[unit] == NULL) @@ -95,108 +87,92 @@ gencnopen(dev, flag, mode, p) tp = gencn_tty[unit]; - tp->t_oproc = gencnstart; - tp->t_param = gencnparam; - tp->t_dev = dev; - if ((tp->t_state & TS_ISOPEN) == 0) { - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; - gencnparam(tp, &tp->t_termios); - ttsetwater(tp); - } else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) - return EBUSY; - tp->t_state |= TS_CARR_ON; + tp->t_oproc = gencnstart; + tp->t_param = gencnparam; + tp->t_dev = dev; + if ((tp->t_state & TS_ISOPEN) == 0) { + ttychars(tp); + tp->t_iflag = TTYDEF_IFLAG; + tp->t_oflag = TTYDEF_OFLAG; + tp->t_cflag = TTYDEF_CFLAG; + tp->t_lflag = TTYDEF_LFLAG; + tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; + gencnparam(tp, &tp->t_termios); + ttsetwater(tp); + } else if (tp->t_state & TS_XCLUDE && p->p_ucred->cr_uid != 0) + return EBUSY; + tp->t_state |= TS_CARR_ON; if (unit == 0) consopened = 1; mtpr(GC_RIE, pr_rxcs[unit]); /* Turn on interrupts */ 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 -gencnclose(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; +gencnclose(dev_t dev, int flag, int mode, struct proc *p) { - struct tty *tp = gencn_tty[minor(dev)]; + struct tty *tp = gencn_tty[minor(dev)]; if (minor(dev) == 0) consopened = 0; - (*linesw[tp->t_line].l_close)(tp, flag); - ttyclose(tp); - return (0); + (*linesw[tp->t_line].l_close)(tp, flag); + ttyclose(tp); + return (0); } struct tty * -gencntty(dev) - dev_t dev; +gencntty(dev_t dev) { return gencn_tty[minor(dev)]; } int -gencnread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; +gencnread(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 -gencnwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; +gencnwrite(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 -gencnioctl(dev, cmd, data, flag, p) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; +gencnioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) { - struct tty *tp = gencn_tty[minor(dev)]; - int error; + struct tty *tp = gencn_tty[minor(dev)]; + int error; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); - if (error >= 0) - return error; - error = ttioctl(tp, cmd, data, flag, p); - if (error >= 0) + error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); + if (error >= 0) + return error; + error = ttioctl(tp, cmd, data, flag, p); + if (error >= 0) return error; return ENOTTY; } void -gencnstart(tp) - struct tty *tp; +gencnstart(struct tty *tp) { - struct clist *cl; - int s, ch; + struct clist *cl; + int s, ch; - s = spltty(); - if (tp->t_state & (TS_BUSY|TS_TTSTOP|TS_TIMEOUT)) - goto out; - cl = &tp->t_outq; + s = spltty(); + if (tp->t_state & (TS_BUSY|TS_TTSTOP|TS_TIMEOUT)) + goto out; + cl = &tp->t_outq; if(cl->c_cc){ - tp->t_state |= TS_BUSY; + tp->t_state |= TS_BUSY; ch = getc(cl); mtpr(ch, pr_txdb[minor(tp->t_dev)]); } else { @@ -210,14 +186,15 @@ gencnstart(tp) out: splx(s); } -void -gencnrint(arg) - void *arg; +static void +gencnrint(void *arg) { struct tty *tp = *(struct tty **) arg; int unit = (struct tty **) arg - gencn_tty; int i; +printf("gencnrint: %x\n", mfpr(PR_RXDB)); +return; i = mfpr(pr_rxdb[unit]) & 0377; /* Mask status flags etc... */ #ifdef DDB @@ -237,15 +214,12 @@ gencnrint(arg) } void -gencnstop(tp, flag) - struct tty *tp; - int flag; +gencnstop(struct tty *tp, int flag) { } -void -gencntint(arg) - void *arg; +static void +gencntint(void *arg) { struct tty *tp = *(struct tty **) arg; @@ -255,20 +229,17 @@ gencntint(arg) } int -gencnparam(tp, t) - struct tty *tp; - struct termios *t; +gencnparam(struct tty *tp, struct termios *t) { - /* XXX - These are ignored... */ - tp->t_ispeed = t->c_ispeed; - tp->t_ospeed = t->c_ospeed; - tp->t_cflag = t->c_cflag; + /* XXX - These are ignored... */ + tp->t_ispeed = t->c_ispeed; + tp->t_ospeed = t->c_ospeed; + tp->t_cflag = t->c_cflag; return 0; } void -gencnprobe(cndev) - struct consdev *cndev; +gencnprobe(struct consdev *cndev) { if ((vax_cputype < VAX_TYP_UV1) || /* All older has MTPR console */ (vax_boardtype == VAX_BTYP_9RR) || @@ -283,8 +254,7 @@ gencnprobe(cndev) } void -gencninit(cndev) - struct consdev *cndev; +gencninit(struct consdev *cndev) { /* Allocate interrupt vectors */ @@ -302,14 +272,38 @@ gencninit(cndev) scb_vecalloc(SCB_G3R, gencnrint, &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); /* ??? */ } void -gencnputc(dev,ch) - dev_t dev; - int ch; +gencnputc(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 */ ; mtpr(ch, PR_TXDB); /* xmit character */ @@ -319,8 +313,7 @@ gencnputc(dev,ch) } int -gencngetc(dev) - dev_t dev; +gencngetc(dev_t dev) { int i; @@ -333,15 +326,13 @@ gencngetc(dev) } void -gencnpollc(dev, pollflag) - dev_t dev; - int pollflag; +gencnpollc(dev_t dev, int pollflag) { - if (pollflag) { - mtpr(0, PR_RXCS); - mtpr(0, PR_TXCS); + if (pollflag) { + mtpr(0, PR_RXCS); + mtpr(0, PR_TXCS); } else if (consopened) { - mtpr(GC_RIE, PR_RXCS); - mtpr(GC_TIE, PR_TXCS); + mtpr(GC_RIE, PR_RXCS); + mtpr(GC_TIE, PR_TXCS); } }