Checksum the configuration EEPROM.
This commit is contained in:
parent
839e119ec8
commit
18e03d5e08
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112824
@ -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 @@ ep_isa_attach (device_t dev)
|
||||
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__
|
||||
|
Loading…
Reference in New Issue
Block a user