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

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