[kernel] Move page mapping into vm_space

vm_space no longer relies on page_manager to map pages during a page
fault. Other changes that come with this commit:

- C++ standard has been changed to C++17
- enum bitfield operators became constexpr
- enum bifrield operators can take a mix of ints and enum arguments
- added page table flags enum instead of relying on ints
- remove page_table::unmap_table and page_table::unmap_pages
This commit is contained in:
2020-09-20 10:52:57 -07:00
parent deb2fa0a09
commit 1b392a0551
7 changed files with 107 additions and 143 deletions

View File

@@ -1,3 +1,4 @@
#include "frame_allocator.h"
#include "log.h"
#include "objects/process.h"
#include "objects/thread.h"
@@ -5,6 +6,8 @@
#include "page_manager.h"
#include "vm_space.h"
extern frame_allocator &g_frame_allocator;
int
vm_space::area::compare(const vm_space::area &o) const
{
@@ -152,17 +155,26 @@ vm_space::handle_fault(uintptr_t addr, fault_type fault)
page_table::iterator it {addr, m_pml4};
// TODO: Handle more fult types
if (fault && fault_type::present)
return false;
if (!it.allowed())
return false;
// TODO: pull this out of PM
page_manager::get()->map_pages(page, 1, m_pml4);
uintptr_t phys = 0;
size_t n = g_frame_allocator.allocate(1, &phys);
kassert(n, "Failed to allocate a new page during page fault");
/* TODO: Tell the VMA if there is one
uintptr_t base = 0;
vm_area *area = get(addr, &base);
*/
page_table::flag flags =
page_table::flag::present |
page_table::flag::write |
page_table::flag::allowed |
(is_kernel()
? page_table::flag::global
: page_table::flag::user);
it.entry(page_table::level::pt) = phys | flags;
return true;
}