Antti wrote:Owen wrote:Why does it matter which when the first thing you're going to do with it is shove it into some actually useful data structure?
So it does not make sense if my BIOS and UEFI boot loaders give a memory map that is uniform, compact, and is already verified to be correct?
That makes perfect sense. (Well, except for checking the UEFI memory map. A UEFI implementation which gives you a bad memory map is serious trouble of the nothing can possibly work variety)
Antti wrote:Is it better that my system checked those BIOS/UEFI-specific things after boot loaders? Or is it better that I create those "useful data structures" while still running boot loaders and make the decision of what is a useful data structure?
A "Useful data structure" probably doesn't look like a flat array. After all, they are terrible for resizing, etc, which undoubtedly your kernel is going to have to do whenever it needs to update the memory map ("I mapped PCI device 1.2.5 BAR 0 here")
So why invent something new and perfect?
Why not pick something that already exists and just use it?
Today Linux uses E820 as its' standard PC memory map representation. Now, they regret this somewhat, partially because it is less expressive than the UEFI memory map (therefore on UEFI systems they both need a converted version and the original)
But why not the UEFI memory map structure? No translation on UEFI. On non-UEFI, map the "native" format into a UEFI memory map. And if you need a type which UEFI doesn't define? Well, as said, there are 2^31 type codes reserved for arbitrary use by the OS.
Additionally, whatever part of your system sets up paging needs to make a call back into UEFI with the address map anyway. If all you have is a translated map, you're in for a world of hurt there.
Plus, the less translation you do, the easier it is to work around certain firmware bugs (e.g. on some implementations SetVirtualAddressMap incorrectly calls into boot services code. On certain MacBooks, UEFI forgets to turn off the Wi-Fi card so you can't reuse boot services data until you've enumerated the PCI bus)