That goddamn auto&

Setting frames works now!
This commit is contained in:
Eryn Wells 2016-04-16 01:26:02 -04:00
parent 1daa3df74e
commit f641b5fc8d
2 changed files with 7 additions and 9 deletions

View file

@ -3,7 +3,8 @@
* Eryn Wells <eryn@erynwells.me> * Eryn Wells <eryn@erynwells.me>
*/ */
/** /**
* An object to tracks and allocate physical page frames. * This file deals with page frames, chunks of physical memory of `pageSize`
* length that can be filled with pages.
*/ */
#include "Kernel.hh" #include "Kernel.hh"
@ -53,16 +54,14 @@ FrameAllocator::allocate()
// Find the first bitmap with a free slot, and the first free slot, and return it. // Find the first bitmap with a free slot, and the first free slot, and return it.
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()) {
continue; continue;
} }
kstd::printFormat("Found partially full bitmap %ld -> %02X\n", i, u8(bitmap));
for (usize j = 0; j < pagesPerBitmap; j++) { for (usize j = 0; j < pagesPerBitmap; j++) {
if (bitmap.isSet(j)) { if (bitmap.isSet(j)) {
continue; continue;
} }
kstd::printFormat("Found unset bit %ld\n", j);
bitmap.set(j); bitmap.set(j);
usize page = i * pagesPerBitmap + j; usize page = i * pagesPerBitmap + j;
void* pageAddress = addressOfPage(page); void* pageAddress = addressOfPage(page);

View file

@ -3,7 +3,8 @@
* Eryn Wells <eryn@erynwells.me> * Eryn Wells <eryn@erynwells.me>
*/ */
/** /**
* An object to tracks and allocate physical page frames. * This file deals with page frames, chunks of physical memory of `pageSize`
* length that can be filled with pages.
*/ */
#ifndef __MEMORY_FRAMEALLOCATOR_HH__ #ifndef __MEMORY_FRAMEALLOCATOR_HH__
@ -22,10 +23,8 @@ struct FrameAllocator
void initialize(const StartupInformation& startupInformation); void initialize(const StartupInformation& startupInformation);
/** /**
* Allocate a page. Find a free page, mark it in use, and return its * Allocate a page frame. Find a free page frame, mark it in use, and return
* address. * its address.
*
* @return The base address of a free page, or 0 if no page could be allocated.
*/ */
void* allocate(); void* allocate();