Add option to map_region to indicate we only use the region during startup.

This will avoid unnecessary remapping of the ACPI tables if they are
located in the third GB of memory.
This commit is contained in:
Martin Whitaker 2022-02-27 15:48:27 +00:00
parent a65d6a795d
commit 5211b67e6c
4 changed files with 7 additions and 6 deletions

View File

@ -215,7 +215,7 @@ void screen_init(void)
if (lfb_height > 8192) lfb_height = 8192;
// The above clipping should guarantee the mapping never fails.
lfb_base = map_region(lfb_base, lfb_height * lfb_width * lfb_bytes_per_pixel);
lfb_base = map_region(lfb_base, lfb_height * lfb_width * lfb_bytes_per_pixel, false);
// Blank the whole framebuffer.
int pixels_per_word = sizeof(uint32_t) / lfb_bytes_per_pixel;

View File

@ -616,7 +616,7 @@ static void probe_usb_controller(int bus, int dev, int func, hci_type_t controll
print_usb_info("Found %s controller %04x:%04x at %08x size %08x", hci_name[controller_type],
(uintptr_t)vendor_id, (uintptr_t)device_id, base_addr, mmio_size);
base_addr = map_region(base_addr, mmio_size);
base_addr = map_region(base_addr, mmio_size, false);
if (base_addr == 0) {
print_usb_info(" Failed to map device into virtual memory");
return;

View File

@ -74,11 +74,12 @@ static void load_pdbr()
// Public Functions
//------------------------------------------------------------------------------
uintptr_t map_region(uintptr_t base_addr, size_t size)
uintptr_t map_region(uintptr_t base_addr, size_t size, bool only_for_startup)
{
uintptr_t last_addr = base_addr + size - 1;
// Check if the requested region is permanently mapped.
if (last_addr < VM_WINDOW_START || (base_addr > VM_REGION_END && last_addr <= VM_SPACE_END)) {
// Check if the requested region is permanently mapped. If it is only needed during startup,
// this includes the region we will eventually use for the memory test window.
if (last_addr < (only_for_startup ? VM_REGION_START : VM_WINDOW_START) || (base_addr > VM_REGION_END && last_addr <= VM_SPACE_END)) {
return base_addr;
}
// Check if the requested region is already mapped.

View File

@ -19,7 +19,7 @@
#define VM_WINDOW_SIZE PAGE_C(1,GB)
uintptr_t map_region(uintptr_t base_addr, size_t size);
uintptr_t map_region(uintptr_t base_addr, size_t size, bool only_for_startup);
bool map_window(uintptr_t start_page);