Added TargetMemoryAddress, TargetMemorySize, TargetProgramCounter and TargetStackPointer aliases

This commit is contained in:
Nav
2022-09-06 17:16:49 +01:00
parent 620e6dc06a
commit 46d8ce1854
46 changed files with 234 additions and 174 deletions

View File

@@ -20,7 +20,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
/**
* Start address of the memory operation.
*/
std::uint32_t startAddress = 0;
Targets::TargetMemoryAddress startAddress = 0;
/**
* The type of memory to read from.
@@ -30,7 +30,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
/**
* Number of bytes to read.
*/
std::uint32_t bytes = 0;
Targets::TargetMemorySize bytes = 0;
explicit ReadMemory(const RawPacketType& rawPacket, const Gdb::TargetDescriptor& gdbTargetDescriptor);

View File

@@ -20,7 +20,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
/**
* Start address of the memory operation.
*/
std::uint32_t startAddress = 0;
Targets::TargetMemoryAddress startAddress = 0;
/**
* The type of memory to read from.

View File

@@ -16,7 +16,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
: CommandPacket(rawPacket)
{
if (this->data.size() > 1) {
this->fromProgramCounter = static_cast<std::uint32_t>(
this->fromProgramCounter = static_cast<Targets::TargetProgramCounter>(
std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16)
);
}

View File

@@ -5,6 +5,8 @@
#include "CommandPacket.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::DebugServer::Gdb::CommandPackets
{
/**
@@ -22,7 +24,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
*
* Although the packet *can* contain this address, it is not required, hence the std::optional type.
*/
std::optional<std::uint32_t> fromProgramCounter;
std::optional<Targets::TargetProgramCounter> fromProgramCounter;
explicit ContinueExecution(const RawPacketType& rawPacket);

View File

