Massive refactor to accommodate RISC-V targets

- Refactored entire codebase (excluding the Insight component) to accommodate multiple target architectures (no longer specific to AVR)
- Deleted 'generate SVD' GDB monitor command - I will eventually move this functionality to the Bloom website
- Added unit size property to address spaces
- Many other changes which I couldn't be bothered to describe here
This commit is contained in:
Nav
2024-07-23 21:14:22 +01:00
parent 2986934485
commit 6cdbfbe950
331 changed files with 8815 additions and 8565 deletions

View File

@@ -2,21 +2,21 @@
#include <cstdint>
#include <set>
#include <vector>
#include <optional>
#include "src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp"
#include "src/Targets/Microchip/AVR/TargetSignature.hpp"
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
#include "src/Targets/Microchip/AVR/AVR8/ProgramMemorySection.hpp"
#include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp"
#include "src/Targets/Microchip/AVR8/TargetSignature.hpp"
#include "src/Targets/Microchip/AVR8/Family.hpp"
#include "src/Targets/Microchip/AVR8/ProgramMemorySection.hpp"
#include "src/Targets/TargetDescriptor.hpp"
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
#include "src/Targets/TargetState.hpp"
#include "src/Targets/TargetRegisterDescriptor.hpp"
#include "src/Targets/TargetRegister.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr8
{
/**
* Interfacing with an AVR8 target for debugging operations can vary significantly, depending on the debug tool
@@ -41,40 +41,17 @@ namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
Avr8DebugInterface& operator = (const Avr8DebugInterface& other) = default;
Avr8DebugInterface& operator = (Avr8DebugInterface&& other) = default;
/**
* Should initialise the interface between the debug tool and the AVR8 target.
*/
virtual void init() = 0;
/**
* Should stop execution on that target.
*/
virtual void stop() = 0;
/**
* Should resume execution on the AVR8 target.
*/
virtual void run() = 0;
/**
* Continue execution up to a specific byte address.
*/
virtual void runTo(Targets::TargetMemoryAddress address) = 0;
/**
* Step execution on teh AVR8 target.
*/
virtual void step() = 0;
/**
* Should reset the AVR8 target.
*/
virtual void reset() = 0;
/**
* Should activate the physical interface between the debug tool and the AVR8 target.
*
* If the debugWire interface has been selected - this function should throw a DebugWirePhysicalInterfaceError
* If the debugWIRE interface has been selected - this function should throw a DebugWirePhysicalInterfaceError
* exception, in the event of a failure when activating the interface. The reason for this is to allow us the
* chance to check the DWEN fuse bit, via an ISP interface. See Avr8::activate() for more.
*/
@@ -85,6 +62,30 @@ namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
*/
virtual void deactivate() = 0;
/**
* We can specify access restrictions for individual registers in our TDFs, but this is only at a target
* level - it does not account for any restrictions that the debug interface may be subject to.
*
* For example, EDBG debug tools cannot access fuse registers on JTAG targets, during a debug session. Those
* registers can only be accessed during a programming session. This restriction is specific to the EDBG debug
* interface.
*
* This function should communicate any access restrictions for the given register, which apply during a debug
* session. It does not need to account for any access restrictions that only apply outside of a debug session.
*
* @param registerDescriptor
* The descriptor of the register.
*
* @param addressSpaceDescriptor
* The descriptor of the address space in which the register resides.
*
* @return
*/
virtual Targets::TargetRegisterAccess getRegisterAccess(
const Targets::TargetRegisterDescriptor& registerDescriptor,
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor
) = 0;
/**
* Should retrieve the AVR8 target signature of the AVR8 target.
*
@@ -93,97 +94,29 @@ namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
*
* @return
*/
virtual Targets::Microchip::Avr::TargetSignature getDeviceId() = 0;
virtual Targets::Microchip::Avr8::TargetSignature getDeviceId() = 0;
/**
* Should set a software breakpoint at a given address.
*
* @param address
*/
virtual void setSoftwareBreakpoint(Targets::TargetMemoryAddress address) = 0;
/**
* Should remove a software breakpoint at a given address.
*
* @param address
*/
virtual void clearSoftwareBreakpoint(Targets::TargetMemoryAddress address) = 0;
/**
* Should set a hardware breakpoint at a given address.
*
* @param address
*/
virtual void setHardwareBreakpoint(Targets::TargetMemoryAddress address) = 0;
/**
* Should remove a hardware breakpoint at a given address.
*
* @param address
*/
virtual void clearHardwareBreakpoint(Targets::TargetMemoryAddress address) = 0;
/**
* Should remove all software and hardware breakpoints on the target.
*/
virtual void clearAllBreakpoints() = 0;
/**
* Should retrieve the current program counter value from the target.
*
* @return
*/
virtual Targets::TargetMemoryAddress getProgramCounter() = 0;
/**
* Should update the program counter value on the target.
*
* @param programCounter
*/
virtual void setProgramCounter(Targets::TargetMemoryAddress programCounter) = 0;
/**
* Should read the requested registers from the target.
*
* @param descriptorIds
* A collection of register descriptor IDs, for the registers to be read.
*
* @return
*/
virtual Targets::TargetRegisters readRegisters(const Targets::TargetRegisterDescriptorIds& descriptorIds) = 0;
/**
* Should update the value of the given registers.
*
* @param registers
*/
virtual void writeRegisters(const Targets::TargetRegisters& registers) = 0;
/**
* Should read memory from the target, for the given memory type.
*
* @param memoryType
* @param startAddress
* @param bytes
* @param excludedAddressRanges
* @return
*/
virtual Targets::TargetRegisterDescriptorAndValuePairs readRegisters(
const Targets::TargetRegisterDescriptors& descriptors
) = 0;
virtual void writeRegisters(const Targets::TargetRegisterDescriptorAndValuePairs& registers) = 0;
virtual Targets::TargetMemoryBuffer readMemory(
Targets::TargetMemoryType memoryType,
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
) = 0;
/**
* Should write memory to the target, for a given memory type.
*
* @param memoryType
* @param startAddress
* @param buffer
*/
virtual void writeMemory(
Targets::TargetMemoryType memoryType,
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
Targets::TargetMemoryAddress startAddress,
const Targets::TargetMemoryBuffer& buffer
) = 0;
@@ -195,29 +128,12 @@ namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
* The section to erase, or std::nullopt to erase the entire program memory.
*/
virtual void eraseProgramMemory(
std::optional<Targets::Microchip::Avr::Avr8Bit::ProgramMemorySection> section = std::nullopt
std::optional<Targets::Microchip::Avr8::ProgramMemorySection> section = std::nullopt
) = 0;
/**
* Should erase the chip.
*/
virtual void eraseChip() = 0;
/**
* Should obtain the current target state.
*
* @return
*/
virtual Targets::TargetState getTargetState() = 0;
/**
* Should prepare the debug interface for programming the target.
*/
virtual Targets::TargetExecutionState getExecutionState() = 0;
virtual void enableProgrammingMode() = 0;
/**
* Should prepare the debug interface for resuming debugging operations after a programming session.
*/
virtual void disableProgrammingMode() = 0;
};
}

