mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Updated memory manager
This commit is contained in:
parent
98d58cf655
commit
18f05c6d83
@ -11,6 +11,38 @@ namespace Memory
|
|||||||
return FROM_PAGES(Size);
|
return FROM_PAGES(Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MemMgr::Add(void *Address, size_t Count)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < AllocatedPagesList.size(); i++)
|
||||||
|
{
|
||||||
|
if (AllocatedPagesList[i].Address == Address)
|
||||||
|
{
|
||||||
|
error("Address already exists!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((uintptr_t)Address < (uintptr_t)AllocatedPagesList[i].Address)
|
||||||
|
{
|
||||||
|
if ((uintptr_t)Address + (Count * PAGE_SIZE) > (uintptr_t)AllocatedPagesList[i].Address)
|
||||||
|
{
|
||||||
|
error("Address intersects with an allocated page!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((uintptr_t)AllocatedPagesList[i].Address + (AllocatedPagesList[i].PageCount * PAGE_SIZE) > (uintptr_t)Address)
|
||||||
|
{
|
||||||
|
error("Address intersects with an allocated page!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AllocatedPagesList.push_back({Address, Count});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void *MemMgr::RequestPages(size_t Count)
|
void *MemMgr::RequestPages(size_t Count)
|
||||||
{
|
{
|
||||||
void *Address = KernelAllocator.RequestPages(Count);
|
void *Address = KernelAllocator.RequestPages(Count);
|
@ -648,6 +648,8 @@ namespace Memory
|
|||||||
public:
|
public:
|
||||||
uint64_t GetAllocatedMemorySize();
|
uint64_t GetAllocatedMemorySize();
|
||||||
|
|
||||||
|
bool Add(void *Address, size_t Count);
|
||||||
|
|
||||||
void *RequestPages(size_t Count);
|
void *RequestPages(size_t Count);
|
||||||
void FreePages(void *Address, size_t Count);
|
void FreePages(void *Address, size_t Count);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user