Page 1 of 1

GNU-EFI bootx64.efi ELF boot example problems

Posted: Thu Feb 01, 2024 9:57 am
by mmarequee
Hi,

recently I found a piece of code by bassaer@github (https://github.com/bassaer/uefi-bootloader) and rewrote it so that it compiles with gnu-efi(https://github.com/mmarequee/gnu-efi-elf).
I just wanted to ask if this is the correct approach (an EFI application which opens an ELF file, reads the virtual address to which the system jumps in order to transfer control)
or if there's a better way to boot a kernel.
This approach is quite easy to test on real hardware.
Also, writing to framebuffer returned by gop seems to be very slow with the gnu-efi version on real hardware(it seems to be faster with bassaers mingw compiled example),
even if writing is done inside the EFI application(before ExitBootServices).
I'm unable to render the entire font included in zxfont.h, getting garbage on real hardware and nothing gets displayed when using qemu-system-x86_64.

Re: GNU-EFI bootx64.efi ELF boot example problems

Posted: Mon Feb 12, 2024 6:54 pm
by Octocontrabass
mmarequee wrote:I just wanted to ask if this is the correct approach (an EFI application which opens an ELF file, reads the virtual address to which the system jumps in order to transfer control)
or if there's a better way to boot a kernel.
The better way is to use paging to map the kernel to its desired virtual address so it doesn't depend on available memory at any specific physical address.
mmarequee wrote:Also, writing to framebuffer returned by gop seems to be very slow with the gnu-efi version on real hardware(it seems to be faster with bassaers mingw compiled example),
even if writing is done inside the EFI application(before ExitBootServices).
Writing to the framebuffer is slow, so any small differences between the binaries can turn into big differences in speed. Enabling compiler optimizations can sometimes help, but you may need to rewrite your code to reduce the number of times it accesses the framebuffer. (Later, you might try programming the MTRRs or PAT to use WC memory for the framebuffer, but that's not something that belongs in a bootloader.)
mmarequee wrote:I'm unable to render the entire font included in zxfont.h, getting garbage on real hardware and nothing gets displayed when using qemu-system-x86_64.
It sounds like a problem with how your code is linked, but I'm not familiar enough with GNU-EFI to spot any problems there.