diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.hpp index 12e1cb31..92825a9f 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.hpp @@ -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); diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.hpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.hpp index 9389095e..cbacb4fd 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.hpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/WriteMemory.hpp @@ -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. diff --git a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp index 07394a5b..e33fad62 100644 --- a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp +++ b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.cpp @@ -16,7 +16,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets : CommandPacket(rawPacket) { if (this->data.size() > 1) { - this->fromProgramCounter = static_cast( + this->fromProgramCounter = static_cast( std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16) ); } diff --git a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp index eb0cd84c..75d4df89 100644 --- a/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp +++ b/src/DebugServer/Gdb/CommandPackets/ContinueExecution.hpp @@ -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 fromProgramCounter; + std::optional fromProgramCounter; explicit ContinueExecution(const RawPacketType& rawPacket); diff --git a/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.hpp b/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.hpp index 8f215f29..e88fd1f1 100644 --- a/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.hpp +++ b/src/DebugServer/Gdb/CommandPackets/RemoveBreakpoint.hpp @@ -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); diff --git a/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.hpp b/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.hpp index 059136d3..6dc1d444 100644 --- a/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.hpp +++ b/src/DebugServer/Gdb/CommandPackets/SetBreakpoint.hpp @@ -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); diff --git a/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp b/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp index 51babcaa..ec9740ac 100644 --- a/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp +++ b/src/DebugServer/Gdb/CommandPackets/StepExecution.cpp @@ -17,7 +17,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets : CommandPacket(rawPacket) { if (this->data.size() > 1) { - this->fromProgramCounter = static_cast( + this->fromProgramCounter = static_cast( std::stoi(std::string(this->data.begin(), this->data.end()), nullptr, 16) ); } diff --git a/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp b/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp index 6d1c5bfb..27a7681d 100644 --- a/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp +++ b/src/DebugServer/Gdb/CommandPackets/StepExecution.hpp @@ -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 fromProgramCounter; + std::optional fromProgramCounter; explicit StepExecution(const RawPacketType& rawPacket); diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp index 130eb10b..53b4230d 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -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>(); /* - * 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; + using AddressRange = std::pair; auto addressRangeByType = std::map(); 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(); + auto excludedAddresses = std::set(); 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& excludedAddressRanges ) { if ( @@ -667,7 +672,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * We will perform the conversion here. */ - auto excludedAddresses = std::set(); + auto excludedAddresses = std::set(); 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::floor( + return static_cast(std::floor( static_cast(address) / static_cast(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::ceil( + return static_cast(std::ceil( static_cast(bytes) / static_cast(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& excludedAddresses + TargetMemoryAddress startAddress, + TargetMemorySize bytes, + const std::set& 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(bytes / pageSize); - TargetMemoryBuffer memoryBuffer; + auto memoryBuffer = Targets::TargetMemoryBuffer(); for (auto i = 0; i < pagesRequired; i++) { auto pageBuffer = this->readMemory( type, - startAddress + static_cast(pageSize * i), + startAddress + static_cast(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(bytes) / static_cast(maximumRequestSize)); - auto output = std::vector(); + auto output = Targets::TargetMemoryBuffer(); output.reserve(bytes); for (float i = 1; i <= totalReadsRequired; i++) { - const auto bytesToRead = static_cast( + const auto bytesToRead = static_cast( (bytes - output.size()) > maximumRequestSize ? maximumRequestSize : bytes - output.size() ); auto data = this->readMemory( type, - static_cast(startAddress + output.size()), + static_cast(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(); + auto output = TargetMemoryBuffer(); for (float i = 1; i <= totalReadsRequired; i++) { - auto bytesToRead = static_cast( + auto bytesToRead = static_cast( (bytes - output.size()) > (singlePacketSize * 2) ? (singlePacketSize * 2) : bytes - output.size() ); auto data = this->readMemory( type, - static_cast(startAddress + output.size()), + static_cast(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(buffer.size()); + void EdbgAvr8Interface::writeMemory( + Avr8MemoryType type, + TargetMemoryAddress startAddress, + const TargetMemoryBuffer& buffer + ) { + const auto bytes = static_cast(buffer.size()); if (this->alignmentRequired(type)) { const auto alignedStartAddress = this->alignMemoryAddress(type, startAddress); diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp index d411bc53..a8f8626d 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp @@ -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& 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 maximumMemoryAccessSizePerRequest; + std::optional 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& excludedAddresses = {} + Targets::TargetMemoryAddress startAddress, + Targets::TargetMemorySize bytes, + const std::set& 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. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp index 0b0a72c1..5785914e 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetProgramCounter.hpp @@ -3,6 +3,9 @@ #include #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& 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(payload[5] << 24 | payload[4] << 16 | payload[3] << 8 | payload[2]) * 2; + return static_cast( + payload[5] << 24 | payload[4] << 16 | payload[3] << 8 | payload[2] + ) * 2; } }; } diff --git a/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8DebugInterface.hpp b/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8DebugInterface.hpp index 7f78f704..4629213b 100644 --- a/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8DebugInterface.hpp +++ b/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8DebugInterface.hpp @@ -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& 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; diff --git a/src/EventManager/Events/MemoryWrittenToTarget.hpp b/src/EventManager/Events/MemoryWrittenToTarget.hpp index cf89f0e7..63101e18 100644 --- a/src/EventManager/Events/MemoryWrittenToTarget.hpp +++ b/src/EventManager/Events/MemoryWrittenToTarget.hpp @@ -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) diff --git a/src/EventManager/Events/TargetExecutionStopped.hpp b/src/EventManager/Events/TargetExecutionStopped.hpp index b3565d00..c4cfa45b 100644 --- a/src/EventManager/Events/TargetExecutionStopped.hpp +++ b/src/EventManager/Events/TargetExecutionStopped.hpp @@ -4,7 +4,9 @@ #include #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; diff --git a/src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp b/src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp index 01509a75..a85a1d09 100644 --- a/src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp +++ b/src/Insight/InsightWorker/Tasks/ReadProgramCounter.hpp @@ -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; diff --git a/src/Insight/InsightWorker/Tasks/ReadStackPointer.hpp b/src/Insight/InsightWorker/Tasks/ReadStackPointer.hpp index 6c9d1295..25e4461a 100644 --- a/src/Insight/InsightWorker/Tasks/ReadStackPointer.hpp +++ b/src/Insight/InsightWorker/Tasks/ReadStackPointer.hpp @@ -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; diff --git a/src/Insight/InsightWorker/Tasks/ReadTargetMemory.cpp b/src/Insight/InsightWorker/Tasks/ReadTargetMemory.cpp index 713694e2..b814fa47 100644 --- a/src/Insight/InsightWorker/Tasks/ReadTargetMemory.cpp +++ b/src/Insight/InsightWorker/Tasks/ReadTargetMemory.cpp @@ -25,10 +25,10 @@ namespace Bloom for (auto i = 0; i < readsRequired; i++) { auto dataSegment = targetControllerConsole.readMemory( this->memoryType, - this->startAddress + static_cast(readSize * i), + this->startAddress + static_cast(readSize * i), (this->size - data.size()) >= readSize ? readSize - : static_cast(this->size - data.size()), + : static_cast(this->size - data.size()), this->excludedAddressRanges ); diff --git a/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp b/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp index dc39c04f..8fd6f045 100644 --- a/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp +++ b/src/Insight/InsightWorker/Tasks/ReadTargetMemory.hpp @@ -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& 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 excludedAddressRanges; }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index c172de76..cd4f66f2 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -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) + ")" ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/AnnotationItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/AnnotationItem.cpp index b164e575..c594ef44 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/AnnotationItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/AnnotationItem.cpp @@ -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 ): diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/AnnotationItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/AnnotationItem.hpp index 53a4d5e7..b8cd9c3b 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/AnnotationItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/AnnotationItem.hpp @@ -3,6 +3,8 @@ #include #include +#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 ); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp index 4cddd19e..b1f5f49f 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.cpp @@ -6,8 +6,8 @@ namespace Bloom::Widgets { ByteItem::ByteItem( std::size_t byteIndex, - std::uint32_t address, - std::optional& currentStackPointer, + Targets::TargetMemoryAddress address, + std::optional& currentStackPointer, ByteItem** hoveredByteItem, AnnotationItem** hoveredAnnotationItem, std::set& highlightedByteItems, diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp index 24d763e7..1428ba1e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItem.hpp @@ -7,6 +7,8 @@ #include #include +#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& currentStackPointer, + Targets::TargetMemoryAddress address, + std::optional& currentStackPointer, ByteItem** hoveredByteItem, AnnotationItem** hoveredAnnotationItem, std::set& highlightedByteItems, @@ -71,7 +73,7 @@ namespace Bloom::Widgets ByteItem** hoveredByteItem; AnnotationItem** hoveredAnnotationItem; - std::optional& currentStackPointer; + std::optional& currentStackPointer; std::set& highlightedByteItems; const QColor* getBackgroundColor(); diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp index b92c8a69..98f44cad 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.cpp @@ -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)); } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp index c37419fa..db5de8d3 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemContainerGraphicsView.hpp @@ -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; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp index dffe1687..f7a09e50 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.cpp @@ -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( diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp index 3d3a1532..df004f3e 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/ByteItemGraphicsScene.hpp @@ -53,13 +53,13 @@ namespace Bloom::Widgets ); void updateValues(const Targets::TargetMemoryBuffer& buffer); - void updateStackPointer(std::uint32_t stackPointer); - void setHighlightedAddresses(const std::set& highlightedAddresses); + void updateStackPointer(Targets::TargetStackPointer stackPointer); + void setHighlightedAddresses(const std::set& 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 currentStackPointer; + std::optional currentStackPointer; Targets::TargetMemoryBuffer lastValueBuffer; - std::map byteItemsByAddress; + std::map byteItemsByAddress; std::vector annotationItems; std::vector valueAnnotationItems; std::map> byteItemsByRowIndex; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp index 5b7c0641..d71a18e7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.cpp @@ -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); } diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp index a0f14978..cfe963f6 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/HexViewerWidget/HexViewerWidget.hpp @@ -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; diff --git a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp index c1a42e19..c5fdd5ac 100644 --- a/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/Widgets/TargetMemoryInspectionPane/TargetMemoryInspectionPane.cpp @@ -241,7 +241,7 @@ namespace Bloom::Widgets readStackPointerTask, &ReadStackPointer::stackPointerRead, this, - [this] (std::uint32_t stackPointer) { + [this] (Targets::TargetStackPointer stackPointer) { this->hexViewerWidget->setStackPointer(stackPointer); } ); diff --git a/src/TargetController/Commands/ReadTargetMemory.hpp b/src/TargetController/Commands/ReadTargetMemory.hpp index 1d9689a4..63d59092 100644 --- a/src/TargetController/Commands/ReadTargetMemory.hpp +++ b/src/TargetController/Commands/ReadTargetMemory.hpp @@ -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 excludedAddressRanges; ReadTargetMemory( Targets::TargetMemoryType memoryType, - std::uint32_t startAddress, - std::uint32_t bytes, + Targets::TargetMemoryAddress startAddress, + Targets::TargetMemorySize bytes, const std::set& excludedAddressRanges ) : memoryType(memoryType) diff --git a/src/TargetController/Commands/ResumeTargetExecution.hpp b/src/TargetController/Commands/ResumeTargetExecution.hpp index 51d6433d..0c6f6684 100644 --- a/src/TargetController/Commands/ResumeTargetExecution.hpp +++ b/src/TargetController/Commands/ResumeTargetExecution.hpp @@ -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 fromProgramCounter; + std::optional fromProgramCounter; ResumeTargetExecution() = default; - explicit ResumeTargetExecution(std::uint32_t fromProgramCounter) + explicit ResumeTargetExecution(Targets::TargetProgramCounter fromProgramCounter) : fromProgramCounter(fromProgramCounter) {}; diff --git a/src/TargetController/Commands/SetTargetProgramCounter.hpp b/src/TargetController/Commands/SetTargetProgramCounter.hpp index d666ce9b..1ab158df 100644 --- a/src/TargetController/Commands/SetTargetProgramCounter.hpp +++ b/src/TargetController/Commands/SetTargetProgramCounter.hpp @@ -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) {}; diff --git a/src/TargetController/Commands/StepTargetExecution.hpp b/src/TargetController/Commands/StepTargetExecution.hpp index 19f48673..be194931 100644 --- a/src/TargetController/Commands/StepTargetExecution.hpp +++ b/src/TargetController/Commands/StepTargetExecution.hpp @@ -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 fromProgramCounter; + std::optional fromProgramCounter; StepTargetExecution() = default; - explicit StepTargetExecution(std::uint32_t fromProgramCounter) + explicit StepTargetExecution(Targets::TargetProgramCounter fromProgramCounter) : fromProgramCounter(fromProgramCounter) {}; diff --git a/src/TargetController/Commands/WriteTargetMemory.hpp b/src/TargetController/Commands/WriteTargetMemory.hpp index f5737b04..32f14213 100644 --- a/src/TargetController/Commands/WriteTargetMemory.hpp +++ b/src/TargetController/Commands/WriteTargetMemory.hpp @@ -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) diff --git a/src/TargetController/Responses/TargetProgramCounter.hpp b/src/TargetController/Responses/TargetProgramCounter.hpp index 5c3da181..79058377 100644 --- a/src/TargetController/Responses/TargetProgramCounter.hpp +++ b/src/TargetController/Responses/TargetProgramCounter.hpp @@ -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) {} diff --git a/src/TargetController/Responses/TargetStackPointer.hpp b/src/TargetController/Responses/TargetStackPointer.hpp index 61a7c148..85c3d537 100644 --- a/src/TargetController/Responses/TargetStackPointer.hpp +++ b/src/TargetController/Responses/TargetStackPointer.hpp @@ -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) {} diff --git a/src/TargetController/TargetControllerComponent.cpp b/src/TargetController/TargetControllerComponent.cpp index 6ba2d6d3..67417b54 100644 --- a/src/TargetController/TargetControllerComponent.cpp +++ b/src/TargetController/TargetControllerComponent.cpp @@ -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(); diff --git a/src/TargetController/TargetControllerComponent.hpp b/src/TargetController/TargetControllerComponent.hpp index 5b8248ef..0dfc72e6 100644 --- a/src/TargetController/TargetControllerComponent.hpp +++ b/src/TargetController/TargetControllerComponent.hpp @@ -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 ); diff --git a/src/TargetController/TargetControllerConsole.cpp b/src/TargetController/TargetControllerConsole.cpp index 18c8357b..34caf446 100644 --- a/src/TargetController/TargetControllerConsole.cpp +++ b/src/TargetController/TargetControllerConsole.cpp @@ -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 fromAddress) { + void TargetControllerConsole::continueTargetExecution(std::optional fromAddress) { auto resumeExecutionCommand = std::make_unique(); if (fromAddress.has_value()) { @@ -111,7 +115,7 @@ namespace Bloom::TargetController ); } - void TargetControllerConsole::stepTargetExecution(std::optional fromAddress) { + void TargetControllerConsole::stepTargetExecution(std::optional fromAddress) { auto stepExecutionCommand = std::make_unique(); 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& 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(), this->defaultTimeout )->programCounter; } - void TargetControllerConsole::setProgramCounter(std::uint32_t address) { + void TargetControllerConsole::setProgramCounter(TargetProgramCounter address) { this->commandManager.sendCommandAndWaitForResponse( std::make_unique(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(), this->defaultTimeout diff --git a/src/TargetController/TargetControllerConsole.hpp b/src/TargetController/TargetControllerConsole.hpp index 774d4b6e..dbb24eba 100644 --- a/src/TargetController/TargetControllerConsole.hpp +++ b/src/TargetController/TargetControllerConsole.hpp @@ -73,14 +73,14 @@ namespace Bloom::TargetController * * @param fromAddress */ - void continueTargetExecution(std::optional fromAddress); + void continueTargetExecution(std::optional fromAddress); /** * Requests the TargetController to step execution on the target. * * @param fromAddress */ - void stepTargetExecution(std::optional fromAddress); + void stepTargetExecution(std::optional 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& 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. diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp index f876d7e6..8976d55f 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp @@ -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& 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 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); }; } diff --git a/src/Targets/Target.hpp b/src/Targets/Target.hpp index 867bcebe..9d0c0c3c 100644 --- a/src/Targets/Target.hpp +++ b/src/Targets/Target.hpp @@ -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& 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 diff --git a/src/Targets/TargetBreakpoint.hpp b/src/Targets/TargetBreakpoint.hpp index 3bce157c..dc7c2654 100644 --- a/src/Targets/TargetBreakpoint.hpp +++ b/src/Targets/TargetBreakpoint.hpp @@ -2,6 +2,8 @@ #include +#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) {}; }; } diff --git a/src/Targets/TargetMemory.hpp b/src/Targets/TargetMemory.hpp index a7520ef4..80405328 100644 --- a/src/Targets/TargetMemory.hpp +++ b/src/Targets/TargetMemory.hpp @@ -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; + 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; } diff --git a/src/Targets/TargetRegister.hpp b/src/Targets/TargetRegister.hpp index bfd94e37..56b12aed 100644 --- a/src/Targets/TargetRegister.hpp +++ b/src/Targets/TargetRegister.hpp @@ -25,8 +25,8 @@ namespace Bloom::Targets struct TargetRegisterDescriptor { public: - std::optional startAddress; - std::uint32_t size = 0; + std::optional startAddress; + TargetMemorySize size = 0; TargetRegisterType type = TargetRegisterType::OTHER; TargetMemoryType memoryType = TargetMemoryType::OTHER;