io base and mem base?
Posted: Wed Dec 14, 2016 9:45 pm
Hi, I am following this tutorial trying to implement networking for my os.
http://wiki.osdev.org/Intel_Ethernet_i217
I am not sure how it reads the io_base and mem_base because the constant PCI_BAR_IO and PCI_BAR_MEM is not known.
Is it just extracting the base address from bar0?
I am also very confused that there are 6 BARs, how one knows which is the right one to get info about base address and bar_type?
Thanks in advance
http://wiki.osdev.org/Intel_Ethernet_i217
I am not sure how it reads the io_base and mem_base because the constant PCI_BAR_IO and PCI_BAR_MEM is not known.
Is it just extracting the base address from bar0?
I am also very confused that there are 6 BARs, how one knows which is the right one to get info about base address and bar_type?
Code: Select all
E1000::E1000(PCIConfigHeader * p_pciConfigHeader) : NetworkDriver(p_pciConfigHeader)
{
// Get BAR0 type, io_base address and MMIO base address
bar_type = pciConfigHeader->getPCIBarType(0);
io_base = pciConfigHeader->getPCIBar(PCI_BAR_IO) & ~1;
mem_base = pciConfigHeader->getPCIBar( PCI_BAR_MEM) & ~3;
// Off course you will need here to map the memory address into you page tables and use corresponding virtual addresses
// Enable bus mastering
pciConfigHeader->enablePCIBusMastering();
eerprom_exists = false;
}