fix(vmm): make MMU bring-up and kernel mappings reliable
This commit is contained in:
@@ -56,6 +56,7 @@ static inline void CPUEnableMMU(Address l0PhysicalAddress) {
|
||||
"msr tcr_el1, %1\n"
|
||||
"msr ttbr0_el1, %2\n" // set userspace root
|
||||
"msr ttbr1_el1, %2\n" // set kernelspace root
|
||||
"tlbi vmalle1is\n"
|
||||
"isb\n" // Instruction Synchronization Barrier
|
||||
:: "r"(mair), "r"(tcr), "r"(l0PhysicalAddress) : "memory"
|
||||
);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
#include <Types.h>
|
||||
|
||||
enum {
|
||||
kHeapSizePages = 1024,
|
||||
kHeapBlockHeaderMagic = 0x43555445, // CUTE
|
||||
kKernelHeapStart = 0xFFFFFFFFC0000000
|
||||
};
|
||||
|
||||
static inline Address VMPhysToHeap(Address phys) { return phys + kKernelHeapStart; }
|
||||
static inline Address VMHeapToPhys(Address heap) { return heap - kKernelHeapStart; }
|
||||
|
||||
typedef struct __attribute__((aligned(16))) VMHeapBlockHeader {
|
||||
UInt64 magic;
|
||||
struct VMHeapBlockHeader* next;
|
||||
struct VMHeapBlockHeader* previous;
|
||||
UInt64 size;
|
||||
bool isFree;
|
||||
} VMHeapBlockHeader;
|
||||
|
||||
void HeapInitialize();
|
||||
Pointer HeapAllocate(Size size);
|
||||
void HeapFree(Pointer pointer);
|
||||
Pointer HeapResize(Pointer pointer, Size newSize);
|
||||
@@ -21,6 +21,6 @@ typedef struct {
|
||||
VMMemoryRegion UART;
|
||||
} VMBootMemoryMap;
|
||||
|
||||
void PMMInitialize(VMBootMemoryMap* bootMap, Bootinfo* info);
|
||||
void PMMInitialize(VMBootMemoryMap* bootMap);
|
||||
Pointer PMMAllocatePage();
|
||||
void PMMFreePage(Address address);
|
||||
@@ -29,7 +29,7 @@ enum {
|
||||
|
||||
|
||||
static inline Address VMKernelVirtToPhys(Address virt) {
|
||||
return virt - kVMKernelVMA;
|
||||
return virt - 0xFFFFFFFF80100000 + 0x40100000; // TODO: hardcode is awful
|
||||
}
|
||||
|
||||
static inline Address VMPhysToHHDM(Address phys) {
|
||||
|
||||
Reference in New Issue
Block a user