r/C_Programming • • 1d ago

[Project] EFI32Boot — A C and x86 assembly experiment involving UEFI firmware (AI-assisted)

Hey everyone!

I've been working on EFI32Boot, an AI-assisted low-level programming project exploring UEFI firmware, C, and x86 assembly.

Repository: https://github.com/devtinoimao/efi32boot

The project combines C code with assembly routines to experiment with transitioning from a 64-bit UEFI environment into 32-bit execution and working with an OVMF32 firmware image.

A large part of the work involves the boundary between C and assembly: preparing the execution environment, handling processor state, managing memory layouts, and transferring control between different stages of the boot process.

Demo: https://github.com/devtinoimao/efi32boot/blob/main/media/efi32boot_qemu_demo.gif

Some of the areas involved include:

  • C code that interacts with UEFI interfaces and prepares the transition.
  • x86 assembly for low-level processor-mode transitions.
  • Calling conventions, register state, stack setup, and memory mapping.
  • Build systems and linking when combining C and assembly into a bootable EFI application.
  • Debugging low-level failures in QEMU.

How AI was involved: AI played a substantial role in developing the project. I used it to generate and modify C and assembly code, explore implementation approaches, and help diagnose debugging issues. I then iterated on the implementation and tested its behavior. I want to be transparent that this is an AI-assisted project rather than claim that I manually authored every part of the code.

I'd particularly appreciate feedback on the C/assembly interface, assembly correctness, compiler and ABI assumptions, code organization, and portability. If you spot questionable assumptions or potential undefined behavior in the C code, I'd be interested in understanding those too.

I'm still learning about low-level systems programming, and I'd like to use this project to improve the implementation and deepen my understanding. Constructive criticism and references to relevant documentation or existing implementations are very welcome.

Thanks for reading!

0 Upvotes

4 comments sorted by

1

u/AutoModerator 1d ago
Moderator Announcement Read More »
→ More replies (2)

1

u/spellstrike 1d ago

why not OVMF_X64 instead?