blob: db3bee8026d345d7df6dce850b0738ef689a12d5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
/*
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Panic.h>
#include <Kernel/VM/MemoryManager.h>
#include <Kernel/VM/ProcessPagingScope.h>
namespace Kernel {
ProcessPagingScope::ProcessPagingScope(Process& process)
{
VERIFY(Thread::current() != nullptr);
m_previous_cr3 = read_cr3();
MM.enter_process_paging_scope(process);
}
ProcessPagingScope::~ProcessPagingScope()
{
InterruptDisabler disabler;
#if ARCH(I386)
Thread::current()->tss().cr3 = m_previous_cr3;
#else
PANIC("ProcessPagingScope::~ProcessPagingScope() not implemented");
#endif
write_cr3(m_previous_cr3);
}
}
|