nstool/lib/libnx/source/MemoryPageEntry.cpp

92 lines
1.7 KiB
C++
Raw Normal View History

#include <nx/MemoryPageEntry.h>
nx::MemoryPageEntry::MemoryPageEntry() :
mCap(KernelCapability::KC_INVALID),
mPage(0),
mFlag(false),
mUseFlag(false)
{}
nx::MemoryPageEntry::MemoryPageEntry(const KernelCapability & kernel_cap) :
mCap(KernelCapability::KC_INVALID),
mPage(0),
mFlag(false),
mUseFlag(false)
{
setKernelCapability(kernel_cap);
}
2018-03-22 05:26:22 +00:00
nx::MemoryPageEntry::MemoryPageEntry(uint32_t page) :
mCap(KernelCapability::KC_INVALID),
mPage(0),
mFlag(false),
mUseFlag(false)
{
setPage(page);
}
2018-03-22 05:26:22 +00:00
nx::MemoryPageEntry::MemoryPageEntry(uint32_t page, bool flag) :
mCap(KernelCapability::KC_INVALID),
mPage(0),
mFlag(false),
mUseFlag(true)
{
setPage(page);
setFlag(flag);
}
const nx::KernelCapability & nx::MemoryPageEntry::getKernelCapability() const
{
return mCap;
}
void nx::MemoryPageEntry::setKernelCapability(const KernelCapability & kernel_cap)
{
if (kernel_cap.getType() != KernelCapability::KC_MEMORY_MAP && kernel_cap.getType() != KernelCapability::KC_IO_MEMORY_MAP)
{
throw fnd::Exception(kModuleName, "KernelCapability is not type 'MemoryMap' or 'IOMemoryMap");
}
mCap = kernel_cap;
processCapField();
}
2018-03-22 05:26:22 +00:00
uint32_t nx::MemoryPageEntry::getPage() const
{
return mPage;
}
2018-03-22 05:26:22 +00:00
void nx::MemoryPageEntry::setPage(uint32_t page)
{
if (page > kMaxPage)
{
throw fnd::Exception(kModuleName, "Illegal memory page. (range: 0x000000 - 0xFFFFFF)");
}
mPage = page;
updateCapField();
}
bool nx::MemoryPageEntry::getFlag() const
{
return mFlag;
}
void nx::MemoryPageEntry::setFlag(bool flag)
{
mFlag = flag;
updateCapField();
}
bool nx::MemoryPageEntry::isMultiplePages() const
{
return mUseFlag;
}
void nx::MemoryPageEntry::setMapMultiplePages(bool useFlag)
{
mUseFlag = useFlag;
}