RISC-V target ID verification upon activation

This commit is contained in:
Nav
2023-12-17 18:41:38 +00:00
parent 66cbd89051
commit cc33eea712
2 changed files with 11 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
#include <cstdint>
#include "src/Targets/RiscV/RiscVGeneric.hpp"
#include "src/Targets/RiscV/DebugModule/DebugModule.hpp"
#include "src/Targets/RiscV/DebugModule/Registers/RegisterAddresses.hpp"

View File

@@ -11,6 +11,7 @@
#include "DebugModule/Registers/MemoryAccessControlField.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Exceptions/InvalidConfig.hpp"
#include "src/TargetController/Exceptions/TargetOperationFailure.hpp"
#include "src/Services/StringService.hpp"
@@ -60,6 +61,15 @@ namespace Targets::RiscV
void RiscV::activate() {
this->riscVDebugInterface->activate({});
const auto deviceId = this->riscVDebugInterface->getDeviceId();
const auto tdfDeviceId = this->targetDescriptionFile.getTargetId();
if (deviceId != tdfDeviceId) {
throw Exceptions::InvalidConfig(
"RISC-V target ID mismatch - expected " + tdfDeviceId + " but got " + deviceId +
". Please check target configuration."
);
}
this->hartIndices = this->discoverHartIndices();
if (this->hartIndices.empty()) {