for(a=0;gaSuperBitmap[a]==-1&&a<num;a++);
if(a == num) {
RELEASE( &giPhysAlloc );
- Warning("MM_AllocPhys - OUT OF MEMORY (Called by %p)", __builtin_return_address(0));
+ Warning("MM_AllocPhys - OUT OF MEMORY (Called by %p)", __builtin_return_address(0));
return 0;
}
for(b=0;gaSuperBitmap[a]&(1<<b);b++);
*/
tPAddr MM_Allocate(Uint VAddr)
{
+ tPAddr paddr;
// Check if the directory is mapped
if( gaPageDir[ VAddr >> 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;
}
// 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;
}
/**