From ce480a996c65a9350b9e46effaead45f30e2b246 Mon Sep 17 00:00:00 2001 From: Nav Date: Mon, 24 May 2021 20:58:49 +0100 Subject: [PATCH] Removed all using declarations and directives from header files --- src/Application.cpp | 2 +- src/Application.hpp | 8 +- src/DebugServers/DebugServer.cpp | 1 + src/DebugServers/DebugServer.hpp | 8 -- .../GdbRsp/AvrGdbRsp/AvrGdbRsp.hpp | 12 +- .../CommandPackets/CommandPacketFactory.cpp | 1 + .../CommandPackets/CommandPacketFactory.hpp | 4 +- .../CommandPackets/ContinueExecution.hpp | 2 - .../CommandPackets/InterruptExecution.hpp | 2 - .../CommandPackets/ReadGeneralRegisters.hpp | 2 - .../GdbRsp/CommandPackets/ReadMemory.hpp | 2 - .../CommandPackets/RemoveBreakpoint.hpp | 5 +- .../GdbRsp/CommandPackets/SetBreakpoint.hpp | 5 +- .../GdbRsp/CommandPackets/StepExecution.hpp | 2 - .../CommandPackets/SupportedFeaturesQuery.cpp | 3 +- .../CommandPackets/SupportedFeaturesQuery.hpp | 2 - .../CommandPackets/WriteGeneralRegisters.cpp | 2 + .../CommandPackets/WriteGeneralRegisters.hpp | 6 +- .../GdbRsp/CommandPackets/WriteMemory.hpp | 5 +- src/DebugServers/GdbRsp/Connection.cpp | 2 + src/DebugServers/GdbRsp/Connection.hpp | 9 +- .../Exceptions/ClientCommunicationError.hpp | 8 +- .../GdbRsp/Exceptions/ClientDisconnected.hpp | 8 +- .../GdbRsp/Exceptions/ClientNotSupported.hpp | 8 +- src/DebugServers/GdbRsp/GdbRspDebugServer.cpp | 12 +- src/DebugServers/GdbRsp/GdbRspDebugServer.hpp | 20 ++-- .../GdbRsp/ResponsePackets/TargetStopped.hpp | 4 +- src/DebugToolDrivers/DebugTool.hpp | 4 +- .../Microchip/AtmelICE/AtmelIce.hpp | 14 +-- .../Microchip/MplabSnap/MplabSnap.hpp | 14 +-- .../Microchip/PowerDebugger/PowerDebugger.cpp | 12 +- .../Microchip/PowerDebugger/PowerDebugger.hpp | 17 +-- .../Protocols/CMSIS-DAP/CmsisDapInterface.hpp | 2 - .../VendorSpecific/EDBG/AVR/AvrEvent.hpp | 2 - .../AVR8Generic/Avr8GenericCommandFrame.hpp | 3 - .../CommandFrames/AVR8Generic/ReadMemory.hpp | 2 - .../AVR8Generic/SetParameter.hpp | 2 - .../AVR8Generic/SetProgramCounter.hpp | 2 - .../CommandFrames/AVR8Generic/WriteMemory.hpp | 7 +- .../AVR/CommandFrames/AvrCommandFrame.hpp | 3 - .../Discovery/DiscoveryCommandFrame.hpp | 1 - .../EDBG/AVR/EdbgAvr8Interface.cpp | 6 +- .../EDBG/AVR/EdbgAvr8Interface.hpp | 50 ++++---- .../AVR/Events/AVR8Generic/BreakEvent.cpp | 1 + .../AVR/Events/AVR8Generic/BreakEvent.hpp | 6 +- .../AVR/Exceptions/Avr8CommandFailure.hpp | 7 +- .../AVR8Generic/GetDeviceId.hpp | 16 +-- .../AVR8Generic/GetProgramCounter.hpp | 5 +- .../ResponseFrames/AVR8Generic/ReadMemory.hpp | 5 +- .../AVR/ResponseFrames/AvrResponseFrame.hpp | 2 - .../VendorSpecific/EDBG/EdbgInterface.cpp | 3 +- .../VendorSpecific/EDBG/EdbgInterface.hpp | 10 +- .../Microchip/AVR/AVR8/Avr8Interface.hpp | 41 +++---- src/EventManager/EventListener.cpp | 2 +- src/EventManager/EventListener.hpp | 56 +++++---- src/EventManager/EventManager.hpp | 2 +- .../Events/MemoryRetrievedFromTarget.hpp | 3 +- .../Events/MemoryWrittenToTarget.hpp | 2 - .../Events/RegistersRetrievedFromTarget.hpp | 4 +- .../Events/RemoveBreakpointOnTarget.hpp | 4 +- .../Events/RetrieveMemoryFromTarget.hpp | 4 +- .../Events/RetrieveRegistersFromTarget.hpp | 4 +- .../Events/SetBreakpointOnTarget.hpp | 4 +- .../Events/TargetExecutionStopped.hpp | 6 +- .../Events/WriteMemoryToTarget.hpp | 13 ++- .../Events/WriteRegistersToTarget.hpp | 6 +- src/Helpers/EventNotifier.hpp | 12 +- src/Insight/Insight.cpp | 3 +- src/Insight/Insight.hpp | 2 +- src/Insight/InsightWorker.cpp | 5 +- src/Insight/InsightWorker.hpp | 11 +- .../InsightWindow/InsightWindow.cpp | 12 +- .../InsightWindow/InsightWindow.hpp | 27 ++--- .../DIP/DualInlinePackageWidget.cpp | 9 +- .../DIP/DualInlinePackageWidget.hpp | 4 +- .../TargetWidgets/DIP/PinBodyWidget.cpp | 1 + .../TargetWidgets/DIP/PinBodyWidget.hpp | 15 ++- .../TargetWidgets/DIP/PinWidget.cpp | 1 + .../TargetWidgets/DIP/PinWidget.hpp | 16 ++- .../TargetWidgets/QFP/PinBodyWidget.cpp | 4 +- .../TargetWidgets/QFP/PinBodyWidget.hpp | 12 +- .../TargetWidgets/QFP/PinWidget.cpp | 1 + .../TargetWidgets/QFP/PinWidget.hpp | 19 ++- .../QFP/QuadFlatPackageWidget.cpp | 12 +- .../QFP/QuadFlatPackageWidget.hpp | 4 +- .../TargetWidgets/TargetPackageWidget.hpp | 9 +- .../TargetWidgets/TargetPinWidget.hpp | 30 +++-- src/TargetController/TargetController.cpp | 4 +- src/TargetController/TargetController.hpp | 110 +++++++++--------- .../TargetControllerConsole.cpp | 3 + .../TargetControllerConsole.hpp | 26 +++-- src/Targets/Microchip/AVR/AVR8/Avr8.cpp | 11 +- src/Targets/Microchip/AVR/AVR8/Avr8.hpp | 11 +- .../PartDescription/PartDescriptionFile.cpp | 2 + .../PartDescription/PartDescriptionFile.hpp | 4 +- src/Targets/TargetRegister.hpp | 16 +-- 96 files changed, 415 insertions(+), 473 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 99d372bb..d03e7b7b 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -284,7 +284,7 @@ void Application::startDebugServer() { Logger::info("Selected DebugServer: " + this->debugServer->getName()); this->debugServerThread = std::thread( - &DebugServer::run, + &DebugServers::DebugServer::run, this->debugServer.get() ); diff --git a/src/Application.hpp b/src/Application.hpp index 30f551d0..72ee67eb 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -20,8 +20,6 @@ namespace Bloom { - using namespace DebugServers; - /** * Bloom - a debug interface for embedded systems development on Linux. * @@ -68,7 +66,7 @@ namespace Bloom * * See the DebugServer and GdbRspDebugServer class for more on this. */ - std::unique_ptr debugServer = nullptr; + std::unique_ptr debugServer = nullptr; std::thread debugServerThread; /** @@ -203,10 +201,10 @@ namespace Bloom * @return */ auto getSupportedDebugServers() { - return std::map()>> { + return std::map()>> { { "avr-gdb-rsp", - [this]() -> std::unique_ptr { + [this]() -> std::unique_ptr { return std::make_unique(this->eventManager); } }, diff --git a/src/DebugServers/DebugServer.cpp b/src/DebugServers/DebugServer.cpp index e4744cdc..57d9a493 100644 --- a/src/DebugServers/DebugServer.cpp +++ b/src/DebugServers/DebugServer.cpp @@ -6,6 +6,7 @@ #include "src/Logger/Logger.hpp" using namespace Bloom::DebugServers; +using namespace Bloom::Events; void DebugServer::run() { try { diff --git a/src/DebugServers/DebugServer.hpp b/src/DebugServers/DebugServer.hpp index d70ecfb6..0796a5dc 100644 --- a/src/DebugServers/DebugServer.hpp +++ b/src/DebugServers/DebugServer.hpp @@ -15,14 +15,6 @@ namespace Bloom::DebugServers { - using Targets::TargetRegister; - using Targets::TargetRegisterDescriptor; - using Targets::TargetRegisters; - using Targets::TargetRegisterMap; - using Targets::TargetMemoryBuffer; - using Targets::TargetMemoryType; - using Targets::TargetBreakpoint; - /** * The DebugServer exposes the connected target to third-party debugging software such as IDEs. * The DebugServer runs on a dedicated thread which is kicked off shortly after the TargetController has been diff --git a/src/DebugServers/GdbRsp/AvrGdbRsp/AvrGdbRsp.hpp b/src/DebugServers/GdbRsp/AvrGdbRsp/AvrGdbRsp.hpp index dccfff06..0f33fe9d 100644 --- a/src/DebugServers/GdbRsp/AvrGdbRsp/AvrGdbRsp.hpp +++ b/src/DebugServers/GdbRsp/AvrGdbRsp/AvrGdbRsp.hpp @@ -4,6 +4,7 @@ #include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp" #include "src/DebugServers/GdbRsp/Register.hpp" +#include "src/Helpers/BiMap.hpp" namespace Bloom::DebugServers::Gdb { @@ -44,7 +45,10 @@ namespace Bloom::DebugServers::Gdb * * @return */ - BiMap getRegisterNumberToDescriptorMapping() override { + BiMap getRegisterNumberToDescriptorMapping() override { + using Targets::TargetRegisterDescriptor; + using Targets::TargetRegisterType; + static BiMap mapping = { {0, TargetRegisterDescriptor(0, TargetRegisterType::GENERAL_PURPOSE_REGISTER)}, {1, TargetRegisterDescriptor(1, TargetRegisterType::GENERAL_PURPOSE_REGISTER)}, @@ -93,12 +97,12 @@ namespace Bloom::DebugServers::Gdb * @param address * @return */ - TargetMemoryType getMemoryTypeFromGdbAddress(std::uint32_t address) override { + Targets::TargetMemoryType getMemoryTypeFromGdbAddress(std::uint32_t address) override { if (address & this->gdbInternalMemoryMask) { - return TargetMemoryType::RAM; + return Targets::TargetMemoryType::RAM; } - return TargetMemoryType::FLASH; + return Targets::TargetMemoryType::FLASH; }; /** diff --git a/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.cpp b/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.cpp index 8980b176..0ee70891 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.cpp +++ b/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.cpp @@ -5,6 +5,7 @@ #include "CommandPacketFactory.hpp" using namespace Bloom::DebugServers::Gdb; +using namespace Bloom::DebugServers::Gdb::CommandPackets; std::unique_ptr CommandPacketFactory::create(std::vector rawPacket) { diff --git a/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.hpp b/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.hpp index 3a418df6..b75339bf 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/CommandPacketFactory.hpp @@ -18,8 +18,6 @@ namespace Bloom::DebugServers::Gdb { - using namespace CommandPackets; - /** * The CommandPacketFactory class provides a means for extracting raw packet data from a raw buffer, and * constructing the appropriate CommandPacket objects. @@ -46,6 +44,6 @@ namespace Bloom::DebugServers::Gdb * * @return */ - static std::unique_ptr create(std::vector rawPacket); + static std::unique_ptr create(std::vector rawPacket); }; } diff --git a/src/DebugServers/GdbRsp/CommandPackets/ContinueExecution.hpp b/src/DebugServers/GdbRsp/CommandPackets/ContinueExecution.hpp index 02ab1e86..ec9478e5 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/ContinueExecution.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/ContinueExecution.hpp @@ -7,8 +7,6 @@ namespace Bloom::DebugServers::Gdb::CommandPackets { - using namespace Bloom::DebugServers::Gdb; - /** * The ContinueExecution class implements a structure for "c" packets. These packets instruct the server * to continue execution on the target. diff --git a/src/DebugServers/GdbRsp/CommandPackets/InterruptExecution.hpp b/src/DebugServers/GdbRsp/CommandPackets/InterruptExecution.hpp index 448018ab..5f97c55c 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/InterruptExecution.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/InterruptExecution.hpp @@ -4,8 +4,6 @@ namespace Bloom::DebugServers::Gdb::CommandPackets { - using namespace Bloom::DebugServers::Gdb; - /** * The InterruptException class represents interrupt command packets. Upon receiving an interrupt packet, the * server is expected to interrupt execution on the target. diff --git a/src/DebugServers/GdbRsp/CommandPackets/ReadGeneralRegisters.hpp b/src/DebugServers/GdbRsp/CommandPackets/ReadGeneralRegisters.hpp index 5b9d4ee0..42734b14 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/ReadGeneralRegisters.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/ReadGeneralRegisters.hpp @@ -6,8 +6,6 @@ namespace Bloom::DebugServers::Gdb::CommandPackets { - using namespace Bloom::DebugServers::Gdb; - /** * The ReadGeneralRegisters class implements a structure for "g" and "p" command packets. In response to these * packets, the server is expected to send register values for all registers (for "g" packets) or for a single diff --git a/src/DebugServers/GdbRsp/CommandPackets/ReadMemory.hpp b/src/DebugServers/GdbRsp/CommandPackets/ReadMemory.hpp index 22b2104e..04299520 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/ReadMemory.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/ReadMemory.hpp @@ -7,8 +7,6 @@ namespace Bloom::DebugServers::Gdb::CommandPackets { - using namespace Bloom::DebugServers::Gdb; - /** * The ReadMemory class implements a structure for "m" packets. Upon receiving these packets, the server is * expected to read memory from the target and send it the client. diff --git a/src/DebugServers/GdbRsp/CommandPackets/RemoveBreakpoint.hpp b/src/DebugServers/GdbRsp/CommandPackets/RemoveBreakpoint.hpp index e347a545..16035d31 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/RemoveBreakpoint.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/RemoveBreakpoint.hpp @@ -7,14 +7,13 @@ #include "../BreakpointType.hpp" #include "CommandPacket.hpp" -namespace Bloom::DebugServers::Gdb { +namespace Bloom::DebugServers::Gdb +{ enum class Feature: int; } namespace Bloom::DebugServers::Gdb::CommandPackets { - using namespace Bloom::DebugServers::Gdb; - /** * The RemoveBreakpoint class implements the structure for "z" command packets. Upon receiving this command, the * server is expected to remove a breakpoint at the specified address. diff --git a/src/DebugServers/GdbRsp/CommandPackets/SetBreakpoint.hpp b/src/DebugServers/GdbRsp/CommandPackets/SetBreakpoint.hpp index b451656b..fae33746 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/SetBreakpoint.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/SetBreakpoint.hpp @@ -7,14 +7,13 @@ #include "../BreakpointType.hpp" #include "CommandPacket.hpp" -namespace Bloom::DebugServers::Gdb { +namespace Bloom::DebugServers::Gdb +{ enum class Feature: int; } namespace Bloom::DebugServers::Gdb::CommandPackets { - using namespace Bloom::DebugServers::Gdb; - /** * The SetBreakpoint class implements the structure for "Z" command packets. Upon receiving this command, the * server is expected to set a breakpoint at the specified address. diff --git a/src/DebugServers/GdbRsp/CommandPackets/StepExecution.hpp b/src/DebugServers/GdbRsp/CommandPackets/StepExecution.hpp index 914f12a4..59c139eb 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/StepExecution.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/StepExecution.hpp @@ -6,8 +6,6 @@ namespace Bloom::DebugServers::Gdb::CommandPackets { - using namespace Bloom::DebugServers::Gdb; - /** * The StepExecution class implements the structure for "s" command packets. Upon receiving this command, the * server is expected to step execution on the target. diff --git a/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.cpp b/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.cpp index 0aaebbda..3ddb28f6 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.cpp +++ b/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.cpp @@ -1,8 +1,7 @@ -#include "SupportedFeaturesQuery.hpp" #include +#include "SupportedFeaturesQuery.hpp" #include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp" -#include "../Feature.hpp" using namespace Bloom::DebugServers::Gdb::CommandPackets; diff --git a/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.hpp b/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.hpp index e770d5e1..e0759450 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/SupportedFeaturesQuery.hpp @@ -8,8 +8,6 @@ namespace Bloom::DebugServers::Gdb::CommandPackets { - using namespace Bloom::DebugServers::Gdb; - /** * The SupportedFeaturesQuery command packet is a query from the GDB client, requesting a list of GDB features * supported by the GDB server. The body of this packet also contains a list GDB features that are supported or diff --git a/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.cpp b/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.cpp index d9ee45c6..e2578662 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.cpp +++ b/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.cpp @@ -1,7 +1,9 @@ #include "WriteGeneralRegisters.hpp" #include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp" +#include "src/Exceptions/Exception.hpp" using namespace Bloom::DebugServers::Gdb::CommandPackets; +using namespace Bloom::Exceptions; void WriteGeneralRegisters::init() { // The P packet updates a single register diff --git a/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.hpp b/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.hpp index 68ce2844..d6039ee7 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/WriteGeneralRegisters.hpp @@ -7,10 +7,6 @@ namespace Bloom::DebugServers::Gdb::CommandPackets { - using namespace Bloom::DebugServers::Gdb; - using Bloom::Targets::TargetRegister; - using Bloom::Targets::TargetRegisterMap; - /** * The WriteGeneralRegisters class implements the structure for "G" and "P" packets. Upon receiving this packet, * server is expected to write register values to the target. @@ -21,7 +17,7 @@ namespace Bloom::DebugServers::Gdb::CommandPackets void init(); public: - TargetRegisterMap registerMap; + Bloom::Targets::TargetRegisterMap registerMap; int registerNumber; std::vector registerValue; diff --git a/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.hpp b/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.hpp index 801bce27..2c64c82f 100644 --- a/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.hpp +++ b/src/DebugServers/GdbRsp/CommandPackets/WriteMemory.hpp @@ -8,9 +8,6 @@ namespace Bloom::DebugServers::Gdb::CommandPackets { - using namespace Bloom::DebugServers::Gdb; - using Bloom::Targets::TargetMemoryBuffer; - /** * The WriteMemory class implements the structure for "M" packets. Upon receiving this packet, the server is * expected to write data to the target's memory, at the specified start address. @@ -27,7 +24,7 @@ namespace Bloom::DebugServers::Gdb::CommandPackets */ std::uint32_t startAddress; - TargetMemoryBuffer buffer; + Targets::TargetMemoryBuffer buffer; WriteMemory(std::vector rawPacket): CommandPacket(rawPacket) { init(); diff --git a/src/DebugServers/GdbRsp/Connection.cpp b/src/DebugServers/GdbRsp/Connection.cpp index 2d37a309..e51c3f1d 100644 --- a/src/DebugServers/GdbRsp/Connection.cpp +++ b/src/DebugServers/GdbRsp/Connection.cpp @@ -12,6 +12,8 @@ #include "CommandPackets/CommandPacketFactory.hpp" using namespace Bloom::DebugServers::Gdb; +using namespace Bloom::DebugServers::Gdb::CommandPackets; +using namespace Bloom::DebugServers::Gdb::ResponsePackets; using namespace Bloom::DebugServers::Gdb::Exceptions; using namespace Bloom::Exceptions; diff --git a/src/DebugServers/GdbRsp/Connection.hpp b/src/DebugServers/GdbRsp/Connection.hpp index 2058ab3e..18a228c3 100644 --- a/src/DebugServers/GdbRsp/Connection.hpp +++ b/src/DebugServers/GdbRsp/Connection.hpp @@ -14,9 +14,6 @@ namespace Bloom::DebugServers::Gdb { - using namespace CommandPackets; - using namespace ResponsePackets; - /** * The Connection class represents an active connection between the GDB RSP server and client. * @@ -46,7 +43,7 @@ namespace Bloom::DebugServers::Gdb * * @param interruptible * If this flag is set to false, no other component within Bloom will be able to gracefully interrupt - * the read (via means of this->interruptEventNotifier). This flag has no affect if this->readInterruptEnabled + * the read (via means of this->interruptEventNotifier). This flag has no effect if this->readInterruptEnabled * is false. * * @param msTimeout @@ -121,14 +118,14 @@ namespace Bloom::DebugServers::Gdb * * @return */ - std::vector> readPackets(); + std::vector> readPackets(); /** * Sends a response packet to the client. * * @param packet */ - void writePacket(const ResponsePacket& packet); + void writePacket(const ResponsePackets::ResponsePacket& packet); int getMaxPacketSize() { return this->maxPacketSize; diff --git a/src/DebugServers/GdbRsp/Exceptions/ClientCommunicationError.hpp b/src/DebugServers/GdbRsp/Exceptions/ClientCommunicationError.hpp index a5cbb5e5..54861872 100644 --- a/src/DebugServers/GdbRsp/Exceptions/ClientCommunicationError.hpp +++ b/src/DebugServers/GdbRsp/Exceptions/ClientCommunicationError.hpp @@ -4,22 +4,20 @@ namespace Bloom::DebugServers::Gdb::Exceptions { - using namespace Bloom::Exceptions; - /** * In the event that communication between the GDB RSP client and Bloom fails, a ClientCommunicationFailure * exception should be thrown. The GDB debug server handles this by severing the connection. * * See GdbRspDebugServer::serve() for handling code. */ - class ClientCommunicationError: public Exception + class ClientCommunicationError: public Bloom::Exceptions::Exception { public: - explicit ClientCommunicationError(const std::string& message): Exception(message) { + explicit ClientCommunicationError(const std::string& message): Bloom::Exceptions::Exception(message) { this->message = message; } - explicit ClientCommunicationError(const char* message): Exception(message) { + explicit ClientCommunicationError(const char* message): Bloom::Exceptions::Exception(message) { this->message = std::string(message); } diff --git a/src/DebugServers/GdbRsp/Exceptions/ClientDisconnected.hpp b/src/DebugServers/GdbRsp/Exceptions/ClientDisconnected.hpp index 3a69d2dd..d7fd865f 100644 --- a/src/DebugServers/GdbRsp/Exceptions/ClientDisconnected.hpp +++ b/src/DebugServers/GdbRsp/Exceptions/ClientDisconnected.hpp @@ -4,8 +4,6 @@ namespace Bloom::DebugServers::Gdb::Exceptions { - using namespace Bloom::Exceptions; - /** * When a GDB RSP client unexpectedly drops the connection in the middle of an IO operation, a ClientDisconnected * exception should be thrown. The GDB debug server handles this by clearing the connection and waiting for a new @@ -13,14 +11,14 @@ namespace Bloom::DebugServers::Gdb::Exceptions * * See GdbRspDebugServer::serve() for handling code. */ - class ClientDisconnected: public Exception + class ClientDisconnected: public Bloom::Exceptions::Exception { public: - explicit ClientDisconnected(const std::string& message): Exception(message) { + explicit ClientDisconnected(const std::string& message): Bloom::Exceptions::Exception(message) { this->message = message; } - explicit ClientDisconnected(const char* message): Exception(message) { + explicit ClientDisconnected(const char* message): Bloom::Exceptions::Exception(message) { this->message = std::string(message); } diff --git a/src/DebugServers/GdbRsp/Exceptions/ClientNotSupported.hpp b/src/DebugServers/GdbRsp/Exceptions/ClientNotSupported.hpp index 7c352b10..1efe7261 100644 --- a/src/DebugServers/GdbRsp/Exceptions/ClientNotSupported.hpp +++ b/src/DebugServers/GdbRsp/Exceptions/ClientNotSupported.hpp @@ -4,22 +4,20 @@ namespace Bloom::DebugServers::Gdb::Exceptions { - using namespace Bloom::Exceptions; - /** * In the event that the GDB debug server determines that the connected client cannot be served, * the ClientNotSupported exception should be thrown. * * See GdbRspDebugServer::serve() for handling code. */ - class ClientNotSupported: public Exception + class ClientNotSupported: public Bloom::Exceptions::Exception { public: - explicit ClientNotSupported(const std::string& message): Exception(message) { + explicit ClientNotSupported(const std::string& message): Bloom::Exceptions::Exception(message) { this->message = message; } - explicit ClientNotSupported(const char* message): Exception(message) { + explicit ClientNotSupported(const char* message): Bloom::Exceptions::Exception(message) { this->message = std::string(message); } diff --git a/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp b/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp index 44cbd7c1..c5c90d2d 100644 --- a/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp +++ b/src/DebugServers/GdbRsp/GdbRspDebugServer.cpp @@ -11,7 +11,17 @@ #include "src/Logger/Logger.hpp" using namespace Bloom::DebugServers::Gdb; -using namespace Exceptions; +using namespace Bloom::DebugServers::Gdb::CommandPackets; +using namespace Bloom::DebugServers::Gdb::ResponsePackets; +using namespace Bloom::DebugServers::Gdb::Exceptions; +using namespace Bloom::Events; +using namespace Bloom::Exceptions; + +using Bloom::Targets::TargetRegister; +using Bloom::Targets::TargetRegisterType; +using Bloom::Targets::TargetRegisterDescriptor; +using Bloom::Targets::TargetRegisterDescriptors; +using Bloom::Targets::TargetBreakpoint; void GdbRspDebugServer::init() { auto ipAddress = this->debugServerConfig.jsonObject.find("ipAddress")->toString().toStdString(); diff --git a/src/DebugServers/GdbRsp/GdbRspDebugServer.hpp b/src/DebugServers/GdbRsp/GdbRspDebugServer.hpp index a6b3edb0..de7f4d4c 100644 --- a/src/DebugServers/GdbRsp/GdbRspDebugServer.hpp +++ b/src/DebugServers/GdbRsp/GdbRspDebugServer.hpp @@ -22,9 +22,6 @@ namespace Bloom::DebugServers::Gdb { - using Bloom::Targets::TargetRegisterType; - using Bloom::Targets::TargetRegisterDescriptor; - /** * The GdbRspDebugServer is an implementation of a GDB server using the GDB Remote Serial Protocol. * @@ -123,7 +120,7 @@ namespace Bloom::DebugServers::Gdb * @param address * @return */ - virtual TargetMemoryType getMemoryTypeFromGdbAddress(std::uint32_t address) = 0; + virtual Targets::TargetMemoryType getMemoryTypeFromGdbAddress(std::uint32_t address) = 0; /** * Removes memory type information from memory address. @@ -143,7 +140,10 @@ namespace Bloom::DebugServers::Gdb * * @return */ - virtual BiMap getRegisterNumberToDescriptorMapping() = 0; + virtual BiMap< + GdbRegisterNumber, + Targets::TargetRegisterDescriptor + > getRegisterNumberToDescriptorMapping() = 0; /** * Obtains the appropriate register descriptor from a register number. @@ -151,12 +151,12 @@ namespace Bloom::DebugServers::Gdb * @param number * @return */ - virtual TargetRegisterDescriptor getRegisterDescriptorFromNumber(GdbRegisterNumber number) { + virtual Targets::TargetRegisterDescriptor getRegisterDescriptorFromNumber(GdbRegisterNumber number) { auto mapping = this->getRegisterNumberToDescriptorMapping(); if (!mapping.contains(number)) { - throw Exception("Unknown register from GDB - register number (" + std::to_string(number) - + ") not mapped to any register descriptor."); + throw Exceptions::Exception("Unknown register from GDB - register number (" + + std::to_string(number) + ") not mapped to any register descriptor."); } return mapping.valueAt(number).value(); @@ -173,7 +173,7 @@ namespace Bloom::DebugServers::Gdb * If the GDB client is currently waiting for the target execution to stop, this event handler will issue * a "stop reply" packet to the client once the target execution stops. */ - void onTargetExecutionStopped(EventPointer); + void onTargetExecutionStopped(Events::EventPointer); /** * Handles any other GDB command packet that has not been promoted to a more specific type. @@ -181,7 +181,7 @@ namespace Bloom::DebugServers::Gdb * * @param packet */ - virtual void handleGdbPacket(CommandPacket& packet); + virtual void handleGdbPacket(CommandPackets::CommandPacket& packet); /** * Handles the supported features query ("qSupported") command packet. diff --git a/src/DebugServers/GdbRsp/ResponsePackets/TargetStopped.hpp b/src/DebugServers/GdbRsp/ResponsePackets/TargetStopped.hpp index 85540e68..92ee790c 100644 --- a/src/DebugServers/GdbRsp/ResponsePackets/TargetStopped.hpp +++ b/src/DebugServers/GdbRsp/ResponsePackets/TargetStopped.hpp @@ -7,8 +7,6 @@ namespace Bloom::DebugServers::Gdb::ResponsePackets { - using Bloom::Targets::TargetRegisterMap; - /** * The TargetStopped class implements the response packet structure for any commands that expect a "StopReply" * packet in response. @@ -17,7 +15,7 @@ namespace Bloom::DebugServers::Gdb::ResponsePackets { public: Signal signal; - std::optional registerMap; + std::optional registerMap; std::optional stopReason; TargetStopped(Signal signal): signal(signal) {} diff --git a/src/DebugToolDrivers/DebugTool.hpp b/src/DebugToolDrivers/DebugTool.hpp index b4717e3b..74d6de13 100644 --- a/src/DebugToolDrivers/DebugTool.hpp +++ b/src/DebugToolDrivers/DebugTool.hpp @@ -4,8 +4,6 @@ namespace Bloom { - using DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8::Avr8Interface; - /** * A debug tool can be any device that provides access to the connected target. Debug tools are usually connected * to the host machine via USB. @@ -53,7 +51,7 @@ namespace Bloom * * @return */ - virtual Avr8Interface* getAvr8Interface() { + virtual DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8::Avr8Interface* getAvr8Interface() { return nullptr; }; diff --git a/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.hpp b/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.hpp index 83eeef4e..216083cf 100644 --- a/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.hpp +++ b/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.hpp @@ -14,10 +14,6 @@ namespace Bloom::DebugToolDrivers { - using namespace Protocols::CmsisDap; - using Protocols::CmsisDap::Edbg::EdbgInterface; - using Protocols::CmsisDap::Edbg::Avr::EdbgAvr8Interface; - /** * The Atmel-ICE device is an EDBG (Embedded Debugger) device. It implements the CMSIS-DAP layer as well * as an Atmel Data Gateway Interface (DGI). @@ -53,13 +49,13 @@ namespace Bloom::DebugToolDrivers * Any non-EDBG CMSIS-DAP commands for the Atmel-ICE can be sent through the EdbgInterface (as the * EdbgInterface extends the CmsisDapInterface). */ - EdbgInterface edbgInterface = EdbgInterface(); + Protocols::CmsisDap::Edbg::EdbgInterface edbgInterface = Protocols::CmsisDap::Edbg::EdbgInterface(); /** * The Atmel-ICE employs the EDBG AVR8 Generic protocol, for debugging AVR8 targets. This protocol is * implemented in EdbgAvr8Interface. See the EdbgAvr8Interface class for more information. */ - std::unique_ptr edbgAvr8Interface = nullptr; + std::unique_ptr edbgAvr8Interface = nullptr; bool sessionStarted = false; @@ -70,13 +66,15 @@ namespace Bloom::DebugToolDrivers AtmelIce(): UsbDevice(AtmelIce::USB_VENDOR_ID, AtmelIce::USB_PRODUCT_ID) {} void init() override; + void close() override; - EdbgInterface& getEdbgInterface() { + + Protocols::CmsisDap::Edbg::EdbgInterface& getEdbgInterface() { return this->edbgInterface; } - Avr8Interface* getAvr8Interface() override { + TargetInterfaces::Microchip::Avr::Avr8::Avr8Interface* getAvr8Interface() override { return this->edbgAvr8Interface.get(); } diff --git a/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.hpp b/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.hpp index 5697abce..8e26f335 100644 --- a/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.hpp +++ b/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.hpp @@ -14,10 +14,6 @@ namespace Bloom::DebugToolDrivers { - using namespace Protocols::CmsisDap; - using Protocols::CmsisDap::Edbg::EdbgInterface; - using Protocols::CmsisDap::Edbg::Avr::EdbgAvr8Interface; - /** * The MPLAB Snap device is a hybrid device - that is, it can present itself as an "MPLAB Snap ICD" device, as well * as an EDBG (Embedded Debugger) device. The device switches between these two modes via a firmware update, issued @@ -39,13 +35,13 @@ namespace Bloom::DebugToolDrivers class MplabSnap: public DebugTool, public Usb::UsbDevice { private: - EdbgInterface edbgInterface = EdbgInterface(); + Protocols::CmsisDap::Edbg::EdbgInterface edbgInterface = Protocols::CmsisDap::Edbg::EdbgInterface(); /** * The MPLAB Snap employs the EDBG AVR8 Generic protocol, for debugging AVR8 targets. This protocol is * implemented in EdbgAvr8Interface. See the EdbgAvr8Interface class for more information. */ - std::unique_ptr edbgAvr8Interface = nullptr; + std::unique_ptr edbgAvr8Interface = nullptr; bool sessionStarted = false; @@ -56,13 +52,15 @@ namespace Bloom::DebugToolDrivers MplabSnap(): UsbDevice(MplabSnap::USB_VENDOR_ID, MplabSnap::USB_PRODUCT_ID) {} void init() override; + void close() override; - EdbgInterface& getEdbgInterface() { + + Protocols::CmsisDap::Edbg::EdbgInterface& getEdbgInterface() { return this->edbgInterface; } - Avr8Interface* getAvr8Interface() override { + TargetInterfaces::Microchip::Avr::Avr8::Avr8Interface* getAvr8Interface() override { return this->edbgAvr8Interface.get(); } diff --git a/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp b/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp index 166d885f..861b91c5 100644 --- a/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp +++ b/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp @@ -2,9 +2,11 @@ #include "src/Exceptions/Exception.hpp" using namespace Bloom::DebugToolDrivers; -using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr; +using namespace Protocols::CmsisDap::Edbg::Avr; using namespace Bloom::Exceptions; +using Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::EdbgAvr8Interface; + void PowerDebugger::init() { UsbDevice::init(); @@ -48,10 +50,10 @@ void PowerDebugger::close() { std::string PowerDebugger::getSerialNumber() { auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame( - CommandFrames::Discovery::Query(Discovery::QueryContext::SERIAL_NUMBER) + CommandFrames::Discovery::Query(CommandFrames::Discovery::QueryContext::SERIAL_NUMBER) ); - if (response.getResponseId() != Discovery::ResponseId::OK) { + if (response.getResponseId() != CommandFrames::Discovery::ResponseId::OK) { throw Exception("Failed to fetch serial number from device - invalid Discovery Protocol response ID."); } @@ -64,7 +66,7 @@ void PowerDebugger::startSession() { CommandFrames::HouseKeeping::StartSession() ); - if (response.getResponseId() == HouseKeeping::ResponseId::FAILED) { + if (response.getResponseId() == CommandFrames::HouseKeeping::ResponseId::FAILED) { // Failed response returned! throw Exception("Failed to start session with the Power Debugger - device returned failed response ID"); } @@ -77,7 +79,7 @@ void PowerDebugger::endSession() { CommandFrames::HouseKeeping::EndSession() ); - if (response.getResponseId() == HouseKeeping::ResponseId::FAILED) { + if (response.getResponseId() == CommandFrames::HouseKeeping::ResponseId::FAILED) { // Failed response returned! throw Exception("Failed to end session with the Power Debugger - device returned failed response ID"); } diff --git a/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.hpp b/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.hpp index 27d32c49..cd5a9277 100644 --- a/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.hpp +++ b/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.hpp @@ -14,13 +14,6 @@ namespace Bloom::DebugToolDrivers { - using namespace Protocols::CmsisDap; - using namespace Protocols::CmsisDap::Edbg::Avr::CommandFrames; - using namespace Protocols::CmsisDap::Edbg::Avr::CommandFrames::Discovery; - using namespace Protocols::CmsisDap::Edbg::Avr::CommandFrames::HouseKeeping; - using Protocols::CmsisDap::Edbg::EdbgInterface; - using Protocols::CmsisDap::Edbg::Avr::EdbgAvr8Interface; - /** * The Power Debugger device is very similar to the Atmel-ICE. It implements the CMSIS-DAP layer as well * as an Atmel Data Gateway Interface (DGI). @@ -43,12 +36,12 @@ namespace Bloom::DebugToolDrivers * Any non-EDBG CMSIS-DAP commands for the Power Debugger can be sent through the EDBGInterface (as the * EdbgInterface extends the CmsisDapInterface). */ - EdbgInterface edbgInterface = EdbgInterface(); + Protocols::CmsisDap::Edbg::EdbgInterface edbgInterface = Protocols::CmsisDap::Edbg::EdbgInterface(); /** * The Power Debugger employs the EDBG AVR8Generic protocol for interfacing with AVR8 targets. */ - std::unique_ptr edbgAvr8Interface; + std::unique_ptr edbgAvr8Interface; bool sessionStarted = false; @@ -59,13 +52,15 @@ namespace Bloom::DebugToolDrivers PowerDebugger(): UsbDevice(PowerDebugger::USB_VENDOR_ID, PowerDebugger::USB_PRODUCT_ID) {} void init() override; + void close() override; - EdbgInterface& getEdbgInterface() { + + Protocols::CmsisDap::Edbg::EdbgInterface& getEdbgInterface() { return this->edbgInterface; } - Avr8Interface* getAvr8Interface() override { + TargetInterfaces::Microchip::Avr::Avr8::Avr8Interface* getAvr8Interface() override { return this->edbgAvr8Interface.get(); } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.hpp index a3b1d101..f51ca608 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.hpp @@ -8,8 +8,6 @@ #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp" #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrCommand.hpp" -using namespace Bloom::DebugToolDrivers; - namespace Bloom::DebugToolDrivers::Protocols::CmsisDap { /** diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp index 4d26deb9..dab8877d 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/AvrEvent.hpp @@ -7,8 +7,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { - using Edbg::ProtocolHandlerId; - enum class AvrEventId : unsigned char { AVR8_BREAK_EVENT = 0x40, diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp index 33e45295..c887a34c 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/Avr8GenericCommandFrame.hpp @@ -7,9 +7,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { - using namespace DebugToolDrivers::Protocols::CmsisDap; - using namespace DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr; - class Avr8GenericCommandFrame: public AvrCommandFrame { public: diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp index fbf96079..ddcdc34a 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/ReadMemory.hpp @@ -7,8 +7,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { - using namespace Exceptions; - class ReadMemory: public Avr8GenericCommandFrame { private: diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp index 6cd97b7c..7dd0d55f 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp @@ -4,8 +4,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { - using namespace Exceptions; - class SetParameter: public Avr8GenericCommandFrame { private: diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp index 1715a0c8..cf0bc7a3 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetProgramCounter.hpp @@ -6,8 +6,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { - using namespace Exceptions; - class SetProgramCounter: public Avr8GenericCommandFrame { private: diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp index a0b1a156..62fc0b6b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/WriteMemory.hpp @@ -7,15 +7,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic { - using namespace Exceptions; - using Bloom::Targets::TargetMemoryBuffer; - class WriteMemory: public Avr8GenericCommandFrame { private: Avr8MemoryType type; std::uint32_t address = 0; - TargetMemoryBuffer buffer; + Targets::TargetMemoryBuffer buffer; public: WriteMemory() = default; @@ -28,7 +25,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames this->address = address; } - void setBuffer(const TargetMemoryBuffer& buffer) { + void setBuffer(const Targets::TargetMemoryBuffer& buffer) { this->buffer = buffer; } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp index 91e57d83..1d441112 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AvrCommandFrame.hpp @@ -12,9 +12,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { - using namespace Edbg; - using namespace DebugToolDrivers::Protocols::CmsisDap; - class AvrCommandFrame { private: diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp index 8c534303..26b9b627 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp @@ -5,7 +5,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Discovery { - using namespace DebugToolDrivers::Protocols::CmsisDap; /** * Discovery commands can only return two responses; A LIST response and a failure. */ 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 b2484750..7ed971b8 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -33,13 +33,17 @@ // AVR events #include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp" +using namespace Bloom::Targets::Microchip::Avr; +using namespace Bloom::Targets::Microchip::Avr::Avr8Bit; using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr; using namespace Bloom::Exceptions; using Bloom::Targets::TargetState; +using Bloom::Targets::TargetMemoryType; +using Bloom::Targets::TargetMemoryBuffer; using Bloom::Targets::TargetRegister; -using Bloom::Targets::TargetRegisters; using Bloom::Targets::TargetRegisterType; +using Bloom::Targets::TargetRegisters; void EdbgAvr8Interface::setParameter(const Avr8EdbgParameter& parameter, const std::vector& value) { auto commandFrame = CommandFrames::Avr8Generic::SetParameter(parameter, value); 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 3bb1f072..e5e8f633 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.hpp @@ -13,16 +13,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { - using namespace DebugToolDrivers; - using namespace Targets; - using namespace Targets::Microchip::Avr; - - using Protocols::CmsisDap::Edbg::EdbgInterface; - using Targets::Microchip::Avr::Avr8Bit::Family; - using Targets::TargetRegister; - using Targets::TargetRegisterMap; - using Targets::TargetMemoryBuffer; - inline bool operator==(unsigned char rawId, Avr8ResponseId id) { return static_cast(id) == rawId; } @@ -40,7 +30,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * This implementation should work with any Microchip EDBG based CMSIS-DAP debug tool (such as the Atmel-ICE, * Power Debugger and the MPLAB SNAP debugger (in "AVR mode")). */ - class EdbgAvr8Interface: public Avr8Interface + class EdbgAvr8Interface: public TargetInterfaces::Microchip::Avr::Avr8::Avr8Interface { private: /** @@ -78,7 +68,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * For the EdbgAvr8Interface, we send the required parameters to the debug tool immediately upon receiving * them. See EdbgAvr8Interface::setTargetParameters(). */ - Avr8Bit::TargetParameters targetParameters; + Targets::Microchip::Avr::Avr8Bit::TargetParameters targetParameters; /** * We keep record of the current target state for caching purposes. We'll only refresh the target state if the @@ -87,7 +77,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * @TODO: Review this. Is the above assumption correct? Always? Explore the option of polling the target state. */ - TargetState targetState = TargetState::UNKNOWN; + Targets::TargetState targetState = Targets::TargetState::UNKNOWN; /** * Upon configuration, the physical interface must be activated on the debug tool. We keep record of this to @@ -256,7 +246,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * @return */ - TargetMemoryBuffer readMemory(Avr8MemoryType type, std::uint32_t address, std::uint32_t bytes); + Targets::TargetMemoryBuffer readMemory(Avr8MemoryType type, std::uint32_t address, std::uint32_t bytes); /** * Writes memory to the target. @@ -269,7 +259,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param address * @param buffer */ - void writeMemory(Avr8MemoryType type, std::uint32_t address, TargetMemoryBuffer buffer); + void writeMemory(Avr8MemoryType type, std::uint32_t address, Targets::TargetMemoryBuffer buffer); /** * Fetches the current target state. @@ -354,7 +344,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * @param config */ - virtual void setTargetParameters(const Avr8Bit::TargetParameters& config) override; + virtual void setTargetParameters(const Targets::Microchip::Avr::Avr8Bit::TargetParameters& config) override; /** * Initialises the AVR8 Generic protocol interface by setting the appropriate parameters on the debug tool. @@ -415,28 +405,28 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * @return */ - virtual TargetRegister getStackPointerRegister() override; + virtual Targets::TargetRegister getStackPointerRegister() override; /** * Reads the status register from the target. * * @return */ - virtual TargetRegister getStatusRegister() override; + virtual Targets::TargetRegister getStatusRegister() override; /** * Updates the stack pointer register on ther target. * * @param stackPointerRegister */ - virtual void setStackPointerRegister(const TargetRegister& stackPointerRegister) override; + virtual void setStackPointerRegister(const Targets::TargetRegister& stackPointerRegister) override; /** * Updates the status register on the target. * * @param statusRegister */ - virtual void setStatusRegister(const TargetRegister& statusRegister) override; + virtual void setStatusRegister(const Targets::TargetRegister& statusRegister) override; /** * Issues the "PC Write" command to the debug tool, setting the program counter on the target. @@ -451,7 +441,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * * @return */ - virtual TargetSignature getDeviceId() override; + virtual Targets::Microchip::Avr::TargetSignature getDeviceId() override; /** * Issues the "Software Breakpoint Set" command to the debug tool, setting a software breakpoint at the given @@ -485,14 +475,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param registerIds * @return */ - virtual TargetRegisters readGeneralPurposeRegisters(std::set registerIds) override; + virtual Targets::TargetRegisters readGeneralPurposeRegisters(std::set registerIds) override; /** * Writes general purpose registers to target. * * @param registers */ - virtual void writeGeneralPurposeRegisters(const TargetRegisters& registers) override; + virtual void writeGeneralPurposeRegisters(const Targets::TargetRegisters& registers) override; /** * This is an overloaded method. @@ -504,7 +494,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param bytes * @return */ - virtual TargetMemoryBuffer readMemory(TargetMemoryType memoryType, std::uint32_t startAddress, std::uint32_t bytes) override; + virtual Targets::TargetMemoryBuffer readMemory( + Targets::TargetMemoryType memoryType, + std::uint32_t startAddress, + std::uint32_t bytes + ) override; /** * This is an overloaded method. @@ -515,13 +509,17 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr * @param startAddress * @param buffer */ - virtual void writeMemory(TargetMemoryType memoryType, std::uint32_t startAddress, const TargetMemoryBuffer& buffer) override; + virtual void writeMemory( + Targets::TargetMemoryType memoryType, + std::uint32_t startAddress, + const Targets::TargetMemoryBuffer& buffer + ) override; /** * Returns the current state of the target. * * @return */ - virtual TargetState getTargetState() override; + virtual Targets::TargetState getTargetState() override; }; } \ No newline at end of file diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.cpp index 0e4d2f18..fcfb6210 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.cpp @@ -4,6 +4,7 @@ #include "src/Exceptions/Exception.hpp" using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr; +using namespace Bloom::Targets; using namespace Bloom::Exceptions; void BreakEvent::init(const AvrEvent& event) { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp index e639e808..16399f3e 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Events/AVR8Generic/BreakEvent.hpp @@ -7,13 +7,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { - using Targets::TargetBreakCause; - class BreakEvent: public AvrEvent { private: std::uint32_t programCounter; - TargetBreakCause breakCause; + Targets::TargetBreakCause breakCause; void init(const AvrEvent& event); @@ -26,7 +24,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr return this->programCounter; } - TargetBreakCause getBreakCause() { + Targets::TargetBreakCause getBreakCause() { return this->breakCause; } }; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp index d4f76a06..392bf95e 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp @@ -5,7 +5,6 @@ namespace Bloom::Exceptions { - using Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic::Avr8GenericResponseFrame; class Avr8CommandFailure: public Exception { private: @@ -68,8 +67,10 @@ namespace Bloom::Exceptions this->message = std::string(message); } - explicit Avr8CommandFailure(const std::string& message, Avr8GenericResponseFrame& responseFrame) - : Exception(message) { + explicit Avr8CommandFailure( + const std::string& message, + DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic::Avr8GenericResponseFrame& responseFrame + ): Exception(message) { this->message = message; auto responsePayload = responseFrame.getPayload(); diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp index 56d26160..4a2b642f 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/GetDeviceId.hpp @@ -5,15 +5,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic { - using namespace Targets::Microchip::Avr; - class GetDeviceId: public Avr8GenericResponseFrame { public: GetDeviceId(const std::vector& AvrResponses): Avr8GenericResponseFrame(AvrResponses) {} GetDeviceId() {} - TargetSignature extractSignature(Avr8PhysicalInterface physicalInterface) { + Targets::Microchip::Avr::TargetSignature extractSignature(Avr8PhysicalInterface physicalInterface) { auto payloadData = this->getPayloadData(); switch (physicalInterface) { @@ -22,14 +20,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame * When using the DebugWire physical interface, the get device ID command will return * four bytes, where the first can be ignored. */ - return TargetSignature(payloadData[1], payloadData[2], payloadData[3]); + return Targets::Microchip::Avr::TargetSignature(payloadData[1], payloadData[2], payloadData[3]); } case Avr8PhysicalInterface::PDI: case Avr8PhysicalInterface::PDI_1W: { /* * When using the PDI physical interface, the signature is returned in LSB format. */ - return TargetSignature(payloadData[3], payloadData[2], payloadData[1]); + return Targets::Microchip::Avr::TargetSignature(payloadData[3], payloadData[2], payloadData[1]); } case Avr8PhysicalInterface::JTAG: { /* @@ -54,14 +52,18 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame (payloadData[0] << 24) | (payloadData[1] << 16) | (payloadData[2] << 8) | (payloadData[3]) ); - return TargetSignature( + return Targets::Microchip::Avr::TargetSignature( 0x1E, static_cast((jtagId << 4) >> 24), static_cast((jtagId << 12) >> 24) ); } default: { - return TargetSignature(payloadData[0], payloadData[1], payloadData[2]); + return Targets::Microchip::Avr::TargetSignature( + payloadData[0], + payloadData[1], + payloadData[2] + ); } } } 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 8c34e645..55e2e0f0 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 @@ -7,8 +7,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic { - using namespace Bloom::Exceptions; - class GetProgramCounter: public Avr8GenericResponseFrame { public: @@ -22,7 +20,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame */ auto& payload = this->getPayload(); if (payload.size() != 6) { - throw Exception("Failed to extract PC from payload of PC read command response frame - unexpected payload size."); + throw Exceptions::Exception("Failed to extract PC from payload of PC read command response " + "frame - unexpected payload size."); } return static_cast(payload[5] << 24 | payload[4] << 16 | payload[3] << 8 | payload[2]) * 2; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp index d2ab0aa1..d9efc3ee 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AVR8Generic/ReadMemory.hpp @@ -5,16 +5,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic { - using namespace Bloom::Exceptions; - using Bloom::Targets::TargetMemoryBuffer; - class ReadMemory: public Avr8GenericResponseFrame { public: ReadMemory(const std::vector& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {} ReadMemory() {} - TargetMemoryBuffer getMemoryBuffer() { + Targets::TargetMemoryBuffer getMemoryBuffer() { /* * AVR8 data payloads are typically in little endian form, but this does not apply the data returned * from the READ MEMORY commands. diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp index 61e0039e..e004a2d3 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp @@ -11,8 +11,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr { - using namespace Edbg; - class AvrResponseFrame { private: diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp index 0b810fc9..631d9e4f 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.cpp @@ -4,8 +4,9 @@ #include "EdbgInterface.hpp" -using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr; +using namespace Bloom::DebugToolDrivers; using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg; +using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr; using namespace Bloom::Exceptions; Protocols::CmsisDap::Response EdbgInterface::sendAvrCommandFrameAndWaitForResponse( diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp index abf9849d..bae8c60b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp @@ -14,9 +14,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg { - using namespace Protocols::CmsisDap::Edbg::Avr; - using namespace Exceptions; - /** * The EdbgInterface class implements the EDBG sub-protocol, which takes the form of numerous CMSIS-DAP vendor * commands. @@ -52,12 +49,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg const CommandFrameType& avrCommandFrame ) { static_assert( - std::is_base_of::value, + std::is_base_of::value, "AVR Command must be base of AvrCommandFrame." ); static_assert( - std::is_base_of::value, + std::is_base_of::value, "AVR Command must specify a valid response frame type, derived from AvrResponseFrame." ); @@ -65,7 +62,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg if (response.getData()[0] != 0x01) { // The last response packet should always acknowledge receipt of the AvrCommandFrame - throw Exception("Failed to send AvrCommandFrame to device - device did not acknowledge receipt."); + throw Exceptions::Exception("Failed to send AvrCommandFrame to device " + "- device did not acknowledge receipt."); } auto responses = this->requestAvrResponses(); diff --git a/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8Interface.hpp b/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8Interface.hpp index 5eeb726f..9f1cdc23 100644 --- a/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8Interface.hpp +++ b/src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8Interface.hpp @@ -12,17 +12,6 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 { - using namespace Bloom; - using namespace Targets::Microchip::Avr; - - using Targets::TargetState; - using Targets::TargetRegisterMap; - using Targets::TargetMemoryBuffer; - using Targets::TargetMemoryType; - using Targets::TargetRegister; - using Targets::TargetRegisters; - using Targets::Microchip::Avr::TargetSignature; - /** * Interfacing with an AVR8 target can vary significantly, depending on the debug tool being used. * @@ -52,7 +41,7 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 * * @param config */ - virtual void setTargetParameters(const Avr8Bit::TargetParameters& config) = 0; + virtual void setTargetParameters(const Targets::Microchip::Avr::Avr8Bit::TargetParameters& config) = 0; /** * Should initialise the interface between the debug tool and the AVR8 target. @@ -102,7 +91,7 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 * * @return */ - virtual TargetSignature getDeviceId() = 0; + virtual Targets::Microchip::Avr::TargetSignature getDeviceId() = 0; /** * Should set a software breakpoint at a given address. @@ -135,14 +124,14 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 * * @return */ - virtual TargetRegister getStackPointerRegister() = 0; + virtual Targets::TargetRegister getStackPointerRegister() = 0; /** * Should retrieve the current status register value from the target. * * @return */ - virtual TargetRegister getStatusRegister() = 0; + virtual Targets::TargetRegister getStatusRegister() = 0; /** * Should update the program counter value on the target. @@ -156,14 +145,14 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 * * @param stackPointerRegister */ - virtual void setStackPointerRegister(const TargetRegister& stackPointerRegister) = 0; + virtual void setStackPointerRegister(const Targets::TargetRegister& stackPointerRegister) = 0; /** * Should update the status register value on the target. * * @param statusRegister */ - virtual void setStatusRegister(const TargetRegister& statusRegister) = 0; + virtual void setStatusRegister(const Targets::TargetRegister& statusRegister) = 0; /** * Should read the requested general purpose register from the target. @@ -173,14 +162,14 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 * * @return */ - virtual TargetRegisters readGeneralPurposeRegisters(std::set registerIds) = 0; + virtual Targets::TargetRegisters readGeneralPurposeRegisters(std::set registerIds) = 0; /** * Should update the value of general purpose registers. * * @param registers */ - virtual void writeGeneralPurposeRegisters(const TargetRegisters& registers) = 0; + virtual void writeGeneralPurposeRegisters(const Targets::TargetRegisters& registers) = 0; /** * Should read memory from the target, for the given memory type. @@ -190,7 +179,11 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 * @param bytes * @return */ - virtual TargetMemoryBuffer readMemory(TargetMemoryType memoryType, std::uint32_t startAddress, std::uint32_t bytes) = 0; + virtual Targets::TargetMemoryBuffer readMemory( + Targets::TargetMemoryType memoryType, + std::uint32_t startAddress, + std::uint32_t bytes + ) = 0; /** * Should write memory to the target, for a given memory type. @@ -199,13 +192,17 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8 * @param startAddress * @param buffer */ - virtual void writeMemory(TargetMemoryType memoryType, std::uint32_t startAddress, const TargetMemoryBuffer& buffer) = 0; + virtual void writeMemory( + Targets::TargetMemoryType memoryType, + std::uint32_t startAddress, + const Targets::TargetMemoryBuffer& buffer + ) = 0; /** * Should obtain the current target state. * * @return */ - virtual TargetState getTargetState() = 0; + virtual Targets::TargetState getTargetState() = 0; }; } \ No newline at end of file diff --git a/src/EventManager/EventListener.cpp b/src/EventManager/EventListener.cpp index 2aedd4c1..b90b1801 100644 --- a/src/EventManager/EventListener.cpp +++ b/src/EventManager/EventListener.cpp @@ -1,7 +1,7 @@ -#include #include "EventListener.hpp" using namespace Bloom; +using namespace Bloom::Events; std::set EventListener::getRegisteredEventTypeNames() { return this->registeredEventTypes.getValue(); diff --git a/src/EventManager/EventListener.hpp b/src/EventManager/EventListener.hpp index 5abe2021..0a1f259f 100644 --- a/src/EventManager/EventListener.hpp +++ b/src/EventManager/EventListener.hpp @@ -19,8 +19,6 @@ namespace Bloom { - using namespace Events; - /** * The EventListener allows specific threads the ability to handle any events, from other threads, that * are of interest. @@ -65,7 +63,7 @@ namespace Bloom * Events are grouped by event type name, and removed from their queue just *before* the dispatching to * registered handlers begins. */ - SyncSafe>> eventQueueByEventType; + SyncSafe>> eventQueueByEventType; std::condition_variable eventQueueByEventTypeCV; /** @@ -75,12 +73,12 @@ namespace Bloom * Each callback will be passed an std::shared_ptr of the event (we downcast the events in * EventListener::waiteAndDispatch() before dispatching them). */ - SyncSafe>>> eventTypeToCallbacksMapping; + SyncSafe>>> eventTypeToCallbacksMapping; SyncSafe> registeredEventTypes; std::shared_ptr interruptEventNotifier = nullptr; - std::vector getEvents(); + std::vector getEvents(); public: explicit EventListener(const std::string& name): name(name) {}; @@ -105,7 +103,7 @@ namespace Bloom * * @param event */ - void registerEvent(GenericEventPointer event); + void registerEvent(Events::GenericEventPointer event); void setInterruptEventNotifier(std::shared_ptr interruptEventNotifier) { this->interruptEventNotifier = interruptEventNotifier; @@ -121,8 +119,8 @@ namespace Bloom template void registerCallbackForEventType(std::function)> callback) { // We encapsulate the callback in a lambda to handle the downcasting. - std::function parentCallback = - [callback] (GenericEventPointer event) { + std::function parentCallback = + [callback] (Events::GenericEventPointer event) { // Downcast the event to the expected type callback(std::dynamic_pointer_cast(event)); } @@ -139,9 +137,9 @@ namespace Bloom * the type name to callback vector mapping. */ mapping.insert( - std::pair>>( + std::pair>>( EventType::name, - std::vector>() + std::vector>() ) ); } @@ -177,20 +175,20 @@ namespace Bloom std::optional correlationId = std::nullopt ) { // Different return types, depending on how many event type arguments are passed in. - using MonoType = std::optional>; + using MonoType = std::optional>; using BiVariantType = std::optional< std::variant< std::monostate, - EventPointer, - EventPointer + Events::EventPointer, + Events::EventPointer > >; using TriVariantType = std::optional< std::variant< std::monostate, - EventPointer, - EventPointer, - EventPointer + Events::EventPointer, + Events::EventPointer, + Events::EventPointer > >; using ReturnType = typename std::conditional< @@ -211,12 +209,18 @@ namespace Bloom auto eventTypeNamesToDeRegister = std::set(); if constexpr (!std::is_same_v) { - static_assert(std::is_base_of_v, "All event types must be derived from the Event base class."); + static_assert( + std::is_base_of_v, + "All event types must be derived from the Event base class." + ); eventTypeNames.insert(EventTypeB::name); } if constexpr (!std::is_same_v) { - static_assert(std::is_base_of_v, "All event types must be derived from the Event base class."); + static_assert( + std::is_base_of_v, + "All event types must be derived from the Event base class." + ); eventTypeNames.insert(EventTypeC::name); } @@ -232,7 +236,7 @@ namespace Bloom } } - GenericEventPointer foundEvent = nullptr; + Events::GenericEventPointer foundEvent = nullptr; auto eventsFound = [&eventTypeNames, &eventQueueByType, &correlationId, &foundEvent]() -> bool { for (const auto& eventTypeName : eventTypeNames) { if (eventQueueByType.find(eventTypeName) != eventQueueByType.end() @@ -279,17 +283,23 @@ namespace Bloom // If we're looking for multiple event types, use an std::variant. if constexpr (!std::is_same_v || !std::is_same_v) { if (foundEvent->getName() == EventTypeA::name) { - output = std::optional(std::dynamic_pointer_cast(foundEvent)); + output = std::optional( + std::dynamic_pointer_cast(foundEvent) + ); } else if constexpr (!std::is_same_v) { if (foundEvent->getName() == EventTypeB::name) { - output = std::optional(std::dynamic_pointer_cast(foundEvent)); + output = std::optional( + std::dynamic_pointer_cast(foundEvent) + ); } } if constexpr (!std::is_same_v) { if (foundEvent->getName() == EventTypeC::name) { - output = std::optional(std::dynamic_pointer_cast(foundEvent)); + output = std::optional( + std::dynamic_pointer_cast(foundEvent) + ); } } @@ -311,7 +321,7 @@ namespace Bloom */ void waitAndDispatch(int msTimeout = 0); - void dispatchEvent(GenericEventPointer event); + void dispatchEvent(Events::GenericEventPointer event); void dispatchCurrentEvents(); diff --git a/src/EventManager/EventManager.hpp b/src/EventManager/EventManager.hpp index 3ec77728..2999619c 100644 --- a/src/EventManager/EventManager.hpp +++ b/src/EventManager/EventManager.hpp @@ -53,7 +53,7 @@ namespace Bloom * * @param event */ - void triggerEvent(GenericEventPointer event); + void triggerEvent(Events::GenericEventPointer event); }; } diff --git a/src/EventManager/Events/MemoryRetrievedFromTarget.hpp b/src/EventManager/Events/MemoryRetrievedFromTarget.hpp index 98a34b95..20c06fa4 100644 --- a/src/EventManager/Events/MemoryRetrievedFromTarget.hpp +++ b/src/EventManager/Events/MemoryRetrievedFromTarget.hpp @@ -7,12 +7,11 @@ namespace Bloom::Events { - using Targets::TargetMemoryBuffer; class MemoryRetrievedFromTarget: public Event { public: static inline const std::string name = "MemoryRetrievedFromTarget"; - TargetMemoryBuffer data; + Targets::TargetMemoryBuffer data; std::string getName() const override { return MemoryRetrievedFromTarget::name; diff --git a/src/EventManager/Events/MemoryWrittenToTarget.hpp b/src/EventManager/Events/MemoryWrittenToTarget.hpp index e6f1494f..38047a34 100644 --- a/src/EventManager/Events/MemoryWrittenToTarget.hpp +++ b/src/EventManager/Events/MemoryWrittenToTarget.hpp @@ -5,8 +5,6 @@ namespace Bloom::Events { - using Bloom::Targets::TargetMemoryBuffer; - class MemoryWrittenToTarget: public Event { public: diff --git a/src/EventManager/Events/RegistersRetrievedFromTarget.hpp b/src/EventManager/Events/RegistersRetrievedFromTarget.hpp index 61d43e61..8df1f719 100644 --- a/src/EventManager/Events/RegistersRetrievedFromTarget.hpp +++ b/src/EventManager/Events/RegistersRetrievedFromTarget.hpp @@ -7,13 +7,11 @@ namespace Bloom::Events { - using Targets::TargetRegisters; - class RegistersRetrievedFromTarget: public Event { public: static inline const std::string name = "RegistersRetrievedFromTarget"; - TargetRegisters registers; + Targets::TargetRegisters registers; std::string getName() const override { return RegistersRetrievedFromTarget::name; diff --git a/src/EventManager/Events/RemoveBreakpointOnTarget.hpp b/src/EventManager/Events/RemoveBreakpointOnTarget.hpp index c50a3fc9..221005a6 100644 --- a/src/EventManager/Events/RemoveBreakpointOnTarget.hpp +++ b/src/EventManager/Events/RemoveBreakpointOnTarget.hpp @@ -7,14 +7,12 @@ namespace Bloom::Events { - using Targets::TargetBreakpoint; - class RemoveBreakpointOnTarget: public Event { public: static inline const std::string name = "RemoveBreakpointOnTarget"; std::uint32_t address; - TargetBreakpoint breakpoint; + Targets::TargetBreakpoint breakpoint; std::string getName() const override { return RemoveBreakpointOnTarget::name; diff --git a/src/EventManager/Events/RetrieveMemoryFromTarget.hpp b/src/EventManager/Events/RetrieveMemoryFromTarget.hpp index 84373d68..aabff146 100644 --- a/src/EventManager/Events/RetrieveMemoryFromTarget.hpp +++ b/src/EventManager/Events/RetrieveMemoryFromTarget.hpp @@ -7,13 +7,11 @@ namespace Bloom::Events { - using Targets::TargetMemoryType; - class RetrieveMemoryFromTarget: public Event { public: static inline const std::string name = "RetrieveMemoryFromTarget"; - TargetMemoryType memoryType = TargetMemoryType::RAM; + Targets::TargetMemoryType memoryType = Targets::TargetMemoryType::RAM; std::uint32_t startAddress; std::uint32_t bytes; diff --git a/src/EventManager/Events/RetrieveRegistersFromTarget.hpp b/src/EventManager/Events/RetrieveRegistersFromTarget.hpp index ae6f8b48..26d3782c 100644 --- a/src/EventManager/Events/RetrieveRegistersFromTarget.hpp +++ b/src/EventManager/Events/RetrieveRegistersFromTarget.hpp @@ -7,13 +7,11 @@ namespace Bloom::Events { - using Bloom::Targets::TargetRegisterDescriptors; - class RetrieveRegistersFromTarget: public Event { public: static inline const std::string name = "RetrieveRegistersFromTarget"; - TargetRegisterDescriptors descriptors; + Targets::TargetRegisterDescriptors descriptors; std::string getName() const override { return RetrieveRegistersFromTarget::name; diff --git a/src/EventManager/Events/SetBreakpointOnTarget.hpp b/src/EventManager/Events/SetBreakpointOnTarget.hpp index 16dce3c2..18b98ef6 100644 --- a/src/EventManager/Events/SetBreakpointOnTarget.hpp +++ b/src/EventManager/Events/SetBreakpointOnTarget.hpp @@ -7,14 +7,12 @@ namespace Bloom::Events { - using Targets::TargetBreakpoint; - class SetBreakpointOnTarget: public Event { public: static inline const std::string name = "SetBreakpointOnTarget"; std::uint32_t address; - TargetBreakpoint breakpoint; + Targets::TargetBreakpoint breakpoint; std::string getName() const override { return SetBreakpointOnTarget::name; diff --git a/src/EventManager/Events/TargetExecutionStopped.hpp b/src/EventManager/Events/TargetExecutionStopped.hpp index 219d900f..1b854255 100644 --- a/src/EventManager/Events/TargetExecutionStopped.hpp +++ b/src/EventManager/Events/TargetExecutionStopped.hpp @@ -7,16 +7,14 @@ namespace Bloom::Events { - using Targets::TargetBreakCause; - class TargetExecutionStopped: public Event { public: static inline const std::string name = "TargetExecutionStopped"; std::uint32_t programCounter; - TargetBreakCause breakCause; + Targets::TargetBreakCause breakCause; - TargetExecutionStopped(std::uint32_t programCounter, TargetBreakCause breakCause) : + TargetExecutionStopped(std::uint32_t programCounter, Targets::TargetBreakCause breakCause) : programCounter(programCounter), breakCause(breakCause) {} std::string getName() const override { diff --git a/src/EventManager/Events/WriteMemoryToTarget.hpp b/src/EventManager/Events/WriteMemoryToTarget.hpp index c2bbb384..6049c888 100644 --- a/src/EventManager/Events/WriteMemoryToTarget.hpp +++ b/src/EventManager/Events/WriteMemoryToTarget.hpp @@ -7,22 +7,23 @@ namespace Bloom::Events { - using Bloom::Targets::TargetMemoryBuffer; - class WriteMemoryToTarget: public Event { public: static inline const std::string name = "WriteMemoryToTarget"; - TargetMemoryType memoryType; + Targets::TargetMemoryType memoryType; std::uint32_t startAddress; - TargetMemoryBuffer buffer; + Targets::TargetMemoryBuffer buffer; std::string getName() const override { return WriteMemoryToTarget::name; } WriteMemoryToTarget() = default; - WriteMemoryToTarget(TargetMemoryType memoryType, std::uint32_t startAddress, const TargetMemoryBuffer& buffer) - : memoryType(memoryType), startAddress(startAddress), buffer(buffer) {}; + WriteMemoryToTarget( + Targets::TargetMemoryType memoryType, + std::uint32_t startAddress, + const Targets::TargetMemoryBuffer& buffer + ): memoryType(memoryType), startAddress(startAddress), buffer(buffer) {}; }; } diff --git a/src/EventManager/Events/WriteRegistersToTarget.hpp b/src/EventManager/Events/WriteRegistersToTarget.hpp index 79933ad9..ed81a1d5 100644 --- a/src/EventManager/Events/WriteRegistersToTarget.hpp +++ b/src/EventManager/Events/WriteRegistersToTarget.hpp @@ -7,19 +7,17 @@ namespace Bloom::Events { - using Bloom::Targets::TargetRegister; - class WriteRegistersToTarget: public Event { public: static inline const std::string name = "WriteRegistersToTarget"; - TargetRegisters registers; + Targets::TargetRegisters registers; std::string getName() const override { return WriteRegistersToTarget::name; } WriteRegistersToTarget() = default; - WriteRegistersToTarget(const TargetRegisters& registers): registers(registers) {}; + WriteRegistersToTarget(const Targets::TargetRegisters& registers): registers(registers) {}; }; } diff --git a/src/Helpers/EventNotifier.hpp b/src/Helpers/EventNotifier.hpp index 2fb1871a..08d3812d 100644 --- a/src/Helpers/EventNotifier.hpp +++ b/src/Helpers/EventNotifier.hpp @@ -9,8 +9,6 @@ namespace Bloom { - using namespace Exceptions; - /** * The EventNotifier class provides a means to interrupt a thread that is blocked by an IO call. * @@ -36,7 +34,8 @@ namespace Bloom this->fileDescriptor = ::eventfd(0, EFD_NONBLOCK); if (this->fileDescriptor < -1) { - throw Exception("Failed to create new eventfd object - error number: " + std::to_string(errno)); + throw Exceptions::Exception("Failed to create new eventfd object - error number: " + + std::to_string(errno)); } } @@ -46,15 +45,16 @@ namespace Bloom void notify() { if (::eventfd_write(this->fileDescriptor, 1) < 0) { - throw Exception("Failed to increment eventfd counter - error number: " + std::to_string(errno)); + throw Exceptions::Exception("Failed to increment eventfd counter - error number: " + + std::to_string(errno)); } } void clear() { eventfd_t counter; if (::eventfd_read(this->fileDescriptor, &counter) < 0 && errno != EAGAIN) { - throw Exception("Failed to clear EventNotifier object - eventfd_read failed - error number: " - + std::to_string(errno)); + throw Exceptions::Exception("Failed to clear EventNotifier object - eventfd_read failed - " + "error number: " + std::to_string(errno)); } } diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index 1fcda414..5143e863 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -10,7 +10,8 @@ #include "src/Targets/TargetState.hpp" using namespace Bloom; -using namespace Exceptions; +using namespace Bloom::Events; +using namespace Bloom::Exceptions; void Insight::run() { try { diff --git a/src/Insight/Insight.hpp b/src/Insight/Insight.hpp index b75ec215..daaf130f 100644 --- a/src/Insight/Insight.hpp +++ b/src/Insight/Insight.hpp @@ -81,7 +81,7 @@ namespace Bloom * * @param event */ - void onShutdownApplicationEvent(EventPointer event); + void onShutdownApplicationEvent(Events::EventPointer event); /** * If the something horrible was to happen and the TC dies unexpectedly, Insight will shutdown in response. diff --git a/src/Insight/InsightWorker.cpp b/src/Insight/InsightWorker.cpp index 77a0d5ef..1aeb6ef7 100644 --- a/src/Insight/InsightWorker.cpp +++ b/src/Insight/InsightWorker.cpp @@ -11,7 +11,10 @@ #include "src/Exceptions/InvalidConfig.hpp" using namespace Bloom; -using namespace Exceptions; +using namespace Bloom::Events; +using namespace Bloom::Exceptions; + +using Bloom::Targets::TargetState; void InsightWorker::startup() { Logger::debug("Starting InsightWorker thread"); diff --git a/src/Insight/InsightWorker.hpp b/src/Insight/InsightWorker.hpp index 1677a4d3..ee519066 100644 --- a/src/Insight/InsightWorker.hpp +++ b/src/Insight/InsightWorker.hpp @@ -12,9 +12,6 @@ namespace Bloom { - using namespace Events; - using Targets::TargetState; - /** * The InsightWorker runs on a separate thread to the main GUI thread. Its purpose is to handle any * blocking/time-expensive operations. @@ -33,10 +30,10 @@ namespace Bloom QTimer* eventDispatchTimer = nullptr; - void onTargetStoppedEvent(EventPointer event); - void onTargetResumedEvent(EventPointer event); - void onTargetPinStatesRetrievedEvent(EventPointer event); - void onTargetIoPortsUpdatedEvent(EventPointer event); + void onTargetStoppedEvent(Events::EventPointer event); + void onTargetResumedEvent(Events::EventPointer event); + void onTargetPinStatesRetrievedEvent(Events::EventPointer event); + void onTargetIoPortsUpdatedEvent(Events::EventPointer event); public: InsightWorker(EventManager& eventManager): eventManager(eventManager) {}; diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index 15bccbeb..81a7ee41 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -10,10 +10,14 @@ #include "src/Targets/TargetDescriptor.hpp" using namespace Bloom; -using namespace Exceptions; -using Targets::TargetDescriptor; -using Targets::TargetVariant; -using Targets::TargetPackage; +using namespace Bloom::Exceptions; +using namespace Bloom::InsightTargetWidgets; + +using Bloom::Targets::TargetDescriptor; +using Bloom::Targets::TargetState; +using Bloom::Targets::TargetPinState; +using Bloom::Targets::TargetVariant; +using Bloom::Targets::TargetPackage; void InsightWindow::init( QApplication& application, diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp index 880bc632..5ce19629 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp @@ -15,21 +15,12 @@ namespace Bloom { - using InsightTargetWidgets::TargetPackageWidget; - using InsightTargetWidgets::TargetPinWidget; - - using Targets::TargetDescriptor; - using Targets::TargetVariant; - using Targets::TargetPackage; - using Targets::TargetState; - using Targets::TargetPinState; - class InsightWindow: public QObject { Q_OBJECT private: - TargetDescriptor targetDescriptor; - TargetState targetState = TargetState::UNKNOWN; + Targets::TargetDescriptor targetDescriptor; + Targets::TargetState targetState = Targets::TargetState::UNKNOWN; QWidget* mainWindowWidget = nullptr; AboutWindow* aboutWindowWidget = nullptr; @@ -41,19 +32,19 @@ namespace Bloom QWidget* ioContainerWidget = nullptr; QWidget* ioUnavailableWidget = nullptr; - TargetPackageWidget* targetPackageWidget = nullptr; + InsightTargetWidgets::TargetPackageWidget* targetPackageWidget = nullptr; QWidget* footer = nullptr; QLabel* targetStatusLabel = nullptr; QLabel* programCounterValueLabel = nullptr; - std::map supportedVariantsByName; - const TargetVariant* selectedVariant = nullptr; + std::map supportedVariantsByName; + const Targets::TargetVariant* selectedVariant = nullptr; bool uiDisabled = false; - bool isVariantSupported(const TargetVariant& variant); + bool isVariantSupported(const Targets::TargetVariant& variant); - void selectVariant(const TargetVariant* variant); + void selectVariant(const Targets::TargetVariant* variant); void toggleUi(bool disable) { this->uiDisabled = disable; @@ -83,14 +74,14 @@ namespace Bloom public slots: void onTargetPinStatesUpdate(int variantId, Bloom::Targets::TargetPinStateMappingType pinStatesByNumber); - void onTargetStateUpdate(TargetState newState); + void onTargetStateUpdate(Targets::TargetState newState); void onTargetProgramCounterUpdate(quint32 programCounter); void onTargetIoPortsUpdate(); void close(); void openReportIssuesUrl(); void openGettingStartedUrl(); void openAboutWindow(); - void togglePinIoState(TargetPinWidget* pinWidget); + void togglePinIoState(InsightTargetWidgets::TargetPinWidget* pinWidget); signals: void refreshTargetPinStates(int variantId); diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/DualInlinePackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/DualInlinePackageWidget.cpp index ce806043..fa61f098 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/DualInlinePackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/DualInlinePackageWidget.cpp @@ -15,8 +15,13 @@ using namespace Bloom::InsightTargetWidgets::Dip; using namespace Bloom::Exceptions; -DualInlinePackageWidget::DualInlinePackageWidget(const TargetVariant& targetVariant, QObject* insightWindowObj, QWidget* parent): -TargetPackageWidget(targetVariant, insightWindowObj, parent) { +using Bloom::Targets::TargetVariant; + +DualInlinePackageWidget::DualInlinePackageWidget( + const TargetVariant& targetVariant, + QObject* insightWindowObj, + QWidget* parent +): TargetPackageWidget(targetVariant, insightWindowObj, parent) { auto stylesheetFile = QFile(":/compiled/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/Stylesheets/DualInlinePackage.qss"); stylesheetFile.open(QFile::ReadOnly); this->setStyleSheet(stylesheetFile.readAll()); diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/DualInlinePackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/DualInlinePackageWidget.hpp index f2ec1fb0..7ceea44d 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/DualInlinePackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/DualInlinePackageWidget.hpp @@ -12,8 +12,6 @@ namespace Bloom::InsightTargetWidgets::Dip { - using Targets::TargetVariant; - /** * The DualInlinePackageWidget implements a custom Qt widget for the Dual-inline package target variants. */ @@ -32,6 +30,6 @@ namespace Bloom::InsightTargetWidgets::Dip void drawWidget(QPainter& painter); public: - DualInlinePackageWidget(const TargetVariant& targetVariant, QObject* insightWindowObj, QWidget* parent); + DualInlinePackageWidget(const Targets::TargetVariant& targetVariant, QObject* insightWindowObj, QWidget* parent); }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinBodyWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinBodyWidget.cpp index 2abc9ad9..09a969b9 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinBodyWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinBodyWidget.cpp @@ -10,6 +10,7 @@ #include "src/Exceptions/Exception.hpp" using namespace Bloom::InsightTargetWidgets::Dip; +using namespace Bloom::Targets; using namespace Bloom::Exceptions; void PinBodyWidget::paintEvent(QPaintEvent* event) { diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinBodyWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinBodyWidget.hpp index 6484a2ea..85d00740 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinBodyWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinBodyWidget.hpp @@ -7,10 +7,6 @@ namespace Bloom::InsightTargetWidgets::Dip { - using Targets::TargetPinDescriptor; - using Targets::TargetPinType; - using Targets::TargetPinState; - class PinBodyWidget: public QWidget { Q_OBJECT @@ -18,8 +14,8 @@ namespace Bloom::InsightTargetWidgets::Dip Q_PROPERTY(int disableAlphaLevel READ getDisableAlphaLevel WRITE setDisableAlphaLevel DESIGNABLE true) private: - TargetPinDescriptor pinDescriptor; - std::optional pinState; + Targets::TargetPinDescriptor pinDescriptor; + std::optional pinState; QColor bodyColor = QColor("#AFB1B3"); int disableAlphaLevel = 100; @@ -40,12 +36,15 @@ namespace Bloom::InsightTargetWidgets::Dip static const int WIDTH = 30; static const int HEIGHT = 40; - PinBodyWidget(QWidget* parent, const TargetPinDescriptor& pinDescriptor): QWidget(parent), pinDescriptor(pinDescriptor) { + PinBodyWidget( + QWidget* parent, + const Targets::TargetPinDescriptor& pinDescriptor + ): QWidget(parent), pinDescriptor(pinDescriptor) { this->setFixedSize(PinBodyWidget::WIDTH, PinBodyWidget::HEIGHT); this->setObjectName("target-pin-body"); } - void setPinState(const TargetPinState& pinState) { + void setPinState(const Targets::TargetPinState& pinState) { this->pinState = pinState; } diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinWidget.cpp index 3f6a1228..87520e82 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinWidget.cpp @@ -9,6 +9,7 @@ #include "src/Logger/Logger.hpp" using namespace Bloom::InsightTargetWidgets::Dip; +using namespace Bloom::Targets; PinWidget::PinWidget(QWidget* parent, const TargetPinDescriptor& pinDescriptor, const TargetVariant& targetVariant): TargetPinWidget(parent, pinDescriptor, targetVariant) { diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinWidget.hpp index 5a4f51cd..5545b1b5 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/DIP/PinWidget.hpp @@ -34,16 +34,22 @@ namespace Bloom::InsightTargetWidgets::Dip static const int MINIMUM_WIDTH = 30; static const int MAXIMUM_LABEL_COUNT = 3; static const int LABEL_HEIGHT = 20; - static const int MAXIMUM_HEIGHT = PinBodyWidget::HEIGHT + (PinWidget::LABEL_HEIGHT * PinWidget::MAXIMUM_LABEL_COUNT); + static const int MAXIMUM_HEIGHT = PinBodyWidget::HEIGHT + + (PinWidget::LABEL_HEIGHT * PinWidget::MAXIMUM_LABEL_COUNT); - PinWidget(QWidget* parent, const TargetPinDescriptor& pinDescriptor, const TargetVariant& targetVariant); + PinWidget( + QWidget* parent, + const Targets::TargetPinDescriptor& pinDescriptor, + const Targets::TargetVariant& targetVariant + ); - virtual void updatePinState(const TargetPinState& pinState) override { + virtual void updatePinState(const Targets::TargetPinState& pinState) override { TargetPinWidget::updatePinState(pinState); if (pinState.ioDirection.has_value()) { - this->pinDirectionLabel->setText(pinState.ioDirection.value() == TargetPinState::IoDirection::INPUT ? - "IN" : "OUT"); + this->pinDirectionLabel->setText( + pinState.ioDirection.value() == Targets::TargetPinState::IoDirection::INPUT ? "IN" : "OUT" + ); } else { this->pinDirectionLabel->setText(""); diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinBodyWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinBodyWidget.cpp index 9dbb5d6e..23f99871 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinBodyWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinBodyWidget.cpp @@ -1,16 +1,14 @@ #include #include -#include #include #include #include #include "PinBodyWidget.hpp" #include "src/Logger/Logger.hpp" -#include "src/Exceptions/Exception.hpp" using namespace Bloom::InsightTargetWidgets::Qfp; -using namespace Bloom::Exceptions; +using namespace Bloom::Targets; void PinBodyWidget::paintEvent(QPaintEvent* event) { auto painter = QPainter(this); diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinBodyWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinBodyWidget.hpp index ee1e7c92..fd431317 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinBodyWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinBodyWidget.hpp @@ -7,10 +7,6 @@ namespace Bloom::InsightTargetWidgets::Qfp { - using Targets::TargetPinDescriptor; - using Targets::TargetPinType; - using Targets::TargetPinState; - class PinBodyWidget: public QWidget { Q_OBJECT @@ -18,8 +14,8 @@ namespace Bloom::InsightTargetWidgets::Qfp Q_PROPERTY(int disableAlphaLevel READ getDisableAlphaLevel WRITE setDisableAlphaLevel DESIGNABLE true) private: - TargetPinDescriptor pinDescriptor; - std::optional pinState; + Targets::TargetPinDescriptor pinDescriptor; + std::optional pinState; QColor bodyColor = QColor("#AFB1B3"); int disableAlphaLevel = 100; bool isVertical = false; @@ -42,7 +38,7 @@ namespace Bloom::InsightTargetWidgets::Qfp static const int WIDTH = 30; static const int HEIGHT = 40; - PinBodyWidget(QWidget* parent, const TargetPinDescriptor& pinDescriptor, bool isVertical): + PinBodyWidget(QWidget* parent, const Targets::TargetPinDescriptor& pinDescriptor, bool isVertical): QWidget(parent), pinDescriptor(pinDescriptor), isVertical(isVertical) { this->setObjectName("target-pin-body"); @@ -54,7 +50,7 @@ namespace Bloom::InsightTargetWidgets::Qfp } } - void setPinState(const TargetPinState& pinState) { + void setPinState(const Targets::TargetPinState& pinState) { this->pinState = pinState; } diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinWidget.cpp index 6279df9d..4ae7cec7 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinWidget.cpp @@ -9,6 +9,7 @@ #include "src/Logger/Logger.hpp" using namespace Bloom::InsightTargetWidgets::Qfp; +using namespace Bloom::Targets; PinWidget::PinWidget(QWidget* parent, const TargetPinDescriptor& pinDescriptor, const TargetVariant& targetVariant): TargetPinWidget(parent, pinDescriptor, targetVariant) { diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinWidget.hpp index 2e273219..5ae48ee1 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/PinWidget.hpp @@ -41,19 +41,26 @@ namespace Bloom::InsightTargetWidgets::Qfp static const int LABEL_HEIGHT = 20; static const int MAXIMUM_LABEL_WIDTH = PinBodyWidget::WIDTH; static const int MAXIMUM_LABEL_HEIGHT = 20; - static const int MAXIMUM_HORIZONTAL_WIDTH = PinBodyWidget::HEIGHT + (PinWidget::MAXIMUM_LABEL_WIDTH * PinWidget::MAXIMUM_LABEL_COUNT); + static const int MAXIMUM_HORIZONTAL_WIDTH = PinBodyWidget::HEIGHT + + (PinWidget::MAXIMUM_LABEL_WIDTH * PinWidget::MAXIMUM_LABEL_COUNT); static const int MAXIMUM_HORIZONTAL_HEIGHT = PinBodyWidget::WIDTH; - static const int MAXIMUM_VERTICAL_HEIGHT = PinBodyWidget::HEIGHT + (PinWidget::MAXIMUM_LABEL_HEIGHT * PinWidget::MAXIMUM_LABEL_COUNT); + static const int MAXIMUM_VERTICAL_HEIGHT = PinBodyWidget::HEIGHT + + (PinWidget::MAXIMUM_LABEL_HEIGHT * PinWidget::MAXIMUM_LABEL_COUNT); static const int MAXIMUM_VERTICAL_WIDTH = PinBodyWidget::WIDTH; - PinWidget(QWidget* parent, const TargetPinDescriptor& pinDescriptor, const TargetVariant& targetVariant); + PinWidget( + QWidget* parent, + const Targets::TargetPinDescriptor& pinDescriptor, + const Targets::TargetVariant& targetVariant + ); - virtual void updatePinState(const TargetPinState& pinState) override { + virtual void updatePinState(const Targets::TargetPinState& pinState) override { TargetPinWidget::updatePinState(pinState); if (pinState.ioDirection.has_value()) { - this->pinDirectionLabel->setText(pinState.ioDirection.value() == TargetPinState::IoDirection::INPUT ? - "IN" : "OUT"); + this->pinDirectionLabel->setText( + pinState.ioDirection.value() == Targets::TargetPinState::IoDirection::INPUT ? "IN" : "OUT" + ); } else { this->pinDirectionLabel->setText(""); diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/QuadFlatPackageWidget.cpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/QuadFlatPackageWidget.cpp index 6b74e00a..8755f6f4 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/QuadFlatPackageWidget.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/QuadFlatPackageWidget.cpp @@ -7,16 +7,17 @@ #include "../../InsightWindow.hpp" #include "QuadFlatPackageWidget.hpp" -#include "src/Logger/Logger.hpp" -#include "src/Exceptions/Exception.hpp" #include "PinWidget.hpp" #include "BodyWidget.hpp" using namespace Bloom::InsightTargetWidgets::Qfp; -using namespace Bloom::Exceptions; +using namespace Bloom::Targets; -QuadFlatPackageWidget::QuadFlatPackageWidget(const TargetVariant& targetVariant, QObject* insightWindowObj, QWidget* parent): -TargetPackageWidget(targetVariant, insightWindowObj, parent) { +QuadFlatPackageWidget::QuadFlatPackageWidget( + const TargetVariant& targetVariant, + QObject* insightWindowObj, + QWidget* parent +): TargetPackageWidget(targetVariant, insightWindowObj, parent) { assert((targetVariant.pinDescriptorsByNumber.size() % 4) == 0); auto stylesheetFile = QFile(":/compiled/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/Stylesheets/QuadFlatPackage.qss"); @@ -212,4 +213,3 @@ void QuadFlatPackageWidget::drawWidget(QPainter& painter) { containerHeight ); } - diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/QuadFlatPackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/QuadFlatPackageWidget.hpp index c3c841a8..79cce053 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/QuadFlatPackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/QFP/QuadFlatPackageWidget.hpp @@ -12,8 +12,6 @@ namespace Bloom::InsightTargetWidgets::Qfp { - using Targets::TargetVariant; - /** * QuadFlatPackageWidget implements a custom Qt widget for Quad-flat package variants. */ @@ -36,6 +34,6 @@ namespace Bloom::InsightTargetWidgets::Qfp public: static const int PIN_WIDGET_LAYOUT_PADDING = 46; static const int PIN_WIDGET_SPACING = 8; - QuadFlatPackageWidget(const TargetVariant& targetVariant, QObject* insightWindowObj, QWidget* parent); + QuadFlatPackageWidget(const Targets::TargetVariant& targetVariant, QObject* insightWindowObj, QWidget* parent); }; } diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/TargetPackageWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/TargetPackageWidget.hpp index b9a62d6a..28eedfd2 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/TargetPackageWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/TargetPackageWidget.hpp @@ -10,9 +10,6 @@ namespace Bloom::InsightTargetWidgets { - using Targets::TargetVariant; - using Targets::TargetPinState; - /** * Each custom target package widget should be derived from this class. */ @@ -20,14 +17,14 @@ namespace Bloom::InsightTargetWidgets { Q_OBJECT protected: - TargetVariant targetVariant; + Targets::TargetVariant targetVariant; std::vector pinWidgets; public: - TargetPackageWidget(const TargetVariant& targetVariant, QObject* insightWindowObj, QWidget* parent): + TargetPackageWidget(const Targets::TargetVariant& targetVariant, QObject* insightWindowObj, QWidget* parent): QWidget(parent), targetVariant(targetVariant) {}; - virtual void updatePinStates(std::map pinStatesByNumber) { + virtual void updatePinStates(std::map pinStatesByNumber) { for (auto& pinWidget : this->pinWidgets) { auto pinNumber = pinWidget->getPinNumber(); if (pinStatesByNumber.contains(pinNumber)) { diff --git a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/TargetPinWidget.hpp b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/TargetPinWidget.hpp index 31e2cc3e..5767ced9 100644 --- a/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/TargetPinWidget.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/TargetWidgets/TargetPinWidget.hpp @@ -7,23 +7,21 @@ namespace Bloom::InsightTargetWidgets { - using Targets::TargetVariant; - using Targets::TargetPinDescriptor; - using Targets::TargetPinType; - using Targets::TargetPinState; - class TargetPinWidget: public QWidget { Q_OBJECT protected: - TargetVariant targetVariant; - TargetPinDescriptor pinDescriptor; - std::optional pinState; + Targets::TargetVariant targetVariant; + Targets::TargetPinDescriptor pinDescriptor; + std::optional pinState; bool pinStateChanged = false; public: - TargetPinWidget(QWidget* parent, const TargetPinDescriptor& pinDescriptor, const TargetVariant& targetVariant): - QWidget(parent), targetVariant(targetVariant), pinDescriptor(pinDescriptor) { + TargetPinWidget( + QWidget* parent, + const Targets::TargetPinDescriptor& pinDescriptor, + const Targets::TargetVariant& targetVariant + ): QWidget(parent), targetVariant(targetVariant), pinDescriptor(pinDescriptor) { this->setDisabled(false); }; @@ -31,15 +29,15 @@ namespace Bloom::InsightTargetWidgets return this->pinDescriptor.number; } - const TargetPinDescriptor& getPinDescriptor() const { + const Targets::TargetPinDescriptor& getPinDescriptor() const { return this->pinDescriptor; } - std::optional getPinState() const { + std::optional getPinState() const { return this->pinState; } - virtual void updatePinState(const TargetPinState& pinState) { + virtual void updatePinState(const Targets::TargetPinState& pinState) { this->pinStateChanged = !this->pinState.has_value() || this->pinState->ioState != pinState.ioState || this->pinState->ioDirection != pinState.ioDirection; @@ -48,9 +46,9 @@ namespace Bloom::InsightTargetWidgets } void setDisabled(bool disabled) { - if (pinDescriptor.type != TargetPinType::GND - && pinDescriptor.type != TargetPinType::VCC - && pinDescriptor.type != TargetPinType::UNKNOWN + if (pinDescriptor.type != Targets::TargetPinType::GND + && pinDescriptor.type != Targets::TargetPinType::VCC + && pinDescriptor.type != Targets::TargetPinType::UNKNOWN ) { QWidget::setDisabled(disabled); diff --git a/src/TargetController/TargetController.cpp b/src/TargetController/TargetController.cpp index 94289655..044db3db 100644 --- a/src/TargetController/TargetController.cpp +++ b/src/TargetController/TargetController.cpp @@ -8,7 +8,9 @@ #include "src/Application.hpp" using namespace Bloom; -using namespace Exceptions; +using namespace Bloom::Targets; +using namespace Bloom::Events; +using namespace Bloom::Exceptions; void TargetController::run() { try { diff --git a/src/TargetController/TargetController.hpp b/src/TargetController/TargetController.hpp index 1f30140f..ff427ca6 100644 --- a/src/TargetController/TargetController.hpp +++ b/src/TargetController/TargetController.hpp @@ -18,12 +18,6 @@ namespace Bloom { - using namespace Targets; - using namespace DebugToolDrivers; - using namespace Targets::Microchip::Avr; - using Avr8Bit::Avr8; - using Events::EventPointer; - /** * The TargetController possesses full control of the debugging target and the debug tool. * @@ -55,12 +49,12 @@ namespace Bloom * different state to what's stored in lastTargetState, a state change (TargetExecutionStopped/TargetExecutionResumed) * event is emitted. */ - TargetState lastTargetState = TargetState::UNKNOWN; + Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN; /** * Obtaining a TargetDescriptor for the connected target can be quite expensive. We cache it here. */ - std::optional cachedTargetDescriptor; + std::optional cachedTargetDescriptor; /** * Constructs a mapping of supported debug tool names to lambdas. The lambdas should *only* instantiate @@ -70,26 +64,28 @@ namespace Bloom * @return */ static auto getSupportedDebugTools() { - return std::map()>> { + static auto mapping = std::map()>> { { "atmel-ice", []() { - return std::make_unique(); + return std::make_unique(); } }, { "power-debugger", []() { - return std::make_unique(); + return std::make_unique(); } }, { "snap", []() { - return std::make_unique(); + return std::make_unique(); } }, }; + + return mapping; } /** @@ -99,34 +95,42 @@ namespace Bloom * @return */ static auto getSupportedTargets() { - auto mapping = std::map()>> { - { - "avr8", - []() { - return std::make_unique(); - } - }, - }; + static std::map()>> mapping; - // Include all targets from AVR8 part description files - auto avr8PdMapping = Avr8Bit::PartDescriptionFile::getPartDescriptionMapping(); + if (mapping.empty()) { + mapping = { + { + "avr8", + []() { + return std::make_unique(); + } + }, + }; - for (auto mapIt = avr8PdMapping.begin(); mapIt != avr8PdMapping.end(); mapIt++) { - // Each target signature maps to an array of targets, as numerous targets can possess the same signature. - auto targets = mapIt.value().toArray(); + // Include all targets from AVR8 part description files + auto avr8PdMapping = + Targets::Microchip::Avr::Avr8Bit::PartDescription::PartDescriptionFile::getPartDescriptionMapping(); - for (auto targetIt = targets.begin(); targetIt != targets.end(); targetIt++) { - auto targetName = targetIt->toObject().find("targetName").value().toString() - .toLower().toStdString(); - auto targetSignatureHex = mapIt.key().toLower().toStdString(); + for (auto mapIt = avr8PdMapping.begin(); mapIt != avr8PdMapping.end(); mapIt++) { + // Each target signature maps to an array of targets, as numerous targets can possess the same signature. + auto targets = mapIt.value().toArray(); - if (!mapping.contains(targetName)) { - mapping.insert({ - targetName, - [targetName, targetSignatureHex]() { - return std::make_unique(targetName, TargetSignature(targetSignatureHex)); - } - }); + for (auto targetIt = targets.begin(); targetIt != targets.end(); targetIt++) { + auto targetName = targetIt->toObject().find("targetName").value().toString() + .toLower().toStdString(); + auto targetSignatureHex = mapIt.key().toLower().toStdString(); + + if (!mapping.contains(targetName)) { + mapping.insert({ + targetName, + [targetName, targetSignatureHex]() { + return std::make_unique( + targetName, + Targets::Microchip::Avr::TargetSignature(targetSignatureHex) + ); + } + }); + } } } } @@ -216,63 +220,63 @@ namespace Bloom * * @param event */ - void onExtractTargetDescriptor(EventPointer event); + void onExtractTargetDescriptor(Events::EventPointer event); /** * Will attempt to stop execution on the target and emit a TargetExecutionStopped event. * * @param event */ - void onStopTargetExecutionEvent(EventPointer event); + void onStopTargetExecutionEvent(Events::EventPointer event); /** * Will attempt to step execution on the target and emit a TargetExecutionResumed event. * * @param event */ - void onStepTargetExecutionEvent(EventPointer event); + void onStepTargetExecutionEvent(Events::EventPointer event); /** * Will attempt to resume execution on the target and emit a TargetExecutionResumed event. * * @param event */ - void onResumeTargetExecutionEvent(EventPointer event); + void onResumeTargetExecutionEvent(Events::EventPointer event); /** * Invokes a shutdown. * * @param event */ - void onShutdownTargetControllerEvent(EventPointer event); + void onShutdownTargetControllerEvent(Events::EventPointer event); /** * Will attempt to read the requested registers and emit a RegistersRetrievedFromTarget event. * * @param event */ - void onReadRegistersEvent(EventPointer event); + void onReadRegistersEvent(Events::EventPointer event); /** * Will attempt to write the specified register values and emit a RegistersWrittenToTarget event. * * @param event */ - void onWriteRegistersEvent(EventPointer event); + void onWriteRegistersEvent(Events::EventPointer event); /** * Will attempt to read memory from the target and include the data in a MemoryRetrievedFromTarget event. * * @param event */ - void onReadMemoryEvent(EventPointer event); + void onReadMemoryEvent(Events::EventPointer event); /** * Will attempt to write memory to the target. On success, a MemoryWrittenToTarget event is emitted. * * @param event */ - void onWriteMemoryEvent(EventPointer event); + void onWriteMemoryEvent(Events::EventPointer event); /** * Will attempt to set the specific breakpoint on the target. On success, the BreakpointSetOnTarget event will @@ -280,7 +284,7 @@ namespace Bloom * * @param event */ - void onSetBreakpointEvent(EventPointer event); + void onSetBreakpointEvent(Events::EventPointer event); /** * Will attempt to remove a breakpoint at the specified address, on the target. On success, the @@ -288,21 +292,21 @@ namespace Bloom * * @param event */ - void onRemoveBreakpointEvent(EventPointer event); + void onRemoveBreakpointEvent(Events::EventPointer event); /** * Will hold the target stopped at it's current state. * * @param event */ - void onDebugSessionStartedEvent(EventPointer event); + void onDebugSessionStartedEvent(Events::EventPointer event); /** * Will simply kick off execution on the target. * * @param event */ - void onDebugSessionFinishedEvent(EventPointer event); + void onDebugSessionFinishedEvent(Events::EventPointer event); /** * Will update the program counter value on the target. On success, a ProgramCounterSetOnTarget event is @@ -310,7 +314,7 @@ namespace Bloom * * @param event */ - void onSetProgramCounterEvent(EventPointer event); + void onSetProgramCounterEvent(Events::EventPointer event); /** * Will automatically fire a target state update event. @@ -318,14 +322,14 @@ namespace Bloom * * @param event */ - void onInsightStateChangedEvent(EventPointer event); + void onInsightStateChangedEvent(Events::EventPointer event); /** * Will attempt to obtain the pin states from the target. Will emit a TargetPinStatesRetrieved event on success. * * @param event */ - void onRetrieveTargetPinStatesEvent(EventPointer event); + void onRetrieveTargetPinStatesEvent(Events::EventPointer event); /** * Will update a pin state for a particular pin. Will emit a TargetPinStatesRetrieved with the new pin @@ -333,6 +337,6 @@ namespace Bloom * * @param event */ - void onSetPinStateEvent(EventPointer event); + void onSetPinStateEvent(Events::EventPointer event); }; } diff --git a/src/TargetController/TargetControllerConsole.cpp b/src/TargetController/TargetControllerConsole.cpp index 7c553287..17b765f0 100644 --- a/src/TargetController/TargetControllerConsole.cpp +++ b/src/TargetController/TargetControllerConsole.cpp @@ -5,6 +5,9 @@ #include "src/Logger/Logger.hpp" using namespace Bloom; +using namespace Bloom::Targets; +using namespace Bloom::Events; +using namespace Bloom::Exceptions; Targets::TargetDescriptor TargetControllerConsole::getTargetDescriptor() { auto extractEvent = std::make_shared(); diff --git a/src/TargetController/TargetControllerConsole.hpp b/src/TargetController/TargetControllerConsole.hpp index c40514ff..3bffd425 100644 --- a/src/TargetController/TargetControllerConsole.hpp +++ b/src/TargetController/TargetControllerConsole.hpp @@ -15,8 +15,6 @@ namespace Bloom { - using namespace Targets; - /** * The TargetControllerConsole provides an interface to the TargetController, for components within Bloom that * require access to common functionality from the TargetController. @@ -42,7 +40,7 @@ namespace Bloom * * @return */ - TargetDescriptor getTargetDescriptor(); + Targets::TargetDescriptor getTargetDescriptor(); /** * Requests the TargetController to halt execution on the target. @@ -71,14 +69,14 @@ namespace Bloom * * @return */ - TargetRegisters readGeneralRegisters(TargetRegisterDescriptors descriptors); + Targets::TargetRegisters readGeneralRegisters(Targets::TargetRegisterDescriptors descriptors); /** * Requests the TargetController to write register values to the target. * * @param registers */ - void writeGeneralRegisters(TargetRegisters registers); + void writeGeneralRegisters(Targets::TargetRegisters registers); /** * Requests the TargetController to read memory from the target. @@ -88,7 +86,11 @@ namespace Bloom * @param bytes * @return */ - TargetMemoryBuffer readMemory(TargetMemoryType memoryType, std::uint32_t startAddress, std::uint32_t bytes); + Targets::TargetMemoryBuffer readMemory( + Targets::TargetMemoryType memoryType, + std::uint32_t startAddress, + std::uint32_t bytes + ); /** * Requests the TargetController to write memory to the target. @@ -97,21 +99,25 @@ namespace Bloom * @param startAddress * @param buffer */ - void writeMemory(TargetMemoryType memoryType, std::uint32_t startAddress, const TargetMemoryBuffer& buffer); + void writeMemory( + Targets::TargetMemoryType memoryType, + std::uint32_t startAddress, + const Targets::TargetMemoryBuffer& buffer + ); /** * Requests the TargetController to set a breakpoint on the target. * * @param breakpoint */ - void setBreakpoint(TargetBreakpoint breakpoint); + void setBreakpoint(Targets::TargetBreakpoint breakpoint); /** * Requests the TargetController to remove a breakpoint from the target. * * @param breakpoint */ - void removeBreakpoint(TargetBreakpoint breakpoint); + void removeBreakpoint(Targets::TargetBreakpoint breakpoint); /** * Requests a pin state update on the target, for a specific pin. @@ -120,7 +126,7 @@ namespace Bloom * @param pinDescriptor * @param pinState */ - void setPinState(int variantId, TargetPinDescriptor pinDescriptor, TargetPinState pinState); + void setPinState(int variantId, Targets::TargetPinDescriptor pinDescriptor, Targets::TargetPinState pinState); /** * Requests a pin state refresh from the TargetController, for a specific target variant. diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index a12fa97f..ca07ee1c 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -2,8 +2,6 @@ #include #include #include -#include -#include #include #include @@ -20,11 +18,10 @@ #include "Tiny/Tiny.hpp" using namespace Bloom; -using namespace Targets; -using namespace Targets::Microchip::Avr; -using namespace Avr8Bit; +using namespace Bloom::Targets; +using namespace Bloom::Targets::Microchip::Avr; +using namespace Bloom::Targets::Microchip::Avr::Avr8Bit; using namespace Exceptions; -using Avr8Bit::Avr8; /** * Initialises the target from config parameters extracted from user's config file. @@ -71,7 +68,7 @@ void Avr8::postPromotionConfigure() { void Avr8::loadPartDescription() { auto targetSignature = this->getId(); - auto partDescription = PartDescriptionFile( + auto partDescription = PartDescription::PartDescriptionFile( targetSignature.toHex(), (!this->name.empty()) ? std::optional(this->name) : std::nullopt ); diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp index 4383f490..32e81f9f 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp @@ -19,20 +19,13 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit { - using namespace Exceptions; - using namespace PartDescription; - - using PartDescription::PartDescriptionFile; - using DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8::Avr8Interface; - using Targets::TargetRegisterMap; - class Avr8: public Target { protected: - Avr8Interface* avr8Interface; + DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8::Avr8Interface* avr8Interface; std::string name = ""; std::optional family; - std::optional partDescription; + std::optional partDescription; std::optional targetParameters; std::map padDescriptorsByName; std::map targetVariantsById; diff --git a/src/Targets/Microchip/AVR/AVR8/PartDescription/PartDescriptionFile.cpp b/src/Targets/Microchip/AVR/AVR8/PartDescription/PartDescriptionFile.cpp index c10d934c..14fbdb5c 100644 --- a/src/Targets/Microchip/AVR/AVR8/PartDescription/PartDescriptionFile.cpp +++ b/src/Targets/Microchip/AVR/AVR8/PartDescription/PartDescriptionFile.cpp @@ -3,7 +3,9 @@ #include "src/Logger/Logger.hpp" #include "src/Application.hpp" +using namespace Bloom::Targets::Microchip::Avr::Avr8Bit::PartDescription; using namespace Bloom::Targets::Microchip::Avr::Avr8Bit; +using namespace Bloom::Targets::Microchip::Avr; using namespace Bloom::Exceptions; // TODO: Move this into a resolvePartDescriptionFile() method. diff --git a/src/Targets/Microchip/AVR/AVR8/PartDescription/PartDescriptionFile.hpp b/src/Targets/Microchip/AVR/AVR8/PartDescription/PartDescriptionFile.hpp index f0f2cb91..2c4234b1 100644 --- a/src/Targets/Microchip/AVR/AVR8/PartDescription/PartDescriptionFile.hpp +++ b/src/Targets/Microchip/AVR/AVR8/PartDescription/PartDescriptionFile.hpp @@ -15,8 +15,6 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::PartDescription { - using Avr::TargetSignature; - /** * An AVR8 part description file is an XML file that describes a particular AVR8 target. * All supported AVR8 targets come with a part description file. @@ -27,7 +25,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::PartDescription * During the build process, all part description files are copied to the distribution directory, ready * to be shipped with the Bloom binary. Alongside these files is a JSON file, containing a mapping of AVR8 target * signatures to part description file paths. Bloom uses this mapping to find a particular part description - * file, given a target signature. See directory "bin/Distribution/Resources/TargetPartDescriptions". + * file, given a target signature. See directory "build/resources/TargetPartDescriptions". * The copying of the part description files, and the generation of the JSON mapping, is done by a PHP script: * "build/scripts/CopyAvrPartFilesAndCreateMapping.php". This script is invoked via a custom command, at build time. * diff --git a/src/Targets/TargetRegister.hpp b/src/Targets/TargetRegister.hpp index ba72e30b..c0f134ef 100644 --- a/src/Targets/TargetRegister.hpp +++ b/src/Targets/TargetRegister.hpp @@ -50,21 +50,23 @@ namespace Bloom::Targets } }; - using TargetRegisterMap = std::map; + using TargetRegisterMap = std::map; using TargetRegisters = std::vector; using TargetRegisterDescriptors = std::vector; } namespace std { - - using Bloom::Targets::TargetRegisterDescriptor; - + /** + * Hashing function for TargetRegisterDescriptor type. + * + * This is required in order to use TargetRegisterDescriptor as a key in an std::unordered_map (see the BiMap + * class) + */ template<> - class hash { + class hash { public: - size_t operator()(const TargetRegisterDescriptor& descriptor) const { + size_t operator()(const Bloom::Targets::TargetRegisterDescriptor& descriptor) const { return descriptor.id.value_or(0) + static_cast(descriptor.type); } }; - }