Add number of pages as attribute of FrameAllocator
This commit is contained in:
parent
3d0ee684ba
commit
1e02f3779d
2 changed files with 6 additions and 4 deletions
|
@ -26,16 +26,16 @@ FrameAllocator::initialize(const StartupInformation& startupInformation)
|
||||||
// Page frame bitmap starts immediately after the kernel.
|
// Page frame bitmap starts immediately after the kernel.
|
||||||
mBitmap = reinterpret_cast<Bitmap*>(startupInformation.kernelEnd);
|
mBitmap = reinterpret_cast<Bitmap*>(startupInformation.kernelEnd);
|
||||||
|
|
||||||
const u32 numberOfPages = startupInformation.memorySize() / memory::pageSize;
|
mNumberOfPages = startupInformation.memorySize() / memory::pageSize;
|
||||||
const u32 pagesPerBitmap = Bitmap::length;
|
const u32 pagesPerBitmap = Bitmap::length;
|
||||||
|
|
||||||
mBitmapSize = numberOfPages / pagesPerBitmap;
|
mBitmapSize = mNumberOfPages / pagesPerBitmap;
|
||||||
if ((numberOfPages % pagesPerBitmap) != 0) {
|
if ((mNumberOfPages % pagesPerBitmap) != 0) {
|
||||||
// Add an extra bitmap for the last few pages.
|
// Add an extra bitmap for the last few pages.
|
||||||
mBitmapSize++;
|
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?
|
// TODO: Before modifying this memory, maybe make sure none of the multiboot information is hanging out there?
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@ private:
|
||||||
Bitmap* mBitmap;
|
Bitmap* mBitmap;
|
||||||
/** Size of the bitmap in `sizeof(Bitmap)` units. */
|
/** Size of the bitmap in `sizeof(Bitmap)` units. */
|
||||||
u32 mBitmapSize;
|
u32 mBitmapSize;
|
||||||
|
/** Total number of pages. */
|
||||||
|
u32 mNumberOfPages;
|
||||||
|
|
||||||
/** Reserve a range of memory. */
|
/** Reserve a range of memory. */
|
||||||
void reserveRange(u32 start, u32 length);
|
void reserveRange(u32 start, u32 length);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue