nstool/lib/libhac/source/ThreadInfoEntry.cpp

135 lines
3 KiB
C++
Raw Permalink Normal View History

2018-08-07 07:17:51 +00:00
#include <nn/hac/ThreadInfoEntry.h>
2018-08-07 07:17:51 +00:00
nn::hac::ThreadInfoEntry::ThreadInfoEntry() :
mCap(kCapId),
mMinPriority(kDefaultPriority),
mMaxPriority(kDefaultPriority),
mMinCpuId(kDefaultCpuId),
mMaxCpuId(kDefaultCpuId)
{}
2018-08-07 07:17:51 +00:00
nn::hac::ThreadInfoEntry::ThreadInfoEntry(const KernelCapabilityEntry & kernel_cap) :
mCap(kCapId),
mMinPriority(kDefaultPriority),
mMaxPriority(kDefaultPriority),
mMinCpuId(kDefaultCpuId),
mMaxCpuId(kDefaultCpuId)
{
setKernelCapability(kernel_cap);
}
2018-08-07 07:17:51 +00:00
nn::hac::ThreadInfoEntry::ThreadInfoEntry(uint8_t min_priority, uint8_t max_priority, uint8_t min_core_number, uint8_t max_core_number) :
mCap(kCapId),
mMinPriority(kDefaultPriority),
mMaxPriority(kDefaultPriority),
mMinCpuId(kDefaultCpuId),
mMaxCpuId(kDefaultCpuId)
{
setMinPriority(min_priority);
setMaxPriority(max_priority);
setMinCpuId(min_core_number);
setMaxCpuId(max_core_number);
}
2018-08-07 07:17:51 +00:00
void nn::hac::ThreadInfoEntry::operator=(const ThreadInfoEntry& other)
{
mMinPriority = other.mMinPriority;
mMaxPriority = other.mMaxPriority;
mMinCpuId = other.mMinCpuId;
mMaxCpuId = other.mMaxCpuId;
updateCapField();
}
2018-08-07 07:17:51 +00:00
bool nn::hac::ThreadInfoEntry::operator==(const ThreadInfoEntry& other) const
{
return (mMinPriority == other.mMinPriority) \
&& (mMaxPriority == other.mMaxPriority) \
&& (mMinCpuId == other.mMinCpuId) \
&& (mMaxCpuId == other.mMaxCpuId);
}
2018-08-07 07:17:51 +00:00
bool nn::hac::ThreadInfoEntry::operator!=(const ThreadInfoEntry& other) const
{
return !(*this == other);
}
2018-08-07 07:17:51 +00:00
const nn::hac::KernelCapabilityEntry & nn::hac::ThreadInfoEntry::getKernelCapability() const
{
return mCap;
}
2018-08-07 07:17:51 +00:00
void nn::hac::ThreadInfoEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
{
if (kernel_cap.getType() != kCapId)
{
throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'ThreadInfo'");
}
mCap = kernel_cap;
processCapField();
}
2018-08-07 07:17:51 +00:00
uint8_t nn::hac::ThreadInfoEntry::getMinPriority() const
{
return mMinPriority;
}
2018-08-07 07:17:51 +00:00
void nn::hac::ThreadInfoEntry::setMinPriority(uint8_t priority)
{
if (priority > kMaxVal)
{
throw fnd::Exception(kModuleName, "Illegal MinPriority (range 0-63)");
}
mMinPriority = priority;
updateCapField();
}
2018-08-07 07:17:51 +00:00
uint8_t nn::hac::ThreadInfoEntry::getMaxPriority() const
{
return mMaxPriority;
}
2018-08-07 07:17:51 +00:00
void nn::hac::ThreadInfoEntry::setMaxPriority(uint8_t priority)
{
if (priority > kMaxVal)
{
throw fnd::Exception(kModuleName, "Illegal MaxPriority (range 0-63)");
}
mMaxPriority = priority;
updateCapField();
}
2018-08-07 07:17:51 +00:00
uint8_t nn::hac::ThreadInfoEntry::getMinCpuId() const
{
return mMinCpuId;
}
2018-08-07 07:17:51 +00:00
void nn::hac::ThreadInfoEntry::setMinCpuId(uint8_t core_num)
{
if (core_num > kMaxVal)
{
throw fnd::Exception(kModuleName, "Illegal MinCoreNumber (range 0-63)");
}
mMinCpuId = core_num;
updateCapField();
}
2018-08-07 07:17:51 +00:00
uint8_t nn::hac::ThreadInfoEntry::getMaxCpuId() const
{
return mMaxCpuId;
}
2018-08-07 07:17:51 +00:00
void nn::hac::ThreadInfoEntry::setMaxCpuId(uint8_t core_num)
{
if (core_num > kMaxVal)
{
throw fnd::Exception(kModuleName, "Illegal MaxCoreNumber (range 0-63)");
}
mMaxCpuId = core_num;
updateCapField();
}