// === PROTOTYPES ===
void MM_InitPhys_Multiboot(tMBoot_Info *MBoot);
-tPAddr MM_AllocPhysRange(int Num, int Bits);
-tPAddr MM_AllocPhys(void);
-void MM_RefPhys(tPAddr PAddr);
-void MM_DerefPhys(tPAddr PAddr);
+//tPAddr MM_AllocPhysRange(int Num, int Bits);
+//tPAddr MM_AllocPhys(void);
+//void MM_RefPhys(tPAddr PAddr);
+//void MM_DerefPhys(tPAddr PAddr);
int MM_int_GetRangeID( tPAddr Addr );
// === 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
{
// 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