diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2003-03-09 01:43:47 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2003-03-09 01:43:47 +0000 |
commit | 8cf7a45e373025e4cbd2f25cb83fe987f5bf1667 (patch) | |
tree | dd70fde4d558268d293ddd3646ebf6800d1b674d /sys/arch/sparc64/dev | |
parent | 11820976fc09e613dd88eebdd9a7e6a5b73471ab (diff) |
When a sparc machine is running with serial console, the zskbd probe would
try to use short cuts, and would not correctly initialize its channel if a
keyboard is connected to it, which might have been done on purpose.
It would then become impossible to run X11 on this machine afterwards.
Fix this by being more cautious during the probe, at the extent of a couple
of seconds if no keyboard is present.
Tested by various, ok deraadt@
Diffstat (limited to 'sys/arch/sparc64/dev')
-rw-r--r-- | sys/arch/sparc64/dev/z8530kbd.c | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/sys/arch/sparc64/dev/z8530kbd.c b/sys/arch/sparc64/dev/z8530kbd.c index 2b2a67d8255..001d1f53ccf 100644 --- a/sys/arch/sparc64/dev/z8530kbd.c +++ b/sys/arch/sparc64/dev/z8530kbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530kbd.c,v 1.13 2002/11/29 01:00:49 miod Exp $ */ +/* $OpenBSD: z8530kbd.c,v 1.14 2003/03/09 01:43:46 miod Exp $ */ /* $NetBSD: z8530tty.c,v 1.77 2001/05/30 15:24:24 lukem Exp $ */ /*- @@ -230,7 +230,7 @@ static void zskbd_txint(struct zs_chanstate *); static void zskbd_softint(struct zs_chanstate *); static void zskbd_diag(void *); -void zskbd_init(struct zskbd_softc *); +int zskbd_init(struct zskbd_softc *); void zskbd_putc(struct zskbd_softc *, u_int8_t); void zskbd_raw(struct zskbd_softc *, u_int8_t); @@ -369,40 +369,40 @@ zskbd_attach(parent, self, aux) /* Wait a while for previous console output to complete */ DELAY(10000); - - /* - * Turn on receiver and status interrupts. - * We defer the actual write of the register to zsparam(), - * but we must make sure status interrupts are turned on by - * the time zsparam() reads the initial rr0 state. - */ - zskbd_init(zst); - SET(cs->cs_preg[1], ZSWR1_RIE | ZSWR1_SIE); - zs_write_reg(cs, 1, cs->cs_creg[1]); - - s = splzs(); - - /* Make sure DTR is on now. */ - zs_modem(zst, 1); - - splx(s); } else if (!ISSET(zst->zst_hwflags, ZS_HWFLAG_NORESET)) { /* Not the console; may need reset. */ int reset; reset = (channel == 0) ? ZSWR9_A_RESET : ZSWR9_B_RESET; - s = splzs(); - zs_write_reg(cs, 9, reset); + splx(s); + } + + /* + * Probe for a keyboard. + * If one is found, turn on receiver and status interrupts. + * We defer the actual write of the register to zsparam(), + * but we must make sure status interrupts are turned on by + * the time zsparam() reads the initial rr0 state. + */ + if (zskbd_init(zst)) { + SET(cs->cs_preg[1], ZSWR1_RIE | ZSWR1_SIE); + zs_write_reg(cs, 1, cs->cs_creg[1]); + /* Make sure DTR is on now. */ + s = splzs(); + zs_modem(zst, 1); + splx(s); + } else { /* Will raise DTR in open. */ + s = splzs(); zs_modem(zst, 0); - splx(s); - printf("\n"); - } else - printf("\n"); + + printf("%s: no keyboard\n", self->dv_xname); + return; + } a.console = console; if (ISTYPE5(zst->zst_layout)) { @@ -431,7 +431,7 @@ zskbd_attach(parent, self, aux) zst->zst_wskbddev = config_found(self, &a, wskbddevprint); } -void +int zskbd_init(zst) struct zskbd_softc *zst; { @@ -442,11 +442,11 @@ zskbd_init(zst) /* setup for 1200n81 */ if (zs_set_speed(cs, 1200)) { /* set 1200bps */ printf(": failed to set baudrate\n"); - return; + return 0; } if (zs_set_modes(cs, CS8 | CLOCAL)) { printf(": failed to set modes\n"); - return; + return 0; } s = splzs(); @@ -575,6 +575,8 @@ zskbd_init(zst) else printf(": layout %d\n", zst->zst_layout); splx(s); + + return tries; } void |