X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Fmm_phys.c;h=cc6857d150c559e6e3389e8ba6e7190be4c07c6c;hb=717454930aa0e255517c68c837927deac49bd78e;hp=4dbb2c32958e2f9044b851da3211430e76565aeb;hpb=f624a806d931617e6ae3eb21a28e4f886aa7cd63;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/mm_phys.c b/Kernel/arch/x86/mm_phys.c index 4dbb2c32..cc6857d1 100644 --- a/Kernel/arch/x86/mm_phys.c +++ b/Kernel/arch/x86/mm_phys.c @@ -16,10 +16,12 @@ extern void gKernelEnd; // === PROTOTYPES === -tPAddr MM_AllocPhys(void); -tPAddr MM_AllocPhysRange(int Pages, int MaxBits); -void MM_RefPhys(tPAddr PAddr); -void MM_DerefPhys(tPAddr PAddr); +void MM_Install(tMBoot_Info *MBoot); +//tPAddr MM_AllocPhys(void); +//tPAddr MM_AllocPhysRange(int Pages, int MaxBits); +//void MM_RefPhys(tPAddr PAddr); +//void MM_DerefPhys(tPAddr PAddr); +// int MM_GetRefCount(tPAddr PAddr); // === GLOBALS === tMutex glPhysAlloc; @@ -246,6 +248,13 @@ tPAddr MM_AllocPhys(void) Panic("The fuck? Too many pages! (indx = 0x%x)", indx); } + if( indx >= giPageCount ) { + Mutex_Release( &glPhysAlloc ); + Log_Error("PMem", "MM_AllocPhys - indx(%i) > giPageCount(%i)", indx, giPageCount); + LEAVE('i', 0); + return 0; + } + // Mark page used if(gaPageReferences) gaPageReferences[ indx ] = 1; @@ -481,14 +490,14 @@ void MM_DerefPhys(tPAddr PAddr) /** * \fn int MM_GetRefCount(tPAddr Addr) */ -int MM_GetRefCount(tPAddr Addr) +int MM_GetRefCount(tPAddr PAddr) { // Get page number - Addr >>= 12; + PAddr >>= 12; // We don't care about non-ram pages - if(Addr >= giPageCount) return -1; + if(PAddr >= giPageCount) return -1; // Check if it is freed - return gaPageReferences[ Addr ]; + return gaPageReferences[ PAddr ]; }