@@ -7,6 +7,8 @@
#include "CommandPacket.hpp"
#include "src/DebugServer/Gdb/BreakpointType.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::DebugServer::Gdb::CommandPackets
{
/**
@@ -24,7 +26,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
/**
* Address at which the breakpoint should be located.
*/
std::uint32_t address = 0;
Targets::TargetMemoryAddress address = 0;
explicit RemoveBreakpoint(const RawPacketType& rawPacket);

View File

@@ -7,6 +7,8 @@
#include "CommandPacket.hpp"
#include "src/DebugServer/Gdb/BreakpointType.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::DebugServer::Gdb::CommandPackets
{
/**
@@ -24,7 +26,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
/**
* Address at which the breakpoint should be located.
*/
std::uint32_t address = 0;
Targets::TargetMemoryAddress address = 0;
explicit SetBreakpoint(const RawPacketType& rawPacket);

View File

@@ -17,7 +17,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
: CommandPacket(rawPacket)
{
if (this->data.size() > 1) {
this->fromProgramCounter = static_cast<std::uint32_t>(
this->fromProgramCounter = static_cast<Targets::TargetProgramCounter>(
std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16)
);
}

View File

@@ -5,6 +5,8 @@
#include "CommandPacket.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::DebugServer::Gdb::CommandPackets
{
/**
@@ -17,7 +19,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
/**
* The address from which to begin the step.
*/
std::optional<std::size_t> fromProgramCounter;
std::optional<Targets::TargetProgramCounter> fromProgramCounter;
explicit StepExecution(const RawPacketType& rawPacket);

View File

@@ -74,6 +74,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
using Bloom::Targets::TargetState;
using Bloom::Targets::TargetMemoryType;
using Bloom::Targets::TargetMemoryBuffer;
using Bloom::Targets::TargetMemoryAddress;
using Bloom::Targets::TargetMemorySize;
using Bloom::Targets::TargetProgramCounter;
using Bloom::Targets::TargetRegister;
using Bloom::Targets::TargetRegisterDescriptor;
using Bloom::Targets::TargetRegisterDescriptors;
@@ -219,7 +222,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
this->targetState = TargetState::RUNNING;
}
void EdbgAvr8Interface::runTo(std::uint32_t address) {
void EdbgAvr8Interface::runTo(TargetProgramCounter address) {
this->clearEvents();
auto response = this->edbgInterface.sendAvrCommandFrameAndWaitForResponseFrame(
RunTo(address)
@@ -319,7 +322,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
}
}
std::uint32_t EdbgAvr8Interface::getProgramCounter() {
TargetProgramCounter EdbgAvr8Interface::getProgramCounter() {
if (this->targetState != TargetState::STOPPED) {
this->stop();
}
@@ -335,7 +338,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
return response.extractProgramCounter();
}
void EdbgAvr8Interface::setProgramCounter(std::uint32_t programCounter) {
void EdbgAvr8Interface::setProgramCounter(TargetProgramCounter programCounter) {
if (this->targetState != TargetState::STOPPED) {
this->stop();
}
@@ -366,7 +369,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
* TODO: Currently, we're assuming the signature will always only ever be three bytes in size, but we may
* want to consider pulling the size from the TDF.
*/
auto signatureMemory = this->readMemory(
const auto signatureMemory = this->readMemory(
Avr8MemoryType::SRAM,
this->targetParameters.signatureSegmentStartAddress.value(),
3
@@ -390,7 +393,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
return response.extractSignature(this->targetConfig->physicalInterface);
}
void EdbgAvr8Interface::setBreakpoint(std::uint32_t address) {
void EdbgAvr8Interface::setBreakpoint(TargetMemoryAddress address) {
auto response = this->edbgInterface.sendAvrCommandFrameAndWaitForResponseFrame(
SetSoftwareBreakpoints({address})
);
@@ -400,7 +403,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
}
}
void EdbgAvr8Interface::clearBreakpoint(std::uint32_t address) {
void EdbgAvr8Interface::clearBreakpoint(TargetMemoryAddress address) {
auto response = this->edbgInterface.sendAvrCommandFrameAndWaitForResponseFrame(
ClearSoftwareBreakpoints({address})
);
@@ -444,10 +447,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
auto descriptorsByType = std::map<TargetRegisterType, std::set<const TargetRegisterDescriptor*>>();
/*
* An address range is just an std::pair of integers - the first being the start address, the second being the
* end address.
* An address range is just an std::pair of addresses - the first being the start address, the second being
* the end address.
*
* TODO: Can't we just use the TargetMemoryAddressRange struct here? Review
*/
using AddressRange = std::pair<std::uint32_t, std::uint32_t>;
using AddressRange = std::pair<TargetMemoryAddress, TargetMemoryAddress>;
auto addressRangeByType = std::map<TargetRegisterType, AddressRange>();
for (const auto& descriptor : descriptors) {
@@ -519,7 +524,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
*
* See CommandFrames::Avr8Generic::ReadMemory(); and the Microchip EDBG documentation for more.
*/
auto excludedAddresses = std::set<std::uint32_t>();
auto excludedAddresses = std::set<TargetMemoryAddress>();
if (memoryType == Avr8MemoryType::SRAM && this->targetParameters.ocdDataRegister.has_value()) {
excludedAddresses.insert(
this->targetParameters.ocdDataRegister.value()
@@ -608,8 +613,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
TargetMemoryBuffer EdbgAvr8Interface::readMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
TargetMemoryAddress startAddress,
TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges
) {
if (
@@ -667,7 +672,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
*
* We will perform the conversion here.
*/
auto excludedAddresses = std::set<std::uint32_t>();
auto excludedAddresses = std::set<TargetMemoryAddress>();
auto endAddress = startAddress + bytes - 1;
for (const auto& addressRange : excludedAddressRanges) {
@@ -686,7 +691,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
void EdbgAvr8Interface::writeMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
TargetMemoryAddress startAddress,
const TargetMemoryBuffer& buffer
) {
auto avr8MemoryType = Avr8MemoryType::SRAM;
@@ -1459,7 +1464,10 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
;
}
std::uint32_t EdbgAvr8Interface::alignMemoryAddress(Avr8MemoryType memoryType, std::uint32_t address) {
TargetMemoryAddress EdbgAvr8Interface::alignMemoryAddress(
Avr8MemoryType memoryType,
TargetMemoryAddress address
) {
std::uint16_t alignTo = 1;
// We don't have to align to the page size in all cases. We may only need to align to the word size (2 bytes).
@@ -1497,7 +1505,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
}
if ((address % alignTo) != 0) {
return static_cast<std::uint32_t>(std::floor(
return static_cast<TargetMemoryAddress>(std::floor(
static_cast<float>(address) / static_cast<float>(alignTo)
) * alignTo);
}
@@ -1505,7 +1513,10 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
return address;
}
std::uint32_t EdbgAvr8Interface::alignMemoryBytes(Avr8MemoryType memoryType, std::uint32_t bytes) {
TargetMemorySize EdbgAvr8Interface::alignMemoryBytes(
Avr8MemoryType memoryType,
TargetMemorySize bytes
) {
std::uint16_t alignTo = 1;
// We don't have to align to the page size in all cases. We may only need to align to the word size (2 bytes).
@@ -1537,7 +1548,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
}
if ((bytes % alignTo) != 0) {
return static_cast<std::uint32_t>(std::ceil(
return static_cast<TargetMemorySize>(std::ceil(
static_cast<float>(bytes) / static_cast<float>(alignTo)
) * alignTo);
}
@@ -1547,9 +1558,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
TargetMemoryBuffer EdbgAvr8Interface::readMemory(
Avr8MemoryType type,
std::uint32_t startAddress,
std::uint32_t bytes,
const std::set<std::uint32_t>& excludedAddresses
TargetMemoryAddress startAddress,
TargetMemorySize bytes,
const std::set<TargetMemoryAddress>& excludedAddresses
) {
if (!excludedAddresses.empty() && (this->avoidMaskedMemoryRead || type != Avr8MemoryType::SRAM)) {
/*
@@ -1632,12 +1643,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
// bytes should always be a multiple of pageSize (given the code above)
assert(bytes % pageSize == 0);
int pagesRequired = static_cast<int>(bytes / pageSize);
TargetMemoryBuffer memoryBuffer;
auto memoryBuffer = Targets::TargetMemoryBuffer();
for (auto i = 0; i < pagesRequired; i++) {
auto pageBuffer = this->readMemory(
type,
startAddress + static_cast<std::uint32_t>(pageSize * i),
startAddress + static_cast<TargetMemoryAddress>(pageSize * i),
pageSize
);
std::move(pageBuffer.begin(), pageBuffer.end(), std::back_inserter(memoryBuffer));
@@ -1655,17 +1666,17 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
if (this->maximumMemoryAccessSizePerRequest.has_value() && bytes > this->maximumMemoryAccessSizePerRequest) {
auto maximumRequestSize = this->maximumMemoryAccessSizePerRequest.value();
auto totalReadsRequired = std::ceil(static_cast<float>(bytes) / static_cast<float>(maximumRequestSize));
auto output = std::vector<unsigned char>();
auto output = Targets::TargetMemoryBuffer();
output.reserve(bytes);
for (float i = 1; i <= totalReadsRequired; i++) {
const auto bytesToRead = static_cast<std::uint32_t>(
const auto bytesToRead = static_cast<TargetMemorySize>(
(bytes - output.size()) > maximumRequestSize ? maximumRequestSize : bytes - output.size()
);
auto data = this->readMemory(
type,
static_cast<std::uint32_t>(startAddress + output.size()),
static_cast<TargetMemoryAddress>(startAddress + output.size()),
bytesToRead,
excludedAddresses
);
@@ -1704,16 +1715,16 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
* This call to readMemory() will result in more than two response packets, so split it into multiple
* calls that will result in no more than two response packets per call.
*/
auto output = std::vector<unsigned char>();
auto output = TargetMemoryBuffer();
for (float i = 1; i <= totalReadsRequired; i++) {
auto bytesToRead = static_cast<std::uint32_t>(
auto bytesToRead = static_cast<TargetMemorySize>(
(bytes - output.size()) > (singlePacketSize * 2) ? (singlePacketSize * 2)
: bytes - output.size()
);
auto data = this->readMemory(
type,
static_cast<std::uint32_t>(startAddress + output.size()),
static_cast<TargetMemoryAddress>(startAddress + output.size()),
bytesToRead,
excludedAddresses
);
@@ -1740,8 +1751,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
return response.getMemoryBuffer();
}
void EdbgAvr8Interface::writeMemory(Avr8MemoryType type, std::uint32_t startAddress, const TargetMemoryBuffer& buffer) {
const auto bytes = static_cast<std::uint32_t>(buffer.size());
void EdbgAvr8Interface::writeMemory(
Avr8MemoryType type,
TargetMemoryAddress startAddress,
const TargetMemoryBuffer& buffer
) {
const auto bytes = static_cast<TargetMemorySize>(buffer.size());
if (this->alignmentRequired(type)) {
const auto alignedStartAddress = this->alignMemoryAddress(type, startAddress);

View File

@@ -8,6 +8,7 @@
#include "src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8DebugInterface.hpp"
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Avr8Generic.hpp"
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp"
#include "src/Targets/TargetMemory.hpp"
#include "src/Targets/Microchip/AVR/Target.hpp"
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
@@ -65,7 +66,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
*
* @param maximumSize
*/
void setMaximumMemoryAccessSizePerRequest(std::uint32_t maximumSize) {
void setMaximumMemoryAccessSizePerRequest(Targets::TargetMemorySize maximumSize) {
this->maximumMemoryAccessSizePerRequest = maximumSize;
}
@@ -122,7 +123,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
* @param address
* The (byte) address to run to.
*/
void runTo(std::uint32_t address) override;
void runTo(Targets::TargetProgramCounter address) override;
/**
* Issues the "step" command to the debug tool, stepping the execution on the target. The stepping can be
@@ -152,7 +153,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
*
* @return
*/
std::uint32_t getProgramCounter() override;
Targets::TargetProgramCounter getProgramCounter() override;
/**
* Issues the "PC Write" command to the debug tool, setting the program counter on the target.
@@ -160,7 +161,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
* @param programCounter
* The byte address to set as the program counter.
*/
void setProgramCounter(std::uint32_t programCounter) override;
void setProgramCounter(Targets::TargetProgramCounter programCounter) override;
/**
* Issues the "Get ID" command to the debug tool, to extract the signature from the target.
@@ -176,7 +177,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
* @param address
* The byte address to position the breakpoint.
*/
void setBreakpoint(std::uint32_t address) override;
void setBreakpoint(Targets::TargetMemoryAddress address) override;
/**
* Issues the "Software Breakpoint Clear" command to the debug tool, clearing any breakpoint at the given
@@ -185,7 +186,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
* @param address
* The byte address of the breakpoint to clear.
*/
void clearBreakpoint(std::uint32_t address) override;
void clearBreakpoint(Targets::TargetMemoryAddress address) override;
/**
* Issues the "Software Breakpoint Clear All" command to the debug tool, clearing all software breakpoints
@@ -222,8 +223,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
*/
Targets::TargetMemoryBuffer readMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
) override;
@@ -238,7 +239,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
*/
void writeMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
Targets::TargetMemoryAddress startAddress,
const Targets::TargetMemoryBuffer& buffer
) override;
@@ -321,7 +322,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
/**
* See the comment for EdbgAvr8Interface::setMaximumMemoryAccessSizePerRequest().
*/
std::optional<std::uint32_t> maximumMemoryAccessSizePerRequest;
std::optional<Targets::TargetMemorySize> maximumMemoryAccessSizePerRequest;
/**
* We keep record of the current target state for caching purposes. We'll only refresh the target state if the
@@ -492,7 +493,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
* @param address
* @return
*/
std::uint32_t alignMemoryAddress(Avr8MemoryType memoryType, std::uint32_t address);
Targets::TargetMemoryAddress alignMemoryAddress(Avr8MemoryType memoryType, Targets::TargetMemoryAddress address);
/**
* Aligns a number of bytes used to address memory, for a given memory type's page size.
@@ -501,7 +502,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
* @param bytes
* @return
*/
std::uint32_t alignMemoryBytes(Avr8MemoryType memoryType, std::uint32_t bytes);
Targets::TargetMemorySize alignMemoryBytes(Avr8MemoryType memoryType, Targets::TargetMemorySize bytes);
/**
* Reads memory on the target.
@@ -527,9 +528,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
*/
Targets::TargetMemoryBuffer readMemory(
Avr8MemoryType type,
std::uint32_t startAddress,
std::uint32_t bytes,
const std::set<std::uint32_t>& excludedAddresses = {}
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddress>& excludedAddresses = {}
);
/**
@@ -543,7 +544,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
* @param address
* @param buffer
*/
void writeMemory(Avr8MemoryType type, std::uint32_t address, const Targets::TargetMemoryBuffer& buffer);
void writeMemory(Avr8MemoryType type, Targets::TargetMemoryAddress address, const Targets::TargetMemoryBuffer& buffer);
/**
* Fetches the current target state.

View File

@@ -3,6 +3,9 @@
#include <cstdint>
#include "Avr8GenericResponseFrame.hpp"
#include "src/Targets/TargetMemory.hpp"
#include "src/Exceptions/Exception.hpp"
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic
@@ -13,7 +16,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
GetProgramCounter() = default;
explicit GetProgramCounter(const std::vector<AvrResponse>& avrResponses): Avr8GenericResponseFrame(avrResponses) {}
std::uint32_t extractProgramCounter() {
Targets::TargetProgramCounter extractProgramCounter() {
/*
* The payload for the PC Read command should always consist of six bytes. Thr first two being the
* command ID and version, the other four being the PC. The four PC bytes are little-endian.
@@ -24,7 +27,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
"frame - unexpected payload size.");
}
return static_cast<std::uint32_t>(payload[5] << 24 | payload[4] << 16 | payload[3] << 8 | payload[2]) * 2;
return static_cast<Targets::TargetProgramCounter>(
payload[5] << 24 | payload[4] << 16 | payload[3] << 8 | payload[2]
) * 2;
}
};
}

View File

@@ -81,7 +81,7 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
/**
* Continue execution up to a specific byte address.
*/
virtual void runTo(std::uint32_t address) = 0;
virtual void runTo(Targets::TargetProgramCounter address) = 0;
/**
* Step execution on teh AVR8 target.
@@ -122,14 +122,14 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
*
* @param address
*/
virtual void setBreakpoint(std::uint32_t address) = 0;
virtual void setBreakpoint(Targets::TargetMemoryAddress address) = 0;
/**
* Should remove a software breakpoint at a given address.
*
* @param address
*/
virtual void clearBreakpoint(std::uint32_t address) = 0;
virtual void clearBreakpoint(Targets::TargetMemoryAddress address) = 0;
/**
* Should remove all software and hardware breakpoints on the target.
@@ -141,14 +141,14 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
*
* @return
*/
virtual std::uint32_t getProgramCounter() = 0;
virtual Targets::TargetProgramCounter getProgramCounter() = 0;
/**
* Should update the program counter value on the target.
*
* @param programCounter
*/
virtual void setProgramCounter(std::uint32_t programCounter) = 0;
virtual void setProgramCounter(Targets::TargetProgramCounter programCounter) = 0;
/**
* Should read the requested registers from the target.
@@ -178,8 +178,8 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
*/
virtual Targets::TargetMemoryBuffer readMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
) = 0;
@@ -192,7 +192,7 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
*/
virtual void writeMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
Targets::TargetMemoryAddress startAddress,
const Targets::TargetMemoryBuffer& buffer
) = 0;

View File

@@ -14,13 +14,13 @@ namespace Bloom::Events
static inline const std::string name = "MemoryWrittenToTarget";
Targets::TargetMemoryType memoryType;
std::uint32_t startAddress;
std::uint32_t size;
Targets::TargetMemoryAddress startAddress;
Targets::TargetMemorySize size;
MemoryWrittenToTarget(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t size
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize size
)
: memoryType(memoryType)
, startAddress(startAddress)

View File

@@ -4,7 +4,9 @@
#include <string>
#include "Event.hpp"
#include "src/Targets/Target.hpp"
#include "src/Targets/TargetBreakpoint.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::Events
{
@@ -13,11 +15,14 @@ namespace Bloom::Events
public:
static constexpr EventType type = EventType::TARGET_EXECUTION_STOPPED;
static inline const std::string name = "TargetExecutionStopped";
std::uint32_t programCounter;
Targets::TargetProgramCounter programCounter;
Targets::TargetBreakCause breakCause;
TargetExecutionStopped(std::uint32_t programCounter, Targets::TargetBreakCause breakCause) :
programCounter(programCounter), breakCause(breakCause) {}
TargetExecutionStopped(Targets::TargetProgramCounter programCounter, Targets::TargetBreakCause breakCause)
: programCounter(programCounter)
, breakCause(breakCause)
{}
[[nodiscard]] EventType getType() const override {
return TargetExecutionStopped::type;

View File

@@ -2,6 +2,8 @@
#include "InsightWorkerTask.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom
{
class ReadProgramCounter: public InsightWorkerTask
@@ -12,7 +14,7 @@ namespace Bloom
ReadProgramCounter() = default;
signals:
void programCounterRead(std::uint32_t programCounter);
void programCounterRead(Targets::TargetProgramCounter programCounter);
protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;

View File

@@ -2,6 +2,8 @@
#include "InsightWorkerTask.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom
{
class ReadStackPointer: public InsightWorkerTask
@@ -12,7 +14,7 @@ namespace Bloom
ReadStackPointer() = default;
signals:
void stackPointerRead(std::uint32_t stackPointer);
void stackPointerRead(Targets::TargetStackPointer stackPointer);
protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override;

View File

@@ -25,10 +25,10 @@ namespace Bloom
for (auto i = 0; i < readsRequired; i++) {
auto dataSegment = targetControllerConsole.readMemory(
this->memoryType,
this->startAddress + static_cast<std::uint32_t>(readSize * i),
this->startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i),
(this->size - data.size()) >= readSize
? readSize
: static_cast<std::uint32_t>(this->size - data.size()),
: static_cast<Targets::TargetMemorySize>(this->size - data.size()),
this->excludedAddressRanges
);

View File

@@ -15,8 +15,8 @@ namespace Bloom
public:
ReadTargetMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t size,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize size,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
)
: memoryType(memoryType)
@@ -32,8 +32,8 @@ namespace Bloom
private:
Targets::TargetMemoryType memoryType;
std::uint32_t startAddress;
std::uint32_t size;
Targets::TargetMemoryAddress startAddress;
Targets::TargetMemorySize size;
std::set<Targets::TargetMemoryAddressRange> excludedAddressRanges;
};
}

View File

@@ -13,7 +13,8 @@
#include "src/Logger/Logger.hpp"
#include "src/Exceptions/Exception.hpp"
#include "src/Helpers/Paths.hpp"
#include "src/Targets/TargetDescriptor.hpp"
#include "src/Targets/TargetMemory.hpp"
#include "src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp"
@@ -896,7 +897,7 @@ namespace Bloom
readProgramCounterTask,
&ReadProgramCounter::programCounterRead,
this,
[this] (std::uint32_t programCounter) {
[this] (Targets::TargetProgramCounter programCounter) {
this->programCounterValueLabel->setText(
"0x" + QString::number(programCounter, 16).toUpper() + " (" + QString::number(programCounter) + ")"
);

View File

@@ -7,8 +7,8 @@
namespace Bloom::Widgets
{
AnnotationItem::AnnotationItem(
std::uint32_t startAddress,
std::size_t size,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize size,
QString labelText,
AnnotationItemPosition position
):

View File

@@ -3,6 +3,8 @@
#include <QGraphicsItem>
#include <cstdint>
#include "src/Targets/TargetMemory.hpp"
#include "src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/FocusedMemoryRegion.hpp"
namespace Bloom::Widgets
@@ -22,14 +24,14 @@ namespace Bloom::Widgets
const int width;
const int height;
const std::uint32_t startAddress;
const std::uint32_t endAddress;
const std::size_t size;
const Targets::TargetMemoryAddress startAddress;
const Targets::TargetMemoryAddress endAddress;
const Targets::TargetMemorySize size;
AnnotationItemPosition position = AnnotationItemPosition::TOP;
AnnotationItem(
std::uint32_t startAddress,
std::size_t size,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize size,
QString labelText,
AnnotationItemPosition position
);

View File

@@ -6,8 +6,8 @@ namespace Bloom::Widgets
{
ByteItem::ByteItem(
std::size_t byteIndex,
std::uint32_t address,
std::optional<std::uint32_t>& currentStackPointer,
Targets::TargetMemoryAddress address,
std::optional<Targets::TargetStackPointer>& currentStackPointer,
ByteItem** hoveredByteItem,
AnnotationItem** hoveredAnnotationItem,
std::set<ByteItem*>& highlightedByteItems,

View File

@@ -7,6 +7,8 @@
#include <optional>
#include <set>
#include "src/Targets/TargetMemory.hpp"
#include "HexViewerWidgetSettings.hpp"
#include "AnnotationItem.hpp"
@@ -25,7 +27,7 @@ namespace Bloom::Widgets
static constexpr int BOTTOM_MARGIN = 5;
std::size_t byteIndex;
std::uint32_t address = 0x00;
Targets::TargetMemoryAddress address = 0x00;
QString addressHex;
QString relativeAddressHex;
@@ -40,8 +42,8 @@ namespace Bloom::Widgets
ByteItem(
std::size_t byteIndex,
std::uint32_t address,
std::optional<std::uint32_t>& currentStackPointer,
Targets::TargetMemoryAddress address,
std::optional<Targets::TargetStackPointer>& currentStackPointer,
ByteItem** hoveredByteItem,
AnnotationItem** hoveredAnnotationItem,
std::set<ByteItem*>& highlightedByteItems,
@@ -71,7 +73,7 @@ namespace Bloom::Widgets
ByteItem** hoveredByteItem;
AnnotationItem** hoveredAnnotationItem;
std::optional<std::uint32_t>& currentStackPointer;
std::optional<Targets::TargetStackPointer>& currentStackPointer;
std::set<ByteItem*>& highlightedByteItems;
const QColor* getBackgroundColor();

View File

@@ -36,7 +36,7 @@ namespace Bloom::Widgets
}
void ByteItemContainerGraphicsView::scrollToByteItemAtAddress(std::uint32_t address) {
void ByteItemContainerGraphicsView::scrollToByteItemAtAddress(Targets::TargetMemoryAddress address) {
this->centerOn(this->scene->getByteItemPositionByAddress(address));
}

View File

@@ -34,7 +34,7 @@ namespace Bloom::Widgets
return this->scene;
}
void scrollToByteItemAtAddress(std::uint32_t address);
void scrollToByteItemAtAddress(Targets::TargetMemoryAddress address);
protected:
bool event(QEvent* event) override;

View File

@@ -32,7 +32,7 @@ namespace Bloom::Widgets
// Construct ByteWidget objects
const auto memorySize = this->targetMemoryDescriptor.size();
const auto startAddress = this->targetMemoryDescriptor.addressRange.startAddress;
for (std::uint32_t i = 0; i < memorySize; i++) {
for (Targets::TargetMemorySize i = 0; i < memorySize; i++) {
const auto address = startAddress + i;
auto* byteWidget = new ByteItem(

View File

@@ -53,13 +53,13 @@ namespace Bloom::Widgets
);
void updateValues(const Targets::TargetMemoryBuffer& buffer);
void updateStackPointer(std::uint32_t stackPointer);
void setHighlightedAddresses(const std::set<std::uint32_t>& highlightedAddresses);
void updateStackPointer(Targets::TargetStackPointer stackPointer);
void setHighlightedAddresses(const std::set<Targets::TargetMemoryAddress>& highlightedAddresses);
void refreshRegions();
void adjustSize(bool forced = false);
void setEnabled(bool enabled);
void invalidateChildItemCaches();
QPointF getByteItemPositionByAddress(std::uint32_t address);
QPointF getByteItemPositionByAddress(Targets::TargetMemoryAddress address);
signals:
void byteWidgetsAdjusted();
@@ -81,11 +81,11 @@ namespace Bloom::Widgets
ByteItem* hoveredByteWidget = nullptr;
AnnotationItem* hoveredAnnotationItem = nullptr;
std::optional<std::uint32_t> currentStackPointer;
std::optional<Targets::TargetStackPointer> currentStackPointer;
Targets::TargetMemoryBuffer lastValueBuffer;
std::map<std::uint32_t, ByteItem*> byteItemsByAddress;
std::map<Targets::TargetMemoryAddress, ByteItem*> byteItemsByAddress;
std::vector<AnnotationItem*> annotationItems;
std::vector<ValueAnnotationItem*> valueAnnotationItems;
std::map<std::size_t, std::vector<ByteItem*>> byteItemsByRowIndex;

View File

@@ -173,7 +173,7 @@ namespace Bloom::Widgets
this->byteItemGraphicsScene->refreshRegions();
}
void HexViewerWidget::setStackPointer(std::uint32_t stackPointer) {
void HexViewerWidget::setStackPointer(Targets::TargetStackPointer stackPointer) {
this->byteItemGraphicsScene->updateStackPointer(stackPointer);
}

View File

@@ -39,7 +39,7 @@ namespace Bloom::Widgets
void updateValues(const Targets::TargetMemoryBuffer& buffer);
void refreshRegions();
void setStackPointer(std::uint32_t stackPointer);
void setStackPointer(Targets::TargetStackPointer stackPointer);
protected:
void resizeEvent(QResizeEvent* event) override;

View File

@@ -241,7 +241,7 @@ namespace Bloom::Widgets
readStackPointerTask,
&ReadStackPointer::stackPointerRead,
this,
[this] (std::uint32_t stackPointer) {
[this] (Targets::TargetStackPointer stackPointer) {
this->hexViewerWidget->setStackPointer(stackPointer);
}
);

View File

@@ -19,14 +19,14 @@ namespace Bloom::TargetController::Commands
static inline const std::string name = "ReadTargetMemory";
Targets::TargetMemoryType memoryType;
std::uint32_t startAddress;
std::uint32_t bytes;
Targets::TargetMemoryAddress startAddress;
Targets::TargetMemorySize bytes;
std::set<Targets::TargetMemoryAddressRange> excludedAddressRanges;
ReadTargetMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges
)
: memoryType(memoryType)

View File

@@ -4,6 +4,8 @@
#include "Command.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::TargetController::Commands
{
class ResumeTargetExecution: public Command
@@ -12,10 +14,10 @@ namespace Bloom::TargetController::Commands
static constexpr CommandType type = CommandType::RESUME_TARGET_EXECUTION;
static inline const std::string name = "ResumeTargetExecution";
std::optional<std::uint32_t> fromProgramCounter;
std::optional<Targets::TargetProgramCounter> fromProgramCounter;
ResumeTargetExecution() = default;
explicit ResumeTargetExecution(std::uint32_t fromProgramCounter)
explicit ResumeTargetExecution(Targets::TargetProgramCounter fromProgramCounter)
: fromProgramCounter(fromProgramCounter)
{};

View File

@@ -5,6 +5,7 @@
#include "Command.hpp"
#include "src/Targets/TargetBreakpoint.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::TargetController::Commands
{
@@ -14,9 +15,9 @@ namespace Bloom::TargetController::Commands
static constexpr CommandType type = CommandType::SET_TARGET_PROGRAM_COUNTER;
static inline const std::string name = "SetTargetProgramCounter";
std::uint32_t address = 0;
Targets::TargetProgramCounter address = 0;
explicit SetTargetProgramCounter(std::uint32_t address)
explicit SetTargetProgramCounter(Targets::TargetProgramCounter address)
: address(address)
{};

View File

@@ -4,6 +4,8 @@
#include "Command.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::TargetController::Commands
{
class StepTargetExecution: public Command
@@ -12,10 +14,10 @@ namespace Bloom::TargetController::Commands
static constexpr CommandType type = CommandType::STEP_TARGET_EXECUTION;
static inline const std::string name = "StepTargetExecution";
std::optional<std::uint32_t> fromProgramCounter;
std::optional<Targets::TargetProgramCounter> fromProgramCounter;
StepTargetExecution() = default;
explicit StepTargetExecution(std::uint32_t fromProgramCounter)
explicit StepTargetExecution(Targets::TargetProgramCounter fromProgramCounter)
: fromProgramCounter(fromProgramCounter)
{};

View File

@@ -14,12 +14,12 @@ namespace Bloom::TargetController::Commands
static inline const std::string name = "WriteTargetMemory";
Targets::TargetMemoryType memoryType;
std::uint32_t startAddress;
Targets::TargetMemoryAddress startAddress;
Targets::TargetMemoryBuffer buffer;
WriteTargetMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
Targets::TargetMemoryAddress startAddress,
const Targets::TargetMemoryBuffer& buffer
)
: memoryType(memoryType)

View File

@@ -4,6 +4,8 @@
#include "Response.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::TargetController::Responses
{
class TargetProgramCounter: public Response
@@ -11,9 +13,9 @@ namespace Bloom::TargetController::Responses
public:
static constexpr ResponseType type = ResponseType::TARGET_PROGRAM_COUNTER;
std::uint32_t programCounter;
Targets::TargetProgramCounter programCounter;
explicit TargetProgramCounter(std::uint32_t programCounter)
explicit TargetProgramCounter(Targets::TargetProgramCounter programCounter)
: programCounter(programCounter)
{}

View File

@@ -4,6 +4,8 @@
#include "Response.hpp"
#include "src/Targets/TargetMemory.hpp"
namespace Bloom::TargetController::Responses
{
class TargetStackPointer: public Response
@@ -11,9 +13,9 @@ namespace Bloom::TargetController::Responses
public:
static constexpr ResponseType type = ResponseType::TARGET_STACK_POINTER;
std::uint32_t stackPointer;
Targets::TargetStackPointer stackPointer;
explicit TargetStackPointer(std::uint32_t stackPointer)
explicit TargetStackPointer(Targets::TargetStackPointer stackPointer)
: stackPointer(stackPointer)
{}

View File

@@ -648,8 +648,8 @@ namespace Bloom::TargetController
}
TargetRegisterDescriptors TargetControllerComponent::getRegisterDescriptorsWithinAddressRange(
std::uint32_t startAddress,
std::uint32_t endAddress,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemoryAddress endAddress,
Targets::TargetMemoryType memoryType
) {
auto output = TargetRegisterDescriptors();

View File

@@ -279,8 +279,8 @@ namespace Bloom::TargetController
* @return
*/
Targets::TargetRegisterDescriptors getRegisterDescriptorsWithinAddressRange(
std::uint32_t startAddress,
std::uint32_t endAddress,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemoryAddress endAddress,
Targets::TargetMemoryType memoryType
);

View File

@@ -52,8 +52,12 @@ namespace Bloom::TargetController
using Targets::TargetRegisterDescriptors;
using Targets::TargetMemoryType;
using Targets::TargetMemoryAddress;
using Targets::TargetMemorySize;
using Targets::TargetMemoryAddressRange;
using Targets::TargetMemoryBuffer;
using Targets::TargetProgramCounter;
using Targets::TargetStackPointer;
using Targets::TargetBreakpoint;
@@ -98,7 +102,7 @@ namespace Bloom::TargetController
);
}
void TargetControllerConsole::continueTargetExecution(std::optional<std::uint32_t> fromAddress) {
void TargetControllerConsole::continueTargetExecution(std::optional<TargetProgramCounter> fromAddress) {
auto resumeExecutionCommand = std::make_unique<ResumeTargetExecution>();
if (fromAddress.has_value()) {
@@ -111,7 +115,7 @@ namespace Bloom::TargetController
);
}
void TargetControllerConsole::stepTargetExecution(std::optional<std::uint32_t> fromAddress) {
void TargetControllerConsole::stepTargetExecution(std::optional<TargetProgramCounter> fromAddress) {
auto stepExecutionCommand = std::make_unique<StepTargetExecution>();
if (fromAddress.has_value()) {
@@ -140,8 +144,8 @@ namespace Bloom::TargetController
TargetMemoryBuffer TargetControllerConsole::readMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
TargetMemoryAddress startAddress,
TargetMemorySize bytes,
const std::set<TargetMemoryAddressRange>& excludedAddressRanges
) {
return this->commandManager.sendCommandAndWaitForResponse(
@@ -157,7 +161,7 @@ namespace Bloom::TargetController
void TargetControllerConsole::writeMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
TargetMemoryAddress startAddress,
const TargetMemoryBuffer& buffer
) {
this->commandManager.sendCommandAndWaitForResponse(
@@ -180,14 +184,14 @@ namespace Bloom::TargetController
);
}
std::uint32_t TargetControllerConsole::getProgramCounter() {
TargetProgramCounter TargetControllerConsole::getProgramCounter() {
return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetProgramCounter>(),
this->defaultTimeout
)->programCounter;
}
void TargetControllerConsole::setProgramCounter(std::uint32_t address) {
void TargetControllerConsole::setProgramCounter(TargetProgramCounter address) {
this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<SetTargetProgramCounter>(address),
this->defaultTimeout
@@ -208,7 +212,7 @@ namespace Bloom::TargetController
);
}
std::uint32_t TargetControllerConsole::getStackPointer() {
TargetStackPointer TargetControllerConsole::getStackPointer() {
return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetStackPointer>(),
this->defaultTimeout

View File

@@ -73,14 +73,14 @@ namespace Bloom::TargetController
*
* @param fromAddress
*/
void continueTargetExecution(std::optional<std::uint32_t> fromAddress);
void continueTargetExecution(std::optional<Targets::TargetProgramCounter> fromAddress);
/**
* Requests the TargetController to step execution on the target.
*
* @param fromAddress
*/
void stepTargetExecution(std::optional<std::uint32_t> fromAddress);
void stepTargetExecution(std::optional<Targets::TargetProgramCounter> fromAddress);
/**
* Requests the TargetController to read register values from the target.
@@ -110,8 +110,8 @@ namespace Bloom::TargetController
*/
Targets::TargetMemoryBuffer readMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
);
@@ -124,7 +124,7 @@ namespace Bloom::TargetController
*/
void writeMemory(
Targets::TargetMemoryType memoryType,
std::uint32_t startAddress,
Targets::TargetMemoryAddress startAddress,
const Targets::TargetMemoryBuffer& buffer
);
@@ -147,14 +147,14 @@ namespace Bloom::TargetController
*
* @return
*/
std::uint32_t getProgramCounter();
Targets::TargetProgramCounter getProgramCounter();
/**
* Sets the target's program counter to the given address.
*
* @param address
*/
void setProgramCounter(std::uint32_t address);
void setProgramCounter(Targets::TargetProgramCounter address);
/**
* Retrieves the pin states for a particular target variant.
@@ -176,7 +176,7 @@ namespace Bloom::TargetController
*
* @return
*/
std::uint32_t getStackPointer();
Targets::TargetStackPointer getStackPointer();
/**
* Triggers a reset on the target. The target will be held in a stopped state.

View File

@@ -90,8 +90,8 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
void step() override;
void reset() override;
void setBreakpoint(std::uint32_t address) override;
void removeBreakpoint(std::uint32_t address) override;
void setBreakpoint(TargetProgramCounter address) override;
void removeBreakpoint(TargetProgramCounter address) override;
void clearAllBreakpoints() override;
void writeRegisters(TargetRegisters registers) override;
@@ -99,23 +99,23 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
TargetMemoryBuffer readMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
TargetMemoryAddress startAddress,
TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
) override;
void writeMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
TargetMemoryAddress startAddress,
const TargetMemoryBuffer& buffer
) override;
TargetState getState() override;
std::uint32_t getProgramCounter() override;
TargetProgramCounter getProgramCounter() override;
TargetRegister getProgramCounterRegister();
void setProgramCounter(std::uint32_t programCounter) override;
void setProgramCounter(TargetProgramCounter programCounter) override;
std::uint32_t getStackPointer() override;
TargetStackPointer getStackPointer() override;
std::map<int, TargetPinState> getPinStates(int variantId) override;
void setPinState(
@@ -186,6 +186,6 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
* @param address
* @return
*/
ProgramMemorySection getProgramMemorySectionFromAddress(std::uint32_t address);
ProgramMemorySection getProgramMemorySectionFromAddress(TargetMemoryAddress address);
};
}

View File

@@ -202,14 +202,14 @@ namespace Bloom::Targets
*
* @param address
*/
virtual void setBreakpoint(std::uint32_t address) = 0;
virtual void setBreakpoint(TargetMemoryAddress address) = 0;
/**
* Should remove a breakpoint at the given address.
*
* @param address
*/
virtual void removeBreakpoint(std::uint32_t address) = 0;
virtual void removeBreakpoint(TargetMemoryAddress address) = 0;
/**
* Should clear all breakpoints on the target.
@@ -246,8 +246,8 @@ namespace Bloom::Targets
*/
virtual TargetMemoryBuffer readMemory(
TargetMemoryType memoryType,
std::uint32_t startAddress,
std::uint32_t bytes,
TargetMemoryAddress startAddress,
TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
) = 0;
@@ -258,7 +258,7 @@ namespace Bloom::Targets
* @param startAddress
* @param buffer
*/
virtual void writeMemory(TargetMemoryType memoryType, std::uint32_t startAddress, const TargetMemoryBuffer& buffer) = 0;
virtual void writeMemory(TargetMemoryType memoryType, TargetMemoryAddress startAddress, const TargetMemoryBuffer& buffer) = 0;
/**
* Should return the current state of the target.
@@ -272,21 +272,21 @@ namespace Bloom::Targets
*
* @return
*/
virtual std::uint32_t getProgramCounter() = 0;
virtual TargetProgramCounter getProgramCounter() = 0;
/**
* Should update the program counter on the target.
*
* @param programCounter
*/
virtual void setProgramCounter(std::uint32_t programCounter) = 0;
virtual void setProgramCounter(TargetProgramCounter programCounter) = 0;
/**
* Should fetch the current stack pointer value.
*
* @return
*/
virtual std::uint32_t getStackPointer() = 0;
virtual TargetStackPointer getStackPointer() = 0;
/**
* Should get the current pin states for each pin on the target, mapped by pin number

View File

@@ -2,6 +2,8 @@
#include <cstdint>
#include "TargetMemory.hpp"
namespace Bloom::Targets
{
enum class TargetBreakCause: int
@@ -10,18 +12,16 @@ namespace Bloom::Targets
UNKNOWN,
};
using TargetBreakpointAddress = std::uint32_t;
struct TargetBreakpoint
{
/**
* Byte address of the breakpoint.
*/
TargetBreakpointAddress address = 0;
TargetMemoryAddress address = 0;
bool disabled = false;
TargetBreakpoint() = default;
explicit TargetBreakpoint(TargetBreakpointAddress address): address(address) {};
explicit TargetBreakpoint(TargetMemoryAddress address): address(address) {};
};
}

View File

@@ -6,6 +6,12 @@
namespace Bloom::Targets
{
using TargetMemoryAddress = std::uint32_t;
using TargetMemorySize = std::uint32_t;
using TargetProgramCounter = TargetMemoryAddress;
using TargetStackPointer = TargetMemoryAddress;
using TargetMemoryBuffer = std::vector<unsigned char>;
enum class TargetMemoryEndianness: std::uint8_t
{
BIG,
@@ -22,11 +28,11 @@ namespace Bloom::Targets
struct TargetMemoryAddressRange
{
std::uint32_t startAddress = 0;
std::uint32_t endAddress = 0;
TargetMemoryAddress startAddress = 0;
TargetMemoryAddress endAddress = 0;
TargetMemoryAddressRange() = default;
TargetMemoryAddressRange(std::uint32_t startAddress, std::uint32_t endAddress)
TargetMemoryAddressRange(TargetMemoryAddress startAddress, TargetMemoryAddress endAddress)
: startAddress(startAddress)
, endAddress(endAddress)
{};
@@ -46,7 +52,7 @@ namespace Bloom::Targets
;
}
[[nodiscard]] bool contains(std::uint32_t address) const {
[[nodiscard]] bool contains(TargetMemoryAddress address) const {
return address >= this->startAddress && address <= this->endAddress;
}
@@ -75,10 +81,8 @@ namespace Bloom::Targets
return this->type == rhs.type && this->addressRange == rhs.addressRange;
}
[[nodiscard]] std::uint32_t size() const {
[[nodiscard]] TargetMemorySize size() const {
return (this->addressRange.endAddress - this->addressRange.startAddress) + 1;
}
};
using TargetMemoryBuffer = std::vector<unsigned char>;
}

View File

@@ -25,8 +25,8 @@ namespace Bloom::Targets
struct TargetRegisterDescriptor
{
public:
std::optional<std::uint32_t> startAddress;
std::uint32_t size = 0;
std::optional<TargetMemoryAddress> startAddress;
TargetMemorySize size = 0;
TargetRegisterType type = TargetRegisterType::OTHER;
TargetMemoryType memoryType = TargetMemoryType::OTHER;