mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
0223faf6f4
SonarCloud flagged this "Code Smell", where we are accessing these static methods as if they are instance methods. While it is technically possible, it is very confusing to read when you realize they are static functions.
27 lines
673 B
C++
27 lines
673 B
C++
/*
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <Kernel/Arch/x86/InterruptDisabler.h>
|
|
#include <Kernel/Memory/MemoryManager.h>
|
|
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>
|
|
|
|
namespace Kernel {
|
|
|
|
ScopedAddressSpaceSwitcher::ScopedAddressSpaceSwitcher(Process& process)
|
|
{
|
|
VERIFY(Thread::current() != nullptr);
|
|
m_previous_cr3 = read_cr3();
|
|
Memory::MemoryManager::enter_process_address_space(process);
|
|
}
|
|
|
|
ScopedAddressSpaceSwitcher::~ScopedAddressSpaceSwitcher()
|
|
{
|
|
InterruptDisabler disabler;
|
|
Thread::current()->regs().cr3 = m_previous_cr3;
|
|
write_cr3(m_previous_cr3);
|
|
}
|
|
|
|
}
|