Rearrange memory manager into two classes.

page_manager and memory_manager are now separate, and are also pre
allocated in the kernel so they don't have to allocate themselves.
This commit is contained in:
Justin C. Miller
2018-04-21 17:34:33 -07:00
parent 4a38a74b16
commit 57abb03deb
6 changed files with 68 additions and 30 deletions

View File

@@ -1,13 +1,23 @@
#include "assert.h"
#include "console.h"
#include "memory_pages.h"
page_manager g_page_manager;
page_manager::page_manager() :
m_free(nullptr),
m_used(nullptr),
m_pool(nullptr)
{
kassert(this == &g_page_manager, "Attempt to create another page_manager.");
}
page_block *
page_block::list_consolidate()
{
page_block *cur = this;
page_block *freed_head = nullptr, **freed = &freed_head;
while (cur) {
for (page_block *cur = this; cur; cur = cur->next) {
page_block *next = cur->next;
if (next && cur->flags == next->flags &&
@@ -21,8 +31,6 @@ page_block::list_consolidate()
freed = &next->next;
continue;
}
cur = next;
}
return freed_head;