From 0ff067bdb7eed3589857dad96443da9010058802 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 16 May 2023 00:25:30 +0300 Subject: [PATCH] Kernel: Add MMUScope This disables interrupts and loads specified mmu for the scope it lives in --- kernel/include/kernel/Memory/MMUScope.h | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 kernel/include/kernel/Memory/MMUScope.h diff --git a/kernel/include/kernel/Memory/MMUScope.h b/kernel/include/kernel/Memory/MMUScope.h new file mode 100644 index 00000000..5ed43cd6 --- /dev/null +++ b/kernel/include/kernel/Memory/MMUScope.h @@ -0,0 +1,30 @@ +#pragma once + +#include +#include + +namespace Kernel +{ + + class MMUScope + { + public: + MMUScope(MMU& mmu) + : m_old(MMU::current()) + , m_temp(mmu) + { + if (&m_old != &m_temp) + m_temp.load(); + } + ~MMUScope() + { + if (&m_old != &m_temp) + m_old.load(); + } + private: + CriticalScope m_scope; + MMU& m_old; + MMU& m_temp; + }; + +} \ No newline at end of file