e1000 memory mapped I/O

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
deltafoxtrot
Posts: 2
Joined: Wed May 14, 2014 2:41 pm

e1000 memory mapped I/O

Post 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?
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: e1000 memory mapped I/O

Post 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.
deltafoxtrot
Posts: 2
Joined: Wed May 14, 2014 2:41 pm

Re: e1000 memory mapped I/O

Post 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.?
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: e1000 memory mapped I/O

Post 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.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Post Reply