Page 1 of 1

e1000 memory mapped I/O

Posted: Wed May 14, 2014 2:47 pm
by deltafoxtrot
Hi,

I am trying to write a network driver for Intel 8254x ethernet controller for my 32 bit toy OS.

I am using VMware to develop this. The virtual machine is configured to use "e1000" virtual device.

When read the BAR0 register, the flags in the BAR0 register indicates that the device supports 64 bit memory mapped I/O. But i am my OS is 32 bit. How does it work then?

Do i just take bits 3....31 as the base address or do i need to read other BAR registers?

Re: e1000 memory mapped I/O

Posted: Wed May 14, 2014 3:20 pm
by sortie
You recognize whether this is a 32-bit BAR or a 64-bit BAR. If it is a 32-bit BAR, nothing unusual about this. If it is a 64-bit, you see if the BAR is inside the 32-bit physical address space (or larger, if you use PAE), and if so, you just use it normally. If the BAR points to memory you cannot access, that's trouble. Either don't use the hardware or attempt to remap the BAR somewhere more convenient.

Note that if you find a 64-bit BAR as specified by the bits in the first BAR entry, you need to get the high bits from the following second BAR entry. All this is detailed in the wiki article.

Re: e1000 memory mapped I/O

Posted: Wed May 14, 2014 3:35 pm
by deltafoxtrot
thanks for the reply.

the higher order bits indicated in BAR1 seems to be 0. So, my BAR is below 4GB. So, i guess i am fine.

BTW, in case the BAR was above 4GB in a 32 bit CPU(without PAE), how would you remap it to a address lower than 4GB.?

Re: e1000 memory mapped I/O

Posted: Wed May 14, 2014 8:50 pm
by thepowersgang
PCI BARs are writiable, to remap a device you find out how much space it requires (by writing all ones to the address bits - the ones that aren't flags - then reading them back and seeing what bits were hard-wired to zero), then locate an unused section of physical address space (not used by RAM or another device) and writing that address to the BAR.