Added abstract data register count check when identifying supported memory access strategies

This commit is contained in:
Nav
2024-11-23 23:12:38 +00:00
parent e4e2bd1796
commit 71150163c4
3 changed files with 28 additions and 23 deletions

View File

@@ -8,7 +8,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
{ {
struct AbstractControlStatusRegister struct AbstractControlStatusRegister
{ {
std::uint8_t dataCount = 0; std::uint8_t dataRegisterCount = 0;
AbstractCommandError commandError = AbstractCommandError::NONE; AbstractCommandError commandError = AbstractCommandError::NONE;
bool relaxedPrivilege = false; bool relaxedPrivilege = false;
bool busy = false; bool busy = false;
@@ -16,7 +16,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
static constexpr AbstractControlStatusRegister fromValue(RegisterValue value) { static constexpr AbstractControlStatusRegister fromValue(RegisterValue value) {
return { return {
.dataCount = static_cast<std::uint8_t>(value & 0x0F), .dataRegisterCount = static_cast<std::uint8_t>(value & 0x0F),
.commandError = static_cast<AbstractCommandError>((value >> 8) & 0x07), .commandError = static_cast<AbstractCommandError>((value >> 8) & 0x07),
.relaxedPrivilege = static_cast<bool>(value & (0x01 << 11)), .relaxedPrivilege = static_cast<bool>(value & (0x01 << 11)),
.busy = static_cast<bool>(value & (0x01 << 12)), .busy = static_cast<bool>(value & (0x01 << 12)),
@@ -26,7 +26,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec::DebugModule::Registers
[[nodiscard]] constexpr RegisterValue value() const { [[nodiscard]] constexpr RegisterValue value() const {
return RegisterValue{0} return RegisterValue{0}
| static_cast<RegisterValue>(this->dataCount & 0x0F) | static_cast<RegisterValue>(this->dataRegisterCount & 0x0F)
| static_cast<RegisterValue>(this->commandError) << 8 | static_cast<RegisterValue>(this->commandError) << 8
| static_cast<RegisterValue>(this->relaxedPrivilege) << 11 | static_cast<RegisterValue>(this->relaxedPrivilege) << 11
| static_cast<RegisterValue>(this->busy) << 12 | static_cast<RegisterValue>(this->busy) << 12

View File

@@ -19,6 +19,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
std::vector<DebugModule::HartIndex> hartIndices; std::vector<DebugModule::HartIndex> hartIndices;
std::unordered_set<DebugModule::MemoryAccessStrategy> memoryAccessStrategies; std::unordered_set<DebugModule::MemoryAccessStrategy> memoryAccessStrategies;
std::uint8_t abstractDataRegisterCount = 0;
std::uint8_t programBufferSize = 0; std::uint8_t programBufferSize = 0;
std::unordered_map<TriggerModule::TriggerIndex, TriggerModule::TriggerDescriptor> triggerDescriptorsByIndex; std::unordered_map<TriggerModule::TriggerIndex, TriggerModule::TriggerDescriptor> triggerDescriptorsByIndex;

View File

@@ -128,10 +128,13 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
this->initDebugControlStatusRegister(); this->initDebugControlStatusRegister();
const auto abstractControlStatusRegister = this->readDebugModuleAbstractControlStatusRegister(); const auto abstractControlStatusRegister = this->readDebugModuleAbstractControlStatusRegister();
this->debugModuleDescriptor.abstractDataRegisterCount = abstractControlStatusRegister.dataRegisterCount;
this->debugModuleDescriptor.programBufferSize = abstractControlStatusRegister.programBufferSize; this->debugModuleDescriptor.programBufferSize = abstractControlStatusRegister.programBufferSize;
Logger::debug("Data register count: " + std::to_string(this->debugModuleDescriptor.abstractDataRegisterCount));
Logger::debug("Program buffer size: " + std::to_string(this->debugModuleDescriptor.programBufferSize)); Logger::debug("Program buffer size: " + std::to_string(this->debugModuleDescriptor.programBufferSize));
if (this->debugModuleDescriptor.abstractDataRegisterCount > 0) {
if (this->debugModuleDescriptor.programBufferSize >= 3) { if (this->debugModuleDescriptor.programBufferSize >= 3) {
this->debugModuleDescriptor.memoryAccessStrategies.insert(MemoryAccessStrategy::PROGRAM_BUFFER); this->debugModuleDescriptor.memoryAccessStrategies.insert(MemoryAccessStrategy::PROGRAM_BUFFER);
} }
@@ -156,6 +159,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
if (this->tryExecuteAbstractCommand(probingMemoryAccessCommand) == AbstractCommandError::NONE) { if (this->tryExecuteAbstractCommand(probingMemoryAccessCommand) == AbstractCommandError::NONE) {
this->debugModuleDescriptor.memoryAccessStrategies.insert(MemoryAccessStrategy::ABSTRACT_COMMAND); this->debugModuleDescriptor.memoryAccessStrategies.insert(MemoryAccessStrategy::ABSTRACT_COMMAND);
} }
}
if (this->debugModuleDescriptor.memoryAccessStrategies.empty()) { if (this->debugModuleDescriptor.memoryAccessStrategies.empty()) {
throw Exceptions::TargetOperationFailure{"Target doesn't support any known memory access strategies"}; throw Exceptions::TargetOperationFailure{"Target doesn't support any known memory access strategies"};