Removed all using declarations and directives from header files

This commit is contained in:
Nav
2021-05-24 20:58:49 +01:00
parent d39ca609bc
commit ce480a996c
96 changed files with 415 additions and 473 deletions

View File

@@ -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()
);

View File

@@ -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> debugServer = nullptr;
std::unique_ptr<DebugServers::DebugServer> debugServer = nullptr;
std::thread debugServerThread;
/**
@@ -203,10 +201,10 @@ namespace Bloom
* @return
*/
auto getSupportedDebugServers() {
return std::map<std::string, std::function<std::unique_ptr<DebugServer>()>> {
return std::map<std::string, std::function<std::unique_ptr<DebugServers::DebugServer>()>> {
{
"avr-gdb-rsp",
[this]() -> std::unique_ptr<DebugServer> {
[this]() -> std::unique_ptr<DebugServers::DebugServer> {
return std::make_unique<DebugServers::Gdb::AvrGdbRsp>(this->eventManager);
}
},

View File

@@ -6,6 +6,7 @@
#include "src/Logger/Logger.hpp"
using namespace Bloom::DebugServers;
using namespace Bloom::Events;
void DebugServer::run() {
try {

View File

@@ -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

View File

@@ -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<GdbRegisterNumber, TargetRegisterDescriptor> getRegisterNumberToDescriptorMapping() override {
BiMap<GdbRegisterNumber, Targets::TargetRegisterDescriptor> getRegisterNumberToDescriptorMapping() override {
using Targets::TargetRegisterDescriptor;
using Targets::TargetRegisterType;
static BiMap<GdbRegisterNumber, TargetRegisterDescriptor> 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;
};
/**

View File

@@ -5,6 +5,7 @@
#include "CommandPacketFactory.hpp"
using namespace Bloom::DebugServers::Gdb;
using namespace Bloom::DebugServers::Gdb::CommandPackets;
std::unique_ptr<CommandPacket> CommandPacketFactory::create(std::vector<unsigned char> rawPacket) {

View File

@@ -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<CommandPacket> create(std::vector<unsigned char> rawPacket);
static std::unique_ptr<CommandPackets::CommandPacket> create(std::vector<unsigned char> rawPacket);
};
}

View File

@@ -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.

View File

@@ -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.

View File

@@ -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

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -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.

View File

@@ -1,8 +1,7 @@
#include "SupportedFeaturesQuery.hpp"
#include <QtCore/QString>
#include "SupportedFeaturesQuery.hpp"
#include "src/DebugServers/GdbRsp/GdbRspDebugServer.hpp"
#include "../Feature.hpp"
using namespace Bloom::DebugServers::Gdb::CommandPackets;

View File

@@ -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

View File

@@ -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

View File

@@ -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<unsigned char> registerValue;

View File

@@ -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<unsigned char> rawPacket): CommandPacket(rawPacket) {
init();

View File

@@ -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;

View File

@@ -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<std::unique_ptr<CommandPacket>> readPackets();
std::vector<std::unique_ptr<CommandPackets::CommandPacket>> 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;

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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<GdbRegisterNumber, TargetRegisterDescriptor> 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<Events::TargetExecutionStopped>);
void onTargetExecutionStopped(Events::EventPointer<Events::TargetExecutionStopped>);
/**
* 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.

View File

@@ -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<TargetRegisterMap> registerMap;
std::optional<Targets::TargetRegisterMap> registerMap;
std::optional<StopReason> stopReason;
TargetStopped(Signal signal): signal(signal) {}

View File

@@ -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;
};

View File

@@ -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> edbgAvr8Interface = nullptr;
std::unique_ptr<Protocols::CmsisDap::Edbg::Avr::EdbgAvr8Interface> 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();
}

View File

@@ -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> edbgAvr8Interface = nullptr;
std::unique_ptr<Protocols::CmsisDap::Edbg::Avr::EdbgAvr8Interface> 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();
}

View File

@@ -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");
}

View File

@@ -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> edbgAvr8Interface;
std::unique_ptr<Protocols::CmsisDap::Edbg::Avr::EdbgAvr8Interface> 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();
}

View File

@@ -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
{
/**

View File

@@ -7,8 +7,6 @@
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
{
using Edbg::ProtocolHandlerId;
enum class AvrEventId : unsigned char
{
AVR8_BREAK_EVENT = 0x40,

View File

@@ -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:

View File

@@ -7,8 +7,6 @@
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic
{
using namespace Exceptions;
class ReadMemory: public Avr8GenericCommandFrame
{
private:

View File

@@ -4,8 +4,6 @@
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic
{
using namespace Exceptions;
class SetParameter: public Avr8GenericCommandFrame
{
private:

View File

@@ -6,8 +6,6 @@
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Avr8Generic
{
using namespace Exceptions;
class SetProgramCounter: public Avr8GenericCommandFrame
{
private:

View File

@@ -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;
}

View File

@@ -12,9 +12,6 @@
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
{
using namespace Edbg;
using namespace DebugToolDrivers::Protocols::CmsisDap;
class AvrCommandFrame
{
private:

View File

@@ -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.
*/

View File

@@ -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<unsigned char>& value) {
auto commandFrame = CommandFrames::Avr8Generic::SetParameter(parameter, value);

View File

@@ -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<unsigned char>(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<std::size_t> registerIds) override;
virtual Targets::TargetRegisters readGeneralPurposeRegisters(std::set<std::size_t> 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;
};
}

View File

@@ -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) {

View File

@@ -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;
}
};

View File

@@ -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();

View File

@@ -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<AvrResponse>& 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<unsigned char>((jtagId << 4) >> 24),
static_cast<unsigned char>((jtagId << 12) >> 24)
);
}
default: {
return TargetSignature(payloadData[0], payloadData[1], payloadData[2]);
return Targets::Microchip::Avr::TargetSignature(
payloadData[0],
payloadData[1],
payloadData[2]
);
}
}
}

