nstool/lib/libhac/source/KernelVersionEntry.cpp

91 lines
1.9 KiB
C++
Raw Permalink Normal View History

2018-08-07 07:17:51 +00:00
#include <nn/hac/KernelVersionEntry.h>
2018-08-07 07:17:51 +00:00
nn::hac::KernelVersionEntry::KernelVersionEntry() :
mCap(kCapId),
mVerMajor(0),
mVerMinor(0)
{}
2018-08-07 07:17:51 +00:00
nn::hac::KernelVersionEntry::KernelVersionEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(kCapId),
mVerMajor(0),
mVerMinor(0)
{
setKernelCapability(kernel_cap);
}
2018-08-07 07:17:51 +00:00
nn::hac::KernelVersionEntry::KernelVersionEntry(uint16_t major, uint8_t minor) :
mCap(kCapId),
mVerMajor(0),
mVerMinor(0)
{
setVerMajor(major);
setVerMinor(minor);
}
2018-08-07 07:17:51 +00:00
void nn::hac::KernelVersionEntry::operator=(const KernelVersionEntry& other)
{
mVerMajor = other.mVerMajor;
mVerMinor = other.mVerMinor;
updateCapField();
}
2018-08-07 07:17:51 +00:00
bool nn::hac::KernelVersionEntry::operator==(const KernelVersionEntry& other) const
{
return (mVerMajor == other.mVerMajor) \
&& (mVerMinor == other.mVerMinor);
}
2018-08-07 07:17:51 +00:00
bool nn::hac::KernelVersionEntry::operator!=(const KernelVersionEntry& other) const
{
return !(*this == other);
}
2018-08-07 07:17:51 +00:00
const nn::hac::KernelCapabilityEntry & nn::hac::KernelVersionEntry::getKernelCapability() const
{
return mCap;
}
2018-08-07 07:17:51 +00:00
void nn::hac::KernelVersionEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{
if (kernel_cap.getType() != kCapId)
{
throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'KernelVersion'");
}
mCap = kernel_cap;
processCapField();
}
2018-08-07 07:17:51 +00:00
uint16_t nn::hac::KernelVersionEntry::getVerMajor() const
{
return mVerMajor;
}
2018-08-07 07:17:51 +00:00
void nn::hac::KernelVersionEntry::setVerMajor(uint16_t major)
{
if (major > kVerMajorMax)
{
throw fnd::Exception(kModuleName, "Illegal KernelVersionMajor. (range: 0-0x1fff)");
}
mVerMajor = major;
updateCapField();
}
2018-08-07 07:17:51 +00:00
uint8_t nn::hac::KernelVersionEntry::getVerMinor() const
{
return mVerMinor;
}
2018-08-07 07:17:51 +00:00
void nn::hac::KernelVersionEntry::setVerMinor(uint8_t minor)
{
if (minor > kVerMinorMax)
{
throw fnd::Exception(kModuleName, "Illegal KernelVersionMinor. (range: 0-0xf)");
}
mVerMinor = minor;
updateCapField();
}