fix: various fixes
This commit is contained in:
@@ -105,4 +105,21 @@ namespace Memory {
|
||||
Free((void*)(uint64_t)ptr + (0x1000 * n));
|
||||
}
|
||||
}
|
||||
|
||||
void PageFrameAllocator::GetStats(Zenith::MemStats* out) {
|
||||
if (!out) return;
|
||||
Lock.Acquire();
|
||||
uint64_t freeBytes = 0;
|
||||
Page* current = head.next;
|
||||
while (current != nullptr) {
|
||||
freeBytes += current->size;
|
||||
current = current->next;
|
||||
}
|
||||
Lock.Release();
|
||||
|
||||
out->totalBytes = g_section.size;
|
||||
out->freeBytes = freeBytes;
|
||||
out->usedBytes = g_section.size > freeBytes ? g_section.size - freeBytes : 0;
|
||||
out->pageSize = 0x1000;
|
||||
}
|
||||
};
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "Memmap.hpp"
|
||||
#include <Api/Syscall.hpp>
|
||||
|
||||
#include <CppLib/Spinlock.hpp>
|
||||
|
||||
@@ -27,6 +28,8 @@ public:
|
||||
void* ReallocConsecutive(void* ptr, int n);
|
||||
void Free(void* ptr);
|
||||
void Free(void* ptr, int n);
|
||||
|
||||
void GetStats(Zenith::MemStats* out);
|
||||
};
|
||||
|
||||
extern PageFrameAllocator* g_pfa;
|
||||
|
||||
Reference in New Issue
Block a user