nstool/lib/libhac/include/nn/hac/KernelVersionEntry.h

58 lines
1.6 KiB
C
Raw Permalink Normal View History

#pragma once
#include <string>
#include <fnd/types.h>
2018-08-07 07:17:51 +00:00
#include <nn/hac/KernelCapabilityEntry.h>
2018-08-07 07:17:51 +00:00
namespace nn
{
namespace hac
{
class KernelVersionEntry
{
public:
KernelVersionEntry();
KernelVersionEntry(const KernelCapabilityEntry& kernel_cap);
2018-03-22 05:26:22 +00:00
KernelVersionEntry(uint16_t major, uint8_t minor);
void operator=(const KernelVersionEntry& other);
bool operator==(const KernelVersionEntry& other) const;
bool operator!=(const KernelVersionEntry& other) const;
// kernel capability
const KernelCapabilityEntry& getKernelCapability() const;
void setKernelCapability(const KernelCapabilityEntry& kernel_cap);
// variables
2018-03-22 05:26:22 +00:00
uint16_t getVerMajor() const;
void setVerMajor(uint16_t major);
uint8_t getVerMinor() const;
void setVerMinor(uint8_t minor);
private:
const std::string kModuleName = "KERNEL_VERSION_ENTRY";
static const kc::KernelCapId kCapId = kc::KC_KERNEL_VERSION;
2018-03-22 05:26:22 +00:00
static const uint32_t kVerMajorBits = 13;
static const uint32_t kVerMajorMax = BIT(kVerMajorBits) - 1;
static const uint32_t kVerMinorBits = 4;
static const uint32_t kVerMinorMax = BIT(kVerMinorBits) - 1;
KernelCapabilityEntry mCap;
2018-03-22 05:26:22 +00:00
uint16_t mVerMajor;
uint8_t mVerMinor;
inline void updateCapField()
{
2018-03-22 05:26:22 +00:00
uint32_t field = 0;
field |= (uint32_t)(mVerMinor & kVerMinorMax) << 0;
field |= (uint32_t)(mVerMajor & kVerMajorMax) << kVerMinorBits;
mCap.setField(field);
}
inline void processCapField()
{
2018-03-22 05:26:22 +00:00
uint32_t field = mCap.getField();
mVerMinor = (field >> 0) & kVerMinorMax;
mVerMajor = (field >> kVerMinorBits) & kVerMajorMax;
}
};
}
2018-08-07 07:17:51 +00:00
}