Handling 64bit MMIO BAR in 32bit OS

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
User avatar
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

Handling 64bit MMIO BAR in 32bit OS

Post by prajwal »

Hi,

For my OS dev, I use QEMU and TianoCore OVMF (both 32bit & 64bit - downloaded from sourceforge. On QEMU, my OS works fine with both 32bit OVMF and 64bit OVMF while my OS itself is a 32bit protected mode OS (developed for x86 platform)

I recently decided to locally build and use the latest stable tag of OVMF from: https://github.com/tianocore/edk2.git

I was able to build 3 different variants - OvmfIa32, Ovmf3264 and OvmfX64

My OS works fine when using OvmfIa32, however when using Ovmf3264, the XHCI controller initialization in my OS fails because the BAR address is a 64 bit address while I can only map 32bit address

Is it correct for the firmware to assign 64bit BAR to a PCI device while loading a 32bit OS ? If so, how to handle this scenario ? (b/w the problem doesn't happen on my laptop that runs on i7 processor)

Thanks
Prajwal
complexity is the core of simplicity
8infy
Member
Member
Posts: 185
Joined: Sun Apr 05, 2020 1:01 pm

Re: Handling 64bit MMIO BAR in 32bit OS

Post by 8infy »

prajwal wrote:Hi,

For my OS dev, I use QEMU and TianoCore OVMF (both 32bit & 64bit - downloaded from sourceforge. On QEMU, my OS works fine with both 32bit OVMF and 64bit OVMF while my OS itself is a 32bit protected mode OS (developed for x86 platform)

I recently decided to locally build and use the latest stable tag of OVMF from: https://github.com/tianocore/edk2.git

I was able to build 3 different variants - OvmfIa32, Ovmf3264 and OvmfX64

My OS works fine when using OvmfIa32, however when using Ovmf3264, the XHCI controller initialization in my OS fails because the BAR address is a 64 bit address while I can only map 32bit address

Is it correct for the firmware to assign 64bit BAR to a PCI device while loading a 32bit OS ? If so, how to handle this scenario ? (b/w the problem doesn't happen on my laptop that runs on i7 processor)

Thanks
Prajwal
Simple, don't support non-PAE 32 bit. Problem solved. This is only < 2000 hardware anyways.
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Handling 64bit MMIO BAR in 32bit OS

Post by iansjack »

Exactly. A computer that is 32-bit only won't have a 64-bit UEFI.
User avatar
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

Re: Handling 64bit MMIO BAR in 32bit OS

Post by prajwal »

Is there way to configure OVMF to assign only 32bit BAR to PCI devices ? Wouldn't it be correct for OVMF to do that by default to make it compatible for both 32bit and 64bit OS to run - particularly when it is built with config to support both IA32 and X64 ARCH.
complexity is the core of simplicity
User avatar
iansjack
Member
Member
Posts: 4703
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Handling 64bit MMIO BAR in 32bit OS

Post by iansjack »

If you are using the 64 bit OVMF you must have a 64-bit capable processor. So, even if your OS is 32-bit, you can use PAE to access 64-bit addresses.
User avatar
prajwal
Member
Member
Posts: 154
Joined: Sat Oct 23, 2004 11:00 pm
Contact:

Re: Handling 64bit MMIO BAR in 32bit OS

Post by prajwal »

Got it! Thanks for clarifying.
complexity is the core of simplicity
Post Reply