diff options
author | mdodd <mdodd@FreeBSD.org> | 2003-03-29 21:57:32 +0000 |
---|---|---|
committer | mdodd <mdodd@FreeBSD.org> | 2003-03-29 21:57:32 +0000 |
commit | 46dc207e19b88df2f1458fd0de816784af11270f (patch) | |
tree | a2ead2a8d419ce4815ff08da72015e4c6777d566 /sys/dev/ep | |
parent | 87c6ef38a1a63f994ebc35187008bd021aebc387 (diff) | |
download | FreeBSD-src-46dc207e19b88df2f1458fd0de816784af11270f.zip FreeBSD-src-46dc207e19b88df2f1458fd0de816784af11270f.tar.gz |
Checksum the configuration EEPROM.
Diffstat (limited to 'sys/dev/ep')
-rw-r--r-- | sys/dev/ep/if_ep_isa.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/sys/dev/ep/if_ep_isa.c b/sys/dev/ep/if_ep_isa.c index 07500c9..c47f1d8 100644 --- a/sys/dev/ep/if_ep_isa.c +++ b/sys/dev/ep/if_ep_isa.c @@ -61,6 +61,7 @@ static void ep_isa_identify (driver_t *, device_t); #endif static int ep_isa_probe (device_t); static int ep_isa_attach (device_t); +static int ep_eeprom_cksum (struct ep_softc *); struct isa_ident { u_int32_t id; @@ -343,6 +344,12 @@ ep_isa_attach (device_t dev) goto bad; } + error = ep_eeprom_cksum(sc); + if (error) { + device_printf(sc->dev, "Invalid EEPROM checksum!\n"); + goto bad; + } + if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET, ep_intr, sc, &sc->ep_intrhand))) { device_printf(dev, "bus_setup_intr() failed! (%d)\n", error); @@ -355,6 +362,42 @@ bad: return (error); } +static int +ep_eeprom_cksum (sc) + struct ep_softc * sc; +{ + int i; + int error; + u_int16_t val; + u_int16_t cksum; + u_int8_t cksum_high = 0; + u_int8_t cksum_low = 0; + + error = get_e(sc, 0x0f, &val); + if (error) + return (ENXIO); + cksum = val; + + for (i = 0; i < 0x0f; i++) { + error = get_e(sc, i, &val); + if (error) + return (ENXIO); + switch (i) { + case 0x08: + case 0x09: + case 0x0d: + cksum_low ^= (u_int8_t)(val & 0x00ff) ^ + (u_int8_t)((val & 0xff00) >> 8); + break; + default: + cksum_high ^= (u_int8_t)(val & 0x00ff) ^ + (u_int8_t)((val & 0xff00) >> 8); + break; + } + } + return (cksum != ((u_int16_t)cksum_low | (u_int16_t)(cksum_high << 8))); +} + static device_method_t ep_isa_methods[] = { /* Device interface */ #ifdef __i386__ |