2017-08-05 13:09:50 +00:00
|
|
|
#include <nx/ThreadInfoEntry.h>
|
2017-07-07 07:09:03 +00:00
|
|
|
|
|
|
|
nx::ThreadInfoEntry::ThreadInfoEntry() :
|
|
|
|
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
|
|
|
{}
|
|
|
|
|
|
|
|
nx::ThreadInfoEntry::ThreadInfoEntry(const KernelCapability & kernel_cap) :
|
|
|
|
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-03-22 05:26:22 +00:00
|
|
|
nx::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-06-24 15:01:16 +00:00
|
|
|
void nx::ThreadInfoEntry::operator=(const ThreadInfoEntry& other)
|
|
|
|
{
|
|
|
|
mMinPriority = other.mMinPriority;
|
|
|
|
mMaxPriority = other.mMaxPriority;
|
|
|
|
mMinCpuId = other.mMinCpuId;
|
|
|
|
mMaxCpuId = other.mMaxCpuId;
|
|
|
|
updateCapField();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nx::ThreadInfoEntry::operator==(const ThreadInfoEntry& other) const
|
|
|
|
{
|
|
|
|
return (mMinPriority == other.mMinPriority) \
|
|
|
|
&& (mMaxPriority == other.mMaxPriority) \
|
|
|
|
&& (mMinCpuId == other.mMinCpuId) \
|
|
|
|
&& (mMaxCpuId == other.mMaxCpuId);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool nx::ThreadInfoEntry::operator!=(const ThreadInfoEntry& other) const
|
|
|
|
{
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
|
2017-07-07 07:09:03 +00:00
|
|
|
const nx::KernelCapability & nx::ThreadInfoEntry::getKernelCapability() const
|
|
|
|
{
|
|
|
|
return mCap;
|
|
|
|
}
|
|
|
|
|
|
|
|
void nx::ThreadInfoEntry::setKernelCapability(const KernelCapability & kernel_cap)
|
|
|
|
{
|
|
|
|
if (kernel_cap.getType() != kCapId)
|
|
|
|
{
|
|
|
|
throw fnd::Exception(kModuleName, "KernelCapability is not type 'ThreadInfo'");
|
|
|
|
}
|
|
|
|
|
|
|
|
mCap = kernel_cap;
|
|
|
|
processCapField();
|
|
|
|
}
|
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint8_t nx::ThreadInfoEntry::getMinPriority() const
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
return mMinPriority;
|
|
|
|
}
|
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
void nx::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-03-22 05:26:22 +00:00
|
|
|
uint8_t nx::ThreadInfoEntry::getMaxPriority() const
|
2017-07-07 07:09:03 +00:00
|
|
|
{
|
|
|
|
return mMaxPriority;
|
|
|
|
}
|
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
void nx::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-03-22 05:26:22 +00:00
|
|
|
uint8_t nx::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-03-22 05:26:22 +00:00
|
|
|
void nx::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-03-22 05:26:22 +00:00
|
|
|
uint8_t nx::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-03-22 05:26:22 +00:00
|
|
|
void nx::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();
|
|
|
|
}
|