Added RiscVProgramInterface for RISC-V debug tools that are unable to program RISC-V targets via the debug interface

This commit is contained in:
Nav
2023-12-08 23:04:04 +00:00
parent 084eef1a30
commit f4b30dbdf6
4 changed files with 48 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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;
};
}