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 worksThe Simple File System protocol exposes FAT volumes on the EFI System Partition. Open the volume with OpenVolume, then Open a file with EFI_FILE_MODE_READ, and use Read in a loop until bytes returned is zero. For example, loading \\\\kernel.elf means wide-character paths like L"\\\\kernel.elf" on the root directory handle.
cLoading…
EFI_FILE_INFO for size before allocating buffersExitBootServices, file protocols are invalidLocate the Simple File System protocol on the handle that represents the ESP volume, not the disk handle. OpenRoot on the loaded image's device handle is a common shortcut in small loaders. Always close file and volume handles to avoid leaking pool memory before exit boot services. Status EFI_BUFFER_TOO_SMALL on GetInfo tells you how large the file info buffer must be.
The file metadata behind every GetInfo call lives in 32-byte FAT directory entries on the ESP. You will decode one raw entry exactly as the Simple File System does: extract the 8.3 name, attribute byte, little-endian 32-bit first cluster (high word at offset 20, low word at 26) and file size (offset 28), and recognize deleted/LFN/end markers. This exercise requires reading the on-disk structure the protocol wraps.
UEFI's Simple File System protocol reads FAT, where every file is a 32-byte directory entry. Decode one entry.
Check the markers first, in this order, and stop at the first that matches:
| Condition | Output |
|---|---|
byte 0 is 0x00 | entry end (no more entries in this directory) |
byte 0 is 0xE5 | entry deleted |
byte 11 (attributes) is 0x0F | entry lfn (a long-file-name fragment, not a file) |
Otherwise it is a file or directory:
. and the extension with trailing spaces removed: KERNEL ELF becomes KERNEL.ELF, and EFI plus three spaces stays EFI.0x10 marks a directory.(bytes 20-21) << 16 | (bytes 26-27), each half little-endian.32 bytes in hexadecimal.
For a file or directory:
cLoading…
with an extra line directory after attr when bit 0x10 is set. The attribute is 2 uppercase hex digits. For a marker, only its single line.