Master the fundamental concepts of bios & uefi programming through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksUEFI boots PE/COFF .efi executables linked for the firmware subsystem, not DOS or Linux ELF. A minimal app locates EFI_SYSTEM_TABLE, then calls ConOut->OutputString to print text in UTF-16. For example, GNU-EFI's InitializeLib macro stores the table pointer your efi_main receives in registers per the calling convention.
cLoading…
-nostdlib -e efi_main against libefi/libgnuefiCHAR16 (wide) with L prefixExitBootServices is called.efi from the EFI System Partition (FAT32)GNU-EFI or EDK2-style builds produce a PE32+ image with subsystem EFI_APPLICATION. Copy the .efi to EFI/BOOT/BOOTX64.EFI on a FAT ESP for firmware to auto-run it. OVMF in QEMU boots that path when you point -drive at a vfat disk image. If the screen stays blank, confirm you passed wide strings to ConOut and returned EFI_SUCCESS so firmware does not hang waiting for exit.
You will encode exactly what OutputString consumes: every ASCII character you would print with printf becomes a two-byte little-endian CHAR16 unit, plus a null terminator. This exercise requires producing the UTF-16LE byte stream the UEFI console protocol expects.
UEFI's ConOut->OutputString takes a CHAR16*: UTF-16LE text ending in a 16-bit NUL, not a C string. Encode an ASCII word the way a UEFI application must pass it.
Each ASCII character becomes two bytes, the character and then 00, and the string ends with the terminator 00 00.
One word of ASCII text, with no spaces.
Three lines:
cLoading…
for Hello. Bytes are two-digit uppercase hex separated by single spaces. The total counts the terminator: 2 * (length + 1).