View File

@@ -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<std::uint32_t>(payload[5] << 24 | payload[4] << 16 | payload[3] << 8 | payload[2]) * 2;

View File

@@ -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<AvrResponse>& 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.

View File

@@ -11,8 +11,6 @@
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
{
using namespace Edbg;
class AvrResponseFrame
{
private:

View File

@@ -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(

View File

@@ -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<AvrCommandFrame, CommandFrameType>::value,
std::is_base_of<Protocols::CmsisDap::Edbg::Avr::AvrCommandFrame, CommandFrameType>::value,
"AVR Command must be base of AvrCommandFrame."
);
static_assert(
std::is_base_of<AvrResponseFrame, typename CommandFrameType::ResponseFrameType>::value,
std::is_base_of<Protocols::CmsisDap::Edbg::Avr::AvrResponseFrame, typename CommandFrameType::ResponseFrameType>::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();

View File

@@ -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<size_t> registerIds) = 0;
virtual Targets::TargetRegisters readGeneralPurposeRegisters(std::set<size_t> 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;
};
}

View File

@@ -1,7 +1,7 @@
#include <sys/eventfd.h>
#include "EventListener.hpp"
using namespace Bloom;
using namespace Bloom::Events;
std::set<std::string> EventListener::getRegisteredEventTypeNames() {
return this->registeredEventTypes.getValue();

View File

@@ -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<std::map<std::string, std::queue<GenericEventPointer>>> eventQueueByEventType;
SyncSafe<std::map<std::string, std::queue<Events::GenericEventPointer>>> eventQueueByEventType;
std::condition_variable eventQueueByEventTypeCV;
/**
@@ -75,12 +73,12 @@ namespace Bloom
* Each callback will be passed an std::shared_ptr<const EventType> of the event (we downcast the events in
* EventListener::waiteAndDispatch() before dispatching them).
*/
SyncSafe<std::map<std::string, std::vector<std::function<void(GenericEventPointer)>>>> eventTypeToCallbacksMapping;
SyncSafe<std::map<std::string, std::vector<std::function<void(Events::GenericEventPointer)>>>> eventTypeToCallbacksMapping;
SyncSafe<std::set<std::string>> registeredEventTypes;
std::shared_ptr<EventNotifier> interruptEventNotifier = nullptr;
std::vector<GenericEventPointer> getEvents();
std::vector<Events::GenericEventPointer> 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<EventNotifier> interruptEventNotifier) {
this->interruptEventNotifier = interruptEventNotifier;
@@ -121,8 +119,8 @@ namespace Bloom
template<class EventType>
void registerCallbackForEventType(std::function<void(std::shared_ptr<const EventType>)> callback) {
// We encapsulate the callback in a lambda to handle the downcasting.
std::function<void(GenericEventPointer)> parentCallback =
[callback] (GenericEventPointer event) {
std::function<void(Events::GenericEventPointer)> parentCallback =
[callback] (Events::GenericEventPointer event) {
// Downcast the event to the expected type
callback(std::dynamic_pointer_cast<const EventType>(event));
}
@@ -139,9 +137,9 @@ namespace Bloom
* the type name to callback vector mapping.
*/
mapping.insert(
std::pair<std::string, std::vector<std::function<void(GenericEventPointer)>>>(
std::pair<std::string, std::vector<std::function<void(Events::GenericEventPointer)>>>(
EventType::name,
std::vector<std::function<void(GenericEventPointer)>>()
std::vector<std::function<void(Events::GenericEventPointer)>>()
)
);
}
@@ -177,20 +175,20 @@ namespace Bloom
std::optional<int> correlationId = std::nullopt
) {
// Different return types, depending on how many event type arguments are passed in.
using MonoType = std::optional<EventPointer<EventTypeA>>;
using MonoType = std::optional<Events::EventPointer<EventTypeA>>;
using BiVariantType = std::optional<
std::variant<
std::monostate,
EventPointer<EventTypeA>,
EventPointer<EventTypeB>
Events::EventPointer<EventTypeA>,
Events::EventPointer<EventTypeB>
>
>;
using TriVariantType = std::optional<
std::variant<
std::monostate,
EventPointer<EventTypeA>,
EventPointer<EventTypeB>,
EventPointer<EventTypeC>
Events::EventPointer<EventTypeA>,
Events::EventPointer<EventTypeB>,
Events::EventPointer<EventTypeC>
>
>;
using ReturnType = typename std::conditional<
@@ -211,12 +209,18 @@ namespace Bloom
auto eventTypeNamesToDeRegister = std::set<std::string>();
if constexpr (!std::is_same_v<EventTypeA, EventTypeB>) {
static_assert(std::is_base_of_v<Event, EventTypeB>, "All event types must be derived from the Event base class.");
static_assert(
std::is_base_of_v<Events::Event, EventTypeB>,
"All event types must be derived from the Event base class."
);
eventTypeNames.insert(EventTypeB::name);
}
if constexpr (!std::is_same_v<EventTypeB, EventTypeC>) {
static_assert(std::is_base_of_v<Event, EventTypeC>, "All event types must be derived from the Event base class.");
static_assert(
std::is_base_of_v<Events::Event, EventTypeC>,
"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<EventTypeA, EventTypeB> || !std::is_same_v<EventTypeB, EventTypeC>) {
if (foundEvent->getName() == EventTypeA::name) {
output = std::optional<typename decltype(output)::value_type>(std::dynamic_pointer_cast<const EventTypeA>(foundEvent));
output = std::optional<typename decltype(output)::value_type>(
std::dynamic_pointer_cast<const EventTypeA>(foundEvent)
);
} else if constexpr (!std::is_same_v<EventTypeA, EventTypeB>) {
if (foundEvent->getName() == EventTypeB::name) {
output = std::optional<typename decltype(output)::value_type>(std::dynamic_pointer_cast<const EventTypeB>(foundEvent));
output = std::optional<typename decltype(output)::value_type>(
std::dynamic_pointer_cast<const EventTypeB>(foundEvent)
);
}
}
if constexpr (!std::is_same_v<EventTypeB, EventTypeC>) {
if (foundEvent->getName() == EventTypeC::name) {
output = std::optional<typename decltype(output)::value_type>(std::dynamic_pointer_cast<const EventTypeC>(foundEvent));
output = std::optional<typename decltype(output)::value_type>(
std::dynamic_pointer_cast<const EventTypeC>(foundEvent)
);
}
}
@@ -311,7 +321,7 @@ namespace Bloom
*/
void waitAndDispatch(int msTimeout = 0);
void dispatchEvent(GenericEventPointer event);
void dispatchEvent(Events::GenericEventPointer event);
void dispatchCurrentEvents();

View File

@@ -53,7 +53,7 @@ namespace Bloom
*
* @param event
*/
void triggerEvent(GenericEventPointer event);
void triggerEvent(Events::GenericEventPointer event);
};
}

View File

@@ -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;

View File

@@ -5,8 +5,6 @@
namespace Bloom::Events
{
using Bloom::Targets::TargetMemoryBuffer;
class MemoryWrittenToTarget: public Event
{
public:

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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) {};
};
}

View File

@@ -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) {};
};
}

View File

@@ -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));
}
}

View File

@@ -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 {

View File

@@ -81,7 +81,7 @@ namespace Bloom
*
* @param event
*/
void onShutdownApplicationEvent(EventPointer<ShutdownApplication> event);
void onShutdownApplicationEvent(Events::EventPointer<Events::ShutdownApplication> event);
/**
* If the something horrible was to happen and the TC dies unexpectedly, Insight will shutdown in response.

View File

@@ -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");

View File

@@ -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<TargetExecutionStopped> event);
void onTargetResumedEvent(EventPointer<TargetExecutionResumed> event);
void onTargetPinStatesRetrievedEvent(EventPointer<TargetPinStatesRetrieved> event);
void onTargetIoPortsUpdatedEvent(EventPointer<TargetIoPortsUpdated> event);
void onTargetStoppedEvent(Events::EventPointer<Events::TargetExecutionStopped> event);
void onTargetResumedEvent(Events::EventPointer<Events::TargetExecutionResumed> event);
void onTargetPinStatesRetrievedEvent(Events::EventPointer<Events::TargetPinStatesRetrieved> event);
void onTargetIoPortsUpdatedEvent(Events::EventPointer<Events::TargetIoPortsUpdated> event);
public:
InsightWorker(EventManager& eventManager): eventManager(eventManager) {};

View File

@@ -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,

View File

@@ -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<std::string, TargetVariant> supportedVariantsByName;
const TargetVariant* selectedVariant = nullptr;
std::map<std::string, Targets::TargetVariant> 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);

View File

@@ -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());

View File

@@ -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);
};
}

View File

@@ -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) {

View File

@@ -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<TargetPinState> pinState;
Targets::TargetPinDescriptor pinDescriptor;
std::optional<Targets::TargetPinState> 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;
}

View File

@@ -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) {

View File

@@ -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("");

View File

@@ -1,16 +1,14 @@
#include <QPainter>
#include <QLayout>
#include <cmath>
#include <QEvent>
#include <QMenu>
#include <QContextMenuEvent>
#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);

View File

@@ -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<TargetPinState> pinState;
Targets::TargetPinDescriptor pinDescriptor;
std::optional<Targets::TargetPinState> 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;
}

View File

@@ -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) {

View File

@@ -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("");

View File

@@ -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
);
}

View File

@@ -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);
};
}

View File

@@ -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<TargetPinWidget*> 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<int, TargetPinState> pinStatesByNumber) {
virtual void updatePinStates(std::map<int, Targets::TargetPinState> pinStatesByNumber) {
for (auto& pinWidget : this->pinWidgets) {
auto pinNumber = pinWidget->getPinNumber();
if (pinStatesByNumber.contains(pinNumber)) {

View File

@@ -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<TargetPinState> pinState;
Targets::TargetVariant targetVariant;
Targets::TargetPinDescriptor pinDescriptor;
std::optional<Targets::TargetPinState> 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<TargetPinState> getPinState() const {
std::optional<Targets::TargetPinState> 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);

View File

@@ -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 {

View File

@@ -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<TargetDescriptor> cachedTargetDescriptor;
std::optional<Targets::TargetDescriptor> 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<std::string, std::function<std::unique_ptr<DebugTool>()>> {
static auto mapping = std::map<std::string, std::function<std::unique_ptr<DebugTool>()>> {
{
"atmel-ice",
[]() {
return std::make_unique<AtmelIce>();
return std::make_unique<DebugToolDrivers::AtmelIce>();
}
},
{
"power-debugger",
[]() {
return std::make_unique<PowerDebugger>();
return std::make_unique<DebugToolDrivers::PowerDebugger>();
}
},
{
"snap",
[]() {
return std::make_unique<MplabSnap>();
return std::make_unique<DebugToolDrivers::MplabSnap>();
}
},
};
return mapping;
}
/**
@@ -99,34 +95,42 @@ namespace Bloom
* @return
*/
static auto getSupportedTargets() {
auto mapping = std::map<std::string, std::function<std::unique_ptr<Targets::Target>()>> {
{
"avr8",
[]() {
return std::make_unique<Avr8>();
}
},
};
static std::map<std::string, std::function<std::unique_ptr<Targets::Target>()>> mapping;
// Include all targets from AVR8 part description files
auto avr8PdMapping = Avr8Bit::PartDescriptionFile::getPartDescriptionMapping();
if (mapping.empty()) {
mapping = {
{
"avr8",
[]() {
return std::make_unique<Targets::Microchip::Avr::Avr8Bit::Avr8>();
}
},
};
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<Avr8>(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<Targets::Microchip::Avr::Avr8Bit::Avr8>(
targetName,
Targets::Microchip::Avr::TargetSignature(targetSignatureHex)
);
}
});
}
}
}
}
@@ -216,63 +220,63 @@ namespace Bloom
*
* @param event
*/
void onExtractTargetDescriptor(EventPointer<Events::ExtractTargetDescriptor> event);
void onExtractTargetDescriptor(Events::EventPointer<Events::ExtractTargetDescriptor> event);
/**
* Will attempt to stop execution on the target and emit a TargetExecutionStopped event.
*
* @param event
*/
void onStopTargetExecutionEvent(EventPointer<Events::StopTargetExecution> event);
void onStopTargetExecutionEvent(Events::EventPointer<Events::StopTargetExecution> event);
/**
* Will attempt to step execution on the target and emit a TargetExecutionResumed event.
*
* @param event
*/
void onStepTargetExecutionEvent(EventPointer<Events::StepTargetExecution> event);
void onStepTargetExecutionEvent(Events::EventPointer<Events::StepTargetExecution> event);
/**
* Will attempt to resume execution on the target and emit a TargetExecutionResumed event.
*
* @param event
*/
void onResumeTargetExecutionEvent(EventPointer<Events::ResumeTargetExecution> event);
void onResumeTargetExecutionEvent(Events::EventPointer<Events::ResumeTargetExecution> event);
/**
* Invokes a shutdown.
*
* @param event
*/
void onShutdownTargetControllerEvent(EventPointer<Events::ShutdownTargetController> event);
void onShutdownTargetControllerEvent(Events::EventPointer<Events::ShutdownTargetController> event);
/**
* Will attempt to read the requested registers and emit a RegistersRetrievedFromTarget event.
*
* @param event
*/
void onReadRegistersEvent(EventPointer<Events::RetrieveRegistersFromTarget> event);
void onReadRegistersEvent(Events::EventPointer<Events::RetrieveRegistersFromTarget> event);
/**
* Will attempt to write the specified register values and emit a RegistersWrittenToTarget event.
*
* @param event
*/
void onWriteRegistersEvent(EventPointer<Events::WriteRegistersToTarget> event);
void onWriteRegistersEvent(Events::EventPointer<Events::WriteRegistersToTarget> event);
/**
* Will attempt to read memory from the target and include the data in a MemoryRetrievedFromTarget event.
*
* @param event
*/
void onReadMemoryEvent(EventPointer<Events::RetrieveMemoryFromTarget> event);
void onReadMemoryEvent(Events::EventPointer<Events::RetrieveMemoryFromTarget> event);
/**
* Will attempt to write memory to the target. On success, a MemoryWrittenToTarget event is emitted.
*
* @param event
*/
void onWriteMemoryEvent(EventPointer<Events::WriteMemoryToTarget> event);
void onWriteMemoryEvent(Events::EventPointer<Events::WriteMemoryToTarget> 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<Events::SetBreakpointOnTarget> event);
void onSetBreakpointEvent(Events::EventPointer<Events::SetBreakpointOnTarget> 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<Events::RemoveBreakpointOnTarget> event);
void onRemoveBreakpointEvent(Events::EventPointer<Events::RemoveBreakpointOnTarget> event);
/**
* Will hold the target stopped at it's current state.
*
* @param event
*/
void onDebugSessionStartedEvent(EventPointer<Events::DebugSessionStarted> event);
void onDebugSessionStartedEvent(Events::EventPointer<Events::DebugSessionStarted> event);
/**
* Will simply kick off execution on the target.
*
* @param event
*/
void onDebugSessionFinishedEvent(EventPointer<Events::DebugSessionFinished> event);
void onDebugSessionFinishedEvent(Events::EventPointer<Events::DebugSessionFinished> 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<Events::SetProgramCounterOnTarget> event);
void onSetProgramCounterEvent(Events::EventPointer<Events::SetProgramCounterOnTarget> event);
/**
* Will automatically fire a target state update event.
@@ -318,14 +322,14 @@ namespace Bloom
*
* @param event
*/
void onInsightStateChangedEvent(EventPointer<Events::InsightStateChanged> event);
void onInsightStateChangedEvent(Events::EventPointer<Events::InsightStateChanged> event);
/**
* Will attempt to obtain the pin states from the target. Will emit a TargetPinStatesRetrieved event on success.
*
* @param event
*/
void onRetrieveTargetPinStatesEvent(EventPointer<Events::RetrieveTargetPinStates> event);
void onRetrieveTargetPinStatesEvent(Events::EventPointer<Events::RetrieveTargetPinStates> 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<Events::SetTargetPinState> event);
void onSetPinStateEvent(Events::EventPointer<Events::SetTargetPinState> event);
};
}

View File

@@ -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<Events::ExtractTargetDescriptor>();

View File

@@ -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.

View File

@@ -2,8 +2,6 @@
#include <QtCore>
#include <QJsonDocument>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <limits>
@@ -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
);

View File

@@ -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> family;
std::optional<PartDescriptionFile> partDescription;
std::optional<PartDescription::PartDescriptionFile> partDescription;
std::optional<TargetParameters> targetParameters;
std::map<std::string, PadDescriptor> padDescriptorsByName;
std::map<int, TargetVariant> targetVariantsById;

View File

@@ -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.

View File

@@ -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.
*

View File

@@ -50,21 +50,23 @@ namespace Bloom::Targets
}
};
using TargetRegisterMap = std::map<TargetRegister::IdType , TargetRegister>;
using TargetRegisterMap = std::map<TargetRegister::IdType, TargetRegister>;
using TargetRegisters = std::vector<TargetRegister>;
using TargetRegisterDescriptors = std::vector<TargetRegisterDescriptor>;
}
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<TargetRegisterDescriptor> {
class hash<Bloom::Targets::TargetRegisterDescriptor> {
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<size_t>(descriptor.type);
}
};
}