diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2006-09-17 19:09:21 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2006-09-17 19:09:21 +0000 |
commit | a8a23c807fcc80692b39f05eb0e8cb2a3d874134 (patch) | |
tree | addc8cb0a90700ed6b8dacf1020ceb5d6e8f4d59 /sys/dev | |
parent | d32aaa5a04bb307b81720909d6ba051cd112aa10 (diff) |
Move get ipmi id into the match function. This prevents attach from being
called whenever there is no BMC and hence suppresses a ugly message when a
bios lied that it had ipmi.
tested beck@
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ipmi.c | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/sys/dev/ipmi.c b/sys/dev/ipmi.c index af3bdb3b260..aac750c29c3 100644 --- a/sys/dev/ipmi.c +++ b/sys/dev/ipmi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipmi.c,v 1.47 2006/08/01 22:49:37 marco Exp $ */ +/* $OpenBSD: ipmi.c,v 1.48 2006/09/17 19:09:20 marco Exp $ */ /* * Copyright (c) 2005 Jordan Hargrave @@ -322,7 +322,7 @@ bmc_io_wait_cold(struct ipmi_softc *sc, int offset, u_int8_t mask, delay(1); } - printf("%s: bmc_io_wait_cold fails : *v=%.2x m=%.2x b=%.2x %s\n", + dbg_printf(1, "%s: bmc_io_wait_cold fails : *v=%.2x m=%.2x b=%.2x %s\n", DEVNAME(sc), v, mask, value, lbl); return (-1); @@ -1638,8 +1638,6 @@ ipmi_probe(void *aux) /* we have an IPMI signature, fill in attach arg structure */ ia->iaa_if_type = pipmi->dmd_if_type; ia->iaa_if_rev = pipmi->dmd_if_rev; - - return (1); } return (1); @@ -1651,6 +1649,9 @@ ipmi_match(struct device *parent, void *match, void *aux) struct ipmi_softc sc; struct ipmi_attach_args *ia = aux; struct cfdata *cf = match; + u_int8_t cmd[32]; + int len; + int rv = 0; if (strcmp(ia->iaa_name, cf->cf_driver->cd_name)) return (0); @@ -1658,12 +1659,26 @@ ipmi_match(struct device *parent, void *match, void *aux) /* Map registers */ if (ipmi_map_regs(&sc, ia) == 0) { sc.sc_if->probe(&sc); - ipmi_unmap_regs(&sc, ia); - return (1); + /* Identify BMC device early to detect lying bios */ + if (ipmi_sendcmd(&sc, BMC_SA, 0, APP_NETFN, APP_GET_DEVICE_ID, + 0, NULL)) { + dbg_printf(1, ": unable to send get device id " + "command\n"); + goto unmap; + } + if (ipmi_recvcmd(&sc, sizeof(cmd), &len, cmd)) { + dbg_printf(1, ": unable to retrieve device id\n"); + goto unmap; + } + + dbg_dump(1, "bmc data", len, cmd); +unmap: + rv = 1; /* GETID worked, we got IPMI */ + ipmi_unmap_regs(&sc, ia); } - return (0); + return (rv); } void @@ -1671,8 +1686,6 @@ ipmi_attach(struct device *parent, struct device *self, void *aux) { struct ipmi_softc *sc = (void *) self; struct ipmi_attach_args *ia = aux; - u_int8_t cmd[32]; - int len; u_int16_t rec; sc->sc_thread = malloc(sizeof(struct ipmi_thread), M_DEVBUF, M_NOWAIT); @@ -1686,22 +1699,6 @@ ipmi_attach(struct device *parent, struct device *self, void *aux) /* Map registers */ ipmi_map_regs(sc, ia); - - /* Identify BMC device */ - if (ipmi_sendcmd(sc, BMC_SA, 0, APP_NETFN, APP_GET_DEVICE_ID, - 0, NULL)) { - printf(": unable to send get device id " "command\n"); - ipmi_unmap_regs(sc, ia); - return; - } - if (ipmi_recvcmd(sc, sizeof(cmd), &len, cmd)) { - printf(": unable to retrieve device id\n"); - ipmi_unmap_regs(sc, ia); - return; - } - - dbg_dump(1, "bmc data", len, cmd); - /* Scan SDRs, add sensors */ for (rec = 0; rec != 0xFFFF;) if (get_sdr(sc, rec, &rec)) |