From 1cac4300c3f1520a74c6ebe3155c7dc54f8afad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Mon, 3 Nov 2014 20:49:01 +0100 Subject: [PATCH] ARM: Add an mmu_get_virtual_mapping() call to bootloader Will be needed to figure out the framebuffer address once we allocate it properly instead of hardcoding. --- src/system/boot/arch/arm/arch_mmu.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/system/boot/arch/arm/arch_mmu.cpp b/src/system/boot/arch/arm/arch_mmu.cpp index 890526e9c1..56e6989bc9 100644 --- a/src/system/boot/arch/arm/arch_mmu.cpp +++ b/src/system/boot/arch/arm/arch_mmu.cpp @@ -429,6 +429,28 @@ unmap_page(addr_t virtualAddress) } +// XXX: use phys_addr_t ? +extern "C" bool +mmu_get_virtual_mapping(addr_t virtualAddress, /*phys_*/addr_t *_physicalAddress) +{ + if (virtualAddress < KERNEL_LOAD_BASE) { + panic("mmu_get_virtual_mapping: asked to lookup invalid page %p!\n", + (void *)virtualAddress); + return false; + } + + // map the page to the correct page table + uint32 *pageTable = get_or_create_page_table(virtualAddress, + ARM_MMU_L1_TYPE_COARSE); + + uint32 pageTableIndex = VADDR_TO_PTENT(virtualAddress); + + *_physicalAddress = pageTable[pageTableIndex] & ~(B_PAGE_SIZE - 1); + + return true; +} + + extern "C" void * mmu_allocate(void *virtualAddress, size_t size) {