Added support for excluding address ranges from read memory events

This commit is contained in:
Nav
2021-12-25 20:57:03 +00:00
parent 9054b17bc7
commit 6f364a7009
10 changed files with 67 additions and 11 deletions

View File

@@ -556,7 +556,12 @@ void EdbgAvr8Interface::writeRegisters(const Targets::TargetRegisters& registers
}
}
TargetMemoryBuffer EdbgAvr8Interface::readMemory(TargetMemoryType memoryType, std::uint32_t startAddress, std::uint32_t bytes) {
TargetMemoryBuffer EdbgAvr8Interface::readMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges
) {
auto avr8MemoryType = Avr8MemoryType::SRAM;
switch (memoryType) {
@@ -579,9 +584,32 @@ TargetMemoryBuffer EdbgAvr8Interface::readMemory(TargetMemoryType memoryType, st
case TargetMemoryType::EEPROM: {
avr8MemoryType = Avr8MemoryType::EEPROM;
}
default: {
break;
}
}
return this->readMemory(avr8MemoryType, startAddress, bytes);
/*
* The internal readMemory() function accepts excluded addresses in the form of a set of addresses, as
* opposed to a set of address ranges.
*
* We will perform the conversion here.
*/
auto excludedAddresses = std::set<std::uint32_t>();
auto endAddress = startAddress + bytes - 1;
for (const auto& addressRange : excludedAddressRanges) {
if (addressRange.startAddress > endAddress) {
// This address range is outside of the range from which we will be reading
continue;
}
for (auto i = addressRange.startAddress; i <= addressRange.endAddress; i++) {
excludedAddresses.insert(i);
}
}
return this->readMemory(avr8MemoryType, startAddress, bytes, excludedAddresses);
}
void EdbgAvr8Interface::writeMemory(TargetMemoryType memoryType, std::uint32_t startAddress, const TargetMemoryBuffer& buffer) {
@@ -611,6 +639,9 @@ void EdbgAvr8Interface::writeMemory(TargetMemoryType memoryType, std::uint32_t s
case TargetMemoryType::EEPROM: {
avr8MemoryType = Avr8MemoryType::EEPROM;
}
default: {
break;
}
}
return this->writeMemory(avr8MemoryType, startAddress, buffer);

View File

@@ -218,7 +218,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
Targets::TargetMemoryBuffer readMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes
std::uint32_t bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
) override;
/**

View File

@@ -157,12 +157,14 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
* @param memoryType
* @param startAddress
* @param bytes
* @param excludedAddressRanges
* @return
*/
virtual Targets::TargetMemoryBuffer readMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes
std::uint32_t bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
) = 0;
/**

View File

@@ -19,6 +19,7 @@ namespace Bloom::Events
Targets::TargetMemoryType memoryType = Targets::TargetMemoryType::RAM;
std::uint32_t startAddress = 0;
std::uint32_t bytes = 0;
std::set<Targets::TargetMemoryAddressRange> excludedAddressRanges;
[[nodiscard]] EventType getType() const override {
return RetrieveMemoryFromTarget::type;

View File

@@ -601,7 +601,12 @@ void TargetController::onReadMemoryEvent(const Events::RetrieveMemoryFromTarget&
try {
auto memoryReadEvent = std::make_shared<Events::MemoryRetrievedFromTarget>();
memoryReadEvent->correlationId = event.id;
memoryReadEvent->data = this->target->readMemory(event.memoryType, event.startAddress, event.bytes);
memoryReadEvent->data = this->target->readMemory(
event.memoryType,
event.startAddress,
event.bytes,
event.excludedAddressRanges
);
this->eventManager.triggerEvent(memoryReadEvent);

View File

@@ -73,12 +73,14 @@ void TargetControllerConsole::writeRegisters(const TargetRegisters& registers) {
TargetMemoryBuffer TargetControllerConsole::readMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes
std::uint32_t bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges
) {
auto readMemoryEvent = std::make_shared<RetrieveMemoryFromTarget>();
readMemoryEvent->memoryType = memoryType;
readMemoryEvent->startAddress = startAddress;
readMemoryEvent->bytes = bytes;
readMemoryEvent->excludedAddressRanges = excludedAddressRanges;
return this->triggerTargetControllerEventAndWaitForResponse(readMemoryEvent)->data;
}

View File

@@ -97,12 +97,14 @@ namespace Bloom
* @param memoryType
* @param startAddress
* @param bytes
* @param excludedAddressRanges
* @return
*/
Targets::TargetMemoryBuffer readMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes
std::uint32_t bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
);
/**

View File

@@ -223,8 +223,13 @@ TargetRegisters Avr8::readRegisters(TargetRegisterDescriptors descriptors) {
return registers;
}
TargetMemoryBuffer Avr8::readMemory(TargetMemoryType memoryType, std::uint32_t startAddress, std::uint32_t bytes) {
return this->avr8Interface->readMemory(memoryType, startAddress, bytes);
TargetMemoryBuffer Avr8::readMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges
) {
return this->avr8Interface->readMemory(memoryType, startAddress, bytes, excludedAddressRanges);
}
void Avr8::writeMemory(TargetMemoryType memoryType, std::uint32_t startAddress, const TargetMemoryBuffer& buffer) {

View File

@@ -95,7 +95,8 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
TargetMemoryBuffer readMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes
std::uint32_t bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
) override;
void writeMemory(
TargetMemoryType memoryType,

View File

@@ -240,10 +240,16 @@ namespace Bloom::Targets
* @param memoryType
* @param startAddress
* @param bytes
* @param excludedAddressRanges
*
* @return
*/
virtual TargetMemoryBuffer readMemory(TargetMemoryType memoryType, std::uint32_t startAddress, std::uint32_t bytes) = 0;
virtual TargetMemoryBuffer readMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
) = 0;
/**
* Should write memory to the target.