View File

@@ -2,13 +2,13 @@
#include <cstdint>
#include "src/Targets/Microchip/AVR/TargetSignature.hpp"
#include "src/Targets/Microchip/AVR/IspParameters.hpp"
#include "src/Targets/Microchip/AVR/Fuse.hpp"
#include "src/Targets/Microchip/AVR8/TargetSignature.hpp"
#include "src/Targets/Microchip/AVR8/IspParameters.hpp"
#include "src/Targets/Microchip/AVR8/Fuse.hpp"
#include "src/ProjectConfig.hpp"
namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr
namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr8
{
/**
* Many AVRs can be programmed via an SPI interface. Some debug tools provide access to this interface via the AVR
@@ -17,8 +17,8 @@ namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr
* This interface class is incomplete - it only provides the ability to read the device ID and access AVR fuses and
* lockbit bytes (as that's all we need, for now).
*
* Currently, Bloom only uses the ISP interface for accessing fuses and lockbits on debugWire targets. We can't
* access fuses via the debugWire interface, so we have to use the ISP interface.
* Currently, Bloom only uses the ISP interface for accessing fuses and lockbits on debugWIRE targets. We can't
* access fuses via the debugWIRE interface, so we have to use the ISP interface.
*
* @see Avr8::updateDwenFuseBit() for more.
*/
@@ -34,20 +34,6 @@ namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr
AvrIspInterface& operator = (const AvrIspInterface& other) = default;
AvrIspInterface& operator = (AvrIspInterface&& other) = default;
/**
* Configures the ISP interface with user-provided config parameters.
*
* @param targetConfig
*/
virtual void configure(const TargetConfig& targetConfig) = 0;
/**
* Configures the ISP interface with the target's ISP parameters.
*
* @param ispParameters
*/
virtual void setIspParameters(const Targets::Microchip::Avr::IspParameters& ispParameters) = 0;
/**
* Should initialise and activate the ISP interface between the debug tool and the AVR target.
*/
@@ -63,15 +49,17 @@ namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr
*
* @return
*/
virtual Targets::Microchip::Avr::TargetSignature getDeviceId() = 0;
virtual Targets::Microchip::Avr8::TargetSignature getDeviceId() = 0;
/**
* Should read a fuse from the AVR target.
*
* @param fuseType
* @param fuseRegisterDescriptor
* @return
*/
virtual Targets::Microchip::Avr::Fuse readFuse(Targets::Microchip::Avr::FuseType fuseType) = 0;
virtual Targets::Microchip::Avr8::FuseValue readFuse(
const Targets::TargetRegisterDescriptor& fuseRegisterDescriptor
) = 0;
/**
* Should read the lock bit byte from the AVR target.
@@ -83,8 +71,12 @@ namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr
/**
* Should program a particular fuse byte.
*
* @param fuse
* @param fuseRegisterDescriptor
* @param value
*/
virtual void programFuse(Targets::Microchip::Avr::Fuse fuse) = 0;
virtual void programFuse(
const Targets::TargetRegisterDescriptor& fuseRegisterDescriptor,
Targets::Microchip::Avr8::FuseValue value
) = 0;
};
}

