request pages
This commit is contained in:
@@ -115,6 +115,16 @@ void PageFrameAllocator::ReservePages(void* address, uint64_t pageCount) {
|
||||
}
|
||||
}
|
||||
|
||||
void* PageFrameAllocator::RequestPage() {
|
||||
for (uint64_t index = 0; index < PageBitmap.Size * 8; index++) {
|
||||
if (PageBitmap[index] == true) continue;
|
||||
|
||||
LockPage((void*)(index * 4096));
|
||||
return (void*)(index * 4096);
|
||||
}
|
||||
|
||||
return NULL; // page frame swap to file
|
||||
}
|
||||
|
||||
uint64_t PageFrameAllocator::GetFreeRAM() {
|
||||
return freeMemory;
|
||||
|
||||
@@ -13,6 +13,7 @@ class PageFrameAllocator {
|
||||
void FreePages(void* address, uint64_t pageCount);
|
||||
void LockPage(void* address);
|
||||
void LockPages(void* address, uint64_t pageCount);
|
||||
void* RequestPage();
|
||||
uint64_t GetFreeRAM();
|
||||
uint64_t GetUsedRAM();
|
||||
uint64_t GetReservedRAM();
|
||||
|
||||
@@ -44,6 +44,13 @@ extern "C" void _start(BootInfo* bootInfo) {
|
||||
newRenderer.Print(0xFF00FFFF, " KB");
|
||||
newRenderer.cursorPosition = {0, newRenderer.cursorPosition.y + 18};
|
||||
|
||||
for (int t = 0; t < 20; t++) {
|
||||
void* address = newAllocator.RequestPage();
|
||||
newRenderer.Print(0xFFFFFFFF, "0x");
|
||||
newRenderer.Print(0xFFFFFFFF, to_hstring((uint64_t)address));
|
||||
newRenderer.cursorPosition = {0, newRenderer.cursorPosition.y + 18};
|
||||
}
|
||||
|
||||
//newRenderer.Print(0xFFFFFFFF, to_string(GetMemorySize(bootInfo->mMap, mMapEntries, bootInfo ->mMapDescriptorSize)));
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user