ladybird/Kernel/Memory/ScopedAddressSpaceSwitcher.cpp
Timon Kruiper a4534678f9 Kernel: Implement InterruptDisabler using generic Processor functions
Now that the code does not use architectural specific code, it is moved
to the generic Arch directory and the paths are modified accordingly.
2022-06-02 13:14:12 +01:00

27 lines
669 B
C++

/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/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);
}
}