Kernel: Add MMUScope

This disables interrupts and loads specified mmu for the
scope it lives in
This commit is contained in:
Bananymous 2023-05-16 00:25:30 +03:00
parent 6acb86c14b
commit e0a7e242f8
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
#pragma once
#include <kernel/CriticalScope.h>
#include <kernel/Memory/MMU.h>
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;
};
}