nstool/lib/libhac/source/MemoryPageEntry.cpp

110 lines
2.1 KiB
C++
Raw Permalink Normal View History

2018-08-07 07:17:51 +00:00
#include <nn/hac/MemoryPageEntry.h>
2018-08-07 07:17:51 +00:00
nn::hac::MemoryPageEntry::MemoryPageEntry() :
mCap(kc::KC_INVALID),
mPage(0),
mFlag(false),
mUseFlag(false)
{}
2018-08-07 07:17:51 +00:00
nn::hac::MemoryPageEntry::MemoryPageEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(kc::KC_INVALID),
mPage(0),
mFlag(false),
mUseFlag(false)
{
setKernelCapability(kernel_cap);
}
2018-08-07 07:17:51 +00:00
nn::hac::MemoryPageEntry::MemoryPageEntry(uint32_t page) :
mCap(kc::KC_INVALID),
mPage(0),
mFlag(false),
mUseFlag(false)
{
setPage(page);
}
2018-08-07 07:17:51 +00:00
nn::hac::MemoryPageEntry::MemoryPageEntry(uint32_t page, bool flag) :
mCap(kc::KC_INVALID),
mPage(0),
mFlag(false),
mUseFlag(true)
{
setPage(page);
setFlag(flag);
}
2018-08-07 07:17:51 +00:00
void nn::hac::MemoryPageEntry::operator=(const MemoryPageEntry& other)
{
mPage = other.mPage;
mFlag = other.mFlag;
mUseFlag = other.mUseFlag;
updateCapField();
}
2018-08-07 07:17:51 +00:00
bool nn::hac::MemoryPageEntry::operator==(const MemoryPageEntry& other) const
{
return (mPage == other.mPage) \
&& (mFlag == other.mFlag) \
&& (mUseFlag == other.mUseFlag);
}
2018-08-07 07:17:51 +00:00
bool nn::hac::MemoryPageEntry::operator!=(const MemoryPageEntry& other) const
{
return !(*this == other);
}
2018-08-07 07:17:51 +00:00
const nn::hac::KernelCapabilityEntry & nn::hac::MemoryPageEntry::getKernelCapability() const
{
return mCap;
}
2018-08-07 07:17:51 +00:00
void nn::hac::MemoryPageEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{
if (kernel_cap.getType() != kc::KC_MEMORY_MAP && kernel_cap.getType() != kc::KC_IO_MEMORY_MAP)
{
throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'MemoryMap' or 'IOMemoryMap");
}
mCap = kernel_cap;
processCapField();
}
2018-08-07 07:17:51 +00:00
uint32_t nn::hac::MemoryPageEntry::getPage() const
{
return mPage;
}
2018-08-07 07:17:51 +00:00
void nn::hac::MemoryPageEntry::setPage(uint32_t page)
{
if (page > kMaxPage)
{
throw fnd::Exception(kModuleName, "Illegal memory page. (range: 0x000000 - 0xFFFFFF)");
}
mPage = page;
updateCapField();
}
2018-08-07 07:17:51 +00:00
bool nn::hac::MemoryPageEntry::getFlag() const
{
return mFlag;
}
2018-08-07 07:17:51 +00:00
void nn::hac::MemoryPageEntry::setFlag(bool flag)
{
mFlag = flag;
updateCapField();
}
2018-08-07 07:17:51 +00:00
bool nn::hac::MemoryPageEntry::isMultiplePages() const
{
return mUseFlag;
}
2018-08-07 07:17:51 +00:00
void nn::hac::MemoryPageEntry::setMapMultiplePages(bool useFlag)
{
mUseFlag = useFlag;
}