mirror of
https://github.com/memtest86plus/memtest86plus.git
synced 2025-02-25 18:55:23 -06:00
Rename map_device to map_region to better describe its use.
This commit is contained in:
@@ -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_device(lfb_base, lfb_height * lfb_width * lfb_bytes_per_pixel);
|
||||
lfb_base = map_region(lfb_base, lfb_height * lfb_width * lfb_bytes_per_pixel);
|
||||
|
||||
// Blank the whole framebuffer.
|
||||
int pixels_per_word = sizeof(uint32_t) / lfb_bytes_per_pixel;
|
||||
|
||||
@@ -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_device(base_addr, mmio_size);
|
||||
base_addr = map_region(base_addr, mmio_size);
|
||||
if (base_addr == 0) {
|
||||
print_usb_info(" Failed to map device into virtual memory");
|
||||
return;
|
||||
|
||||
@@ -26,14 +26,15 @@
|
||||
// The startup code sets up the paging tables to give us 4GB of virtual address
|
||||
// space, using 2MB pages, initially identity mapped to the first 4GB of physical
|
||||
// memory. We use the third GB to map the physical memory window we are currently
|
||||
// testing, and the following 512MB to map the screen frame buffer and any hardware
|
||||
// devices we need to access that are not in the permanently mapped regions.
|
||||
// testing, and the following 512MB to map the screen frame buffer, ACPI tables,
|
||||
// and any hardware devices we need to access that are not in the permanently
|
||||
// mapped regions.
|
||||
|
||||
#define MAX_DEVICE_PAGES 256 // VM pages
|
||||
#define MAX_REGION_PAGES 256 // VM pages
|
||||
|
||||
#define VM_WINDOW_START SIZE_C(2,GB)
|
||||
#define VM_DEVICE_START (VM_WINDOW_START + SIZE_C(1,GB))
|
||||
#define VM_DEVICE_END (VM_DEVICE_START + MAX_DEVICE_PAGES * VM_PAGE_SIZE - 1)
|
||||
#define VM_REGION_START (VM_WINDOW_START + SIZE_C(1,GB))
|
||||
#define VM_REGION_END (VM_REGION_START + MAX_REGION_PAGES * VM_PAGE_SIZE - 1)
|
||||
#define VM_SPACE_END 0xffffffff
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@@ -73,11 +74,11 @@ static void load_pdbr()
|
||||
// Public Functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
uintptr_t map_device(uintptr_t base_addr, size_t size)
|
||||
uintptr_t map_region(uintptr_t base_addr, size_t size)
|
||||
{
|
||||
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_DEVICE_END && last_addr <= VM_SPACE_END)) {
|
||||
if (last_addr < VM_WINDOW_START || (base_addr > VM_REGION_END && last_addr <= VM_SPACE_END)) {
|
||||
return base_addr;
|
||||
}
|
||||
// Check if the requested region is already mapped.
|
||||
@@ -97,13 +98,13 @@ uintptr_t map_device(uintptr_t base_addr, size_t size)
|
||||
}
|
||||
// If not, map it. Note that this will extend a partial match at the end of the current map.
|
||||
while (curr_phys_page <= last_phys_page) {
|
||||
if (device_pages_used == MAX_DEVICE_PAGES) return 0;
|
||||
if (device_pages_used == MAX_REGION_PAGES) return 0;
|
||||
pd3[device_pages_used++] = (curr_phys_page++ << VM_PAGE_SHIFT) + 0x83;
|
||||
}
|
||||
// Reload the PDBR to flush any remnants of the old mapping.
|
||||
load_pdbr();
|
||||
// Return the mapped address.
|
||||
return VM_DEVICE_START + first_virt_page * VM_PAGE_SIZE + base_addr % VM_PAGE_SIZE;
|
||||
return VM_REGION_START + first_virt_page * VM_PAGE_SIZE + base_addr % VM_PAGE_SIZE;
|
||||
}
|
||||
|
||||
bool map_window(uintptr_t start_page)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#define VM_WINDOW_SIZE PAGE_C(1,GB)
|
||||
|
||||
uintptr_t map_device(uintptr_t base_addr, size_t size);
|
||||
uintptr_t map_region(uintptr_t base_addr, size_t size);
|
||||
|
||||
bool map_window(uintptr_t start_page);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user