summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-08-08 13:50:25 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-08-08 13:50:25 +0000
commit261b4acddad506aa7c1ab50029df3ee71e2bb311 (patch)
tree36dbca3a956c89907f3fe3810bbecbaadaf2ec2a /sys
parent44efcab1b8f726906822a35c91e42e0575be0d45 (diff)
Try and improve legacy controller emulation heuristics; if we think we should
not attach pckbd but pms attaches, then we are on real hardware, and should attach pckbd anyway. No known regression on legacy free systems; makes the few machines which required device flags changes in UKC work out of the box again. ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/pckbc.c80
1 files changed, 52 insertions, 28 deletions
diff --git a/sys/dev/ic/pckbc.c b/sys/dev/ic/pckbc.c
index e83c3fc8158..7247e30fbb4 100644
--- a/sys/dev/ic/pckbc.c
+++ b/sys/dev/ic/pckbc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pckbc.c,v 1.24 2010/08/05 13:50:00 miod Exp $ */
+/* $OpenBSD: pckbc.c,v 1.25 2010/08/08 13:50:24 miod Exp $ */
/* $NetBSD: pckbc.c,v 1.5 2000/06/09 04:58:35 soda Exp $ */
/*
@@ -72,7 +72,8 @@ struct pckbc_slotdata {
#define CMD_IN_QUEUE(q) (!TAILQ_EMPTY(&(q)->cmdqueue))
void pckbc_init_slotdata(struct pckbc_slotdata *);
-int pckbc_attach_slot(struct pckbc_softc *, pckbc_slot_t);
+int pckbc_attach_slot(struct pckbc_softc *, pckbc_slot_t, int);
+int pckbc_submatch_locators(struct device *, void *, void *);
int pckbc_submatch(struct device *, void *, void *);
int pckbcprint(void *, const char *);
@@ -246,7 +247,7 @@ pckbc_is_console(iot, addr)
}
int
-pckbc_submatch(parent, match, aux)
+pckbc_submatch_locators(parent, match, aux)
struct device *parent;
void *match;
void *aux;
@@ -257,13 +258,27 @@ pckbc_submatch(parent, match, aux)
if (cf->cf_loc[PCKBCCF_SLOT] != PCKBCCF_SLOT_DEFAULT &&
cf->cf_loc[PCKBCCF_SLOT] != pa->pa_slot)
return (0);
+ return (1);
+}
+
+int
+pckbc_submatch(parent, match, aux)
+ struct device *parent;
+ void *match;
+ void *aux;
+{
+ struct cfdata *cf = match;
+
+ if (pckbc_submatch_locators(parent, match, aux) == 0)
+ return (0);
return ((*cf->cf_attach->ca_match)(parent, cf, aux));
}
int
-pckbc_attach_slot(sc, slot)
+pckbc_attach_slot(sc, slot, force)
struct pckbc_softc *sc;
pckbc_slot_t slot;
+ int force;
{
struct pckbc_internal *t = sc->id;
struct pckbc_attach_args pa;
@@ -271,8 +286,8 @@ pckbc_attach_slot(sc, slot)
pa.pa_tag = t;
pa.pa_slot = slot;
- found = (config_found_sm((struct device *)sc, &pa,
- pckbcprint, pckbc_submatch) != NULL);
+ found = (config_found_sm((struct device *)sc, &pa, pckbcprint,
+ force ? pckbc_submatch_locators : pckbc_submatch) != NULL);
if (found && !t->t_slotdata[slot]) {
t->t_slotdata[slot] = malloc(sizeof(struct pckbc_slotdata),
@@ -335,7 +350,7 @@ pckbc_attach(sc, flags)
if (res != 0)
printf("kbc: returned %x on kbd slot test\n", res);
#endif
- if (pckbc_attach_slot(sc, PCKBC_KBD_SLOT)) {
+ if (pckbc_attach_slot(sc, PCKBC_KBD_SLOT, 0)) {
cmdbits |= KC8_KENABLE;
haskbd = 1;
}
@@ -344,30 +359,11 @@ pckbc_attach(sc, flags)
return;
}
#else
- if (pckbc_attach_slot(sc, PCKBC_KBD_SLOT)) {
+ if (pckbc_attach_slot(sc, PCKBC_KBD_SLOT, 0)) {
cmdbits |= KC8_KENABLE;
haskbd = 1;
}
#endif /* 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
- * keyboard was elected as console, but went away as soon
- * as the USB controller drivers attached.
- *
- * In that case, we want to release ourselves from console
- * duties.
- */
- if (pckbc_console != 0) {
- extern void wscn_input_init(int);
-
- pckbc_console = 0;
- wscn_input_init(1);
- }
- }
-#endif
/*
* Check aux port ok.
@@ -418,7 +414,7 @@ pckbc_attach(sc, flags)
printf("kbc: aux echo: %x\n", res);
#endif
t->t_haveaux = 1;
- if (pckbc_attach_slot(sc, PCKBC_AUX_SLOT))
+ if (pckbc_attach_slot(sc, PCKBC_AUX_SLOT, 0))
cmdbits |= KC8_MENABLE;
}
#ifdef PCKBCDEBUG
@@ -426,6 +422,34 @@ pckbc_attach(sc, flags)
printf("kbc: aux echo test failed\n");
#endif
+#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
+ * keyboard was elected as console, but went away as soon
+ * as the USB controller drivers attached.
+ *
+ * In that case, we want to release ourselves from console
+ * duties, unless we have been able to attach a mouse,
+ * which would mean this is a real PS/2 controller
+ * afterwards.
+ */
+
+ if (t->t_haveaux) {
+ if (pckbc_attach_slot(sc, PCKBC_KBD_SLOT, 1))
+ cmdbits |= KC8_KENABLE;
+ } else {
+ if (pckbc_console != 0) {
+ extern void wscn_input_init(int);
+
+ pckbc_console = 0;
+ wscn_input_init(1);
+ }
+ }
+ }
+#endif
+
nomouse:
/* enable needed interrupts */
t->t_cmdbyte |= cmdbits;