X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86_64%2Fmm_phys.c;h=fcc8547369eef65f643c2b2795cbc6a7f15326ed;hb=5255c9f07cb2e0e43cf283e256c964eaa7970c8e;hp=062b138714cf6a5000107b663b80ca593ad5e93c;hpb=dec96d539a700885bace43218e26f684934a1a01;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86_64/mm_phys.c b/Kernel/arch/x86_64/mm_phys.c index 062b1387..fcc85473 100644 --- a/Kernel/arch/x86_64/mm_phys.c +++ b/Kernel/arch/x86_64/mm_phys.c @@ -32,7 +32,7 @@ void MM_InitPhys_Multiboot(tMBoot_Info *MBoot); // === GLOBALS === tMutex glPhysicalPages; -Uint64 *gaSuperBitmap = (void*)MM_PAGE_SUPBMP; // 1 bit = 64 Pages, 16 MiB Per Word +Uint64 *gaSuperBitmap = (void*)MM_PAGE_SUPBMP; // 1 bit = 64 Pages, 16 MiB per Word Uint64 *gaMainBitmap = (void*)MM_PAGE_BITMAP; // 1 bit = 1 Page, 256 KiB per Word Uint64 *gaMultiBitmap = (void*)MM_PAGE_DBLBMP; // Each bit means that the page is being used multiple times Uint32 *gaiPageReferences = (void*)MM_PAGE_COUNTS; // Reference Counts @@ -249,8 +249,8 @@ void MM_InitPhys_Multiboot(tMBoot_Info *MBoot) if(base & 63) { Uint64 val = -1LL << (base & 63); gaSuperBitmap[base / 64] &= ~val; - size -= (base & 63); - base += 64 - (base & 63); +// size -= (base & 63); +// base += 64 - (base & 63); } } @@ -403,9 +403,9 @@ tPAddr MM_AllocPhysRange(int Pages, int MaxBits) { // Oops. ok, let's do an expensive check (scan down the list // until a free range is found) - nFree = 1; - addr = giPhysRangeLast[ rangeID ]; - // TODO +// nFree = 1; +// addr = giPhysRangeLast[ rangeID ]; + // TODO: Expensive Check Mutex_Release(&glPhysicalPages); // TODO: Page out // ATM. Just Warning @@ -481,6 +481,12 @@ void MM_RefPhys(tPAddr PAddr) { // Reference again gaMultiBitmap[ page >> 6 ] |= 1LL << (page&63); + if( !MM_GetPhysAddr( ((tVAddr)&gaiPageReferences[ page ]) & ~0xFFF ) ) { + if( !MM_Allocate( ((tVAddr)&gaiPageReferences[ page ]) & ~0xFFF ) ) { + Log_Error("Arch", "Out of memory when allocating reference count page"); + return ; + } + } gaiPageReferences[ page ] ++; } else