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, FAILED = 0x02,
BUSY = 0x03, 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, MEMORY_ACCESS = 0x02,
}; };
std::uint32_t control = 0; std::uint32_t control;
CommandType commandType = CommandType::REGISTER_ACCESS; CommandType commandType;
AbstractCommandRegister() = default;
constexpr AbstractCommandRegister(std::uint32_t control, CommandType commandType) constexpr AbstractCommandRegister(std::uint32_t control, CommandType commandType)
: control(control) : control(control)

View File

@@ -8,28 +8,15 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
{ {
struct AbstractControlStatusRegister struct AbstractControlStatusRegister
{ {
enum CommandError: std::uint8_t std::uint8_t dataCount:4;
{ AbstractCommandError commandError:3;
NONE = 0x00, bool relaxedPrivilege:1;
BUSY = 0x01, bool busy:1;
NOT_SUPPORTED = 0x02, std::uint8_t programBufferSize:5;
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;
constexpr explicit AbstractControlStatusRegister(RegisterValue registerValue) constexpr explicit AbstractControlStatusRegister(RegisterValue registerValue)
: dataCount(static_cast<std::uint8_t>(registerValue & 0x0F)) : 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))) , relaxedPrivilege(static_cast<bool>(registerValue & (0x01 << 11)))
, busy(static_cast<bool>(registerValue & (0x01 << 12))) , busy(static_cast<bool>(registerValue & (0x01 << 12)))
, programBufferSize(static_cast<std::uint8_t>((registerValue >> 24) & 0x1F)) , programBufferSize(static_cast<std::uint8_t>((registerValue >> 24) & 0x1F))
@@ -47,7 +34,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
constexpr void clearCommandError() { constexpr void clearCommandError() {
// Setting all of the bits will clear the field // 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, SIZE_128 = 0x04,
}; };
bool write:1 = false; bool write:1;
bool postIncrement:1 = false; bool postIncrement:1;
MemorySize size:3 = MemorySize::SIZE_32; MemorySize size:3;
bool virtualAddress:1 = false; bool virtualAddress:1;
constexpr MemoryAccessControlField() = default;
constexpr MemoryAccessControlField( constexpr MemoryAccessControlField(
bool write, bool write,

View File

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

View File

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