Ignored \0 in VT_Write, Added out of memory message
[tpg/acess2.git] / Kernel / arch / x86 / mm_phys.c
index 80e92fe..de30a93 100644 (file)
@@ -85,7 +85,7 @@ void MM_Install(tMBoot_Info *MBoot)
 }
 
 /**
- * \fn Uint32 MM_AllocPhys()
+ * \fn tPAddr MM_AllocPhys()
  * \brief Allocates a physical page
  */
 tPAddr MM_AllocPhys()
@@ -100,6 +100,7 @@ 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++);
@@ -154,7 +155,7 @@ void MM_RefPhys(tPAddr Addr)
 /**
  * \fn void MM_DerefPhys(Uint32 Addr)
  */
-void MM_DerefPhys(Uint32 Addr)
+void MM_DerefPhys(tPAddr Addr)
 {
        // Get page number
        Addr >>= 12;
@@ -185,3 +186,18 @@ void MM_DerefPhys(Uint32 Addr)
        // 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 ];
+}

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