2018-08-07 15:17:51 +08:00
|
|
|
#include <nn/hac/InteruptEntry.h>
|
2017-07-07 17:09:03 +10:00
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
nn::hac::InteruptEntry::InteruptEntry() :
|
2017-07-07 17:09:03 +10:00
|
|
|
mCap(kCapId),
|
|
|
|
mInterupt{0,0}
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
nn::hac::InteruptEntry::InteruptEntry(const KernelCapabilityEntry & kernel_cap) :
|
2017-07-07 17:09:03 +10:00
|
|
|
mCap(kCapId),
|
|
|
|
mInterupt{ 0,0 }
|
|
|
|
{
|
|
|
|
setKernelCapability(kernel_cap);
|
|
|
|
}
|
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
nn::hac::InteruptEntry::InteruptEntry(uint32_t interupt0, uint32_t interupt1) :
|
2017-07-07 17:09:03 +10:00
|
|
|
mCap(kCapId),
|
|
|
|
mInterupt{ 0,0 }
|
|
|
|
{
|
2017-07-13 00:02:10 +10:00
|
|
|
setInterupt(0, interupt0);
|
|
|
|
setInterupt(1, interupt1);
|
2017-07-07 17:09:03 +10:00
|
|
|
}
|
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
void nn::hac::InteruptEntry::operator=(const InteruptEntry& other)
|
2018-06-24 23:01:16 +08:00
|
|
|
{
|
|
|
|
mInterupt[0] = other.mInterupt[0];
|
|
|
|
mInterupt[1] = other.mInterupt[1];
|
|
|
|
updateCapField();
|
|
|
|
}
|
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
bool nn::hac::InteruptEntry::operator==(const InteruptEntry& other) const
|
2018-06-24 23:01:16 +08:00
|
|
|
{
|
|
|
|
return (mInterupt[0] == other.mInterupt[0]) \
|
|
|
|
&& (mInterupt[1] == other.mInterupt[1]);
|
|
|
|
}
|
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
bool nn::hac::InteruptEntry::operator!=(const InteruptEntry& other) const
|
2018-06-24 23:01:16 +08:00
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
const nn::hac::KernelCapabilityEntry & nn::hac::InteruptEntry::getKernelCapability() const
|
2017-07-07 17:09:03 +10:00
|
|
|
{
|
|
|
|
return mCap;
|
|
|
|
}
|
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
void nn::hac::InteruptEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
|
2017-07-07 17:09:03 +10:00
|
|
|
{
|
|
|
|
if (kernel_cap.getType() != kCapId)
|
|
|
|
{
|
2018-06-29 12:24:39 +08:00
|
|
|
throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'EnableInterupts'");
|
2017-07-07 17:09:03 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
mCap = kernel_cap;
|
|
|
|
processCapField();
|
|
|
|
}
|
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
uint32_t nn::hac::InteruptEntry::operator[](size_t index) const
|
2017-07-07 17:09:03 +10:00
|
|
|
{
|
2017-07-13 00:02:10 +10:00
|
|
|
return getInterupt(index);
|
2017-07-07 17:09:03 +10:00
|
|
|
}
|
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
uint32_t nn::hac::InteruptEntry::getInterupt(size_t index) const
|
2017-07-07 17:09:03 +10:00
|
|
|
{
|
2017-07-13 00:02:10 +10:00
|
|
|
return mInterupt[index % kInteruptNum];
|
2017-07-07 17:09:03 +10:00
|
|
|
}
|
|
|
|
|
2018-08-07 15:17:51 +08:00
|
|
|
void nn::hac::InteruptEntry::setInterupt(size_t index, uint32_t interupt)
|
2017-07-07 17:09:03 +10:00
|
|
|
{
|
|
|
|
if (interupt > kInteruptMax)
|
|
|
|
{
|
|
|
|
throw fnd::Exception(kModuleName, "Illegal interupt value.");
|
|
|
|
}
|
|
|
|
|
2017-07-13 00:02:10 +10:00
|
|
|
mInterupt[index % kInteruptNum] = interupt;
|
2017-07-07 17:09:03 +10:00
|
|
|
updateCapField();
|
2017-07-13 00:02:10 +10:00
|
|
|
}
|