Flatten the frame allocator routine
This commit is contained in:
parent
cca8cab1ae
commit
eb419802e2
1 changed files with 13 additions and 10 deletions
|
@ -54,17 +54,20 @@ FrameAllocator::allocate()
|
||||||
const u32 pagesPerBitmap = Bitmap::length;
|
const u32 pagesPerBitmap = Bitmap::length;
|
||||||
for (usize i = 0; i < mNumberOfPages; i++) {
|
for (usize i = 0; i < mNumberOfPages; i++) {
|
||||||
auto bitmap = mBitmap[i];
|
auto bitmap = mBitmap[i];
|
||||||
if (!bitmap.isFull()) {
|
if (bitmap.isFull()) {
|
||||||
kstd::printFormat("Found partially full bitmap %ld -> %02X\n", i, u8(bitmap));
|
continue;
|
||||||
for (usize j = 0; j < pagesPerBitmap; j++) {
|
}
|
||||||
if (!bitmap.isSet(j)) {
|
kstd::printFormat("Found partially full bitmap %ld -> %02X\n", i, u8(bitmap));
|
||||||
bitmap.set(j);
|
for (usize j = 0; j < pagesPerBitmap; j++) {
|
||||||
usize page = i * pagesPerBitmap + j;
|
if (bitmap.isSet(j)) {
|
||||||
void* pageAddress = addressOfPage(page);
|
continue;
|
||||||
kstd::printFormat("Allocating frame for page %ld at address 0x%08lX\n", page, u32(pageAddress));
|
|
||||||
return pageAddress;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
kstd::printFormat("Found unset bit %ld\n", j);
|
||||||
|
bitmap.set(j);
|
||||||
|
usize page = i * pagesPerBitmap + j;
|
||||||
|
void* pageAddress = addressOfPage(page);
|
||||||
|
kstd::printFormat("Allocating frame for page %ld at address 0x%08lX\n", page, u32(pageAddress));
|
||||||
|
return pageAddress;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
kstd::printFormat("Couldn't allocate frame\n");
|
kstd::printFormat("Couldn't allocate frame\n");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue