2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <set>
|
2024-07-23 21:14:22 +01:00
|
|
|
#include <vector>
|
2022-06-04 15:18:53 +01:00
|
|
|
#include <optional>
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2025-01-07 23:31:48 +00:00
|
|
|
#include "src/Targets/Microchip/Avr8/TargetSignature.hpp"
|
|
|
|
|
#include "src/Targets/Microchip/Avr8/Family.hpp"
|
|
|
|
|
#include "src/Targets/Microchip/Avr8/ProgramMemorySection.hpp"
|
2022-03-01 22:40:00 +00:00
|
|
|
|
2024-07-23 21:14:22 +01:00
|
|
|
#include "src/Targets/TargetDescriptor.hpp"
|
|
|
|
|
#include "src/Targets/TargetAddressSpaceDescriptor.hpp"
|
|
|
|
|
#include "src/Targets/TargetMemorySegmentDescriptor.hpp"
|
2021-04-04 21:04:12 +01:00
|
|
|
#include "src/Targets/TargetState.hpp"
|
2024-03-09 17:16:29 +00:00
|
|
|
#include "src/Targets/TargetRegisterDescriptor.hpp"
|
2021-04-04 21:04:12 +01:00
|
|
|
#include "src/Targets/TargetMemory.hpp"
|
2025-01-28 00:14:04 +00:00
|
|
|
#include "src/Targets/TargetMemoryAddressRange.hpp"
|
2025-01-19 14:44:30 +00:00
|
|
|
#include "src/Targets/TargetBreakpoint.hpp"
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2024-07-23 21:14:22 +01:00
|
|
|
namespace DebugToolDrivers::TargetInterfaces::Microchip::Avr8
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
|
|
|
|
/**
|
2022-02-15 13:14:03 +00:00
|
|
|
* Interfacing with an AVR8 target for debugging operations can vary significantly, depending on the debug tool
|
|
|
|
|
* being used. Some debug tools employ different protocols.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2022-02-15 13:14:03 +00:00
|
|
|
* This class describes the interface required for interfacing with AVR8 targets, for debugging operations.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
|
|
|
|
* 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
|
2023-08-13 15:47:51 +01:00
|
|
|
* interfacing with AVR8 targets. See DebugToolDrivers::AtmelIce::getAvr8DebugInterface() and
|
|
|
|
|
* DebugTool::getAvr8DebugInterface() for more on this.
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
2022-02-15 13:14:03 +00:00
|
|
|
class Avr8DebugInterface
|
2021-04-04 21:04:12 +01:00
|
|
|
{
|
|
|
|
|
public:
|
2022-02-15 13:14:03 +00:00
|
|
|
Avr8DebugInterface() = default;
|
|
|
|
|
virtual ~Avr8DebugInterface() = default;
|
2022-01-11 21:12:25 +00:00
|
|
|
|
2022-02-15 13:14:03 +00:00
|
|
|
Avr8DebugInterface(const Avr8DebugInterface& other) = default;
|
|
|
|
|
Avr8DebugInterface(Avr8DebugInterface&& other) = default;
|
2022-01-11 21:12:25 +00:00
|
|
|
|
2022-02-15 13:14:03 +00:00
|
|
|
Avr8DebugInterface& operator = (const Avr8DebugInterface& other) = default;
|
|
|
|
|
Avr8DebugInterface& operator = (Avr8DebugInterface&& other) = default;
|
2022-01-11 21:12:25 +00:00
|
|
|
|
2021-04-04 21:04:12 +01:00
|
|
|
virtual void init() = 0;
|
|
|
|
|
virtual void stop() = 0;
|
|
|
|
|
virtual void run() = 0;
|
2023-04-01 12:40:12 +01:00
|
|
|
virtual void runTo(Targets::TargetMemoryAddress address) = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
virtual void step() = 0;
|
|
|
|
|
virtual void reset() = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should activate the physical interface between the debug tool and the AVR8 target.
|
2022-03-02 00:56:40 +00:00
|
|
|
*
|
2024-07-23 21:14:22 +01:00
|
|
|
* If the debugWIRE interface has been selected - this function should throw a DebugWirePhysicalInterfaceError
|
2022-03-02 00:56:40 +00:00
|
|
|
* 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.
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
|
|
|
|
virtual void activate() = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Should deactivate the physical interface between the debug tool and the AVR8 target.
|
|
|
|
|
*/
|
|
|
|
|
virtual void deactivate() = 0;
|
|
|
|
|
|
|
|
|
|
/**
|
2024-07-23 21:14:22 +01:00
|
|
|
* 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.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2024-07-23 21:14:22 +01:00
|
|
|
* 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.
|
|
|
|
|
*
|
2024-12-07 16:43:16 +00:00
|
|
|
* This function should apply any additional access restrictions for the given register.
|
2024-07-23 21:14:22 +01:00
|
|
|
*
|
|
|
|
|
* @param registerDescriptor
|
|
|
|
|
* The descriptor of the register.
|
|
|
|
|
*
|
|
|
|
|
* @param addressSpaceDescriptor
|
|
|
|
|
* The descriptor of the address space in which the register resides.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
2024-12-07 16:43:16 +00:00
|
|
|
virtual void applyAccessRestrictions(
|
|
|
|
|
Targets::TargetRegisterDescriptor& registerDescriptor,
|
2024-07-23 21:14:22 +01:00
|
|
|
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor
|
|
|
|
|
) = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
|
|
|
|
/**
|
2024-07-23 21:14:22 +01:00
|
|
|
* Should retrieve the AVR8 target signature of the AVR8 target.
|
2021-04-04 21:04:12 +01:00
|
|
|
*
|
2024-07-23 21:14:22 +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
|
|
|
*
|
2024-07-23 21:14:22 +01:00
|
|
|
* @return
|
2021-04-04 21:04:12 +01:00
|
|
|
*/
|
2024-07-23 21:14:22 +01:00
|
|
|
virtual Targets::Microchip::Avr8::TargetSignature getDeviceId() = 0;
|
2023-09-20 23:37:54 +01:00
|
|
|
|
2025-01-19 14:44:30 +00:00
|
|
|
virtual void setProgramBreakpoint(const Targets::TargetProgramBreakpoint& breakpoint) = 0;
|
|
|
|
|
virtual void removeProgramBreakpoint(const Targets::TargetProgramBreakpoint& breakpoint) = 0;
|
2024-12-05 23:09:01 +00:00
|
|
|
|
2023-09-21 00:40:30 +01:00
|
|
|
virtual Targets::TargetMemoryAddress getProgramCounter() = 0;
|
|
|
|
|
virtual void setProgramCounter(Targets::TargetMemoryAddress programCounter) = 0;
|
2024-07-23 21:14:22 +01:00
|
|
|
virtual Targets::TargetRegisterDescriptorAndValuePairs readRegisters(
|
|
|
|
|
const Targets::TargetRegisterDescriptors& descriptors
|
|
|
|
|
) = 0;
|
|
|
|
|
virtual void writeRegisters(const Targets::TargetRegisterDescriptorAndValuePairs& registers) = 0;
|
2021-05-24 20:58:49 +01:00
|
|
|
virtual Targets::TargetMemoryBuffer readMemory(
|
2024-07-23 21:14:22 +01:00
|
|
|
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
|
|
|
|
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
2022-09-06 17:16:49 +01:00
|
|
|
Targets::TargetMemoryAddress startAddress,
|
|
|
|
|
Targets::TargetMemorySize bytes,
|
2021-12-25 20:57:03 +00:00
|
|
|
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
|
2021-05-24 20:58:49 +01:00
|
|
|
) = 0;
|
|
|
|
|
virtual void writeMemory(
|
2024-07-23 21:14:22 +01:00
|
|
|
const Targets::TargetAddressSpaceDescriptor& addressSpaceDescriptor,
|
|
|
|
|
const Targets::TargetMemorySegmentDescriptor& memorySegmentDescriptor,
|
2022-09-06 17:16:49 +01:00
|
|
|
Targets::TargetMemoryAddress startAddress,
|
2024-11-16 21:49:49 +00:00
|
|
|
Targets::TargetMemoryBufferSpan buffer
|
2021-05-24 20:58:49 +01:00
|
|
|
) = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
|
2022-06-03 15:49:12 +01:00
|
|
|
/**
|
2022-06-04 15:18:53 +01:00
|
|
|
* Should erase the target's entire program memory, or a specific section where applicable.
|
2022-06-03 15:49:12 +01:00
|
|
|
*
|
|
|
|
|
* @param section
|
2022-06-04 15:18:53 +01:00
|
|
|
* The section to erase, or std::nullopt to erase the entire program memory.
|
2022-06-03 15:49:12 +01:00
|
|
|
*/
|
2022-06-04 15:18:53 +01:00
|
|
|
virtual void eraseProgramMemory(
|
2024-07-23 21:14:22 +01:00
|
|
|
std::optional<Targets::Microchip::Avr8::ProgramMemorySection> section = std::nullopt
|
2022-06-04 15:18:53 +01:00
|
|
|
) = 0;
|
2022-06-03 15:49:12 +01:00
|
|
|
|
2023-05-26 22:45:57 +01:00
|
|
|
virtual void eraseChip() = 0;
|
2024-07-23 21:14:22 +01:00
|
|
|
virtual Targets::TargetExecutionState getExecutionState() = 0;
|
2022-05-15 17:40:15 +01:00
|
|
|
virtual void enableProgrammingMode() = 0;
|
|
|
|
|
virtual void disableProgrammingMode() = 0;
|
2021-04-04 21:04:12 +01:00
|
|
|
};
|
2021-06-06 17:44:13 +01:00
|
|
|
}
|