summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2003-02-15 23:42:45 +0000
committermiod <miod@openbsd.org>2003-02-15 23:42:45 +0000
commitf307151fac532191f750b3e92a85f9c2eac5687d (patch)
tree2704a420e6429cba0bf36aff31cb18c8729fda2b
parentkill the remaining typedefs (These are about the last trace of Invertex (diff)
downloadwireguard-openbsd-f307151fac532191f750b3e92a85f9c2eac5687d.tar.xz
wireguard-openbsd-f307151fac532191f750b3e92a85f9c2eac5687d.zip
Rework the console management on hppa:
- only attach a keyboard as a console if it matches the PDC keyboard path - on hil, as there can be multiple keyboards on the loop, attach only the first hilkbd device configured as console keyboard. Right now this means the one with the lowest hil code, which was the existing behaviour so far. - do not try to switch to the wscons consdev structure early at all in wscons_machdep, but rather wait for the console to be completely configured (i.e. both wskbd and wsdisplay are attached) to switch. With feedback and help from mickey@
-rw-r--r--sys/arch/hppa/gsc/gsckbc.c11
-rw-r--r--sys/arch/hppa/gsc/gsckbd.c6
-rw-r--r--sys/arch/hppa/gsc/hil_gsc.c8
-rw-r--r--sys/arch/hppa/hppa/wscons_machdep.c70
-rw-r--r--sys/dev/hil/hil.c29
-rw-r--r--sys/dev/hil/hildevs.h5
-rw-r--r--sys/dev/hil/hilkbd.c22
-rw-r--r--sys/dev/hil/hilvar.h6
8 files changed, 64 insertions, 93 deletions
diff --git a/sys/arch/hppa/gsc/gsckbc.c b/sys/arch/hppa/gsc/gsckbc.c
index f598a3e8427..1e145b2760c 100644
--- a/sys/arch/hppa/gsc/gsckbc.c
+++ b/sys/arch/hppa/gsc/gsckbc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gsckbc.c,v 1.1 2003/01/31 22:50:19 miod Exp $ */
+/* $OpenBSD: gsckbc.c,v 1.2 2003/02/15 23:42:45 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -76,9 +76,10 @@
#include <sys/malloc.h>
#include <sys/proc.h>
+#include <machine/autoconf.h>
#include <machine/bus.h>
#include <machine/intr.h>
-#include <machine/autoconf.h>
+#include <machine/iomod.h>
#include <hppa/dev/cpudevs.h>
#include <hppa/gsc/gscbusvar.h>
@@ -268,7 +269,7 @@ probe_sendtmo(bus_space_tag_t iot, bus_space_handle_t ioh, int cmdbyte)
DELAY(500);
}
- if (bus_space_read_1(iot, ioh, KBSTATP) & KBS_OCMD)
+ if (numtries <= 0)
return (1);
bus_space_write_1(iot, ioh, KBDATAP, cmdbyte);
@@ -407,7 +408,9 @@ gsckbc_attach(struct device *parent, struct device *self, void *aux)
sc->sc_dv.dv_xname, gsc->sc_type, ident);
} else {
#if (NGSCKBD > 0)
- if (gsc->sc_type == PCKBC_KBD_SLOT)
+ if (gsc->sc_type == PCKBC_KBD_SLOT &&
+ ga->ga_dp.dp_mod == PAGE0->mem_kbd.pz_dp.dp_mod &&
+ bcmp(ga->ga_dp.dp_bc, PAGE0->mem_kbd.pz_dp.dp_bc, 6) == 0)
gsckbd_cnattach(t, PCKBC_KBD_SLOT);
#endif
pckbc_attach_slot(sc, gsc->sc_type);
diff --git a/sys/arch/hppa/gsc/gsckbd.c b/sys/arch/hppa/gsc/gsckbd.c
index c6e42325f68..60222b439af 100644
--- a/sys/arch/hppa/gsc/gsckbd.c
+++ b/sys/arch/hppa/gsc/gsckbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gsckbd.c,v 1.2 2003/02/15 01:01:21 miod Exp $ */
+/* $OpenBSD: gsckbd.c,v 1.3 2003/02/15 23:42:45 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -155,7 +155,7 @@ struct gsckbd_softc {
#endif
};
-static int gsckbd_is_console(pckbc_tag_t, pckbc_slot_t);
+int gsckbd_is_console(pckbc_tag_t, pckbc_slot_t);
int gsckbdprobe(struct device *, void *, void *);
void gsckbdattach(struct device *, struct device *, void *);
@@ -207,7 +207,7 @@ static int gsckbd_led_decode(int);
struct gsckbd_internal gsckbd_consdata;
-static int
+int
gsckbd_is_console(tag, slot)
pckbc_tag_t tag;
pckbc_slot_t slot;
diff --git a/sys/arch/hppa/gsc/hil_gsc.c b/sys/arch/hppa/gsc/hil_gsc.c
index c0e2683b9d4..d5ab2bdcd44 100644
--- a/sys/arch/hppa/gsc/hil_gsc.c
+++ b/sys/arch/hppa/gsc/hil_gsc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hil_gsc.c,v 1.1 2003/02/11 19:44:23 miod Exp $ */
+/* $OpenBSD: hil_gsc.c,v 1.2 2003/02/15 23:42:45 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -67,6 +67,7 @@ hil_gsc_attach(struct device *parent, struct device *self, void *aux)
{
struct hil_softc *sc = (void *)self;
struct gsc_attach_args *ga = aux;
+ int hil_is_console;
sc->sc_bst = ga->ga_iot;
if (bus_space_map(ga->ga_iot, ga->ga_hpa,
@@ -75,7 +76,10 @@ hil_gsc_attach(struct device *parent, struct device *self, void *aux)
return;
}
- hil_attach(sc);
+ hil_is_console = ga->ga_dp.dp_mod == PAGE0->mem_kbd.pz_dp.dp_mod &&
+ bcmp(ga->ga_dp.dp_bc, PAGE0->mem_kbd.pz_dp.dp_bc, 6) == 0;
+
+ hil_attach(sc, hil_is_console);
gsc_intr_establish((struct gsc_softc *)parent, IPL_TTY,
ga->ga_irq, hil_intr, sc, &sc->sc_dev);
diff --git a/sys/arch/hppa/hppa/wscons_machdep.c b/sys/arch/hppa/hppa/wscons_machdep.c
index ea38f036c77..a5ffe1068c6 100644
--- a/sys/arch/hppa/hppa/wscons_machdep.c
+++ b/sys/arch/hppa/hppa/wscons_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wscons_machdep.c,v 1.4 2003/01/31 22:50:19 miod Exp $ */
+/* $OpenBSD: wscons_machdep.c,v 1.5 2003/02/15 23:42:46 miod Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
@@ -38,21 +38,13 @@
#include <sys/device.h>
#include <sys/extent.h>
+#include <machine/autoconf.h>
#include <machine/bus.h>
#include <machine/pdc.h>
#include <machine/iomod.h>
#include <dev/cons.h>
-#include "sti.h"
-#if NSTI > 0
-#include <dev/ic/stireg.h>
-#include <dev/ic/stivar.h>
-#endif
-
-#if NGSCKBD > 0
-#endif
-
#include "wsdisplay.h"
#if NWSDISPLAY > 0
#include <dev/wscons/wsdisplayvar.h>
@@ -66,57 +58,33 @@
cons_decl(ws);
void
-wscnprobe(cp)
- struct consdev *cp;
+wscnprobe(struct consdev *cp)
{
- int maj;
-
- /* locate the major number */
- for (maj = 0; maj < nchrdev; maj++)
- if (cdevsw[maj].d_open == wsdisplayopen)
- break;
-
- if (maj == nchrdev)
- panic("wsdisplay is not in cdevsw[]");
-
-#if NSTI > 0
- if (PAGE0->mem_cons.pz_class == PCL_DISPL) {
-
- } else
- return;
-#else
- return;
-#endif
-#if NGSCKBD > 0
- if (PAGE0->mem_kbd.pz_class == PCL_KEYBD) {
-
- } else
- return;
-#else
- return;
-#endif
-
- cp->cn_dev = makedev(maj, 0);
- cp->cn_pri = CN_INTERNAL;
+ /*
+ * Due to various device probe restrictions, the wscons console
+ * can never be enabled early during boot.
+ * It will be enabled as soon as enough wscons components get
+ * attached.
+ * So do nothing there, the switch will occur in
+ * wsdisplay_emul_attach() later.
+ */
}
void
-wscninit(cp)
- struct consdev *cp;
+wscninit(struct consdev *cp)
{
}
void
-wscnputc(dev, i)
- dev_t dev;
- char i;
+wscnputc(dev_t dev, int i)
{
- wsdisplay_cnputc(dev, (int)i);
+#if NWSDISPLAY > 0
+ wsdisplay_cnputc(dev, i);
+#endif
}
int
-wscngetc(dev)
- dev_t dev;
+wscngetc(dev_t dev)
{
#if NWSKBD > 0
return (wskbd_cngetc(dev));
@@ -126,9 +94,7 @@ wscngetc(dev)
}
void
-wscnpollc(dev, on)
- dev_t dev;
- int on;
+wscnpollc(dev_t dev, int on)
{
#if NWSKBD > 0
wskbd_cnpollc(dev, on);
diff --git a/sys/dev/hil/hil.c b/sys/dev/hil/hil.c
index 9c9d9bd647c..d8fbd8031bd 100644
--- a/sys/dev/hil/hil.c
+++ b/sys/dev/hil/hil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hil.c,v 1.2 2003/02/15 23:38:46 miod Exp $ */
+/* $OpenBSD: hil.c,v 1.3 2003/02/15 23:42:48 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -125,7 +125,7 @@ hildatawait(struct hil_softc *sc)
*/
void
-hil_attach(struct hil_softc *sc)
+hil_attach(struct hil_softc *sc, int hil_is_console)
{
printf("\n");
@@ -137,7 +137,7 @@ hil_attach(struct hil_softc *sc)
sc->sc_cmddone = 0;
sc->sc_cmdbp = sc->sc_cmdbuf;
sc->sc_pollbp = sc->sc_pollbuf;
- sc->sc_kbddev = 0;
+ sc->sc_console = hil_is_console;
}
/*
@@ -244,24 +244,13 @@ hil_attach_deferred(void *v)
if (sc->sc_cmdbuf[0] >= hd->minid &&
sc->sc_cmdbuf[0] <= hd->maxid) {
+ ha.ha_console = sc->sc_console;
ha.ha_code = id;
ha.ha_type = hd->type;
ha.ha_descr = hd->descr;
ha.ha_infolen = len;
bcopy(sc->sc_cmdbuf, ha.ha_info, len);
- if (ha.ha_type == HIL_DEVICE_KEYBOARD) {
- /*
- * Currently, the first found hil keyboard will
- * be attached as a console keyboard.
- * This will change when we have hil at wax
- * attachment.
- */
- ha.ha_flags = id == sc->sc_kbddev;
- } else {
- ha.ha_flags = 0;
- }
-
config_found(&sc->sc_dev, &ha, hildevprint);
}
}
@@ -387,15 +376,7 @@ hilconfig(struct hil_softc *sc)
#endif
/*
- * Locate the main keyboard device, if present.
- */
- db = 0;
- send_hil_cmd(sc, HIL_READKBDSADR, NULL, 0, &db);
- sc->sc_kbddev = ffs((int)db);
-
- /*
- * Put all keyboards in raw mode, in case we ended there after
- * a reconfigure event.
+ * Put all keyboards in raw mode now.
*/
db = 0;
send_hil_cmd(sc, HIL_WRITEKBDSADR, &db, 1, NULL);
diff --git a/sys/dev/hil/hildevs.h b/sys/dev/hil/hildevs.h
index c093fb10a7a..7ccb01c70d2 100644
--- a/sys/dev/hil/hildevs.h
+++ b/sys/dev/hil/hildevs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hildevs.h,v 1.1 2003/02/11 19:39:30 miod Exp $ */
+/* $OpenBSD: hildevs.h,v 1.2 2003/02/15 23:42:48 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -36,15 +36,14 @@ struct hildevice {
/* Arguments passed to attach routines */
struct hil_attach_args {
- struct confargs ha_ca;
int ha_code; /* hil code */
int ha_type; /* hil device type */
+ int ha_console; /* console set to hil */
int ha_infolen; /* identify info length */
u_int8_t ha_info[HILBUFSIZE]; /* identify info bits */
#define ha_id ha_info[0] /* hil probe id */
const char *ha_descr; /* device description */
- int ha_flags; /* extra information */
};
/* ha_type values */
diff --git a/sys/dev/hil/hilkbd.c b/sys/dev/hil/hilkbd.c
index 3b125145e36..829bf4dcb41 100644
--- a/sys/dev/hil/hilkbd.c
+++ b/sys/dev/hil/hilkbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hilkbd.c,v 1.3 2003/02/15 23:38:46 miod Exp $ */
+/* $OpenBSD: hilkbd.c,v 1.4 2003/02/15 23:42:48 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -99,6 +99,7 @@ struct wskbd_mapdata hilkbd_keymapdata = {
void hilkbd_bell(struct hil_softc *, u_int, u_int, u_int);
void hilkbd_callback(void *, u_int, u_int8_t *);
void hilkbd_decode(u_int8_t, u_int8_t, u_int *, int *);
+int hilkbd_is_console(int);
int
hilkbdprobe(struct device *parent, void *match, void *aux)
@@ -149,7 +150,7 @@ hilkbdattach(struct device *parent, struct device *self, void *aux)
printf("\n");
- a.console = ha->ha_flags;
+ a.console = hilkbd_is_console(ha->ha_console);
a.keymap = &hilkbd_keymapdata;
a.accessops = &hilkbd_accessops;
a.accesscookie = sc;
@@ -292,3 +293,20 @@ hilkbd_decode(u_int8_t stat, u_int8_t data, u_int *type, int *key)
*type = (data & 1) ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
*key = data >> 1;
}
+
+int
+hilkbd_is_console(int hil_is_console)
+{
+ static int seen_hilkbd_console = 0;
+
+ /* if not first hil keyboard, then not the console */
+ if (seen_hilkbd_console)
+ return (0);
+
+ /* if PDC console does not match hil bus path, then not the console */
+ if (hil_is_console == 0)
+ return (0);
+
+ seen_hilkbd_console = 1;
+ return (1);
+}
diff --git a/sys/dev/hil/hilvar.h b/sys/dev/hil/hilvar.h
index 80fc3799a18..58e91aabe7a 100644
--- a/sys/dev/hil/hilvar.h
+++ b/sys/dev/hil/hilvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hilvar.h,v 1.2 2003/02/15 23:38:46 miod Exp $ */
+/* $OpenBSD: hilvar.h,v 1.3 2003/02/15 23:42:48 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -79,6 +79,7 @@ struct hil_softc {
struct device sc_dev;
bus_space_handle_t sc_bsh;
bus_space_tag_t sc_bst;
+ int sc_console; /* console path set to hil */
int sc_cmddone;
int sc_cmdending;
@@ -90,7 +91,6 @@ struct hil_softc {
u_int8_t *sc_cmdbp; /* pointer into sc_cmdbuf */
u_int sc_maxdev; /* number of devices on loop */
- u_int sc_kbddev; /* keyboard device id */
struct hil_cb sc_cb[NHILD]; /* interrupt dispatcher */
};
@@ -101,7 +101,7 @@ void send_hildev_cmd(struct hil_softc *, u_int, u_int, u_int8_t *, u_int *);
void hil_set_poll(struct hil_softc *, int);
int hil_poll_data(struct hil_softc *, u_int8_t *, u_int8_t *);
-void hil_attach(struct hil_softc *);
+void hil_attach(struct hil_softc *, int);
void hil_attach_deferred(void *);
void hil_callback_register(struct hil_softc *, u_int,
void (*)(void *, u_int, u_int8_t *), void *);