GNU-EFI bootx64.efi ELF boot example problems

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
mmarequee
Posts: 1
Joined: Thu Feb 01, 2024 9:41 am

GNU-EFI bootx64.efi ELF boot example problems

Post 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.
Octocontrabass
Member
Member
Posts: 5560
Joined: Mon Mar 25, 2013 7:01 pm

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

Post 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.
Post Reply