Kernel: Add MMUScope
This disables interrupts and loads specified mmu for the scope it lives in
This commit is contained in:
parent
6acb86c14b
commit
e0a7e242f8
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in New Issue