Master the fundamental concepts of bios & uefi programming through this focused micro-challenge.
UEFI tracks physical RAM with a memory map of variable-sized descriptors. Each entry lists type, physical start, page count, and attributes. Boot loaders must call GetMemoryMap, copy the map, then ExitBootServices only after the map is stable. For example, regions tagged EfiLoaderData are free for your stack once firmware hands off.
cLoading…
The map key changes if you allocate between GetMemoryMap calls; you need the key matching the final map before exit.
Allocate scratch buffers with AllocateAnyPages only before the final GetMemoryMap snapshot. Each allocation can change map size and invalidate the previous key. Print descriptor types in hex so you can spot accidental use of MMIO as RAM. The kernel you hand off to should receive a copy in conventional memory or a known physical address recorded in a boot info struct.
You will retrieve and print UEFI memory descriptors before calling ExitBootServices. This exercise requires handling the two-call buffer sizing pattern and identifying conventional memory regions for a kernel.
Simulate UEFI memory map handling 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