forked from Bananymous/banan-os
Kernel: Add MMUScope
This disables interrupts and loads specified mmu for the scope it lives in
This commit is contained in:
parent
31ac3260ed
commit
0ff067bdb7
|
@ -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