+ base = (tPAddr)&gKernelBase >> 12;
+ size = firstFreePage >> 12;
+ memset( &gaMainBitmap[base / 64], -1, size/8 );
+ if( size & 7 ) {
+ Uint64 val = -1L << (size & 7);
+ val <<= (size/8)&7;
+ gaMainBitmap[base / 64] |= val;
+ }
+
+ // Free the unused static allocs
+ for( i = 0; i < NUM_STATIC_ALLOC; i++) {
+ if(gaiStaticAllocPages[i] != 0)
+ continue;
+ gaMainBitmap[ gaiStaticAllocPages[i] >> (12+6) ]
+ &= ~(1L << ((gaiStaticAllocPages[i]>>12)&63));
+ }
+
+ // Fill the super bitmap
+ LOG("Filling super bitmap");
+ memset(gaSuperBitmap, 0, superPages<<12);
+ for( base = 0; base < (size+63)/64; base ++)
+ {
+ if( gaMainBitmap[ base ] + 1 == 0 )
+ gaSuperBitmap[ base/64 ] |= 1L << (base&63);
+ }
+
+ // Set free page counts
+ for( base = 1; base < giMaxPhysPage; base ++ )
+ {
+ int rangeID;
+ // Skip allocated
+ if( gaMainBitmap[ base >> 6 ] & (1L << (base&63)) ) continue;
+
+ // Get range ID
+ rangeID = MM_int_GetRangeID( base << 12 );
+
+ // Increment free page count
+ giPhysRangeFree[ rangeID ] ++;
+
+ // Check for first free page in range
+ if(giPhysRangeFirst[ rangeID ] == 0)
+ giPhysRangeFirst[ rangeID ] = base;
+ // Set last (when the last free page is reached, this won't be
+ // updated anymore, hence will be correct)
+ giPhysRangeLast[ rangeID ] = base;
+ }
+
+ LEAVE('-');