request pages

This commit is contained in:
2026-01-28 18:26:24 +11:00
parent 5b508f4a48
commit 012489a658
9 changed files with 19 additions and 1 deletions

Binary file not shown.

View File

@@ -59,4 +59,4 @@ buildimg:
mcopy -i $(BUILDDIR)/$(OSNAME).img $(BUILDDIR)/zap-light18.psf ::
run:
qemu-system-x86_64 -drive file=$(BUILDDIR)/$(OSNAME).img -m 256M -cpu qemu64 -drive if=pflash,format=raw,unit=0,file="$(OVMFDIR)/OVMF_CODE-pure-efi.fd",readonly=on -drive if=pflash,format=raw,unit=1,file="$(OVMFDIR)/OVMF_VARS-pure-efi.fd" -net none
qemu-system-x86_64 -drive file=$(BUILDDIR)/$(OSNAME).img -m 64M -cpu qemu64 -drive if=pflash,format=raw,unit=0,file="$(OVMFDIR)/OVMF_CODE-pure-efi.fd",readonly=on -drive if=pflash,format=raw,unit=1,file="$(OVMFDIR)/OVMF_VARS-pure-efi.fd" -net none

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -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;

View File

@@ -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();

View File

@@ -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)));