fix(vmm): make MMU bring-up and kernel mappings reliable

This commit is contained in:
karina
2026-04-26 23:41:57 +04:00
parent b56b55e4b3
commit 5d010f7fb2
8 changed files with 167 additions and 13 deletions
+24
View File
@@ -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);
+1 -1
View File
@@ -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);
+1 -1
View File
@@ -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) {