Skip to content
Snippets Groups Projects
Commit 114d7fc0 authored by Kyle Moffett's avatar Kyle Moffett Committed by Wolfgang Denk
Browse files

e1000: Rewrite EEPROM checksum error to give more information


As an aide to debugging, we should print out the expected value of the
EEPROM checksum in addition to just saying that it is wrong.

Signed-off-by: default avatarKyle Moffett <Kyle.D.Moffett@boeing.com>
Cc: Ben Warren <biggerbadderben@gmail.com>
parent d60626f8
No related branches found
No related tags found
No related merge requests found
...@@ -876,29 +876,41 @@ e1000_read_eeprom(struct e1000_hw *hw, uint16_t offset, ...@@ -876,29 +876,41 @@ e1000_read_eeprom(struct e1000_hw *hw, uint16_t offset,
* If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is * If the the sum of the 64 16 bit words is 0xBABA, the EEPROM's checksum is
* valid. * valid.
*****************************************************************************/ *****************************************************************************/
static int static int e1000_validate_eeprom_checksum(struct e1000_hw *hw)
e1000_validate_eeprom_checksum(struct eth_device *nic)
{ {
struct e1000_hw *hw = nic->priv; uint16_t i, checksum, checksum_reg, *buf;
uint16_t checksum = 0;
uint16_t i, eeprom_data;
DEBUGFUNC(); DEBUGFUNC();
for (i = 0; i < (EEPROM_CHECKSUM_REG + 1); i++) { /* Allocate a temporary buffer */
if (e1000_read_eeprom(hw, i, 1, &eeprom_data) < 0) { buf = malloc(sizeof(buf[0]) * (EEPROM_CHECKSUM_REG + 1));
DEBUGOUT("EEPROM Read Error\n"); if (!buf) {
return -E1000_ERR_EEPROM; E1000_ERR(hw->nic, "Unable to allocate EEPROM buffer!\n");
} return -E1000_ERR_EEPROM;
checksum += eeprom_data;
} }
if (checksum == (uint16_t) EEPROM_SUM) { /* Read the EEPROM */
return 0; if (e1000_read_eeprom(hw, 0, EEPROM_CHECKSUM_REG + 1, buf) < 0) {
} else { E1000_ERR(hw->nic, "Unable to read EEPROM!\n");
DEBUGOUT("EEPROM Checksum Invalid\n");
return -E1000_ERR_EEPROM; return -E1000_ERR_EEPROM;
} }
/* Compute the checksum */
for (i = 0; i < EEPROM_CHECKSUM_REG; i++)
checksum += buf[i];
checksum = ((uint16_t)EEPROM_SUM) - checksum;
checksum_reg = buf[i];
/* Verify it! */
if (checksum == checksum_reg)
return 0;
/* Hrm, verification failed, print an error */
E1000_ERR(hw->nic, "EEPROM checksum is incorrect!\n");
E1000_ERR(hw->nic, " ...register was 0x%04hx, calculated 0x%04hx\n",
checksum_reg, checksum);
return -E1000_ERR_EEPROM;
} }
/***************************************************************************** /*****************************************************************************
...@@ -5243,10 +5255,8 @@ e1000_initialize(bd_t * bis) ...@@ -5243,10 +5255,8 @@ e1000_initialize(bd_t * bis)
E1000_ERR(nic, "EEPROM is invalid!\n"); E1000_ERR(nic, "EEPROM is invalid!\n");
continue; continue;
} }
if (e1000_validate_eeprom_checksum(nic) < 0) { if (e1000_validate_eeprom_checksum(hw))
E1000_ERR(nic, "EEPROM checksum is bad!\n");
continue; continue;
}
#endif #endif
e1000_read_mac_addr(nic); e1000_read_mac_addr(nic);
e1000_get_bus_type(hw); e1000_get_bus_type(hw);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment