Tidying RISC-V register structs

This commit is contained in:
Nav
2024-09-04 00:13:55 +01:00
parent e327fe7826
commit 2a01f727bf
6 changed files with 49 additions and 55 deletions

View File

@@ -21,4 +21,15 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule
FAILED = 0x02,
BUSY = 0x03,
};
enum AbstractCommandError: std::uint8_t
{
NONE = 0x00,
BUSY = 0x01,
NOT_SUPPORTED = 0x02,
EXCEPTION = 0x03,
HALT_RESUME = 0x04,
BUS = 0x05,
OTHER = 0x07,
};
}

View File

@@ -16,10 +16,8 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
MEMORY_ACCESS = 0x02,
};
std::uint32_t control = 0;
CommandType commandType = CommandType::REGISTER_ACCESS;
AbstractCommandRegister() = default;
std::uint32_t control;
CommandType commandType;
constexpr AbstractCommandRegister(std::uint32_t control, CommandType commandType)
: control(control)

View File

@@ -8,28 +8,15 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
{
struct AbstractControlStatusRegister
{
enum CommandError: std::uint8_t
{
NONE = 0x00,
BUSY = 0x01,
NOT_SUPPORTED = 0x02,
EXCEPTION = 0x03,
HALT_RESUME = 0x04,
BUS = 0x05,
OTHER = 0x07,
};
std::uint8_t dataCount:4 = 0;
CommandError commandError:3 = CommandError::NONE;
bool relaxedPrivilege:1 = false;
bool busy:1 = false;
std::uint8_t programBufferSize:5 = 0;
AbstractControlStatusRegister() = default;
std::uint8_t dataCount:4;
AbstractCommandError commandError:3;
bool relaxedPrivilege:1;
bool busy:1;
std::uint8_t programBufferSize:5;
constexpr explicit AbstractControlStatusRegister(RegisterValue registerValue)
: dataCount(static_cast<std::uint8_t>(registerValue & 0x0F))
, commandError(static_cast<CommandError>((registerValue >> 8) & 0x07))
, commandError(static_cast<AbstractCommandError>((registerValue >> 8) & 0x07))
, relaxedPrivilege(static_cast<bool>(registerValue & (0x01 << 11)))
, busy(static_cast<bool>(registerValue & (0x01 << 12)))
, programBufferSize(static_cast<std::uint8_t>((registerValue >> 24) & 0x1F))
@@ -47,7 +34,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
constexpr void clearCommandError() {
// Setting all of the bits will clear the field
this->commandError = CommandError::OTHER;
this->commandError = AbstractCommandError::OTHER;
}
};
}

View File

@@ -17,12 +17,10 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
SIZE_128 = 0x04,
};
bool write:1 = false;
bool postIncrement:1 = false;
MemorySize size:3 = MemorySize::SIZE_32;
bool virtualAddress:1 = false;
constexpr MemoryAccessControlField() = default;
bool write:1;
bool postIncrement:1;
MemorySize size:3;
bool virtualAddress:1;
constexpr MemoryAccessControlField(
bool write,

View File

@@ -16,11 +16,11 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
};
RegisterNumber registerNumber;
bool write:1 = false;
bool transfer:1 = false;
bool postExecute:1 = false;
bool postIncrement:1 = false;
RegisterSize size:3 = RegisterSize::SIZE_32;
bool write:1;
bool transfer:1;
bool postExecute:1;
bool postIncrement:1;
RegisterSize size:3;
RegisterAccessControlField(
RegisterNumber registerNumber,

View File

@@ -8,26 +8,26 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
{
struct StatusRegister
{
std::uint8_t version:4 = 0;
bool validConfigStructurePointer:1 = false;
bool supportsResetHalt:1 = false;
bool authBusy:1 = false;
bool authenticated:1 = false;
bool anyHalted:1 = false;
bool allHalted:1 = false;
bool anyRunning:1 = false;
bool allRunning:1 = false;
bool anyUnavailable:1 = false;
bool allUnavailable:1 = false;
bool anyNonExistent:1 = false;
bool allNonExistent:1 = false;
bool anyResumeAcknowledge:1 = false;
bool allResumeAcknowledge:1 = false;
bool anyHaveReset:1 = false;
bool allHaveReset:1 = false;
bool implicitBreak:1 = false;
bool stickyUnavailableBits:1 = false;
bool ndmResetPending:1 = false;
std::uint8_t version:4;
bool validConfigStructurePointer:1;
bool supportsResetHalt:1;
bool authBusy:1;
bool authenticated:1;
bool anyHalted:1;
bool allHalted:1;
bool anyRunning:1;
bool allRunning:1;
bool anyUnavailable:1;
bool allUnavailable:1;
bool anyNonExistent:1;
bool allNonExistent:1;
bool anyResumeAcknowledge:1;
bool allResumeAcknowledge:1;
bool anyHaveReset:1;
bool allHaveReset:1;
bool implicitBreak:1;
bool stickyUnavailableBits:1;
bool ndmResetPending:1;
constexpr explicit StatusRegister(RegisterValue registerValue)
: version(static_cast<std::uint8_t>(registerValue & 0x0F))