diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-08-30 20:02:14 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-08-30 20:02:14 +0000 |
commit | 944ea24171f07abe4e0cc2dfe6a03573937461f1 (patch) | |
tree | a6c68f4e90896ba7159498f671b23f18fb2f4ac6 | |
parent | a8981e77861ae0cbcf698131061f4ed34eac26f6 (diff) |
Horrible code to work around stupid VXT2000 rom getchar() behaviour, but
at least this allows our boot blocks to work with glass console on these
machines now.
Caution: reading this code will hurt your eyes.
ok deraadt@
-rw-r--r-- | sys/arch/vax/boot/boot/boot.c | 4 | ||||
-rw-r--r-- | sys/arch/vax/boot/boot/consio.c | 74 | ||||
-rw-r--r-- | sys/arch/vax/boot/boot/version | 3 | ||||
-rw-r--r-- | sys/arch/vax/stand/boot/boot.c | 4 | ||||
-rw-r--r-- | sys/arch/vax/stand/boot/consio.c | 74 | ||||
-rw-r--r-- | sys/arch/vax/stand/boot/version | 3 |
6 files changed, 112 insertions, 50 deletions
diff --git a/sys/arch/vax/boot/boot/boot.c b/sys/arch/vax/boot/boot/boot.c index e53f54027c6..afc082b5bd3 100644 --- a/sys/arch/vax/boot/boot/boot.c +++ b/sys/arch/vax/boot/boot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.15 2006/08/24 20:29:38 miod Exp $ */ +/* $OpenBSD: boot.c,v 1.16 2006/08/30 20:02:13 miod Exp $ */ /* $NetBSD: boot.c,v 1.18 2002/05/31 15:58:26 ragge Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -111,7 +111,7 @@ Xmain(void) transition = ' '; askname = bootrpb.rpb_bootr5 & RB_ASKNAME; - printf("\n\r>> OpenBSD/vax boot [%s] [%s] <<\n", "1.11", __DATE__); + printf("\n\r>> OpenBSD/vax boot [%s] [%s] <<\n", "1.12", __DATE__); printf(">> Press enter to autoboot now, or any other key to abort: "); sluttid = getsecs() + 5; senast = 0; diff --git a/sys/arch/vax/boot/boot/consio.c b/sys/arch/vax/boot/boot/consio.c index 3ac6a220f39..b2aabd8da37 100644 --- a/sys/arch/vax/boot/boot/consio.c +++ b/sys/arch/vax/boot/boot/consio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: consio.c,v 1.6 2006/08/24 20:29:38 miod Exp $ */ +/* $OpenBSD: consio.c,v 1.7 2006/08/30 20:02:13 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. @@ -151,9 +151,11 @@ consinit(void) break; case VAX_BTYP_VXT: - put_fp = vxt_putchar; + put_fp = rom_putchar; get_fp = vxt_getchar; test_fp = vxt_testchar; + rom_putc = 0x20040058; /* 537133144 */ + rom_getc = 0x20040044; /* 537133124 */ break; case VAX_BTYP_630: @@ -277,39 +279,67 @@ void ka53_consinit(void) test_fp = ka53_rom_testchar; } +/* + * VXT2000 console routines. + * + * While we can use the rom putchar routine, the rom getchar routine + * will happily return the last key pressed, even if it is not pressed + * anymore. + * + * To guard against this, we monitor the keyboard serial port and will + * only invoke the rom function (which will do the keyboard layout + * translation for us) if there is indeed a new keyboard event (we still + * need to guard against dead keys, hence the while() condition in + * vxt_getchar). This still unfortunately causes phantom characters to + * appear when playing with the shift keys, but nothing backspace can't + * erase, so this will be a minor annoyance. + * + * If console is on the serial port, we do not use the prom routines at + * all. + */ static volatile int *vxtregs = (int *)0x200A0000; -#define CH_SR 1 -#define CH_CR 2 -#define CH_DAT 3 +#define CH_SRA 0x01 +#define CH_CRA 0x02 +#define CH_DATA 0x03 +#define CH_SRC 0x11 +#define CH_CRC 0x12 +#define CH_DATC 0x13 + #define CR_RX_ENA 0x01 #define CR_TX_ENA 0x04 #define SR_RX_RDY 0x01 #define SR_TX_RDY 0x04 -void -vxt_putchar(int c) -{ - vxtregs[CH_CR] = CR_TX_ENA; - while ((vxtregs[CH_SR] & SR_TX_RDY) == 0) - ; - vxtregs[CH_DAT] = c; -} - int vxt_getchar(void) { - vxtregs[CH_CR] = CR_RX_ENA; - while ((vxtregs[CH_SR] & SR_RX_RDY) == 0) - ; - return vxtregs[CH_DAT]; + if (vax_confdata & 2) { + vxtregs[CH_CRC] = CR_RX_ENA; + while ((vxtregs[CH_SRC] & SR_RX_RDY) == 0 || + rom_testchar() == 0) + ; + return rom_getchar(); + } else { + vxtregs[CH_CRA] = CR_RX_ENA; + while ((vxtregs[CH_SRA] & SR_RX_RDY) == 0) + ; + return vxtregs[CH_DATA]; + } } int vxt_testchar(void) { - vxtregs[CH_CR] = CR_RX_ENA; - if ((vxtregs[CH_SR] & SR_RX_RDY) == 0) - return 0; - return vxtregs[CH_DAT]; + if (vax_confdata & 2) { + vxtregs[CH_CRC] = CR_RX_ENA; + if ((vxtregs[CH_SRC] & SR_RX_RDY) == 0) + return 0; + return rom_testchar(); + } else { + vxtregs[CH_CRA] = CR_RX_ENA; + if ((vxtregs[CH_SRA] & SR_RX_RDY) == 0) + return 0; + return vxtregs[CH_DATA]; + } } diff --git a/sys/arch/vax/boot/boot/version b/sys/arch/vax/boot/boot/version index b13b00dbe1a..0ac6dfd5468 100644 --- a/sys/arch/vax/boot/boot/version +++ b/sys/arch/vax/boot/boot/version @@ -1,4 +1,4 @@ -$OpenBSD: version,v 1.2 2006/08/24 20:29:38 miod Exp $ +$OpenBSD: version,v 1.3 2006/08/30 20:02:13 miod Exp $ $NetBSD: version,v 1.4 2001/11/09 19:53:15 scw Exp $ NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this @@ -32,3 +32,4 @@ is taken as the current. Work around some PROM bugs in graphics mode which cause \h and \t not to behave as expected. 1.11: Better VXT2000{,+} support. +1.12: Glass console support on VXT2000{,+}. diff --git a/sys/arch/vax/stand/boot/boot.c b/sys/arch/vax/stand/boot/boot.c index e53f54027c6..afc082b5bd3 100644 --- a/sys/arch/vax/stand/boot/boot.c +++ b/sys/arch/vax/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.15 2006/08/24 20:29:38 miod Exp $ */ +/* $OpenBSD: boot.c,v 1.16 2006/08/30 20:02:13 miod Exp $ */ /* $NetBSD: boot.c,v 1.18 2002/05/31 15:58:26 ragge Exp $ */ /*- * Copyright (c) 1982, 1986 The Regents of the University of California. @@ -111,7 +111,7 @@ Xmain(void) transition = ' '; askname = bootrpb.rpb_bootr5 & RB_ASKNAME; - printf("\n\r>> OpenBSD/vax boot [%s] [%s] <<\n", "1.11", __DATE__); + printf("\n\r>> OpenBSD/vax boot [%s] [%s] <<\n", "1.12", __DATE__); printf(">> Press enter to autoboot now, or any other key to abort: "); sluttid = getsecs() + 5; senast = 0; diff --git a/sys/arch/vax/stand/boot/consio.c b/sys/arch/vax/stand/boot/consio.c index 3ac6a220f39..b2aabd8da37 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.6 2006/08/24 20:29:38 miod Exp $ */ +/* $OpenBSD: consio.c,v 1.7 2006/08/30 20:02:13 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. @@ -151,9 +151,11 @@ consinit(void) break; case VAX_BTYP_VXT: - put_fp = vxt_putchar; + put_fp = rom_putchar; get_fp = vxt_getchar; test_fp = vxt_testchar; + rom_putc = 0x20040058; /* 537133144 */ + rom_getc = 0x20040044; /* 537133124 */ break; case VAX_BTYP_630: @@ -277,39 +279,67 @@ void ka53_consinit(void) test_fp = ka53_rom_testchar; } +/* + * VXT2000 console routines. + * + * While we can use the rom putchar routine, the rom getchar routine + * will happily return the last key pressed, even if it is not pressed + * anymore. + * + * To guard against this, we monitor the keyboard serial port and will + * only invoke the rom function (which will do the keyboard layout + * translation for us) if there is indeed a new keyboard event (we still + * need to guard against dead keys, hence the while() condition in + * vxt_getchar). This still unfortunately causes phantom characters to + * appear when playing with the shift keys, but nothing backspace can't + * erase, so this will be a minor annoyance. + * + * If console is on the serial port, we do not use the prom routines at + * all. + */ static volatile int *vxtregs = (int *)0x200A0000; -#define CH_SR 1 -#define CH_CR 2 -#define CH_DAT 3 +#define CH_SRA 0x01 +#define CH_CRA 0x02 +#define CH_DATA 0x03 +#define CH_SRC 0x11 +#define CH_CRC 0x12 +#define CH_DATC 0x13 + #define CR_RX_ENA 0x01 #define CR_TX_ENA 0x04 #define SR_RX_RDY 0x01 #define SR_TX_RDY 0x04 -void -vxt_putchar(int c) -{ - vxtregs[CH_CR] = CR_TX_ENA; - while ((vxtregs[CH_SR] & SR_TX_RDY) == 0) - ; - vxtregs[CH_DAT] = c; -} - int vxt_getchar(void) { - vxtregs[CH_CR] = CR_RX_ENA; - while ((vxtregs[CH_SR] & SR_RX_RDY) == 0) - ; - return vxtregs[CH_DAT]; + if (vax_confdata & 2) { + vxtregs[CH_CRC] = CR_RX_ENA; + while ((vxtregs[CH_SRC] & SR_RX_RDY) == 0 || + rom_testchar() == 0) + ; + return rom_getchar(); + } else { + vxtregs[CH_CRA] = CR_RX_ENA; + while ((vxtregs[CH_SRA] & SR_RX_RDY) == 0) + ; + return vxtregs[CH_DATA]; + } } int vxt_testchar(void) { - vxtregs[CH_CR] = CR_RX_ENA; - if ((vxtregs[CH_SR] & SR_RX_RDY) == 0) - return 0; - return vxtregs[CH_DAT]; + if (vax_confdata & 2) { + vxtregs[CH_CRC] = CR_RX_ENA; + if ((vxtregs[CH_SRC] & SR_RX_RDY) == 0) + return 0; + return rom_testchar(); + } else { + vxtregs[CH_CRA] = CR_RX_ENA; + if ((vxtregs[CH_SRA] & SR_RX_RDY) == 0) + return 0; + return vxtregs[CH_DATA]; + } } diff --git a/sys/arch/vax/stand/boot/version b/sys/arch/vax/stand/boot/version index b13b00dbe1a..0ac6dfd5468 100644 --- a/sys/arch/vax/stand/boot/version +++ b/sys/arch/vax/stand/boot/version @@ -1,4 +1,4 @@ -$OpenBSD: version,v 1.2 2006/08/24 20:29:38 miod Exp $ +$OpenBSD: version,v 1.3 2006/08/30 20:02:13 miod Exp $ $NetBSD: version,v 1.4 2001/11/09 19:53:15 scw Exp $ NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE. The format of this @@ -32,3 +32,4 @@ is taken as the current. Work around some PROM bugs in graphics mode which cause \h and \t not to behave as expected. 1.11: Better VXT2000{,+} support. +1.12: Glass console support on VXT2000{,+}. |