summaryrefslogtreecommitdiffstats
path: root/sys/dev/hil
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2003-02-26 20:22:03 +0000
committermiod <miod@openbsd.org>2003-02-26 20:22:03 +0000
commit60a8f706295043489d6f389dbed5ba05edf84e44 (patch)
tree6f11c0c8878350f79a2b1a595abfafb137324b3a /sys/dev/hil
parentRemove a poor error message which is emitted on perfectly fine MBR labeled (diff)
downloadwireguard-openbsd-60a8f706295043489d6f389dbed5ba05edf84e44.tar.xz
wireguard-openbsd-60a8f706295043489d6f389dbed5ba05edf84e44.zip
New hil child devices attachment framework, that allow them to be detached
at runtime. Handle reconfiguration notices from the loop, and do the necessary detach/attach work so that our vision of the loop is in sync with reality. Adapt all hil child devices to the above changes. "This is not as plug'n'play as usb, but you get the same feeling anyways..."
Diffstat (limited to 'sys/dev/hil')
-rw-r--r--sys/dev/hil/hil.c218
-rw-r--r--sys/dev/hil/hildevs.h22
-rw-r--r--sys/dev/hil/hilid.c23
-rw-r--r--sys/dev/hil/hilkbd.c65
-rw-r--r--sys/dev/hil/hilms.c35
-rw-r--r--sys/dev/hil/hilvar.h16
6 files changed, 241 insertions, 138 deletions
diff --git a/sys/dev/hil/hil.c b/sys/dev/hil/hil.c
index 7c43941cace..24b9d7a63b6 100644
--- a/sys/dev/hil/hil.c
+++ b/sys/dev/hil/hil.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hil.c,v 1.6 2003/02/19 00:03:30 miod Exp $ */
+/* $OpenBSD: hil.c,v 1.7 2003/02/26 20:22:03 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -88,7 +88,11 @@
#include <dev/hil/hildevs.h>
#include <dev/hil/hildevs_data.h>
-#define splhil spltty
+/*
+ * splhigh is extremely conservative but insures atomic operation,
+ * splvm (clock only interrupts) seems to be good enough in practice.
+ */
+#define splhil splvm
struct cfdriver hil_cd = {
NULL, "hil", DV_DULL
@@ -98,6 +102,7 @@ void hilconfig(struct hil_softc *);
int hilsubmatch(struct device *, void *, void *);
void hil_process_int(struct hil_softc *, u_int8_t, u_int8_t);
int hil_process_poll(struct hil_softc *, u_int8_t, u_int8_t);
+void send_device_cmd(struct hil_softc *sc, u_int device, u_int cmd);
void polloff(struct hil_softc *);
void pollon(struct hil_softc *);
@@ -120,7 +125,7 @@ hildatawait(struct hil_softc *sc)
/* nothing */
}
}
-
+
/*
* Common HIL bus attachment
*/
@@ -179,8 +184,7 @@ void
hil_attach_deferred(void *v)
{
struct hil_softc *sc = v;
- struct hil_attach_args ha;
- int id, s, tries;
+ int tries;
u_int8_t db;
/*
@@ -230,68 +234,8 @@ hil_attach_deferred(void *v)
* The reconfiguration interrupt has already called hilconfig().
*/
send_hil_cmd(sc, HIL_INTON, NULL, 0, NULL);
-
- /*
- * Now attach hil devices as they are found.
- */
-
- s = splhil();
-
- /* Attach the remaining devices */
- for (id = 1; id <= sc->sc_maxdev; id++) {
- int len;
- const struct hildevice *hd;
-
- send_hildev_cmd(sc, id, HIL_IDENTIFY, NULL, NULL);
-
- len = sc->sc_cmdbp - sc->sc_cmdbuf;
- if (len == 0) {
-#ifdef HILDEBUG
- printf("%s: no device at code %d\n",
- sc->sc_dev.dv_xname, id);
-#endif
- continue;
- }
-
- /* Attach found devices */
- for (hd = hildevs; hd->minid >= 0; hd++)
- 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);
-
- config_found_sm(&sc->sc_dev, &ha, hildevprint,
- hilsubmatch);
- }
- }
-
- sc->sc_cmdbp = sc->sc_cmdbuf;
-
- splx(s);
}
-void
-hil_callback_register(struct hil_softc *sc, u_int hilid,
- void (*handler)(void *, u_int, u_int8_t *), void *arg)
-{
-#ifdef HILDEBUG
- if (hilid < 0 || hilid >= NHILD)
- panic("hil_callback_register invoked with hilid %d", hilid);
-#endif
-
- if (sc->sc_cb[hilid].cb_fn != NULL)
- panic("hil_callback_register: invoked twice for hilid %d",
- hilid);
-
- sc->sc_cb[hilid].cb_fn = handler;
- sc->sc_cb[hilid].cb_arg = arg;
-}
-
/*
* Asynchronous event processing
*/
@@ -316,6 +260,8 @@ hil_intr(void *v)
void
hil_process_int(struct hil_softc *sc, u_int8_t stat, u_int8_t c)
{
+ struct hildev_softc *dev;
+
switch ((stat >> HIL_SSHIFT) & HIL_SMASK) {
case HIL_STATUS:
if (c & HIL_ERROR) {
@@ -326,9 +272,9 @@ hil_process_int(struct hil_softc *sc, u_int8_t stat, u_int8_t c)
}
if (c & HIL_COMMAND) {
if (c & HIL_POLLDATA) { /* End of data */
- if (sc->sc_cb[sc->sc_actdev].cb_fn != NULL)
- sc->sc_cb[sc->sc_actdev].cb_fn
- (sc->sc_cb[sc->sc_actdev].cb_arg,
+ dev = sc->sc_devices[sc->sc_actdev];
+ if (dev != NULL && dev->sc_fn != NULL)
+ dev->sc_fn(dev,
sc->sc_pollbp - sc->sc_pollbuf,
sc->sc_pollbuf);
} else { /* End of command */
@@ -371,16 +317,28 @@ hil_process_int(struct hil_softc *sc, u_int8_t stat, u_int8_t c)
int
hil_process_poll(struct hil_softc *sc, u_int8_t stat, u_int8_t c)
{
+ u_int8_t db;
+
switch ((stat >> HIL_SSHIFT) & HIL_SMASK) {
case HIL_STATUS:
if (c & HIL_ERROR) {
sc->sc_cmddone = 1;
if (c == HIL_RECONFIG) {
/*
- * XXX We should remember if a configuration
- * event occured and invoke hilconfig() upon
+ * Remember that a configuration event
+ * occured; it will be processed upon
* leaving polled mode...
*/
+ sc->sc_cpending = 1;
+ /*
+ * However, the keyboard will come back as
+ * cooked, and we rely on it being in raw
+ * mode. So, put it back in raw mode right
+ * now.
+ */
+ db = 0;
+ send_hil_cmd(sc, HIL_WRITEKBDSADR, &db,
+ 1, NULL);
}
break;
}
@@ -435,8 +393,9 @@ hil_process_poll(struct hil_softc *sc, u_int8_t stat, u_int8_t c)
void
hilconfig(struct hil_softc *sc)
{
+ struct hil_attach_args ha;
u_int8_t db;
- int s;
+ int id, s;
s = splhil();
@@ -447,7 +406,7 @@ hilconfig(struct hil_softc *sc)
send_hil_cmd(sc, HIL_READLPSTAT, NULL, 0, &db);
sc->sc_maxdev = db & LPS_DEVMASK;
#ifdef HILDEBUG
- printf("%s: %d devices\n", sc->sc_dev.dv_xname, sc->sc_maxdev);
+ printf("%s: %d device(s)\n", sc->sc_dev.dv_xname, sc->sc_maxdev);
#endif
/*
@@ -456,9 +415,76 @@ hilconfig(struct hil_softc *sc)
db = 0;
send_hil_cmd(sc, HIL_WRITEKBDSADR, &db, 1, NULL);
+ /*
+ * Now attach hil devices as they are found.
+ */
+ for (id = 1; id <= sc->sc_maxdev; id++) {
+ int len;
+ const struct hildevice *hd;
+
+ send_device_cmd(sc, id, HIL_IDENTIFY);
+
+ len = sc->sc_cmdbp - sc->sc_cmdbuf;
+ if (len == 0) {
+#ifdef HILDEBUG
+ printf("%s: no device at code %d\n",
+ sc->sc_dev.dv_xname, id);
+#endif
+ continue;
+ }
+
+ /*
+ * If we already have a device configured at this position,
+ * then either it is still the same, or there has been some
+ * removal or insertion in the chain that made it change
+ * its position on the loop.
+ *
+ * Rather than trying to play smart and find where the
+ * device has gone, detach it, it will get reattached at
+ * its new address...
+ */
+ if (sc->sc_devices[id] != NULL) {
+ if (len == sc->sc_devices[id]->sc_infolen &&
+ bcmp(sc->sc_cmdbuf, sc->sc_devices[id]->sc_info,
+ len) == 0)
+ continue;
+
+ config_detach((struct device *)sc->sc_devices[id], 0);
+ }
+
+ /* Identify and attach device */
+ for (hd = hildevs; hd->minid >= 0; hd++)
+ 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);
+
+ sc->sc_devices[id] = (struct hildev_softc *)
+ config_found_sm(&sc->sc_dev, &ha, hildevprint,
+ hilsubmatch);
+ }
+ }
+
+ /*
+ * Detach remaining devices, if they have been removed
+ */
+ for (id = sc->sc_maxdev + 1; id < NHILD; id++) {
+ if (sc->sc_devices[id] != NULL)
+ config_detach((struct device *)sc->sc_devices[id],
+ DETACH_FORCE);
+ sc->sc_devices[id] = NULL;
+ }
+
+ sc->sc_cmdbp = sc->sc_cmdbuf;
+
splx(s);
}
-
+
/*
* Low level routines which actually talk to the 8042 chip.
*/
@@ -466,15 +492,15 @@ hilconfig(struct hil_softc *sc)
/*
* Send a command to the 8042 with zero or more bytes of data.
* If rdata is non-null, wait for and return a byte of data.
- * We run at splvm() to make the transaction as atomic as
- * possible without blocking the clock (is this necessary?)
*/
void
send_hil_cmd(struct hil_softc *sc, u_int cmd, u_int8_t *data, u_int dlen,
u_int8_t *rdata)
{
u_int8_t status;
- int s = splvm();
+ int s;
+
+ s = splhil();
hilwait(sc);
bus_space_write_1(sc->sc_bst, sc->sc_bsh, HILP_CMD, cmd);
@@ -501,16 +527,12 @@ send_hil_cmd(struct hil_softc *sc, u_int cmd, u_int8_t *data, u_int dlen,
* Hence we mask interrupts to prevent potential access from most
* interrupt routines and turn off auto-polling to disable the
* internally generated poll commands.
- *
- * splhigh is extremely conservative but insures atomic operation,
- * splvm (clock only interrupts) seems to be good enough in practice.
+ * Needs to be called at splhil().
*/
void
-send_hildev_cmd(struct hil_softc *sc, u_int device, u_int cmd,
- u_int8_t *outbuf, u_int *outlen)
+send_device_cmd(struct hil_softc *sc, u_int device, u_int cmd)
{
u_int8_t status, c;
- int s = splvm();
polloff(sc);
@@ -544,6 +566,20 @@ send_hildev_cmd(struct hil_softc *sc, u_int device, u_int cmd,
sc->sc_cmddev = 0;
+ pollon(sc);
+}
+
+void
+send_hildev_cmd(struct hildev_softc *dev, u_int cmd,
+ u_int8_t *outbuf, u_int *outlen)
+{
+ struct hil_softc *sc = (struct hil_softc *)dev->sc_dev.dv_parent;
+ int s;
+
+ s = splhil();
+
+ send_device_cmd(sc, dev->sc_code, cmd);
+
/*
* Return the command response in the buffer if necessary
*/
@@ -552,8 +588,6 @@ send_hildev_cmd(struct hil_softc *sc, u_int device, u_int cmd,
bcopy(sc->sc_cmdbuf, outbuf, *outlen);
}
- pollon(sc);
-
splx(s);
}
@@ -630,13 +664,21 @@ pollon(struct hil_softc *sc)
void
hil_set_poll(struct hil_softc *sc, int on)
{
- /* Always work in auto polled mode... */
- pollon(sc);
+ if (on) {
+ pollon(sc);
+ } else {
+ if (sc->sc_cpending) {
+ sc->sc_cpending = 0;
+ hilconfig(sc);
+ }
+ send_hil_cmd(sc, HIL_INTON, NULL, 0, NULL);
+ }
}
int
-hil_poll_data(struct hil_softc *sc, u_int code, u_int8_t *stat, u_int8_t *data)
+hil_poll_data(struct hildev_softc *dev, u_int8_t *stat, u_int8_t *data)
{
+ struct hil_softc *sc = (struct hil_softc *)dev->sc_dev.dv_parent;
u_int8_t s, c;
s = bus_space_read_1(sc->sc_bst, sc->sc_bsh, HILP_STAT);
@@ -647,7 +689,7 @@ hil_poll_data(struct hil_softc *sc, u_int code, u_int8_t *stat, u_int8_t *data)
if (hil_process_poll(sc, s, c)) {
/* Discard any data not for us */
- if (sc->sc_actdev == code) {
+ if (sc->sc_actdev == dev->sc_code) {
*stat = s;
*data = c;
return 0;
diff --git a/sys/dev/hil/hildevs.h b/sys/dev/hil/hildevs.h
index 7ccb01c70d2..c4c93e1c30c 100644
--- a/sys/dev/hil/hildevs.h
+++ b/sys/dev/hil/hildevs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hildevs.h,v 1.2 2003/02/15 23:42:48 miod Exp $ */
+/* $OpenBSD: hildevs.h,v 1.3 2003/02/26 20:22:04 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -50,3 +50,23 @@ struct hil_attach_args {
#define HIL_DEVICE_KEYBOARD 1
#define HIL_DEVICE_IDMODULE 2
#define HIL_DEVICE_MOUSE 3
+
+/* Common softc part for hil devices */
+struct hildev_softc {
+ struct device sc_dev;
+
+ int sc_code; /* hil code */
+ int sc_type; /* hil device type */
+
+ int sc_infolen; /* identify info length */
+ u_int8_t sc_info[HILBUFSIZE]; /* identify info bits */
+
+ void (*sc_fn)(struct hildev_softc *, u_int, u_int8_t *);
+};
+
+#define hd_code sc_hildev.sc_code
+#define hd_fn sc_hildev.sc_fn
+#define hd_info sc_hildev.sc_info
+#define hd_infolen sc_hildev.sc_infolen
+#define hd_parent sc_hildev.sc_dev.dv_parent
+#define hd_type sc_hildev.sc_type
diff --git a/sys/dev/hil/hilid.c b/sys/dev/hil/hilid.c
index 6fba67b1831..ca8ca548cef 100644
--- a/sys/dev/hil/hilid.c
+++ b/sys/dev/hil/hilid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hilid.c,v 1.1 2003/02/15 23:50:02 miod Exp $ */
+/* $OpenBSD: hilid.c,v 1.2 2003/02/26 20:22:04 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -40,20 +40,21 @@
#include <dev/hil/hildevs.h>
struct hilid_softc {
- struct device sc_dev;
+ struct hildev_softc sc_hildev;
u_int8_t sc_id[16];
};
int hilidprobe(struct device *, void *, void *);
void hilidattach(struct device *, struct device *, void *);
+int hiliddetach(struct device *, int);
struct cfdriver hilid_cd = {
NULL, "hilid", DV_DULL
};
struct cfattach hilid_ca = {
- sizeof(struct hilid_softc), hilidprobe, hilidattach
+ sizeof(struct hilid_softc), hilidprobe, hilidattach, hiliddetach,
};
int
@@ -74,16 +75,28 @@ hilidattach(struct device *parent, struct device *self, void *aux)
struct hil_attach_args *ha = aux;
u_int i, len;
+ sc->hd_code = ha->ha_code;
+ sc->hd_type = ha->ha_type;
+ sc->hd_infolen = ha->ha_infolen;
+ bcopy(ha->ha_info, sc->hd_info, ha->ha_infolen);
+ sc->hd_fn = NULL;
+
printf("\n");
bzero(sc->sc_id, sizeof(sc->sc_id));
len = sizeof(sc->sc_id);
- send_hildev_cmd((struct hil_softc *)parent, ha->ha_code,
+ send_hildev_cmd((struct hildev_softc *)sc,
HIL_SECURITY, sc->sc_id, &len);
- printf("%s: security code", sc->sc_dev.dv_xname);
+ printf("%s: security code", self->dv_xname);
for (i = 0; i < sizeof(sc->sc_id); i++)
printf(" %02.2x", sc->sc_id[i]);
printf("\n");
}
+
+int
+hiliddetach(struct device *self, int flags)
+{
+ return (0);
+}
diff --git a/sys/dev/hil/hilkbd.c b/sys/dev/hil/hilkbd.c
index 9538b57975e..fc53ef73508 100644
--- a/sys/dev/hil/hilkbd.c
+++ b/sys/dev/hil/hilkbd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hilkbd.c,v 1.7 2003/02/18 23:48:20 miod Exp $ */
+/* $OpenBSD: hilkbd.c,v 1.8 2003/02/26 20:22:04 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -47,9 +47,8 @@
#include <dev/hil/hilkbdmap.h>
struct hilkbd_softc {
- struct device sc_dev;
+ struct hildev_softc sc_hildev;
- int sc_code;
int sc_numleds;
int sc_ledstate;
int sc_enabled;
@@ -60,13 +59,14 @@ struct hilkbd_softc {
int hilkbdprobe(struct device *, void *, void *);
void hilkbdattach(struct device *, struct device *, void *);
+int hilkbddetach(struct device *, int);
struct cfdriver hilkbd_cd = {
NULL, "hilkbd", DV_DULL
};
struct cfattach hilkbd_ca = {
- sizeof(struct hilkbd_softc), hilkbdprobe, hilkbdattach
+ sizeof(struct hilkbd_softc), hilkbdprobe, hilkbdattach, hilkbddetach,
};
int hilkbd_enable(void *, int);
@@ -99,10 +99,12 @@ 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_callback(struct hildev_softc *, u_int, u_int8_t *);
void hilkbd_decode(u_int8_t, u_int8_t, u_int *, int *);
int hilkbd_is_console(int);
+int seen_hilkbd_console;
+
int
hilkbdprobe(struct device *parent, void *match, void *aux)
{
@@ -122,7 +124,11 @@ hilkbdattach(struct device *parent, struct device *self, void *aux)
struct wskbddev_attach_args a;
u_int8_t layoutcode;
- sc->sc_code = ha->ha_code;
+ sc->hd_code = ha->ha_code;
+ sc->hd_type = ha->ha_type;
+ sc->hd_infolen = ha->ha_infolen;
+ bcopy(ha->ha_info, sc->hd_info, ha->ha_infolen);
+ sc->hd_fn = hilkbd_callback;
/*
* Determine the keyboard language configuration, but don't
@@ -147,9 +153,6 @@ hilkbdattach(struct device *parent, struct device *self, void *aux)
printf(", %d leds", sc->sc_numleds);
}
- hil_callback_register((struct hil_softc *)parent, ha->ha_code,
- hilkbd_callback, sc);
-
printf("\n");
a.console = hilkbd_is_console(ha->ha_console);
@@ -168,6 +171,26 @@ hilkbdattach(struct device *parent, struct device *self, void *aux)
}
int
+hilkbddetach(struct device *self, int flags)
+{
+ struct hilkbd_softc *sc = (void *)self;
+
+ /*
+ * Handle console keyboard for the best. It should have been set
+ * as the first device in the loop anyways.
+ */
+ if (sc->sc_console) {
+ wskbd_cndetach();
+ seen_hilkbd_console = 0;
+ }
+
+ if (sc->sc_wskbddev != NULL)
+ return config_detach(sc->sc_wskbddev, flags);
+
+ return (0);
+}
+
+int
hilkbd_enable(void *v, int on)
{
struct hilkbd_softc *sc = v;
@@ -200,18 +223,15 @@ hilkbd_set_leds(void *v, int leds)
/* We do not handle more than 3 leds here */
if (changemask & WSKBD_LED_SCROLL)
- send_hildev_cmd((struct hil_softc *)sc->sc_dev.dv_parent,
- sc->sc_code,
+ send_hildev_cmd((struct hildev_softc *)sc,
(leds & WSKBD_LED_SCROLL) ? HIL_PROMPT1 : HIL_ACK1,
NULL, NULL);
if (changemask & WSKBD_LED_NUM)
- send_hildev_cmd((struct hil_softc *)sc->sc_dev.dv_parent,
- sc->sc_code,
+ send_hildev_cmd((struct hildev_softc *)sc,
(leds & WSKBD_LED_NUM) ? HIL_PROMPT2 : HIL_ACK2,
NULL, NULL);
if (changemask & WSKBD_LED_CAPS)
- send_hildev_cmd((struct hil_softc *)sc->sc_dev.dv_parent,
- sc->sc_code,
+ send_hildev_cmd((struct hildev_softc *)sc,
(leds & WSKBD_LED_CAPS) ? HIL_PROMPT3 : HIL_ACK3,
NULL, NULL);
@@ -235,7 +255,7 @@ hilkbd_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
return 0;
case WSKBDIO_COMPLEXBELL:
#define d ((struct wskbd_bell_data *)data)
- hilkbd_bell((struct hil_softc *)sc->sc_dev.dv_parent,
+ hilkbd_bell((struct hil_softc *)sc->hd_parent,
d->pitch, d->period, d->volume);
#undef d
return 0;
@@ -251,8 +271,7 @@ hilkbd_cngetc(void *v, u_int *type, int *data)
u_int8_t c, stat;
for (;;) {
- while (hil_poll_data((struct hil_softc *)sc->sc_dev.dv_parent,
- sc->sc_code, &stat, &c) != 0)
+ while (hil_poll_data((struct hildev_softc *)sc, &stat, &c) != 0)
;
/*
@@ -271,7 +290,7 @@ hilkbd_cnpollc(void *v, int on)
{
struct hilkbd_softc *sc = v;
- hil_set_poll((struct hil_softc *)sc->sc_dev.dv_parent, on);
+ hil_set_poll((struct hil_softc *)sc->hd_parent, on);
}
void
@@ -279,7 +298,7 @@ hilkbd_cnbell(void *v, u_int pitch, u_int period, u_int volume)
{
struct hilkbd_softc *sc = v;
- hilkbd_bell((struct hil_softc *)sc->sc_dev.dv_parent,
+ hilkbd_bell((struct hil_softc *)sc->hd_parent,
pitch, period, volume);
}
@@ -297,9 +316,9 @@ hilkbd_bell(struct hil_softc *sc, u_int pitch, u_int period, u_int volume)
}
void
-hilkbd_callback(void *v, u_int buflen, u_int8_t *buf)
+hilkbd_callback(struct hildev_softc *dev, u_int buflen, u_int8_t *buf)
{
- struct hilkbd_softc *sc = v;
+ struct hilkbd_softc *sc = (struct hilkbd_softc *)dev;
u_int type;
int key;
int i;
@@ -329,8 +348,6 @@ hilkbd_decode(u_int8_t stat, u_int8_t data, u_int *type, int *key)
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);
diff --git a/sys/dev/hil/hilms.c b/sys/dev/hil/hilms.c
index e5d4ccdbe68..17775772d75 100644
--- a/sys/dev/hil/hilms.c
+++ b/sys/dev/hil/hilms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hilms.c,v 1.1 2003/02/12 01:43:31 miod Exp $ */
+/* $OpenBSD: hilms.c,v 1.2 2003/02/26 20:22:04 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -43,7 +43,7 @@
#include <dev/wscons/wsmousevar.h>
struct hilms_softc {
- struct device sc_dev;
+ struct hildev_softc sc_hildev;
int sc_features;
int sc_axes;
@@ -55,13 +55,14 @@ struct hilms_softc {
int hilmsprobe(struct device *, void *, void *);
void hilmsattach(struct device *, struct device *, void *);
+int hilmsdetach(struct device *, int);
struct cfdriver hilms_cd = {
NULL, "hilms", DV_DULL
};
struct cfattach hilms_ca = {
- sizeof(struct hilms_softc), hilmsprobe, hilmsattach
+ sizeof(struct hilms_softc), hilmsprobe, hilmsattach, hilmsdetach,
};
int hilms_enable(void *);
@@ -74,7 +75,7 @@ const struct wsmouse_accessops hilms_accessops = {
hilms_disable,
};
-void hilms_callback(void *, u_int, u_int8_t *);
+void hilms_callback(struct hildev_softc *, u_int, u_int8_t *);
int
hilmsprobe(struct device *parent, void *match, void *aux)
@@ -102,6 +103,12 @@ hilmsattach(struct device *parent, struct device *self, void *aux)
struct wsmousedev_attach_args a;
int iob, buttons, rx, ry;
+ sc->hd_code = ha->ha_code;
+ sc->hd_type = ha->ha_type;
+ sc->hd_infolen = ha->ha_infolen;
+ bcopy(ha->ha_info, sc->hd_info, ha->ha_infolen);
+ sc->hd_fn = hilms_callback;
+
/*
* Interpret the identification bytes, if any
*/
@@ -140,7 +147,7 @@ hilmsattach(struct device *parent, struct device *self, void *aux)
if (sc->sc_features & HILIOB_PIO)
printf(", pressure sensor");
if (sc->sc_features & HIL_ABSOLUTE) {
- printf ("\n%s: %d", sc->sc_dev.dv_xname, rx);
+ printf ("\n%s: %d", self->dv_xname, rx);
if (ry != 0)
printf("x%d", ry);
else
@@ -148,9 +155,6 @@ hilmsattach(struct device *parent, struct device *self, void *aux)
printf(" fixed area");
}
- hil_callback_register((struct hil_softc *)parent, ha->ha_code,
- hilms_callback, sc);
-
printf("\n");
sc->sc_enabled = 0;
@@ -162,6 +166,17 @@ hilmsattach(struct device *parent, struct device *self, void *aux)
}
int
+hilmsdetach(struct device *self, int flags)
+{
+ struct hilms_softc *sc = (void *)self;
+
+ if (sc->sc_wsmousedev != NULL)
+ return config_detach(sc->sc_wsmousedev, flags);
+
+ return (0);
+}
+
+int
hilms_enable(void *v)
{
struct hilms_softc *sc = v;
@@ -200,9 +215,9 @@ hilms_ioctl(void *v, u_long cmd, caddr_t data, int flag, struct proc *p)
}
void
-hilms_callback(void *v, u_int buflen, u_int8_t *buf)
+hilms_callback(struct hildev_softc *dev, u_int buflen, u_int8_t *buf)
{
- struct hilms_softc *sc = v;
+ struct hilms_softc *sc = (struct hilms_softc *)dev;
int type, flags;
int dx, dy, dz, button;
#ifdef DIAGNOSTIC
diff --git a/sys/dev/hil/hilvar.h b/sys/dev/hil/hilvar.h
index c663d305d98..2a174cf13db 100644
--- a/sys/dev/hil/hilvar.h
+++ b/sys/dev/hil/hilvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hilvar.h,v 1.4 2003/02/18 02:40:51 miod Exp $ */
+/* $OpenBSD: hilvar.h,v 1.5 2003/02/26 20:22:04 miod Exp $ */
/*
* Copyright (c) 2003, Miodrag Vallat.
* All rights reserved.
@@ -70,10 +70,7 @@
#define NHILD 8 /* 7 actual + loop pseudo (dev 0) */
-struct hil_cb {
- void (*cb_fn)(void *, u_int, u_int8_t *);
- void *cb_arg;
-};
+struct hildev_softc;
struct hil_softc {
struct device sc_dev;
@@ -90,21 +87,20 @@ struct hil_softc {
u_int8_t *sc_pollbp; /* pointer into sc_pollbuf */
u_int8_t *sc_cmdbp; /* pointer into sc_cmdbuf */
+ int sc_cpending; /* reconfiguration in progress */
u_int sc_maxdev; /* number of devices on loop */
- struct hil_cb sc_cb[NHILD]; /* interrupt dispatcher */
+ struct hildev_softc *sc_devices[NHILD]; /* interrupt dispatcher */
};
#ifdef _KERNEL
void send_hil_cmd(struct hil_softc *, u_int, u_int8_t *, u_int, u_int8_t *);
-void send_hildev_cmd(struct hil_softc *, u_int, u_int, u_int8_t *, u_int *);
+void send_hildev_cmd(struct hildev_softc *, u_int, u_int8_t *, u_int *);
void hil_set_poll(struct hil_softc *, int);
-int hil_poll_data(struct hil_softc *, u_int, u_int8_t *, u_int8_t *);
+int hil_poll_data(struct hildev_softc *, u_int8_t *, u_int8_t *);
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 *);
int hil_intr(void *);
int hildevprint(void *, const char *);