Add number of pages as attribute of FrameAllocator

This commit is contained in:
Eryn Wells 2016-04-14 01:38:02 -04:00
parent 3d0ee684ba
commit 1e02f3779d
2 changed files with 6 additions and 4 deletions

View file

@ -26,16 +26,16 @@ FrameAllocator::initialize(const StartupInformation& startupInformation)
// Page frame bitmap starts immediately after the kernel.
mBitmap = reinterpret_cast<Bitmap*>(startupInformation.kernelEnd);
const u32 numberOfPages = startupInformation.memorySize() / memory::pageSize;
mNumberOfPages = startupInformation.memorySize() / memory::pageSize;
const u32 pagesPerBitmap = Bitmap::length;
mBitmapSize = numberOfPages / pagesPerBitmap;
if ((numberOfPages % pagesPerBitmap) != 0) {
mBitmapSize = mNumberOfPages / pagesPerBitmap;
if ((mNumberOfPages % pagesPerBitmap) != 0) {
// Add an extra bitmap for the last few pages.
mBitmapSize++;
}
kstd::printFormat("Allocated bitmap of %ld bytes for %ld pages at 0x%08lX\n", mBitmapSize, numberOfPages, u32(mBitmap));
kstd::printFormat("Allocated bitmap of %ld bytes for %ld pages at 0x%08lX\n", mBitmapSize * sizeof(Bitmap), mNumberOfPages, u32(mBitmap));
// TODO: Before modifying this memory, maybe make sure none of the multiboot information is hanging out there?

View file

@ -28,6 +28,8 @@ private:
Bitmap* mBitmap;
/** Size of the bitmap in `sizeof(Bitmap)` units. */
u32 mBitmapSize;
/** Total number of pages. */
u32 mNumberOfPages;
/** Reserve a range of memory. */
void reserveRange(u32 start, u32 length);