remove bitmap

This commit is contained in:
2026-01-12 14:58:23 +01:00
parent c0c4b64ef9
commit 30a48d25d2
3 changed files with 20 additions and 17 deletions

View File

@@ -5,10 +5,12 @@
class PageFrame { class PageFrame {
private: private:
public:
uintptr_t address; uintptr_t address;
uintptr_t mapped_address; uintptr_t mapped_address;
public: bool available;
PageFrame* queue_link; PageFrame* queue_link;
PageFrame(){};
PageFrame(uintptr_t a):address(a){}; PageFrame(uintptr_t a):address(a){};
uintptr_t getAddr(){return address;}; uintptr_t getAddr(){return address;};
uintptr_t getVirtualAddr(){return address;}; uintptr_t getVirtualAddr(){return address;};

View File

@@ -8,9 +8,8 @@
#include "../arch/lapic.h" #include "../arch/lapic.h"
#include "../arch/apic.h" #include "../arch/apic.h"
uint8_t PageFrameAllocator::bitmap[4294967296 / 4096 / 8]; //uint8_t PageFrameAllocator::bitmap[4294967296 / 4096 / 8];
PageFrame PageFrameAllocator::PageFrames[4294967296 / 4096];
//PageFrame PageFrameList[4294967296 / 4096];
void mark_pageframes(uintptr_t start, uintptr_t end, bool available){ void mark_pageframes(uintptr_t start, uintptr_t end, bool available){
DBG << "start: " << hex << start << " end: " << end; DBG << "start: " << hex << start << " end: " << end;
@@ -20,10 +19,12 @@ void mark_pageframes(uintptr_t start, uintptr_t end, bool available){
for(uint64_t i = start; i < end; i += 4096){ for(uint64_t i = start; i < end; i += 4096){
uint64_t pg = i/4096; uint64_t pg = i/4096;
if(available)
PageFrameAllocator::bitmap[pg/8] |= (1 << pg%8); PageFrameAllocator::PageFrames[pg].available = available;
else //if(available)
PageFrameAllocator::bitmap[pg/8] &= ~(1 << pg%8); // PageFrameAllocator::bitmap[pg/8] |= (1 << pg%8);
//else
// PageFrameAllocator::bitmap[pg/8] &= ~(1 << pg%8);
} }
} }
@@ -83,8 +84,9 @@ void PageFrameAllocator::stats(){
} }
uint64_t pages_available = 0; uint64_t pages_available = 0;
for(uint64_t i=0; i<sizeof(bitmap)*8;i++){ for(uint64_t i=0; i<(sizeof(PageFrames)/sizeof(PageFrames[0]));i++){
if(bitmap[i/8] & (1<<i%8)) if(PageFrames[i].available)
//if(bitmap[i/8] & (1<<i%8))
pages_available++; pages_available++;
} }
for(uint64_t i=0; i < 0x2000000/4096/8; i++){ for(uint64_t i=0; i < 0x2000000/4096/8; i++){
@@ -92,17 +94,15 @@ void PageFrameAllocator::stats(){
DBG << endl << hex << i * 8 * 4096 << " " << flush; DBG << endl << hex << i * 8 * 4096 << " " << flush;
int x,y; int x,y;
dout.getPos(x,y); dout.getPos(x,y);
for(uint8_t i=x; i<10; i++){ for(uint8_t j=x; j<10; j++){
DBG<<" "; DBG<<" ";
} }
} }
if(bitmap[i] == 0xff) if(PageFrames[i].available)
DBG << '#'; DBG << '#';
else if(bitmap[i] == 0x00)
DBG << '.';
else else
DBG << '/'; DBG << '.';
} }
DBG << "\npages available: " << dec << pages_available << endl; DBG << "\npages available: " << dec << pages_available << endl;
} }
@@ -122,7 +122,7 @@ PageFrame* PageFrameAllocator::alloc(bool kernel){
uint64_t free_pageframe=0; uint64_t free_pageframe=0;
//TODO make this more efficent //TODO make this more efficent
for(uint64_t i=search_start/4096; i < search_end/4096; i++){ for(uint64_t i=search_start/4096; i < search_end/4096; i++){
if(bitmap[i/8]&(1<<i%8)){ if(PageFrames[i].available){
free_pageframe = i; free_pageframe = i;
break; break;
} }
@@ -132,7 +132,7 @@ PageFrame* PageFrameAllocator::alloc(bool kernel){
return 0; return 0;
mark_pageframes(free_pageframe*4096, free_pageframe*4096, false); mark_pageframes(free_pageframe*4096, free_pageframe*4096, false);
return 0; return &PageFrames[free_pageframe];
} }
void PageFrameAllocator::free(PageFrame* frame){ void PageFrameAllocator::free(PageFrame* frame){

View File

@@ -7,6 +7,7 @@
namespace PageFrameAllocator { namespace PageFrameAllocator {
extern uint8_t bitmap[4294967296 / 4096 / 8]; extern uint8_t bitmap[4294967296 / 4096 / 8];
extern PageFrame PageFrames[4294967296 / 4096];
//Queue<PageFrame> PageFrameList; //Queue<PageFrame> PageFrameList;
void init (); void init ();