summaryrefslogtreecommitdiff
path: root/sys/arch/vax/stand/boot/consio.c
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2008-08-10 18:20:08 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2008-08-10 18:20:08 +0000
commitbe38412e49d78c13c55bcd0a1f1b3c1959bc4dae (patch)
tree2ca720180c06e2c56472665fefa10cd63a114795 /sys/arch/vax/stand/boot/consio.c
parenta9ae17faa40d7f53f21c89598a89c1a87f985b91 (diff)
Add support for the VAXstation 3[58][24]0 to the bootblocks, currently
limited to serial console. This is enough for a 3520 to mopboot and download a kernel over NFS.
Diffstat (limited to 'sys/arch/vax/stand/boot/consio.c')
-rw-r--r--sys/arch/vax/stand/boot/consio.c213
1 files changed, 180 insertions, 33 deletions
diff --git a/sys/arch/vax/stand/boot/consio.c b/sys/arch/vax/stand/boot/consio.c
index b2aabd8da37..4e87e1321b0 100644
--- a/sys/arch/vax/stand/boot/consio.c
+++ b/sys/arch/vax/stand/boot/consio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: consio.c,v 1.7 2006/08/30 20:02:13 miod Exp $ */
+/* $OpenBSD: consio.c,v 1.8 2008/08/10 18:20:07 miod Exp $ */
/* $NetBSD: consio.c,v 1.13 2002/05/24 21:40:59 ragge Exp $ */
/*
* Copyright (c) 1994, 1998 Ludd, University of Lule}, Sweden.
@@ -32,9 +32,7 @@
/* All bugs are subject to removal without further notice */
-
-
-#include "sys/param.h"
+#include <sys/param.h>
#include "../vax/gencons.h"
@@ -51,45 +49,70 @@ static void (*put_fp)(int) = NULL;
static int (*get_fp)(void) = NULL;
static int (*test_fp)(void) = NULL;
-void pr_putchar(int c); /* putchar() using mtpr/mfpr */
-int pr_getchar(void);
-int pr_testchar(void);
+/*
+ * I/O using mtpr/mfpr
+ */
-void rom_putchar(int c); /* putchar() using ROM routines */
-int rom_getchar(void);
-int rom_testchar(void);
+void pr_putchar(int c);
+int pr_getchar(void);
+int pr_testchar(void);
-int rom_putc; /* ROM-address of put-routine */
-int rom_getc; /* ROM-address of get-routine */
+/*
+ * I/O using ROM routines
+ */
+
+void rom_putchar(int c);
+int rom_getchar(void);
+int rom_testchar(void);
+
+int rom_putc; /* ROM-address of put-routine */
+int rom_getc; /* ROM-address of get-routine */
+
+/*
+ * I/O using the KA630 ROM console routines
+ */
/* Pointer to KA630 console page, initialized by ka630_consinit */
unsigned char *ka630_conspage;
+void ka630_consinit(void);
-/* Function that initializes things for KA630 ROM console I/O */
-void ka630_consinit(void);
+void ka630_rom_putchar(int c);
+int ka630_rom_getchar(void);
+int ka630_rom_testchar(void);
-/* Functions that use KA630 ROM for console I/O */
-void ka630_rom_putchar(int c);
-int ka630_rom_getchar(void);
-int ka630_rom_testchar(void);
+/*
+ * I/O using the KA53 ROM console routines
+ */
-/* Also added such a thing for KA53 - MK-991208 */
unsigned char *ka53_conspage;
-void ka53_consinit(void);
+void ka53_consinit(void);
-void ka53_rom_putchar(int c);
-int ka53_rom_getchar(void);
-int ka53_rom_testchar(void);
+void ka53_rom_putchar(int c);
+int ka53_rom_getchar(void);
+int ka53_rom_testchar(void);
-void vxt_putchar(int c);
-int vxt_getchar(void);
-int vxt_testchar(void);
+/*
+ * I/O using the VXT2000 serial ports
+ */
-void putchar(int);
-int getchar(void);
-int testkey(void);
-void consinit(void);
-void _rtt(void);
+void vxt_putchar(int c);
+int vxt_getchar(void);
+int vxt_testchar(void);
+
+/*
+ * I/O using the VS3[58][24]0 serial ports
+ */
+
+void ff_consinit(void);
+void ff_putchar(int c);
+int ff_getchar(void);
+int ff_testchar(void);
+
+void putchar(int);
+int getchar(void);
+int testkey(void);
+void consinit(void);
+void _rtt(void);
void
putchar(int c)
@@ -108,7 +131,7 @@ getchar(void)
c = (*get_fp)() & 0177;
while (c == 17 || c == 19); /* ignore XON/XOFF */
if (c < 96 && c > 64)
- c += 32;
+ c += 32; /* force lowercase */
return c;
}
@@ -176,11 +199,17 @@ consinit(void)
ka53_consinit();
break;
+ case VAX_BTYP_60:
+ put_fp = ff_putchar;
+ get_fp = ff_getchar;
+ test_fp = ff_testchar;
+ ff_consinit();
+ break;
+
#ifdef notdef
case VAX_BTYP_630:
case VAX_BTYP_650:
case VAX_BTYP_9CC:
- case VAX_BTYP_60:
put_fp = pr_putchar;
get_fp = pr_getchar;
break
@@ -343,3 +372,121 @@ vxt_testchar(void)
return vxtregs[CH_DATA];
}
}
+
+/*
+ * VaxStation 3[58][24]0 console routines.
+ *
+ * We do not know what the proper ROM entry points are, so these routines
+ * drive the serial ports directly.
+ *
+ * Unfortunately the address of the serial ports depend on the position
+ * of the L2003 I/O board in the system, which requires us to check all
+ * slots for their ID. Of course, empty slots will cause a machine check,
+ * and the suggested method of looking at the BUSCTL register to know
+ * which slots are populated is not usable, since we are way too late in
+ * the boot process.
+ */
+
+struct ff_dzregs {
+ volatile unsigned short csr;
+ volatile unsigned short unused;
+ volatile unsigned short rbuf;
+ volatile unsigned short unused2;
+ volatile unsigned short tcr;
+ volatile unsigned short unused3;
+ volatile unsigned short tdr;
+};
+
+#define DZ_CSR_TX_READY 0100000
+#define DZ_CSR_RX_DONE 0000200
+
+int ff_ioslot = -1;
+static struct ff_dzregs *ff_dz;
+
+void
+ff_consinit()
+{
+ extern int jbuf[10];
+ extern int mcheck_silent;
+ extern int setjmp(int *);
+
+ int line = 3; /* printer port */
+ int mid, modaddr, modtype;
+
+ mcheck_silent = 1;
+ for (mid = 0; mid < 8; mid++) {
+ modaddr = 0x31fffffc + (mid << 25);
+ if (setjmp(jbuf)) {
+ /* this slot is empty */
+ continue;
+ }
+ modtype = *(int *)modaddr;
+ if ((modtype & 0xff) == 0x04) {
+ ff_ioslot = mid;
+ break;
+ }
+ }
+ mcheck_silent = 0;
+
+ if (ff_ioslot < 0) {
+ /*
+ * This shouldn't happen. Try mid #5 (slot #4) as a
+ * supposedly sane default.
+ */
+ ff_ioslot = 5;
+ }
+
+ ff_dz = (struct ff_dzregs *)
+ (0x30000000 + (ff_ioslot << 25) + 0x00600000);
+ ff_dz->tcr = 1 << line;
+}
+
+void
+ff_putchar(int c)
+{
+ while ((ff_dz->csr & DZ_CSR_TX_READY) == 0)
+ ;
+ ff_dz->tdr = c;
+ while ((ff_dz->csr & DZ_CSR_TX_READY) == 0)
+ ;
+}
+
+int
+ff_getchar()
+{
+ int line = 3; /* printer port */
+ unsigned short rbuf;
+
+ for(;;) {
+ while ((ff_dz->csr & DZ_CSR_RX_DONE) == 0)
+ ;
+ rbuf = ff_dz->rbuf;
+ if (((rbuf >> 8) & 3) == line)
+ break;
+ }
+
+ rbuf &= 0x7f;
+ if (rbuf == 13)
+ rbuf = 10;
+
+ return (int)rbuf;
+}
+
+int
+ff_testchar()
+{
+ int line = 3; /* printer port */
+ unsigned short rbuf;
+
+ if ((ff_dz->csr & DZ_CSR_RX_DONE) == 0)
+ return 0;
+ rbuf = ff_dz->rbuf;
+ if (((rbuf >> 8) & 3) != line)
+ return 0;
+
+ rbuf &= 0x7f;
+ if (rbuf == 13)
+ rbuf = 10;
+
+ return (int)rbuf;
+}