2020-03-01 14:38:09 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-03-01 14:38:09 +00:00
|
|
|
*/
|
|
|
|
|
2021-06-21 15:34:09 +00:00
|
|
|
#include <Kernel/Arch/x86/InterruptDisabler.h>
|
2021-08-06 08:45:34 +00:00
|
|
|
#include <Kernel/Memory/MemoryManager.h>
|
|
|
|
#include <Kernel/Memory/ProcessPagingScope.h>
|
2020-03-01 14:38:09 +00:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
ProcessPagingScope::ProcessPagingScope(Process& process)
|
|
|
|
{
|
2021-02-23 19:42:32 +00:00
|
|
|
VERIFY(Thread::current() != nullptr);
|
2020-03-01 14:38:09 +00:00
|
|
|
m_previous_cr3 = read_cr3();
|
2021-09-06 15:11:33 +00:00
|
|
|
MM.enter_process_address_space(process);
|
2020-03-01 14:38:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ProcessPagingScope::~ProcessPagingScope()
|
|
|
|
{
|
|
|
|
InterruptDisabler disabler;
|
2021-06-26 17:57:16 +00:00
|
|
|
Thread::current()->regs().cr3 = m_previous_cr3;
|
2020-03-01 14:38:09 +00:00
|
|
|
write_cr3(m_previous_cr3);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|