diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2005-01-09 23:49:37 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2005-01-09 23:49:37 +0000 |
commit | bfd6591ddaf23c5c5304ceaf411ccff7aa6d774f (patch) | |
tree | 639e377c947d8a6c625ea98de435264dddd875dd /sys | |
parent | e4a349ba16ee91528e81919960e13404a419b3ad (diff) |
Allow send_hil{,dev}_cmd to return failure, and handle this where
applicable.
During device probe, if a device does not answer commands, display a warning
message. This apparently happens on hp300 when the console is configured
as remote (i.e. serial console). Unplugging and replugging the device works
fine afterwards...
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/hil/hil.c | 50 | ||||
-rw-r--r-- | sys/dev/hil/hilid.c | 15 | ||||
-rw-r--r-- | sys/dev/hil/hilvar.h | 6 |
3 files changed, 41 insertions, 30 deletions
diff --git a/sys/dev/hil/hil.c b/sys/dev/hil/hil.c index f0756c57c0b..77763bad297 100644 --- a/sys/dev/hil/hil.c +++ b/sys/dev/hil/hil.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hil.c,v 1.14 2004/05/10 05:18:53 jolan Exp $ */ +/* $OpenBSD: hil.c,v 1.15 2005/01/09 23:49:35 miod Exp $ */ /* * Copyright (c) 2003, 2004, Miodrag Vallat. * All rights reserved. @@ -96,7 +96,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); +int send_device_cmd(struct hil_softc *sc, u_int device, u_int cmd); void polloff(struct hil_softc *); void pollon(struct hil_softc *); @@ -219,10 +219,10 @@ hil_attach_deferred(void *v) * few seconds, give up. */ for (tries = 10; tries != 0; tries--) { - send_hil_cmd(sc, HIL_READLPSTAT, NULL, 0, &db); - - if (db & (LPS_CONFFAIL | LPS_CONFGOOD)) - break; + if (send_hil_cmd(sc, HIL_READLPSTAT, NULL, 0, &db) == 0) { + if (db & (LPS_CONFFAIL | LPS_CONFGOOD)) + break; + } #ifdef HILDEBUG printf("%s: loop not ready, retrying...\n", @@ -436,7 +436,11 @@ hilconfig(struct hil_softc *sc) int len; const struct hildevice *hd; - send_device_cmd(sc, id, HIL_IDENTIFY); + if (send_device_cmd(sc, id, HIL_IDENTIFY) != 0) { + printf("%s: no answer from device %d\n", + sc->sc_dev.dv_xname, id); + continue; + } len = sc->sc_cmdbp - sc->sc_cmdbuf; if (len == 0) { @@ -507,7 +511,7 @@ 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. */ -void +int send_hil_cmd(struct hil_softc *sc, u_int cmd, u_int8_t *data, u_int dlen, u_int8_t *rdata) { @@ -521,7 +525,7 @@ send_hil_cmd(struct hil_softc *sc, u_int cmd, u_int8_t *data, u_int dlen, printf("%s: no answer from the loop\n", sc->sc_dev.dv_xname); #endif splx(s); - return; + return (EBUSY); } bus_space_write_1(sc->sc_bst, sc->sc_bsh, HILP_CMD, cmd); @@ -547,6 +551,7 @@ send_hil_cmd(struct hil_softc *sc, u_int cmd, u_int8_t *data, u_int dlen, } while (((status >> HIL_SSHIFT) & HIL_SMASK) != HIL_68K); } splx(s); + return (0); } /* @@ -558,10 +563,11 @@ send_hil_cmd(struct hil_softc *sc, u_int cmd, u_int8_t *data, u_int dlen, * internally generated poll commands. * Needs to be called at splhil(). */ -void +int send_device_cmd(struct hil_softc *sc, u_int device, u_int cmd) { u_int8_t status, c; + int rc = 0; polloff(sc); @@ -573,6 +579,7 @@ send_device_cmd(struct hil_softc *sc, u_int device, u_int cmd) printf("%s: no answer from device %d\n", sc->sc_dev.dv_xname, device); #endif + rc = EBUSY; goto out; } @@ -599,6 +606,7 @@ send_device_cmd(struct hil_softc *sc, u_int device, u_int cmd) printf("%s: no answer from device %d\n", sc->sc_dev.dv_xname, device); #endif + rc = EBUSY; break; } status = bus_space_read_1(sc->sc_bst, sc->sc_bsh, HILP_STAT); @@ -610,28 +618,30 @@ out: sc->sc_cmddev = 0; pollon(sc); + return (rc); } -void +int 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; + int s, rc; s = splhil(); - send_device_cmd(sc, dev->sc_code, cmd); - - /* - * Return the command response in the buffer if necessary - */ - if (outbuf != NULL && outlen != NULL) { - *outlen = min(*outlen, sc->sc_cmdbp - sc->sc_cmdbuf); - bcopy(sc->sc_cmdbuf, outbuf, *outlen); + if ((rc = send_device_cmd(sc, dev->sc_code, cmd)) == 0) { + /* + * Return the command response in the buffer if necessary + */ + if (outbuf != NULL && outlen != NULL) { + *outlen = min(*outlen, sc->sc_cmdbp - sc->sc_cmdbuf); + bcopy(sc->sc_cmdbuf, outbuf, *outlen); + } } splx(s); + return (rc); } /* diff --git a/sys/dev/hil/hilid.c b/sys/dev/hil/hilid.c index 90ddbb22db5..ad65909d55d 100644 --- a/sys/dev/hil/hilid.c +++ b/sys/dev/hil/hilid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hilid.c,v 1.3 2003/12/20 22:53:56 miod Exp $ */ +/* $OpenBSD: hilid.c,v 1.4 2005/01/09 23:49:36 miod Exp $ */ /* * Copyright (c) 2003, Miodrag Vallat. * All rights reserved. @@ -85,14 +85,15 @@ hilidattach(struct device *parent, struct device *self, void *aux) bzero(sc->sc_id, sizeof(sc->sc_id)); len = sizeof(sc->sc_id); - send_hildev_cmd((struct hildev_softc *)sc, - HIL_SECURITY, sc->sc_id, &len); - printf("%s: security code", self->dv_xname); - for (i = 0; i < sizeof(sc->sc_id); i++) - printf(" %02x", sc->sc_id[i]); - printf("\n"); + if (send_hildev_cmd((struct hildev_softc *)sc, + HIL_SECURITY, sc->sc_id, &len) == 0) { + for (i = 0; i < sizeof(sc->sc_id); i++) + printf(" %02x", sc->sc_id[i]); + printf("\n"); + } else + printf(" unavailable\n"); } int diff --git a/sys/dev/hil/hilvar.h b/sys/dev/hil/hilvar.h index 231390b8907..7467899d700 100644 --- a/sys/dev/hil/hilvar.h +++ b/sys/dev/hil/hilvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hilvar.h,v 1.6 2003/06/02 23:28:01 millert Exp $ */ +/* $OpenBSD: hilvar.h,v 1.7 2005/01/09 23:49:36 miod Exp $ */ /* * Copyright (c) 2003, Miodrag Vallat. * All rights reserved. @@ -90,8 +90,8 @@ struct hil_softc { #ifdef _KERNEL -void send_hil_cmd(struct hil_softc *, u_int, u_int8_t *, u_int, u_int8_t *); -void send_hildev_cmd(struct hildev_softc *, u_int, u_int8_t *, u_int *); +int send_hil_cmd(struct hil_softc *, u_int, u_int8_t *, u_int, u_int8_t *); +int 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 hildev_softc *, u_int8_t *, u_int8_t *); |