Restricted memory access member function to system address space, in RISC-V debug translator

This commit is contained in:
Nav
2024-12-21 02:11:13 +00:00
parent 79b7457c89
commit bcdae97638
2 changed files with 11 additions and 0 deletions

View File

@@ -77,6 +77,7 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
, config(config) , config(config)
, targetDescriptionFile(targetDescriptionFile) , targetDescriptionFile(targetDescriptionFile)
, targetConfig(targetConfig) , targetConfig(targetConfig)
, sysAddressSpaceDescriptor(targetDescriptionFile.getSystemAddressSpaceDescriptor())
{} {}
void DebugTranslator::activate() { void DebugTranslator::activate() {
@@ -437,6 +438,10 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
TargetMemorySize bytes, TargetMemorySize bytes,
const std::set<TargetMemoryAddressRange>& excludedAddressRanges const std::set<TargetMemoryAddressRange>& excludedAddressRanges
) { ) {
if (addressSpaceDescriptor != this->sysAddressSpaceDescriptor) {
throw Exceptions::TargetOperationFailure{"Unsupported address space"};
}
// TODO: excluded addresses // TODO: excluded addresses
constexpr auto alignTo = DebugTranslator::WORD_BYTE_SIZE; constexpr auto alignTo = DebugTranslator::WORD_BYTE_SIZE;
@@ -474,6 +479,10 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
TargetMemoryAddress startAddress, TargetMemoryAddress startAddress,
TargetMemoryBufferSpan buffer TargetMemoryBufferSpan buffer
) { ) {
if (addressSpaceDescriptor != this->sysAddressSpaceDescriptor) {
throw Exceptions::TargetOperationFailure{"Unsupported address space"};
}
constexpr auto alignTo = DebugTranslator::WORD_BYTE_SIZE; constexpr auto alignTo = DebugTranslator::WORD_BYTE_SIZE;
const auto bytes = static_cast<TargetMemorySize>(buffer.size()); const auto bytes = static_cast<TargetMemorySize>(buffer.size());
if ((startAddress % alignTo) != 0 || (bytes % alignTo) != 0) { if ((startAddress % alignTo) != 0 || (bytes % alignTo) != 0) {

View File

@@ -115,6 +115,8 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
const ::Targets::RiscV::TargetDescriptionFile& targetDescriptionFile; const ::Targets::RiscV::TargetDescriptionFile& targetDescriptionFile;
const ::Targets::RiscV::RiscVTargetConfig& targetConfig; const ::Targets::RiscV::RiscVTargetConfig& targetConfig;
const ::Targets::TargetAddressSpaceDescriptor sysAddressSpaceDescriptor;
DebugModuleDescriptor debugModuleDescriptor = {}; DebugModuleDescriptor debugModuleDescriptor = {};
DebugModule::HartIndex selectedHartIndex = 0; DebugModule::HartIndex selectedHartIndex = 0;