}
/**
- * \fn Uint32 MM_AllocPhys()
+ * \fn tPAddr MM_AllocPhys()
* \brief Allocates a physical page
*/
tPAddr MM_AllocPhys()
for(a=0;gaSuperBitmap[a]==-1&&a<num;a++);
if(a == num) {
RELEASE( &giPhysAlloc );
+ Warning("MM_AllocPhys - OUT OF MEMORY\n");
return 0;
}
for(b=0;gaSuperBitmap[a]&(1<<b);b++);
/**
* \fn void MM_DerefPhys(Uint32 Addr)
*/
-void MM_DerefPhys(Uint32 Addr)
+void MM_DerefPhys(tPAddr Addr)
{
// Get page number
Addr >>= 12;
// Release spinlock
RELEASE( &giPhysAlloc );
}
+
+/**
+ * \fn int MM_GetRefCount(tPAddr Addr)
+ */
+int MM_GetRefCount(tPAddr Addr)
+{
+ // Get page number
+ Addr >>= 12;
+
+ // We don't care about non-ram pages
+ if(Addr >= giPageCount) return -1;
+
+ // Check if it is freed
+ return gaPageReferences[ Addr ];
+}