- 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));
+ // Scan downwards
+ #if 1
+ LOG("giLastPossibleFree = %i", giLastPossibleFree);
+ for( indx = giLastPossibleFree; indx >= 0; )
+ {
+ if( gaSuperBitmap[indx>>10] == -1 ) {
+ indx -= 1024;
+ continue;
+ }
+
+ if( gaPageBitmap[indx>>5] == -1 ) {
+ indx -= 32;
+ continue;
+ }
+
+ if( gaPageBitmap[indx>>5] & (1 << (indx&31)) ) {
+ indx --;
+ continue;
+ }
+ break;
+ }
+ LOG("indx = %i", indx);
+ #else
+ c = giLastPossibleFree % 32;
+ b = (giLastPossibleFree / 32) % 32;
+ a = giLastPossibleFree / 1024;
+
+ LOG("a=%i,b=%i,c=%i", a, b, c);
+ for( ; gaSuperBitmap[a] == -1 && a >= 0; a-- );
+ if(a < 0) {
+ Mutex_Release( &glPhysAlloc );
+ Warning("MM_AllocPhys - OUT OF MEMORY (Called by %p) - %lli/%lli used",
+ __builtin_return_address(0), giPhysAlloc, giPageCount);
+ LEAVE('i', 0);