diff --git a/system/screen.c b/system/screen.c index e37c66e..91f4913 100644 --- a/system/screen.c +++ b/system/screen.c @@ -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; diff --git a/system/usbhcd.c b/system/usbhcd.c index b6f28d6..c34c96d 100644 --- a/system/usbhcd.c +++ b/system/usbhcd.c @@ -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; diff --git a/system/vmem.c b/system/vmem.c index b5cc031..58d6694 100644 --- a/system/vmem.c +++ b/system/vmem.c @@ -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. diff --git a/system/vmem.h b/system/vmem.h index f9d83f0..cdfa132 100644 --- a/system/vmem.h +++ b/system/vmem.h @@ -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);