csmwrap icon indicating copy to clipboard operation
csmwrap copied to clipboard

Support for framebuffers over 2gb on 64 bit hosts?

Open irtygo opened this issue 7 months ago • 9 comments

irtygo avatar May 15 '25 09:05 irtygo

First, the limitation is 4G not 2G.

Second, even on 64bit hosts the BIOS is 32-bit only for compatibility reason. So it's almost impossible to support framebuffer over 4G. However, it might be possible to relocate PCI BARs to move the framebuffer lower. I will look into it once I get some time.

Thanks

FlyGoat avatar May 15 '25 10:05 FlyGoat

Continue enfocing the limit on 32 bit hosts but increase it on 64 bit host or relocate the framebuf

irtygo avatar May 15 '25 12:05 irtygo

And if possible, Will it be possible to use 64 bit BIOS on 64 bit host and 32 bit BIOS on 32 bit host

irtygo avatar May 15 '25 12:05 irtygo

Don't know about SeaBIOS VGA but some legacy VBIOS like AMD's actually do function with 64-bit BAR (even resized to max) in legacy mode. I guess the internal pointer the VBIOS uses for the framebuffer is 64-bit so it has no problem accessing it.

I would guess this keeps the legacy addresses like 0xA000 functioning so despite what OEMs say legacy VBIOS can actually work with 64-bit BAR, I tested this myself a while ago.

iirc it was limited to 480p though because the VESA function to return the framebuffer address can only return a 32-bit value so it would instead use the real mode addresses like 0xA000 to draw stuff. Though everything would function normally once the OS GPU driver loads like you'd expect.

It looks like CSMWrap uses a 32-bit pointer to pass the internal framebuffer address to SeaBIOS VGA, maybe with a few changes it could function like I said.

Also maybe could add a mode which only installs the SeaBIOS VGA driver, could be useful for people wanting to boot Windows Vista or 7 without the Class 3 update in UEFI mode. Though maybe just using UefiSeven would be better suited for that

xCuri0 avatar May 15 '25 12:05 xCuri0

Also if you could somehow "mirror" the 64-bit BAR (only the first 256mb if resized) into an address like 0xE0000000 (or whatever the UEFI function to allocate an aligned MMIO address can find) that would fix it too and also keep high resolution VESA modes functioning.

xCuri0 avatar May 15 '25 13:05 xCuri0

Don't know about SeaBIOS VGA but some legacy VBIOS like AMD's actually do function with 64-bit BAR (even resized to max) in legacy mode. I guess the internal pointer the VBIOS uses for the framebuffer is 64-bit so it has no problem accessing it.

I actually reversed AMD's atombios based VBIOS before. They are not using any long mode pointers but using indexed IO ports to access internal registers, and legacy VGA memory (0xA000) to access VRAM.

I would guess this keeps the legacy addresses like 0xA000 functioning so despite what OEMs say legacy VBIOS can actually work with 64-bit BAR, I tested this myself a while ago.

Yup, sadly this relies on PCH's native VGA MEM decoding functionality, which seems not working on a couple of new Intel platforms :-(

I'll try to figure out a way to run native VGABIOS, maybe.

iirc it was limited to 480p though because the VESA function to return the framebuffer address can only return a 32-bit value so it would instead use the real mode addresses like 0xA000 to draw stuff. Though everything would function normally once the OS GPU driver loads like you'd expect.

It looks like CSMWrap uses a 32-bit pointer to pass the internal framebuffer address to SeaBIOS VGA, maybe with a few changes it could function like I said.

Unfortunately, SeaBIOS's VBIOS is using Int15h ax=87 to access framebuffer, which is 32bit only, so it's not that easy.

Also maybe could add a mode which only installs the SeaBIOS VGA driver, could be useful for people wanting to boot Windows Vista or 7 without the Class 3 update in UEFI mode. Though maybe just using UefiSeven would be better suited for that

Yes, for now it will fake a mode when Above 4G BAR is detected.

Thanks for those hints anyway! I'll try to figure out something.

FlyGoat avatar May 15 '25 15:05 FlyGoat

If a mode is faked, i won't be able to see anything but its a limiation ):

irtygo avatar May 16 '25 00:05 irtygo

... i think i seen something about "resizable bar only on rtx 3000+ with only some motherboards" there before but now i can't find this text... (or i confused it with some discord channel)

just left it here https://github.com/xCuri0/ReBarUEFI https://github.com/terminatorul/NvStrapsReBar

NS-Clone avatar May 20 '25 14:05 NS-Clone

I think it's partially addressed by #7 at the moment.

FlyGoat avatar May 20 '25 14:05 FlyGoat