2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
|
|
#include "src/Targets/Microchip/AVR/TargetSignature.hpp"
|
|
|
|
|
#include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp"
|
2021-06-06 17:44:13 +01:00
|
|
|
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
|
2021-04-04 21:04:12 +01:00
|
|
|
#include "src/Targets/TargetState.hpp"
|
|
|
|
|
#include "src/Targets/TargetRegister.hpp"
|
|
|
|
|
#include "src/Targets/TargetMemory.hpp"
|
|
|
|
|
#include "src/ApplicationConfig.hpp"
|
|
|
|
|
|
|
|
|
|
namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Interfacing with an AVR8 target can vary significantly, depending on the debug tool being used.
|
|
|
|
|
*
|
|
|
|
|
* This class describes the interface required for interfacing with AVR8 targets.
|
|
|
|
|
*
|
|
|
|
|
* Each debug tool that supports interfacing with AVR8 targets must provide an implementation
|
|
|
|
|
* of this interface class. For example, the Atmel-ICE provides the EdbgAvr8Interface implementation for
|
2021-04-04 21:11:02 +01:00
|
|
|
* interfacing with AVR8 targets. See Bloom::DebugToolDrivers::AtmelIce::getAvr8Interface() and
|
|
|
|
|
* Bloom::DebugTool::getAvr8Interface() for more on this.
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
|
|
|
|
class Avr8Interface
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* Configures the interface. Any debug tool -> target interface specific configuration should take
|
|
|
|
|
* place here.
|
|
|
|
|
*
|
|
|
|
|
* For example, the EdbgAvr8Interface implementation configures the physical interface and config
|
|
|
|
|
* variant here.
|
|
|
|
|
*
|
|
|
|
|
* @param targetConfig
|
|
|
|
|
*/
|
|
|
|
|
virtual void configure(const TargetConfig& targetConfig) = 0;
|
|
|
|
|
|
2021-06-06 17:44:13 +01:00
|
|
|
/**
|
|
|
|
|
* Sets the target family, independent of other configuration.
|
|
|
|
|
*
|
|
|
|
|
* @param family
|
|
|
|
|
*/
|
|
|
|
|
virtual void setFamily(Targets::Microchip::Avr::Avr8Bit::Family family) = 0;
|
|
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
/**
|
|
|
|
|
* Should accept Avr8 target parameters for configuration of the interface.
|
|
|
|
|
*
|
|
|
|
|
* @param config
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual void setTargetParameters(const Targets::Microchip::Avr::Avr8Bit::TargetParameters& config) = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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(std::uint32_t 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.
|
|
|
|
|
*/
|
|
|
|
|
virtual void activate() = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should deactivate the physical interface between the debug tool and the AVR8 target.
|
|
|
|
|
*/
|
|
|
|
|
virtual void deactivate() = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should retrieve the AVR8 target signature of the AVR8 target.
|
|
|
|
|
*
|
2021-06-11 23:59:17 +01:00
|
|
|
* This method may invoke stop(), as the target may be required to be in a halted state before the signature
|
|
|
|
|
* can be read.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual Targets::Microchip::Avr::TargetSignature getDeviceId() = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should set a software breakpoint at a given address.
|
|
|
|
|
*
|
|
|
|
|
* @param address
|
|
|
|
|
*/
|
|
|
|
|
virtual void setBreakpoint(std::uint32_t address) = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should remove a software breakpoint at a given address.
|
|
|
|
|
*
|
|
|
|
|
* @param address
|
|
|
|
|
*/
|
|
|
|
|
virtual void clearBreakpoint(std::uint32_t 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 std::uint32_t getProgramCounter() = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should retrieve the current stack pointer register value from the target.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual Targets::TargetRegister getStackPointerRegister() = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should retrieve the current status register value from the target.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual Targets::TargetRegister getStatusRegister() = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should update the program counter value on the target.
|
|
|
|
|
*
|
|
|
|
|
* @param programCounter
|
|
|
|
|
*/
|
|
|
|
|
virtual void setProgramCounter(std::uint32_t programCounter) = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SHould update the stack pointer register value on the target.
|
|
|
|
|
*
|
|
|
|
|
* @param stackPointerRegister
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual void setStackPointerRegister(const Targets::TargetRegister& stackPointerRegister) = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should update the status register value on the target.
|
|
|
|
|
*
|
|
|
|
|
* @param statusRegister
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual void setStatusRegister(const Targets::TargetRegister& statusRegister) = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should read the requested general purpose register from the target.
|
|
|
|
|
*
|
|
|
|
|
* @param registerIds
|
|
|
|
|
* A set of register IDs: 0 -> 31
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual Targets::TargetRegisters readGeneralPurposeRegisters(std::set<size_t> registerIds) = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should update the value of general purpose registers.
|
|
|
|
|
*
|
|
|
|
|
* @param registers
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual void writeGeneralPurposeRegisters(const Targets::TargetRegisters& registers) = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should read memory from the target, for the given memory type.
|
|
|
|
|
*
|
|
|
|
|
* @param memoryType
|
|
|
|
|
* @param startAddress
|
|
|
|
|
* @param bytes
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual Targets::TargetMemoryBuffer readMemory(
|
|
|
|
|
Targets::TargetMemoryType memoryType,
|
|
|
|
|
std::uint32_t startAddress,
|
|
|
|
|
std::uint32_t bytes
|
|
|
|
|
) = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should write memory to the target, for a given memory type.
|
|
|
|
|
*
|
|
|
|
|
* @param memoryType
|
|
|
|
|
* @param startAddress
|
|
|
|
|
* @param buffer
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual void writeMemory(
|
|
|
|
|
Targets::TargetMemoryType memoryType,
|
|
|
|
|
std::uint32_t startAddress,
|
|
|
|
|
const Targets::TargetMemoryBuffer& buffer
|
|
|
|
|
) = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should obtain the current target state.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual Targets::TargetState getTargetState() = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
2021-06-06 17:44:13 +01:00
|
|
|
}
|