Added EraseTargetMemory TC command

This commit is contained in:
Nav
2022-12-11 23:25:15 +00:00
parent 83c273a22b
commit 76a0207701
7 changed files with 77 additions and 17 deletions

View File

@@ -37,6 +37,7 @@ namespace Bloom::TargetController
using Commands::WriteTargetRegisters;
using Commands::ReadTargetMemory;
using Commands::WriteTargetMemory;
using Commands::EraseTargetMemory;
using Commands::StepTargetExecution;
using Commands::SetBreakpoint;
using Commands::RemoveBreakpoint;
@@ -220,6 +221,10 @@ namespace Bloom::TargetController
std::bind(&TargetControllerComponent::handleWriteTargetMemory, this, std::placeholders::_1)
);
this->registerCommandHandler<EraseTargetMemory>(
std::bind(&TargetControllerComponent::handleEraseTargetMemory, this, std::placeholders::_1)
);
this->registerCommandHandler<StepTargetExecution>(
std::bind(&TargetControllerComponent::handleStepTargetExecution, this, std::placeholders::_1)
);
@@ -930,6 +935,21 @@ namespace Bloom::TargetController
return std::make_unique<Response>();
}
std::unique_ptr<Response> TargetControllerComponent::handleEraseTargetMemory(EraseTargetMemory& command) {
const auto& targetDescriptor = this->getTargetDescriptor();
if (
command.memoryType == this->getTargetDescriptor().programMemoryType
&& !this->target->programmingModeEnabled()
) {
throw Exception("Cannot erase program memory - programming mode not enabled.");
}
this->target->eraseMemory(command.memoryType);
return std::make_unique<Response>();
}
std::unique_ptr<Response> TargetControllerComponent::handleStepTargetExecution(StepTargetExecution& command) {
if (command.fromProgramCounter.has_value()) {
this->target->setProgramCounter(command.fromProgramCounter.value());