Kernel: Rename MMU to PageTable
This is more descriptive name for what it actually represents
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <kernel/Memory/Heap.h>
|
||||
#include <kernel/Memory/MMU.h>
|
||||
#include <kernel/Memory/PageTable.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
@@ -12,10 +12,10 @@ namespace Kernel
|
||||
BAN_NON_MOVABLE(FixedWidthAllocator);
|
||||
|
||||
public:
|
||||
FixedWidthAllocator(MMU&, uint32_t);
|
||||
FixedWidthAllocator(PageTable&, uint32_t);
|
||||
~FixedWidthAllocator();
|
||||
|
||||
BAN::ErrorOr<FixedWidthAllocator*> clone(MMU&);
|
||||
BAN::ErrorOr<FixedWidthAllocator*> clone(PageTable&);
|
||||
|
||||
vaddr_t allocate();
|
||||
bool deallocate(vaddr_t);
|
||||
@@ -44,7 +44,7 @@ namespace Kernel
|
||||
private:
|
||||
static constexpr uint32_t m_min_allocation_size = 16;
|
||||
|
||||
MMU& m_mmu;
|
||||
PageTable& m_page_table;
|
||||
const uint32_t m_allocation_size;
|
||||
|
||||
vaddr_t m_nodes_page { 0 };
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <BAN/LinkedList.h>
|
||||
#include <kernel/Memory/Heap.h>
|
||||
#include <kernel/Memory/MMU.h>
|
||||
#include <kernel/Memory/PageTable.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
@@ -13,13 +13,13 @@ namespace Kernel
|
||||
BAN_NON_MOVABLE(GeneralAllocator);
|
||||
|
||||
public:
|
||||
GeneralAllocator(MMU&);
|
||||
GeneralAllocator(PageTable&);
|
||||
~GeneralAllocator();
|
||||
|
||||
vaddr_t allocate(size_t);
|
||||
bool deallocate(vaddr_t);
|
||||
|
||||
BAN::ErrorOr<GeneralAllocator*> clone(MMU&);
|
||||
BAN::ErrorOr<GeneralAllocator*> clone(PageTable&);
|
||||
|
||||
private:
|
||||
struct Allocation
|
||||
@@ -29,7 +29,7 @@ namespace Kernel
|
||||
};
|
||||
|
||||
private:
|
||||
MMU& m_mmu;
|
||||
PageTable& m_page_table;
|
||||
BAN::LinkedList<Allocation> m_allocations;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <BAN/Errors.h>
|
||||
#include <kernel/Memory/Types.h>
|
||||
#include <kernel/SpinLock.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
class MMU
|
||||
class PageTable
|
||||
{
|
||||
public:
|
||||
using flags_t = uint8_t;
|
||||
@@ -19,12 +20,12 @@ namespace Kernel
|
||||
|
||||
public:
|
||||
static void initialize();
|
||||
static MMU& kernel();
|
||||
|
||||
static MMU& current();
|
||||
static PageTable& kernel();
|
||||
static PageTable& current();
|
||||
|
||||
MMU();
|
||||
~MMU();
|
||||
static BAN::ErrorOr<PageTable*> create_userspace();
|
||||
~PageTable();
|
||||
|
||||
void identity_map_page(paddr_t, flags_t);
|
||||
void identity_map_range(paddr_t, size_t bytes, flags_t);
|
||||
@@ -50,6 +51,7 @@ namespace Kernel
|
||||
void unlock() const { m_lock.unlock(); }
|
||||
|
||||
private:
|
||||
PageTable() = default;
|
||||
uint64_t get_page_data(vaddr_t) const;
|
||||
void initialize_kernel();
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
#pragma once
|
||||
|
||||
#include <kernel/CriticalScope.h>
|
||||
#include <kernel/Memory/MMU.h>
|
||||
#include <kernel/Memory/PageTable.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
class MMUScope
|
||||
class PageTableScope
|
||||
{
|
||||
public:
|
||||
MMUScope(MMU& mmu)
|
||||
: m_old(MMU::current())
|
||||
, m_temp(mmu)
|
||||
PageTableScope(PageTable& page_table)
|
||||
: m_old(PageTable::current())
|
||||
, m_temp(page_table)
|
||||
{
|
||||
if (&m_old != &m_temp)
|
||||
m_temp.load();
|
||||
}
|
||||
~MMUScope()
|
||||
~PageTableScope()
|
||||
{
|
||||
if (&m_old != &m_temp)
|
||||
m_old.load();
|
||||
}
|
||||
private:
|
||||
CriticalScope m_scope;
|
||||
MMU& m_old;
|
||||
MMU& m_temp;
|
||||
PageTable& m_old;
|
||||
PageTable& m_temp;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
#include <BAN/Vector.h>
|
||||
#include <BAN/NoCopyMove.h>
|
||||
#include <kernel/Memory/MMU.h>
|
||||
#include <kernel/Memory/Types.h>
|
||||
#include <kernel/Memory/PageTable.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
@@ -14,21 +13,21 @@ namespace Kernel
|
||||
BAN_NON_MOVABLE(VirtualRange);
|
||||
|
||||
public:
|
||||
static VirtualRange* create(MMU&, vaddr_t, size_t, uint8_t flags);
|
||||
static VirtualRange* create(PageTable&, vaddr_t, size_t, uint8_t flags);
|
||||
static VirtualRange* create_kmalloc(size_t);
|
||||
~VirtualRange();
|
||||
|
||||
VirtualRange* clone(MMU& new_mmu);
|
||||
VirtualRange* clone(PageTable&);
|
||||
|
||||
vaddr_t vaddr() const { return m_vaddr; }
|
||||
size_t size() const { return m_size; }
|
||||
uint8_t flags() const { return m_flags; }
|
||||
|
||||
private:
|
||||
VirtualRange(MMU&);
|
||||
VirtualRange(PageTable&);
|
||||
|
||||
private:
|
||||
MMU& m_mmu;
|
||||
PageTable& m_page_table;
|
||||
vaddr_t m_vaddr { 0 };
|
||||
size_t m_size { 0 };
|
||||
uint8_t m_flags { 0 };
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <kernel/Memory/FixedWidthAllocator.h>
|
||||
#include <kernel/Memory/GeneralAllocator.h>
|
||||
#include <kernel/Memory/Heap.h>
|
||||
#include <kernel/Memory/MMU.h>
|
||||
#include <kernel/Memory/VirtualRange.h>
|
||||
#include <kernel/SpinLock.h>
|
||||
#include <kernel/Terminal/TTY.h>
|
||||
@@ -70,7 +69,7 @@ namespace Kernel
|
||||
|
||||
static Process& current() { return Thread::current().process(); }
|
||||
|
||||
MMU& mmu() { return m_mmu ? *m_mmu : MMU::kernel(); }
|
||||
PageTable& page_table() { return m_page_table ? *m_page_table : PageTable::kernel(); }
|
||||
|
||||
private:
|
||||
Process(pid_t);
|
||||
@@ -104,7 +103,7 @@ namespace Kernel
|
||||
BAN::Vector<FixedWidthAllocator*> m_fixed_width_allocators;
|
||||
GeneralAllocator* m_general_allocator;
|
||||
|
||||
MMU* m_mmu { nullptr };
|
||||
PageTable* m_page_table { nullptr };
|
||||
TTY* m_tty { nullptr };
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user