2018-08-07 07:17:51 +00:00
|
|
|
#include <nn/hac/ThreadInfoEntry.h>
|
2017-07-07 07:09:03 +00:00
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
nn::hac::ThreadInfoEntry::ThreadInfoEntry() :
|
2017-07-07 07:09:03 +00:00
|
|
|
mCap(kCapId),
|
|
|
|
mMinPriority(kDefaultPriority),
|
|
|
|
mMaxPriority(kDefaultPriority),
|
2017-07-17 08:21:39 +00:00
|
|
|
mMinCpuId(kDefaultCpuId),
|
|
|
|
mMaxCpuId(kDefaultCpuId)
|
2017-07-07 07:09:03 +00:00
|
|
|
{}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
nn::hac::ThreadInfoEntry::ThreadInfoEntry(const KernelCapabilityEntry & kernel_cap) :
|
2017-07-07 07:09:03 +00:00
|
|
|
mCap(kCapId),
|
|
|
|
mMinPriority(kDefaultPriority),
|
|
|
|
mMaxPriority(kDefaultPriority),
|
2017-07-17 08:21:39 +00:00
|
|
|
mMinCpuId(kDefaultCpuId),
|
|
|
|
mMaxCpuId(kDefaultCpuId)
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
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) :
|
2017-07-07 07:09:03 +00:00
|
|
|
mCap(kCapId),
|
|
|
|
mMinPriority(kDefaultPriority),
|
|
|
|
mMaxPriority(kDefaultPriority),
|
2017-07-17 08:21:39 +00:00
|
|
|
mMinCpuId(kDefaultCpuId),
|
|
|
|
mMaxCpuId(kDefaultCpuId)
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
setMinPriority(min_priority);
|
|
|
|
setMaxPriority(max_priority);
|
2017-07-17 08:21:39 +00:00
|
|
|
setMinCpuId(min_core_number);
|
|
|
|
setMaxCpuId(max_core_number);
|
2017-07-07 07:09:03 +00:00
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ThreadInfoEntry::operator=(const ThreadInfoEntry& other)
|
2018-06-24 15:01:16 +00:00
|
|
|
{
|
|
|
|
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
|
2018-06-24 15:01:16 +00:00
|
|
|
{
|
|
|
|
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
|
2018-06-24 15:01:16 +00:00
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
const nn::hac::KernelCapabilityEntry & nn::hac::ThreadInfoEntry::getKernelCapability() const
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
return mCap;
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ThreadInfoEntry::setKernelCapability(const KernelCapabilityEntry & kernel_cap)
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
if (kernel_cap.getType() != kCapId)
|
|
|
|
{
|
2018-06-29 04:24:39 +00:00
|
|
|
throw fnd::Exception(kModuleName, "KernelCapabilityEntry is not type 'ThreadInfo'");
|
2017-07-07 07:09:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
mCap = kernel_cap;
|
|
|
|
processCapField();
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
uint8_t nn::hac::ThreadInfoEntry::getMinPriority() const
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
return mMinPriority;
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ThreadInfoEntry::setMinPriority(uint8_t priority)
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
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
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
return mMaxPriority;
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ThreadInfoEntry::setMaxPriority(uint8_t priority)
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
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
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
2017-07-17 08:21:39 +00:00
|
|
|
return mMinCpuId;
|
2017-07-07 07:09:03 +00:00
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ThreadInfoEntry::setMinCpuId(uint8_t core_num)
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
if (core_num > kMaxVal)
|
|
|
|
{
|
|
|
|
throw fnd::Exception(kModuleName, "Illegal MinCoreNumber (range 0-63)");
|
|
|
|
}
|
|
|
|
|
2017-07-17 08:21:39 +00:00
|
|
|
mMinCpuId = core_num;
|
2017-07-07 07:09:03 +00:00
|
|
|
updateCapField();
|
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
uint8_t nn::hac::ThreadInfoEntry::getMaxCpuId() const
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
2017-07-17 08:21:39 +00:00
|
|
|
return mMaxCpuId;
|
2017-07-07 07:09:03 +00:00
|
|
|
}
|
|
|
|
|
2018-08-07 07:17:51 +00:00
|
|
|
void nn::hac::ThreadInfoEntry::setMaxCpuId(uint8_t core_num)
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
if (core_num > kMaxVal)
|
|
|
|
{
|
|
|
|
throw fnd::Exception(kModuleName, "Illegal MaxCoreNumber (range 0-63)");
|
|
|
|
}
|
|
|
|
|
2017-07-17 08:21:39 +00:00
|
|
|
mMaxCpuId = core_num;
|
2017-07-07 07:09:03 +00:00
|
|
|
updateCapField();
|
|
|
|
}
|