Intel Ethernet i217: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
No edit summary
No edit summary
Line 10: Line 10:
<source lang="c">
<source lang="c">


#define INTEL_VEND 0x8086 // Vendor ID for Intel
#define INTEL_VEND 0x8086 // Vendor ID for Intel
#define E1000_DEV 0x100E // Device ID for the e1000 Qemu, Bochs, and VirtualBox emmulated NICs
#define E1000_DEV 0x100E // Device ID for the e1000 Qemu, Bochs, and VirtualBox emmulated NICs
#define E1000_DEV1 0x153A // Device ID for Intel I217
#define E1000_I217 0x153A // Device ID for Intel I217
#define E1000_DEV2 0x10EA // Device ID for Intel 82577LM
#define E1000_82577LM 0x10EA // Device ID for Intel 82577LM




Line 490: Line 490:
}
}
}
}

</source>

Finally we define the sendPacket method as follows

<source lang="c">

int E1000::sendPacket(const void * p_data, uint16_t p_len)
{
tx_descs[tx_cur]->addr = (uint64_t)p_data;
tx_descs[tx_cur]->length = p_len;
tx_descs[tx_cur]->cmd = CMD_EOP | CMD_IFCS | CMD_RS | CMD_RPS;
tx_descs[tx_cur]->status = 0;
uint8_t old_cur = tx_cur;
tx_cur = (tx_cur + 1) % E1000_NUM_TX_DESC;
writeCommand(REG_TXDESCTAIL, tx_cur);
while(!(tx_descs[old_cur]->status & 0xff));
return 0;
}

</source>


This is an example of how to instantiate an object of this class and startup you driver. I assume that you have scanned your PCI buses and loaded the found devices parameters into some data structures; in our example this is done by the PCIConfigManager class, which is outside the scope of this tutorial

<source lang="c">

pciConfigHeaderManager.initialize(); // Initialize the PCIConfigHeaderManager Object and scan PCI devices
if ( e1000PCIConfigHeader == NULL ) e1000PCIConfigHeader = pciConfigHeaderManager.getPCIDevice(INTEL_VEND,E1000_I217);
if ( e1000PCIConfigHeader == NULL ) e1000PCIConfigHeader = pciConfigHeaderManager.getPCIDevice(INTEL_VEND,E1000_82577LM);
if ( e1000PCIConfigHeader != NULL )
{
E1000 * e1000 = new E1000(e1000PCIConfigHeader);
if (!e1000->start())
{
// Error starting the NIC
}
}
else
{
// Intel cards not found
}


</source>
</source>