Get Memory Map & Exit Boot Services | UEFI Dev (in C)

Channel:
Subscribers:
3,970
Published on ● Video Link: https://www.youtube.com/watch?v=mHh2-ixF9Yk



Duration: 1:03:43
1,298 views
58


Getting a memory map and officially exiting boot services, which means full control over all memory and the machine from that point on e.g. you can load your OS!

Errata:
- Fixed the error message for the initial GetMemoryMap() call after this video.

- While there can be reserved space for firmware and micro controllers, etc. on other devices like SSDs, it's probably more common that a storage device's advertized amount is in base 10, and the actual reported amount is in base 2. Like 1024 vs 1000 for KiB vs KB.

- I did move functions into efi_lib.h, which is included in kernel.c, so most likely that is why it "broke" for me and I had to add a linker script for flat binary kernels. Because those functions would be linked to the start of the binary object before the entry point code. Maybe separate .h/.c files for headers and implementations would've fixed that, or otherwise being a better programmer :^)

Also, an array ("map") of index to color would be better than a function for getting a number, but that was mainly to show the linking errors that would come up later anyway.

Links:
https://uefi.org/specifications (uefi & other specifications)
https://wiki.osdev.org/Paging

UEFI Programming playlist:
https://www.youtube.com/playlist?list=PLT7NbkyNWaqZYHNLtOZ1MNxOt8myP5K0p

Git Repo:
https://github.com/queso-fuego/uefi-dev

Repo state at the start of this video:
git clone --recurse-submodules https://github.com/queso-fuego/uefi-dev
cd uefi-dev
git checkout 85f254359dd78d77ec751366fbb022aeca7bdb55

Repo state at the end of this video:
git checkout 74496ccf10bd6ee57d54af322475fd4d8942b881

Shoutout to ThatOSDev https://www.youtube.com/@ThatOSDev
for EFI help, efi_lib.h file and suggestions, and conversation.

Join the Community Discord: https://discord.gg/yKm4T89QFn

Contact:
https://queso_fuego.srht.site/contact.html

If you feel like throwing money my way:
https://queso_fuego.srht.site/support.html

Questions about setup/software/etc.?
Check the FAQ: https://queso_fuego.srht.site/about.html

Next video:
- Thinking about how to show disks or partitions to the user for an installer option, to write the disk image & bootloader to another disk (or only a partition), so the user can then reboot and run the loaded kernel or an OS on another drive or machine.

Misc notes:
- Tried manual camera settings this time for the sony zv1, so it should have the same levels throughout now and not get brighter/darker every few seconds as usual.
ISO 2000 and F 1/60 (shutter speed) works fine with the lamp on, with white balance set to "fluor.: warm white" (is that flourescent?). Without the lamp it's very blue.
Also turned off the color correction filter in OBS as it's not needed with these changes.
If it's slightly too dark, or too orange at night, can tweak it further.

0:00:00 intro, get definitions from UEFI spec
0:11:03 make non-efi header file, add memory map typedefs
0:14:47 make sure main menu only makes 1 timer event
0:15:40 add print memory map option and get/print functions
0:27:53 print memory map
0:44:32 add memory map to kernel parameters & exit boot services
0:49:21 tips for flat binary kernel
0:58:41 more fixes for flat binary (again)

Music credits:
[Chiptune] Medieval: Minstrel Dance by RandomMind
Music: https://www.chosic.com/free-music/all/

#uefidev #cprogramming #memorymap







Tags:
queso fuego
memory
memmap
memory map
uefi
efi memory map
c programming
bootloader
low level
kernel parms
flat binary loading