Kernel/x86 - Emarrasing, stray " at the start of the file
[tpg/acess2.git] / Kernel / arch / x86 / mm_phys.c
index 4dbb2c3..cc6857d 100644 (file)
 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 ];
 }

UCC git Repository :: git.ucc.asn.au