flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > UEFI Test Bootloader

Author
Thread Post new topic Reply to topic
Core i7



Joined: 14 Nov 2024
Posts: 183
Location: Socket on motherboard
Core i7 09 Nov 2026, 06:51
I’ve been learning UEFI programming and have written a small bootloader.
I’m running it in a QEMU virtual machine on Windows; if you have some time, could you please test the application on your end so I can fix any bugs?

Attached is a screenshot of the bootloader window, along with the contents of my Windows batch file.
It is important to include the "-smbios type=1" flag, as the code reads data from the SMBIOS table. The last line specifies a virtual disk to be used as the boot drive. You will need to create a directory structure—"\Bootdrv\EFI\Boot\"—anywhere on your system and place my bootloader image, "Bootx64.efi" (do not change the filename), inside it.

Please run the batch file from within the QEMU folder so that it can locate the EFI firmware ("qemu\share\edk2-x86_64-code.fd") instead of the legacy BIOS. Thanks in advance!

Code:
qemu-system-x86_64 ^
-smp 2 -m 1024M -machine q35 -smbios type=1 ^
-netdev user,id=net0,hostfwd=tcp::5555-:80 ^
-device virtio-net-pci,netdev=net0,vectors=4 ^
-drive if=pflash,format=raw,readonly=on,file=share\edk2-x86_64-code.fd ^
-drive file=fat:rw:D:\_vm\bootdrv,format=raw,if=virtio     


Description:
Filesize: 8.05 KB
Viewed: 216 Time(s)

EfiTest.png


Description:
Download
Filename: BootX64.zip
Filesize: 6.14 KB
Downloaded: 32 Time(s)

Post 09 Nov 2026, 06:51
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4676
Location: vpcmpistri
bitRAKE 09 Nov 2026, 07:41
It worked in QEMU and real hardware.

QEMU looks exactly the same.

Hardware boot has an orange title bar - no text, on titlebar - rest is good.
Post 09 Nov 2026, 07:41
View user's profile Send private message Visit poster's website Reply with quote
Core i7



Joined: 14 Nov 2024
Posts: 183
Location: Socket on motherboard
Core i7 09 Nov 2026, 08:07
bitRAKE, thank you very much, ..especially for testing it on physical hardware.
I will try to fix the issue with the text in the header. Currently, I’m reading the UEFI version string from the SMBIOS table; it seems there’s something wrong with that, even though I’m also pulling the core count and memory size from SMBIOS.
Post 09 Nov 2026, 08:07
View user's profile Send private message Reply with quote
Core i7



Joined: 14 Nov 2024
Posts: 183
Location: Socket on motherboard
Core i7 13 Nov 2026, 22:18
bitRAKE, It turns out that when searching for smbios tables, I didn’t reset the search descriptor to its default state, which is probably why the string wasn’t displayed in the header. I also added a list of the supported graphics modes by the video adapter and the firmware version from SystemTable -> FirmwareVendor to the footer. When testing in qemu, I get as many as 30 modes, but on real hardware there are only 3.


Description:
Filesize: 8.87 KB
Viewed: 70 Time(s)

UefiTest.png


Description:
Download
Filename: BOOTX64.ZIP
Filesize: 6.6 KB
Downloaded: 6 Time(s)

Post 13 Nov 2026, 22:18
View user's profile Send private message Reply with quote
HSE



Joined: 13 Jan 2019
Posts: 18
HSE 14 Nov 2026, 01:00
This capture is from lbochs running in the phone.

Perhaps is a wrong Bochs configuration, or a problem in OVMF (this is older)


Description:
Filesize: 105.11 KB
Viewed: 55 Time(s)

Screenshot_20261113-213051~2.jpg


Post 14 Nov 2026, 01:00
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4676
Location: vpcmpistri
bitRAKE 14 Nov 2026, 01:25
Updated, same hardware. Sorry for the image quality - this monitor is at an odd angle and not easy to get to. Notable:
- orange header,
- SMB v3.5,
- strange leading char on path, as before,
- watchdog not disabled,
- this machine actually has 96GB.

Image

The QEMU display is similar to yours, but dated 08/13/2024 - still EDK II v2.70 though.
(I'm using the same command line settings suggested.)

_________________
¯\(°_o)/¯ AI understands the way 2+2 understands 4.
Post 14 Nov 2026, 01:25
View user's profile Send private message Visit poster's website Reply with quote
Core i7



Joined: 14 Nov 2024
Posts: 183
Location: Socket on motherboard
Core i7 14 Nov 2026, 12:35
HSE, thanks for the test! When I used the standard firmware from the "qemu\share\edk2-x86_64-code.fd" folder in qemu, I also got the same display. In my bootloader, I manually set the text mode to 80x25 right at the start, but it turns out there's a bug in that firmware, and it's set to 70x22. Manually changing the mode to 100x31 solves the problem, but I still downloaded the release ovmf_code_4M + ovmf_vars_4M and now all modes work correctly. https://qemu.weilnetz.de/test/ovmf/usr/share/OVMF/ Here's a version of the bootloader with a 100x31 screen resolution - your screenshot shows that lbochs has this mode.

bitRAKE, thanks for finding the errors!
1. Smb here implies smbios - version 3.5 is current, although the latest is v3.10 from September 7, 2026.
2. On my real hardware, the path is completely empty, but that's what "EFI_LOADED_IMAGE_PROTOCOL.pFilePath" returns.
3. I fixed the memory size query - it used to only read the first smbios slot, but now it does. cycle.
4. In the very last line, I added the OEM-ID and OEM-Table-ID from the ACPI -> RSDT table. The Fw field is "firmware" and Hw is "hardware".

My code works on a desktop with an H61 chipset, but on a Lenovo laptop, it crashes after the first four lines of "Efi-Image." I think the problem is that UEFI starts in graphics mode, and after I set the text resolution to 100x31, my SetCursorPosition function somehow doesn't return control at all (I can't verify the error). It's a shame there are no debuggers for EFI code, although IDA disassembles it just fine.


Description:
Filesize: 72.2 KB
Viewed: 15 Time(s)

photo_2026-11-14_13-43-00.png


Description:
Filesize: 8.75 KB
Viewed: 15 Time(s)

UefiTest.png


Description:
Download
Filename: BOOTX64.ZIP
Filesize: 6.75 KB
Downloaded: 3 Time(s)

Post 14 Nov 2026, 12:35
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2026, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.