2017-07-07 07:09:03 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <fnd/types.h>
|
|
|
|
#include <nx/KernelCapability.h>
|
|
|
|
|
|
|
|
namespace nx
|
|
|
|
{
|
|
|
|
class InteruptEntry
|
|
|
|
{
|
|
|
|
public:
|
2018-03-22 05:26:22 +00:00
|
|
|
static const uint32_t kInteruptBits = 10;
|
|
|
|
static const uint32_t kInteruptMax = BIT(kInteruptBits) - 1;
|
|
|
|
static const uint32_t kInteruptNum = 2;
|
2017-07-12 14:02:10 +00:00
|
|
|
|
2017-07-07 07:09:03 +00:00
|
|
|
InteruptEntry();
|
|
|
|
InteruptEntry(const KernelCapability& kernel_cap);
|
2018-03-22 05:26:22 +00:00
|
|
|
InteruptEntry(uint32_t interupt0, uint32_t interupt1);
|
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
|
|
|
uint32_t operator[](size_t index) const;
|
2017-07-12 14:02:10 +00:00
|
|
|
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t getInterupt(size_t index) const;
|
|
|
|
void setInterupt(size_t index, uint32_t interupt);
|
2017-07-07 07:09:03 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const std::string kModuleName = "INTERUPT_ENTRY";
|
|
|
|
static const KernelCapability::KernelCapId kCapId = KernelCapability::KC_ENABLE_INTERUPTS;
|
|
|
|
|
|
|
|
KernelCapability mCap;
|
2018-03-22 05:26:22 +00:00
|
|
|
uint32_t mInterupt[kInteruptNum];
|
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)(mInterupt[0] & kInteruptMax) << 0;
|
|
|
|
field |= (uint32_t)(mInterupt[1] & kInteruptMax) << kInteruptBits;
|
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
|
|
|
mInterupt[0] = (field >> 0) & kInteruptMax;
|
|
|
|
mInterupt[1] = (field >> kInteruptBits) & kInteruptMax;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|