1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:17:35 +00:00

Kernel: Reorganize Arch/x86 directory to Arch/x86_64 after i686 removal

No functional change.
This commit is contained in:
Liav A 2022-10-04 13:46:11 +03:00 committed by Andreas Kling
parent 5ff318cf3a
commit 91db482ad3
129 changed files with 482 additions and 1116 deletions

View file

@ -0,0 +1,52 @@
/*
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2018-2022, James Mintram <me@jamesrm.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Singleton.h>
#include <Kernel/Memory/PageDirectory.h>
#include <Kernel/Thread.h>
namespace Kernel::Memory {
struct CR3Map {
SpinlockProtected<IntrusiveRedBlackTree<&PageDirectory::m_tree_node>> map { LockRank::None };
};
static Singleton<CR3Map> s_cr3_map;
void PageDirectory::register_page_directory(PageDirectory* directory)
{
s_cr3_map->map.with([&](auto& map) {
map.insert(directory->cr3(), *directory);
});
}
void PageDirectory::deregister_page_directory(PageDirectory* directory)
{
s_cr3_map->map.with([&](auto& map) {
map.remove(directory->cr3());
});
}
LockRefPtr<PageDirectory> PageDirectory::find_current()
{
return s_cr3_map->map.with([&](auto& map) {
return map.find(read_cr3());
});
}
void activate_kernel_page_directory(PageDirectory const& pgd)
{
write_cr3(pgd.cr3());
}
void activate_page_directory(PageDirectory const& pgd, Thread* current_thread)
{
current_thread->regs().cr3 = pgd.cr3();
write_cr3(pgd.cr3());
}
}