Flatten the frame allocator routine

This commit is contained in:
Eryn Wells 2016-04-14 10:42:14 -04:00
parent cca8cab1ae
commit eb419802e2

View file

@ -54,10 +54,15 @@ FrameAllocator::allocate()
const u32 pagesPerBitmap = Bitmap::length;
for (usize i = 0; i < mNumberOfPages; i++) {
auto bitmap = mBitmap[i];
if (!bitmap.isFull()) {
if (bitmap.isFull()) {
continue;
}
kstd::printFormat("Found partially full bitmap %ld -> %02X\n", i, u8(bitmap));
for (usize j = 0; j < pagesPerBitmap; j++) {
if (!bitmap.isSet(j)) {
if (bitmap.isSet(j)) {
continue;
}
kstd::printFormat("Found unset bit %ld\n", j);
bitmap.set(j);
usize page = i * pagesPerBitmap + j;
void* pageAddress = addressOfPage(page);
@ -65,8 +70,6 @@ FrameAllocator::allocate()
return pageAddress;
}
}
}
}
kstd::printFormat("Couldn't allocate frame\n");
return nullptr;
}