View File

@@ -1,99 +1,57 @@
#pragma once
#include <cstdint>
#include <set>
#include <vector>
#include <optional>
#include "src/Targets/RiscV/RiscVGeneric.hpp"
#include "src/Targets/RiscV/DebugModule/DebugModule.hpp"
#include "src/Targets/RiscV/DebugModule/Registers/RegisterAddresses.hpp"
#include "src/Targets/RiscV/TargetParameters.hpp"
#include "src/Targets/TargetDescriptor.hpp"
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
#include "src/Targets/TargetState.hpp"
#include "src/Targets/TargetRegisterDescriptor.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace DebugToolDrivers::TargetInterfaces::RiscV
{
class RiscVDebugInterface
{
public:
RiscVDebugInterface() = default;
virtual ~RiscVDebugInterface() = default;
RiscVDebugInterface(const RiscVDebugInterface& other) = default;
RiscVDebugInterface(RiscVDebugInterface&& other) = default;
RiscVDebugInterface& operator = (const RiscVDebugInterface& other) = default;
RiscVDebugInterface& operator = (RiscVDebugInterface&& other) = default;
/**
* Should prepare for and then activate the physical interface between the debug tool and the RISC-V target.
*
* Should throw an exception if activation fails. The error will be considered fatal, and result in a shutdown.
*
* Unless otherwise stated, it can be assumed that this function will be called (and must succeed)
* before any of the other functions below this point are called. In other words, we can assume that the
* interface has been activated in the implementations of any of the functions below this point.
*
* @param targetParameters
* Parameters for the RISC-V target. These can be ignored if a particular implementation does not require
* any target parameters for activation.
*/
virtual void activate(const Targets::RiscV::TargetParameters& targetParameters) = 0;
/**
* Should deactivate the physical interface between the debug tool and the RISC-V target.
*
* CAUTION: This function **CAN** be called before activate(), or in instances where activate() failed (threw
* an exception). Implementations must accommodate this.
*/
virtual void init() = 0;
virtual void activate() = 0;
virtual void deactivate() = 0;
/**
* Should retrieve the RISC-V target ID in string form.
*
* @return
* The target ID, in the form of a string.
*/
virtual std::string getDeviceId() = 0;
virtual Targets::TargetExecutionState getExecutionState() = 0;
/**
* Should read the value of a debug module register.
*
* @param address
* The address of the debug module register to read.
*
* @return
* The register value.
*/
virtual Targets::RiscV::DebugModule::RegisterValue readDebugModuleRegister(
Targets::RiscV::DebugModule::RegisterAddress address
virtual void stop() = 0;
virtual void run() = 0;
virtual void step() = 0;
virtual void reset() = 0;
virtual void setSoftwareBreakpoint(Targets::TargetMemoryAddress address) = 0;
virtual void clearSoftwareBreakpoint(Targets::TargetMemoryAddress address) = 0;
virtual void setHardwareBreakpoint(Targets::TargetMemoryAddress address) = 0;
virtual void clearHardwareBreakpoint(Targets::TargetMemoryAddress address) = 0;
virtual void clearAllBreakpoints() = 0;
virtual Targets::TargetRegisterDescriptorAndValuePairs readCpuRegisters(
const Targets::TargetRegisterDescriptors& descriptors
) = 0;
virtual void writeCpuRegisters(const Targets::TargetRegisterDescriptorAndValuePairs& registers) = 0;
Targets::RiscV::DebugModule::RegisterValue readDebugModuleRegister(
Targets::RiscV::DebugModule::Registers::RegisterAddress address
) {
return this->readDebugModuleRegister(static_cast<Targets::RiscV::DebugModule::RegisterAddress>(address));
};
/**
* Should write a value to a debug module register.
*
* @param address
* The address of the debug module to update.
*
* @param value
* The value to write.
*/
virtual void writeDebugModuleRegister(
Targets::RiscV::DebugModule::RegisterAddress address,
Targets::RiscV::DebugModule::RegisterValue value
virtual Targets::TargetMemoryBuffer readMemory(
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
) = 0;
virtual void writeMemory(
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
Targets::TargetMemoryAddress startAddress,
const Targets::TargetMemoryBuffer& buffer
) = 0;
void writeDebugModuleRegister(
Targets::RiscV::DebugModule::Registers::RegisterAddress address,
Targets::RiscV::DebugModule::RegisterValue value
) {
return this->writeDebugModuleRegister(
static_cast<Targets::RiscV::DebugModule::RegisterAddress>(address),
value
);
};
};
}

View File

@@ -0,0 +1,18 @@
#pragma once
#include <string>
namespace DebugToolDrivers::TargetInterfaces::RiscV
{
class RiscVIdentificationInterface
{
public:
/**
* Should retrieve the RISC-V target ID in string form.
*
* @return
* The target ID, in the form of a string.
*/
virtual std::string getDeviceId() = 0;
};
}

View File

@@ -1,7 +1,5 @@
#pragma once
#include <cstdint>
namespace DebugToolDrivers::TargetInterfaces
{
/**
@@ -14,20 +12,13 @@ namespace DebugToolDrivers::TargetInterfaces
TargetPowerManagementInterface() = default;
virtual ~TargetPowerManagementInterface() = default;
TargetPowerManagementInterface(const TargetPowerManagementInterface& other) = default;
TargetPowerManagementInterface(TargetPowerManagementInterface&& other) = default;
TargetPowerManagementInterface(const TargetPowerManagementInterface& other) = delete;
TargetPowerManagementInterface& operator = (const TargetPowerManagementInterface& other) = delete;
TargetPowerManagementInterface& operator = (const TargetPowerManagementInterface& other) = default;
TargetPowerManagementInterface(TargetPowerManagementInterface&& other) = default;
TargetPowerManagementInterface& operator = (TargetPowerManagementInterface&& other) = default;
/**
* Should enable the target power if currently disabled.
*/
virtual void enableTargetPower() = 0;
/**
* Should disable the target power if currently enabled.
*/
virtual void disableTargetPower() = 0;
};
}