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/sparc | |
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/sparc')
-rw-r--r-- | sys/arch/sparc/dev/z8530kbd.c | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/sys/arch/sparc/dev/z8530kbd.c b/sys/arch/sparc/dev/z8530kbd.c index 4131cfb1ed5..1e5e723c611 100644 --- a/sys/arch/sparc/dev/z8530kbd.c +++ b/sys/arch/sparc/dev/z8530kbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: z8530kbd.c,v 1.2 2002/11/29 01:00:46 miod Exp $ */ +/* $OpenBSD: z8530kbd.c,v 1.3 2003/03/09 01:43:44 miod Exp $ */ /* $NetBSD: z8530tty.c,v 1.77 2001/05/30 15:24:24 lukem Exp $ */ /*- @@ -235,7 +235,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); void zskbd_reset(struct zskbd_softc *); @@ -375,37 +375,39 @@ 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("%s: no keyboard\n", self->dv_xname); + return; } /* @@ -454,7 +456,7 @@ zskbd_attach(parent, self, aux) zst->zst_wskbddev = config_found(self, &a, wskbddevprint); } -void +int zskbd_init(zst) struct zskbd_softc *zst; { @@ -465,11 +467,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(); @@ -601,6 +603,8 @@ zskbd_init(zst) if (tries == 0) printf(": reset timeout\n"); splx(s); + + return tries; } void |