From 9b69cbd10c2223d501fee5d0908c6a9ebd790500 Mon Sep 17 00:00:00 2001 From: miod Date: Wed, 21 Jul 2010 20:10:14 +0000 Subject: [PATCH] Disable the heuristics for legacy free systems if pckbc flags are set to 1 in UKC; found the hard way by jakemsr@ on an old Tecra laptop. --- share/man/man4/pckbc.4 | 20 +++++++++++++++----- sys/arch/amd64/conf/GENERIC | 4 ++-- sys/arch/i386/conf/GENERIC | 4 ++-- sys/arch/sparc64/dev/pckbc_ebus.c | 4 ++-- sys/dev/ic/pckbc.c | 9 +++++---- sys/dev/ic/pckbcvar.h | 10 ++++++++-- sys/dev/isa/pckbc_isa.c | 5 +++-- sys/dev/pckbc/pckbd.c | 10 +++++++--- 8 files changed, 44 insertions(+), 22 deletions(-) diff --git a/share/man/man4/pckbc.4 b/share/man/man4/pckbc.4 index ee299ef4ef2..2305b5e20b7 100644 --- a/share/man/man4/pckbc.4 +++ b/share/man/man4/pckbc.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: pckbc.4,v 1.15 2007/08/01 21:23:26 miod Exp $ +.\" $OpenBSD: pckbc.4,v 1.16 2010/07/21 20:10:14 miod Exp $ .\" $NetBSD: pckbc.4,v 1.2 2000/06/16 06:42:31 augustss Exp $ .\" .\" Copyright (c) 1999 @@ -25,15 +25,15 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: August 1 2007 $ +.Dd $Mdocdate: July 21 2010 $ .Dt PCKBC 4 .Os .Sh NAME .Nm pckbc .Nd PC (ISA) keyboard controller driver .Sh SYNOPSIS -.Cd "pckbc* at isa? " Pq "alpha, amd64, i386" -.Cd "pckbc* at ebus? " Pq "sparc64" +.Cd "pckbc* at isa? flags 0x00 " Pq "alpha, amd64, i386, loongson" +.Cd "pckbc* at ebus? " Pq "sparc64" .Cd "pckbd* at pckbc?" .Cd "pms* at pckbc?" .Cd "pmsi* at pckbc?" @@ -54,10 +54,20 @@ slot for mice (the latter might be missing in older keyboard controllers). .\" logical slots. .\" This feature is for experimentation only, it will not be .\" useful in normal operation. +.Pp +To avoid attaching a phantom PS/2 keyboard device, the +.Nm +driver will attempt to detect USB legacy keyboard emulation on amd64 and i386 +systems. +Unfortunately, the detection heuristics may fail on older systems with a real +PS/2 keyboard. +The keyboard can be forced to attach on these systems, by changing the +device flags to 1. .Sh SEE ALSO .Xr ebus 4 , .Xr intro 4 , .Xr isa 4 , .Xr pckbd 4 , .Xr pms 4 , -.Xr pmsi 4 +.Xr pmsi 4 , +.Xr ukc 8 diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC index d72c1e2be8b..23286e3d759 100644 --- a/sys/arch/amd64/conf/GENERIC +++ b/sys/arch/amd64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.292 2010/07/03 03:59:16 krw Exp $ +# $OpenBSD: GENERIC,v 1.293 2010/07/21 20:10:17 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -275,7 +275,7 @@ option WSDISPLAY_COMPAT_RAWKBD # provide raw scancodes; needed for X11 option WSDISPLAY_DEFAULTSCREENS=6 # initial number of text consoles option WSDISPLAY_COMPAT_PCVT # emulate some ioctls; needed for X11 -pckbc0 at isa? # PC keyboard controller +pckbc0 at isa? flags 0x00 # PC keyboard controller pckbd* at pckbc? # PC keyboard pms* at pckbc? # PS/2 mouse for wsmouse pmsi* at pckbc? # PS/2 "Intelli"mouse for wsmouse diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index 54e042e6a85..9b42015b7b4 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.688 2010/07/05 22:20:22 tedu Exp $ +# $OpenBSD: GENERIC,v 1.689 2010/07/21 20:10:17 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -337,7 +337,7 @@ option WSDISPLAY_COMPAT_RAWKBD # provide raw scancodes; needed for X11 option WSDISPLAY_DEFAULTSCREENS=6 # initial number of text consoles option WSDISPLAY_COMPAT_PCVT # emulate some ioctls; needed for X11 -pckbc0 at isa? # PC keyboard controller +pckbc0 at isa? flags 0x00 # PC keyboard controller pckbd* at pckbc? # PC keyboard pms* at pckbc? # PS/2 mouse for wsmouse pmsi* at pckbc? # PS/2 "Intelli"mouse for wsmouse diff --git a/sys/arch/sparc64/dev/pckbc_ebus.c b/sys/arch/sparc64/dev/pckbc_ebus.c index bffaae1eabe..e232507c6c5 100644 --- a/sys/arch/sparc64/dev/pckbc_ebus.c +++ b/sys/arch/sparc64/dev/pckbc_ebus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pckbc_ebus.c,v 1.10 2008/07/29 04:20:35 miod Exp $ */ +/* $OpenBSD: pckbc_ebus.c,v 1.11 2010/07/21 20:10:17 miod Exp $ */ /* * Copyright (c) 2002 Jason L. Wright (jason@thought.net) @@ -184,7 +184,7 @@ pckbc_ebus_attach(parent, self, aux) psc->id = t; printf("\n"); - pckbc_attach(psc); + pckbc_attach(psc, 0); } int diff --git a/sys/dev/ic/pckbc.c b/sys/dev/ic/pckbc.c index fe9bebca7e1..8ec830ff8e1 100644 --- a/sys/dev/ic/pckbc.c +++ b/sys/dev/ic/pckbc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pckbc.c,v 1.21 2010/01/12 20:31:22 drahn Exp $ */ +/* $OpenBSD: pckbc.c,v 1.22 2010/07/21 20:10:17 miod Exp $ */ /* $NetBSD: pckbc.c,v 1.5 2000/06/09 04:58:35 soda Exp $ */ /* @@ -285,8 +285,9 @@ pckbc_attach_slot(sc, slot) } void -pckbc_attach(sc) +pckbc_attach(sc, flags) struct pckbc_softc *sc; + int flags; { struct pckbc_internal *t; bus_space_tag_t iot; @@ -348,8 +349,8 @@ pckbc_attach(sc) haskbd = 1; } #endif /* 0 */ - if (haskbd == 0) { #if defined(__i386__) || defined(__amd64__) + if (haskbd == 0 && !ISSET(flags, PCKBCF_FORCE_KEYBOARD_PRESENT)) { /* * If there is no keyboard present, yet we are the console, * we might be on a legacy-free PC where the PS/2 emulated @@ -365,8 +366,8 @@ pckbc_attach(sc) pckbc_console = 0; wscn_input_init(1); } -#endif } +#endif /* * Check aux port ok. diff --git a/sys/dev/ic/pckbcvar.h b/sys/dev/ic/pckbcvar.h index 947f542ce3d..ec8cf9bff4d 100644 --- a/sys/dev/ic/pckbcvar.h +++ b/sys/dev/ic/pckbcvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pckbcvar.h,v 1.7 2008/07/29 04:20:37 miod Exp $ */ +/* $OpenBSD: pckbcvar.h,v 1.8 2010/07/21 20:10:17 miod Exp $ */ /* $NetBSD: pckbcvar.h,v 1.4 2000/06/09 04:58:35 soda Exp $ */ /* @@ -105,10 +105,16 @@ void pckbc_set_poll(pckbc_tag_t, pckbc_slot_t, int); int pckbc_xt_translation(pckbc_tag_t, pckbc_slot_t, int); void pckbc_slot_enable(pckbc_tag_t, pckbc_slot_t, int); -void pckbc_attach(struct pckbc_softc *); +void pckbc_attach(struct pckbc_softc *, int); int pckbc_cnattach(bus_space_tag_t, bus_addr_t, bus_size_t, pckbc_slot_t, int); int pckbc_is_console(bus_space_tag_t, bus_addr_t); int pckbcintr(void *); +/* + * Device configuration flags (cf_flags). + */ + +#define PCKBCF_FORCE_KEYBOARD_PRESENT 0x0001 + #endif /* _DEV_IC_PCKBCVAR_H_ */ diff --git a/sys/dev/isa/pckbc_isa.c b/sys/dev/isa/pckbc_isa.c index dd3d9e20b67..1edd7150d8b 100644 --- a/sys/dev/isa/pckbc_isa.c +++ b/sys/dev/isa/pckbc_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pckbc_isa.c,v 1.5 2007/10/01 15:34:48 krw Exp $ */ +/* $OpenBSD: pckbc_isa.c,v 1.6 2010/07/21 20:10:17 miod Exp $ */ /* $NetBSD: pckbc_isa.c,v 1.2 2000/03/23 07:01:35 thorpej Exp $ */ /* @@ -119,6 +119,7 @@ pckbc_isa_attach(parent, self, aux) { struct pckbc_isa_softc *isc = (void *)self; struct pckbc_softc *sc = &isc->sc_pckbc; + struct cfdata *cf = self->dv_cfdata; struct isa_attach_args *ia = aux; struct pckbc_internal *t; bus_space_tag_t iot; @@ -162,7 +163,7 @@ pckbc_isa_attach(parent, self, aux) printf("\n"); /* Finish off the attach. */ - pckbc_attach(sc); + pckbc_attach(sc, cf->cf_flags); } void diff --git a/sys/dev/pckbc/pckbd.c b/sys/dev/pckbc/pckbd.c index db26455922e..342b9867f54 100644 --- a/sys/dev/pckbc/pckbd.c +++ b/sys/dev/pckbc/pckbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pckbd.c,v 1.25 2010/07/08 19:29:25 deraadt Exp $ */ +/* $OpenBSD: pckbd.c,v 1.26 2010/07/21 20:10:17 miod Exp $ */ /* $NetBSD: pckbd.c,v 1.24 2000/06/05 22:20:57 sommerfeld Exp $ */ /*- @@ -336,8 +336,12 @@ pckbdprobe(parent, match, aux) * be no PS/2 connector at all; in that case, do not * even try to attach; ukbd will take over as console. */ - if (res == ENXIO) - return 0; + if (res == ENXIO) { + /* check cf_flags from parent */ + struct cfdata *cf = parent->dv_cfdata; + if (!ISSET(cf->cf_flags, PCKBCF_FORCE_KEYBOARD_PRESENT)) + return 0; + } #endif return (pckbd_is_console(pa->pa_tag, pa->pa_slot) ? 1 : 0); } -- 2.20.1