From: John Hodge Date: Tue, 22 Sep 2009 12:36:59 +0000 (+0800) Subject: Added out of memory handling to MM_Allocate X-Git-Tag: rel0.06~536 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=9521538a2533451531292eaef4b1a380772831c7;hp=1772867b77bef2030de97f82c1f0daa8c93003d9;p=tpg%2Facess2.git Added out of memory handling to MM_Allocate --- diff --git a/Kernel/arch/x86/mm_phys.c b/Kernel/arch/x86/mm_phys.c index 72f5dc9a..a6656e50 100644 --- a/Kernel/arch/x86/mm_phys.c +++ b/Kernel/arch/x86/mm_phys.c @@ -96,7 +96,7 @@ tPAddr MM_AllocPhys() for(a=0;gaSuperBitmap[a]==-1&&a> 22 ] == 0 ) { // Allocate directory - gaPageDir[ VAddr >> 22 ] = MM_AllocPhys() | 3; + paddr = MM_AllocPhys(); + if( paddr == 0 ) { + Warning("MM_Allocate - Out of Memory (Called by %p)", __builtin_return_address(0)); + return 0; + } + // Map + gaPageDir[ VAddr >> 22 ] = paddr | 3; // Mark as user if(VAddr < MM_USER_MAX) gaPageDir[ VAddr >> 22 ] |= PF_USER; @@ -223,13 +230,19 @@ tPAddr MM_Allocate(Uint VAddr) } // Allocate - gaPageTable[ VAddr >> 12 ] = MM_AllocPhys() | 3; + paddr = MM_AllocPhys(); + if( paddr == 0 ) { + Warning("MM_Allocate - Out of Memory (Called by %p)", __builtin_return_address(0)); + return 0; + } + // Map + gaPageTable[ VAddr >> 12 ] = paddr | 3; // Mark as user if(VAddr < MM_USER_MAX) gaPageTable[ VAddr >> 12 ] |= PF_USER; // Invalidate Cache for address INVLPG( VAddr & ~0xFFF ); - return gaPageTable[ VAddr >> 12 ] & ~0xFFF; + return paddr; } /**