heemogoblin wrote:
nexos wrote:
You put an empty PML4 in CR3. You need to identity map all memory if you have not called ExitBootServices. I still recommend in the bootloader using the page tables EFI set up in the bootloader. Then simply map addresses above the identity map.
Thank you for your reply, but I still have a couple of questions, could you please answer them for me?
Firstly, could you confirm that this means that I just go through the EFI_MEMORY_MAP and just paging_map all of the descriptors?
It means that you probably shouldn't touch CR3 until you call ExitBootServices. You also shouldn't touch any entry in the PML4, or any entry in any PDPT, page directory, or page table that already has its valid bit set. EFI has already set up an identity mapping for you, so you shouldn't change any mapping that is already in place. If you need to make your own mappings, you can do them in regions that are above the highest address of physical memory (and thus aren't mapped in the identity mapping).
Quote:
Secondly, if all my page frames are mapped, then what do I do for a page frame allocator or do I not need one?
It very much depends on how you want to structure your bootloader. You could just run within the existing identity mapping set up by EFI, in which case you don't need one at all (for the bootloader).
Quote:
Lastly, I read about recursive mapping, and do I need to recursively map or can I get away with not doing it? If I do need to do it, do I override the physical memory page entries?
You don't need to do recursive mapping, and probably should not be trying to do it in your bootloader (especially before calling ExitBootServices). It's more a concern for your OS once it's running by itself.