2017-07-07 07:09:03 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <fnd/types.h>
|
2018-06-29 04:24:39 +00:00
|
|
|
#include <nx/KernelCapabilityEntry.h>
|
2017-07-07 07:09:03 +00:00
|
|
|
|
|
|
|
namespace nx
|
|
|
|
{
|
|
|
|
class ThreadInfoEntry
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ThreadInfoEntry();
|
2018-06-29 04:24:39 +00:00
|
|
|
ThreadInfoEntry(const KernelCapabilityEntry& 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
|
|
|
|
2018-06-24 15:01:16 +00:00
|
|
|
void operator=(const ThreadInfoEntry& other);
|
|
|
|
bool operator==(const ThreadInfoEntry& other) const;
|
|
|
|
bool operator!=(const ThreadInfoEntry& other) const;
|
|
|
|
|
2017-07-07 07:09:03 +00:00
|
|
|
// kernel capability
|
2018-06-29 04:24:39 +00:00
|
|
|
const KernelCapabilityEntry& getKernelCapability() const;
|
|
|
|
void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
|
2017-07-07 07:09:03 +00:00
|
|
|
|
|
|
|
// 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";
|
2018-06-29 04:24:39 +00:00
|
|
|
static const kc::KernelCapId kCapId = kc::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
|
|
|
|
2018-06-29 04:24:39 +00:00
|
|
|
KernelCapabilityEntry 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
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|