X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FKernel%2Finclude%2Ftpl_mm_phys_bitmap.h;h=424a3ea427398937c803397558662127fc7a99f5;hb=af67042b8d7f05fe76583aef1afb2022b519a1aa;hp=005a2f8caa62232cf9cbd337dd97f8ce372c89cf;hpb=d0b4559f2936f6d9f06be0f7c3c51527a480ec0d;p=tpg%2Facess2.git diff --git a/KernelLand/Kernel/include/tpl_mm_phys_bitmap.h b/KernelLand/Kernel/include/tpl_mm_phys_bitmap.h index 005a2f8c..424a3ea4 100644 --- a/KernelLand/Kernel/include/tpl_mm_phys_bitmap.h +++ b/KernelLand/Kernel/include/tpl_mm_phys_bitmap.h @@ -9,6 +9,7 @@ * * Uses 4.125+PtrSize bytes per page */ +#include #define MM_PAGE_REFCOUNTS MM_PMM_BASE #define MM_PAGE_NODES (MM_PMM_BASE+(MM_MAXPHYSPAGE*sizeof(Uint32))) @@ -27,7 +28,6 @@ int MM_int_GetRangeID( tPAddr Addr ); int MM_int_GetMapEntry( void *Data, int Index, tPAddr *Start, tPAddr *Length ); void MM_Tpl_InitPhys(int MaxRAMPage, void *MemoryMap); -void MM_DumpStatistics(void); // === GLOBALS === tMutex glPhysicalPages; @@ -84,7 +84,7 @@ void MM_Tpl_InitPhys(int MaxRAMPage, void *MemoryMap) // Only need to allocate bitmaps if( !MM_GetPhysAddr( (void*)bitmap_page ) ) { - if( !MM_Allocate( bitmap_page ) ) { + if( !MM_Allocate( (void*)bitmap_page ) ) { Log_KernelPanic("PMM", "Out of memory during init, this is bad"); return ; } @@ -326,7 +326,7 @@ void MM_RefPhys(tPAddr PAddr) if( !MM_GetPhysAddr( (void*)refpage ) ) { int pages_per_page, basepage, i; - if( MM_Allocate(refpage) == 0 ) { + if( MM_Allocate( (void*) refpage) == 0 ) { // Out of memory, can this be resolved? // TODO: Reclaim memory Log_Error("PMM", "Out of memory (MM_RefPhys)"); @@ -354,7 +354,13 @@ int MM_GetRefCount(tPAddr PAddr) return gaiPageReferences[PAddr]; } - if( gaPageBitmaps[ PAddr / 32 ] & (1LL << (PAddr&31)) ) { + Uint32 *bm = &gaPageBitmaps[ PAddr / 32 ]; + if( !MM_GetPhysAddr(bm) ) { + Log_Error("MMPhys", "MM_GetRefCount: bitmap for ppage 0x%x not mapped %p", + PAddr, bm); + return 0; + } + if( (*bm) & (1LL << (PAddr&31)) ) { return 1; } @@ -416,7 +422,7 @@ int MM_SetPageNode(tPAddr PAddr, void *Node) if( !MM_GetRefCount(PAddr) ) return 1; if( !MM_GetPhysAddr( (void*)node_page ) ) { - if( !MM_Allocate(node_page) ) + if( !MM_Allocate( (void*)node_page) ) return -1; memset( (void*)node_page, 0, PAGE_SIZE ); }