Kernel/x86_64 - Debugging iret->CPL3 crash
[tpg/acess2.git] / Kernel / arch / x86_64 / mm_phys.c
index eb495b3..893fb5b 100644 (file)
@@ -461,7 +461,7 @@ tPAddr MM_AllocPhys(void)
                if( gaiStaticAllocPages[i] ) {
                        tPAddr  ret = gaiStaticAllocPages[i];
                        gaiStaticAllocPages[i] = 0;
-                       Log("MM_AllocPhys: Return %x, static alloc %i", ret, i);
+                       Log("MM_AllocPhys: Return %P, static alloc %i", ret, i);
                        return ret;
                }
        }
@@ -536,6 +536,23 @@ void MM_DerefPhys(tPAddr PAddr)
        }
 }
 
+int MM_GetRefCount( tPAddr PAddr )
+{
+       PAddr >>= 12;
+       
+       if( PAddr >> 12 > giMaxPhysPage )       return 0;
+
+       if( gaMultiBitmap[ PAddr >> 6 ] & (1LL << (PAddr&63)) ) {
+               return gaiPageReferences[PAddr];
+       }
+
+       if( gaMainBitmap[ PAddr >> 6 ] & (1LL << (PAddr&63)) )
+       {
+               return 1;
+       }
+       return 0;
+}
+
 /**
  * \brief Takes a physical address and returns the ID of its range
  * \param Addr Physical address of page

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