Added RiscVProgramInterface for RISC-V debug tools that are unable to program RISC-V targets via the debug interface
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp"
|
||||
|
||||
#include "TargetInterfaces/RiscV/RiscVDebugInterface.hpp"
|
||||
#include "TargetInterfaces/RiscV/RiscVProgramInterface.hpp"
|
||||
|
||||
#include "src/Targets/TargetRegister.hpp"
|
||||
|
||||
@@ -113,6 +114,23 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Some debug tools are unable to program RISC-V targets via the RISC-V debug interface. Such tools must provide
|
||||
* an implementation of the RiscVProgramInterface, which will allow them to implement flash memory writing as a
|
||||
* separate function, independent of the debug interface.
|
||||
*
|
||||
* The RISC-V target driver will forward all flash memory writes to the RiscVProgramInterface returned by this
|
||||
* member function. If nullptr is returned, the driver will fall back to the RiscVDebugInterface for flash memory
|
||||
* writes.
|
||||
*
|
||||
* Note: the caller of this function will not manage the lifetime of the returned instance.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual DebugToolDrivers::TargetInterfaces::RiscV::RiscVProgramInterface* getRiscVProgramInterface() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool isInitialised() const {
|
||||
return this->initialised;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
|
||||
namespace DebugToolDrivers::TargetInterfaces::RiscV
|
||||
{
|
||||
class RiscVProgramInterface
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Should write to the target's FLASH memory.
|
||||
*
|
||||
* @param startAddress
|
||||
* @param buffer
|
||||
*/
|
||||
virtual void writeFlashMemory(
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
const Targets::TargetMemoryBuffer& buffer
|
||||
) = 0;
|
||||
};
|
||||
}
|
||||
@@ -51,6 +51,7 @@ namespace Targets::RiscV
|
||||
|
||||
void RiscV::setDebugTool(DebugTool* debugTool) {
|
||||
this->riscVDebugInterface = debugTool->getRiscVDebugInterface();
|
||||
this->riscVProgramInterface = debugTool->getRiscVProgramInterface();
|
||||
}
|
||||
|
||||
void RiscV::activate() {
|
||||
@@ -395,6 +396,10 @@ namespace Targets::RiscV
|
||||
return this->writeMemory(memoryType, alignedStartAddress, alignedBuffer);
|
||||
}
|
||||
|
||||
if (memoryType == TargetMemoryType::FLASH && this->riscVProgramInterface != nullptr) {
|
||||
return this->riscVProgramInterface->writeFlashMemory(startAddress, buffer);
|
||||
}
|
||||
|
||||
this->riscVDebugInterface->writeDebugModuleRegister(RegisterAddress::ABSTRACT_DATA_1, startAddress);
|
||||
|
||||
auto command = AbstractCommandRegister();
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "src/DebugToolDrivers/DebugTool.hpp"
|
||||
|
||||
#include "src/DebugToolDrivers/TargetInterfaces/RiscV/RiscVDebugInterface.hpp"
|
||||
#include "src/DebugToolDrivers/TargetInterfaces/RiscV/RiscVProgramInterface.hpp"
|
||||
|
||||
#include "src/Targets/RiscV/RiscVGeneric.hpp"
|
||||
#include "src/Targets/RiscV/Registers/RegisterNumbers.hpp"
|
||||
@@ -104,6 +105,7 @@ namespace Targets::RiscV
|
||||
RiscVRegisterDescriptor stackPointerRegisterDescriptor;
|
||||
|
||||
DebugToolDrivers::TargetInterfaces::RiscV::RiscVDebugInterface* riscVDebugInterface = nullptr;
|
||||
DebugToolDrivers::TargetInterfaces::RiscV::RiscVProgramInterface* riscVProgramInterface = nullptr;
|
||||
|
||||
std::set<DebugModule::HartIndex> hartIndices;
|
||||
DebugModule::HartIndex selectedHartIndex = 0;
|
||||
|
||||
Reference in New Issue
Block a user