mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:37:34 +00:00
Kernel: Move Memory/PageDirectory.{cpp,h} to arch-specific directory
The handling of page tables is very architecture specific, so belongs in the Arch directory. Some parts were already architecture-specific, however this commit moves the rest of the PageDirectory class into the Arch directory. While we're here the aarch64/PageDirectory.{h,cpp} files are updated to be aarch64 specific, by renaming some members and removing x86_64 specific code.
This commit is contained in:
parent
55d756a813
commit
697c5ca5e5
23 changed files with 304 additions and 228 deletions
|
@ -6,12 +6,19 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/AtomicRefCounted.h>
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/IntrusiveRedBlackTree.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Forward.h>
|
||||
#include <Kernel/Locking/LockRank.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
#include <Kernel/Memory/PhysicalPage.h>
|
||||
#include <Kernel/PhysicalAddress.h>
|
||||
|
||||
namespace Kernel {
|
||||
namespace Kernel::Memory {
|
||||
|
||||
class PageDirectoryEntry {
|
||||
public:
|
||||
|
@ -151,4 +158,51 @@ public:
|
|||
u64 raw[512];
|
||||
};
|
||||
|
||||
class PageDirectory final : public AtomicRefCounted<PageDirectory> {
|
||||
friend class MemoryManager;
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullLockRefPtr<PageDirectory>> try_create_for_userspace();
|
||||
static NonnullLockRefPtr<PageDirectory> must_create_kernel_page_directory();
|
||||
static LockRefPtr<PageDirectory> find_current();
|
||||
|
||||
~PageDirectory();
|
||||
|
||||
void allocate_kernel_directory();
|
||||
|
||||
FlatPtr cr3() const
|
||||
{
|
||||
return m_pml4t->paddr().get();
|
||||
}
|
||||
|
||||
bool is_cr3_initialized() const
|
||||
{
|
||||
return m_pml4t;
|
||||
}
|
||||
|
||||
AddressSpace* address_space() { return m_space; }
|
||||
AddressSpace const* address_space() const { return m_space; }
|
||||
|
||||
void set_space(Badge<AddressSpace>, AddressSpace& space) { m_space = &space; }
|
||||
|
||||
RecursiveSpinlock<LockRank::None>& get_lock() { return m_lock; }
|
||||
|
||||
// This has to be public to let the global singleton access the member pointer
|
||||
IntrusiveRedBlackTreeNode<FlatPtr, PageDirectory, RawPtr<PageDirectory>> m_tree_node;
|
||||
|
||||
private:
|
||||
PageDirectory();
|
||||
static void register_page_directory(PageDirectory* directory);
|
||||
static void deregister_page_directory(PageDirectory* directory);
|
||||
|
||||
AddressSpace* m_space { nullptr };
|
||||
RefPtr<PhysicalPage> m_pml4t;
|
||||
RefPtr<PhysicalPage> m_directory_table;
|
||||
RefPtr<PhysicalPage> m_directory_pages[512];
|
||||
RecursiveSpinlock<LockRank::None> m_lock {};
|
||||
};
|
||||
|
||||
void activate_kernel_page_directory(PageDirectory const& pgd);
|
||||
void activate_page_directory(PageDirectory const& pgd, Thread* current_thread);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue