Master the fundamental concepts of bios & uefi programming through this focused micro-challenge.
The 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.
You will open a file on the ESP and read its contents into a buffer. This exercise requires chaining OpenVolume, Open, and Read calls with the correct EFI status checks.
Simulate UEFI file I/O in C.
Requirements:
Test:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github