2017-07-07 07:09:03 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <fnd/types.h>
|
|
|
|
#include <nx/KernelCapability.h>
|
|
|
|
|
|
|
|
namespace nx
|
|
|
|
{
|
|
|
|
class ThreadInfoEntry
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ThreadInfoEntry();
|
|
|
|
ThreadInfoEntry(const KernelCapability& kernel_cap);
|
2018-03-22 05:26:22 +00:00
|
|
|
ThreadInfoEntry(uint8_t min_priority, uint8_t max_priority, uint8_t min_cpu_id, uint8_t max_cpu_id);
|
2017-07-07 07:09:03 +00:00
|
|
|
|
|
|
|
// kernel capability
|
|
|
|
const KernelCapability& getKernelCapability() const;
|
|
|
|
void setKernelCapability(const KernelCapability& kernel_cap);
|
|
|
|
|
|
|
|
// variables
|
2018-03-22 05:26:22 +00:00
|
|
|
uint8_t getMinPriority() const;
|
|
|
|
void setMinPriority(uint8_t priority);
|
|
|
|
uint8_t getMaxPriority() const;
|
|
|
|
void setMaxPriority(uint8_t priority);
|
|
|
|
uint8_t getMinCpuId() const;
|
|
|
|
void setMinCpuId(uint8_t cpu_id);
|
|
|
|
uint8_t getMaxCpuId() const;
|
|
|
|
void setMaxCpuId(uint8_t cpu_id);
|
2017-07-07 07:09:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const std::string kModuleName = "THREAD_INFO_ENTRY";
|
|
|
|
static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_THREAD_INFO;
|
2018-03-22 05:26:22 +00:00
|
|
|
static const uint8_t kValBits = 6;
|
|
|
|
static const uint8_t kMaxVal = BIT(kValBits)-1;
|
|
|
|
static const uint8_t kDefaultPriority = 6;
|
|
|
|
static const uint8_t kDefaultCpuId = 8;
|
2017-07-07 07:09:03 +00:00
|
|
|
|
|
|
|
KernelCapability mCap;
|
2018-03-22 05:26:22 +00:00
|
|
|
uint8_t mMinPriority;
|
|
|
|
uint8_t mMaxPriority;
|
|
|
|
uint8_t mMinCpuId;
|
|
|
|
uint8_t mMaxCpuId;
|
2017-07-07 07:09:03 +00:00
|
|
|
|
|
|
|
inline void updateCapField()
|
|
|
|
{
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t field = 0;
|
|
|
|
field |= (uint32_t)(mMinPriority & kMaxVal) << (kValBits * 0);
|
|
|
|
field |= (uint32_t)(mMaxPriority & kMaxVal) << (kValBits * 1);
|
|
|
|
field |= (uint32_t)(mMinCpuId & kMaxVal) << (kValBits * 2);
|
|
|
|
field |= (uint32_t)(mMaxCpuId & kMaxVal) << (kValBits * 3);
|
2017-07-07 07:09:03 +00:00
|
|
|
mCap.setField(field);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void processCapField()
|
|
|
|
{
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t field = mCap.getField();
|
2017-07-07 07:09:03 +00:00
|
|
|
mMinPriority = (field >> (kValBits * 0)) & kMaxVal;
|
|
|
|
mMaxPriority = (field >> (kValBits * 1)) & kMaxVal;
|
2017-07-17 08:21:39 +00:00
|
|
|
mMinCpuId = (field >> (kValBits * 2)) & kMaxVal;
|
|
|
|
mMaxCpuId = (field >> (kValBits * 3)) & kMaxVal;
|
2017-07-07 07:09:03 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|