mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 07:19:20 +00:00
Implemented memory tracker
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
#ifdef __cplusplus
|
||||
#include <boot/binfo.h>
|
||||
#include <bitmap.hpp>
|
||||
#include <vector.hpp>
|
||||
#include <lock.hpp>
|
||||
#endif // __cplusplus
|
||||
#include <types.h>
|
||||
@ -41,7 +42,7 @@ extern uint64_t _kernel_text_end, _kernel_data_end, _kernel_rodata_end;
|
||||
// To pages
|
||||
#define TO_PAGES(d) ((d) / PAGE_SIZE + 1)
|
||||
// From pages
|
||||
#define FROM_PAGES(d) ((d) * PAGE_SIZE - 1)
|
||||
#define FROM_PAGES(d) ((d)*PAGE_SIZE - 1)
|
||||
|
||||
#define NORMAL_VMA_OFFSET 0xFFFF800000000000
|
||||
#define KERNEL_VMA_OFFSET 0xFFFFFFFF80000000
|
||||
@ -625,6 +626,30 @@ namespace Memory
|
||||
*/
|
||||
~StackGuard();
|
||||
};
|
||||
|
||||
class Tracker
|
||||
{
|
||||
private:
|
||||
Bitmap PageBitmap;
|
||||
PageTable4 *PageTable;
|
||||
|
||||
struct AllocatedPages
|
||||
{
|
||||
void *Address;
|
||||
uint64_t PageCount;
|
||||
};
|
||||
|
||||
Vector<AllocatedPages> AllocatedPagesList;
|
||||
|
||||
public:
|
||||
uint64_t GetAllocatedMemorySize();
|
||||
|
||||
void *RequestPages(uint64_t Count);
|
||||
void FreePages(void *Address, uint64_t Count);
|
||||
|
||||
Tracker(PageTable4 *PageTable);
|
||||
~Tracker();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user