Intel Ethernet i217: Difference between revisions

Jump to navigation Jump to search
no edit summary
[unchecked revision][unchecked revision]
No edit summary
No edit summary
Line 217:
}
}
</source>
 
 
Now we need to detect if the card has an EEPROM or not. The Qemu and Bochs emulate EEPROM, but the I217 and 82577LM do not. The following first method tries to read the status field of the EEPROM, the status field should contain the value 0x10, and based on the result the internal data member eerprom_exists. The second method performs a 2-bytes read operation from the EEPROM
 
<source lang="c">
bool E1000::detectEEProm()
{
uint32_t val = 0;
writeCommand(REG_EEPROM, 0x1);
 
for(int i = 0; i < 1000 && ! eerprom_exists; i++)
{
val = readCommand( REG_EEPROM);
if(val & 0x10)
eerprom_exists = true;
else
eerprom_exists = false;
}
return eerprom_exists;
}
 
uint32_t E1000::eepromRead( uint8_t addr)
{
uint16_t data = 0;
uint32_t tmp = 0;
if ( eerprom_exists)
{
writeCommand( REG_EEPROM, (1) | ((uint32_t)(addr) << 8) );
while( !((tmp = readCommand(REG_EEPROM)) & (1 << 4)) );
}
else
{
writeCommand( REG_EEPROM, (1) | ((uint32_t)(addr) << 2) );
while( !((tmp = readCommand(REG_EEPROM)) & (1 << 1)) );
}
data = (uint16_t)((tmp >> 16) & 0xFFFF);
return data;
}
 
</source>
 
 
 
The first thing you will need to do after detecting the BAR0 type and the existence of the EEPROM is to read the hardware MAC address of the NIC. The following method reads the hardware mac address based. If an EEPROM exists it will read it from the EEPROM else it will read it from address 0x5400 where it should be located in that case.
 
<source lang="c">
 
bool E1000::readMACAddress()
{
if ( eerprom_exists)
{
uint32_t temp;
temp = eepromRead( 0);
mac[0] = temp &0xff;
mac[1] = temp >> 8;
temp = eepromRead( 1);
mac[2] = temp &0xff;
mac[3] = temp >> 8;
temp = eepromRead( 2);
mac[4] = temp &0xff;
mac[5] = temp >> 8;
}
else
{
uint8_t * mem_base_mac_8 = (uint8_t *) (mem_base+0x5400);
uint32_t * mem_base_mac_32 = (uint32_t *) (mem_base+0x5400);
if ( mem_base_mac_32[0] != 0 )
{
for(int i = 0; i < 6; i++)
{
mac[i] = mem_base_mac_8[i];
}
}
else return false;
}
return true;
}
</source>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu