buddy: adjust memory mappings for early init

this massively speeds up boot on larger memory systems, as before this
was only tested on a 2GB system. Only identity mapping the first 4GB of
still allows MMIO to work, but without the massive space and time taken
by the previous method
This commit is contained in:
Michael Shaw 2023-05-10 01:10:36 -04:00
commit 29dd9b54e7

View file

@ -421,15 +421,9 @@ void mem_early_init(char *mem, size_t len)
pml4 = NULL; pml4 = NULL;
/* map the kernel */ /* map the kernel */
struct mem_region lastregion = mem_regions[num_regions - 1]; kmap(0, hhdm_start, 4 * GB, attrs.val | PAGE_PCD);
kmap(kpaddr, kvaddr, kernel_size, attrs.val); kmap(kpaddr, kvaddr, kernel_size, attrs.val);
/* identity map the entire physical address space */
attrs.pcd = 1;
kmap(0, hhdm_start, lastregion.base + lastregion.len, attrs.val);
/* remap usable regions with pcd=0 */
attrs.pcd = 0;
for (unsigned int i = 0; i < num_regions; i++) { for (unsigned int i = 0; i < num_regions; i++) {
kmap(regions[i].base, regions[i].base | hhdm_start, regions[i].len, attrs.val); kmap(regions[i].base, regions[i].base | hhdm_start, regions[i].len, attrs.val);
} }