General tidying, addressing issues found by static analysis tool.
This commit is contained in:
@@ -669,7 +669,7 @@ std::uint32_t Avr8::getProgramCounter() {
|
||||
TargetRegister Avr8::getProgramCounterRegister() {
|
||||
auto programCounter = this->getProgramCounter();
|
||||
|
||||
return TargetRegister(TargetRegisterType::PROGRAM_COUNTER, {
|
||||
return TargetRegister(TargetRegisterDescriptor(TargetRegisterType::PROGRAM_COUNTER), {
|
||||
static_cast<unsigned char>(programCounter),
|
||||
static_cast<unsigned char>(programCounter >> 8),
|
||||
static_cast<unsigned char>(programCounter >> 16),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <queue>
|
||||
#include <utility>
|
||||
|
||||
#include "src/DebugToolDrivers/TargetInterfaces/Microchip/AVR/AVR8/Avr8Interface.hpp"
|
||||
#include "src/Targets/Microchip/AVR/Target.hpp"
|
||||
@@ -22,7 +23,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
{
|
||||
protected:
|
||||
DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8::Avr8Interface* avr8Interface = nullptr;
|
||||
std::string name = "";
|
||||
std::string name;
|
||||
std::optional<Family> family;
|
||||
std::optional<TargetDescription::TargetDescriptionFile> targetDescriptionFile;
|
||||
std::optional<TargetParameters> targetParameters;
|
||||
@@ -60,7 +61,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
|
||||
public:
|
||||
explicit Avr8() = default;
|
||||
Avr8(const std::string& name, const TargetSignature& signature): name(name) {
|
||||
Avr8(std::string name, const TargetSignature& signature): name(std::move(name)) {
|
||||
this->id = signature;
|
||||
this->loadTargetDescriptionFile();
|
||||
};
|
||||
@@ -74,7 +75,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
|
||||
void preActivationConfigure(const TargetConfig& targetConfig) override;
|
||||
void postActivationConfigure() override;
|
||||
virtual void postPromotionConfigure() override;
|
||||
void postPromotionConfigure() override;
|
||||
|
||||
void activate() override;
|
||||
void deactivate() override;
|
||||
@@ -108,13 +109,13 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual std::unique_ptr<Targets::Target> promote() override;
|
||||
std::unique_ptr<Targets::Target> promote() override;
|
||||
|
||||
std::string getName() const override {
|
||||
return this->name;
|
||||
}
|
||||
|
||||
virtual TargetDescriptor getDescriptor() override;
|
||||
TargetDescriptor getDescriptor() override;
|
||||
|
||||
void run() override;
|
||||
void stop() override;
|
||||
@@ -125,38 +126,38 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
void removeBreakpoint(std::uint32_t address) override;
|
||||
void clearAllBreakpoints() override;
|
||||
|
||||
virtual TargetRegisters readGeneralPurposeRegisters(std::set<std::size_t> registerIds) override;
|
||||
virtual void writeRegisters(const TargetRegisters& registers) override;
|
||||
virtual TargetRegisters readRegisters(const TargetRegisterDescriptors& descriptors) override;
|
||||
TargetRegisters readGeneralPurposeRegisters(std::set<std::size_t> registerIds) override;
|
||||
void writeRegisters(const TargetRegisters& registers) override;
|
||||
TargetRegisters readRegisters(const TargetRegisterDescriptors& descriptors) override;
|
||||
|
||||
virtual TargetMemoryBuffer readMemory(
|
||||
TargetMemoryBuffer readMemory(
|
||||
TargetMemoryType memoryType,
|
||||
std::uint32_t startAddress,
|
||||
std::uint32_t bytes
|
||||
) override;
|
||||
virtual void writeMemory(
|
||||
void writeMemory(
|
||||
TargetMemoryType memoryType,
|
||||
std::uint32_t startAddress,
|
||||
const TargetMemoryBuffer& buffer
|
||||
) override;
|
||||
|
||||
virtual TargetState getState() override;
|
||||
TargetState getState() override;
|
||||
|
||||
virtual std::uint32_t getProgramCounter() override;
|
||||
virtual TargetRegister getProgramCounterRegister() override;
|
||||
virtual void setProgramCounter(std::uint32_t programCounter) override;
|
||||
std::uint32_t getProgramCounter() override;
|
||||
TargetRegister getProgramCounterRegister() override;
|
||||
void setProgramCounter(std::uint32_t programCounter) override;
|
||||
|
||||
virtual TargetRegister getStackPointerRegister() override;
|
||||
virtual TargetRegister getStatusRegister() override;
|
||||
TargetRegister getStackPointerRegister() override;
|
||||
TargetRegister getStatusRegister() override;
|
||||
|
||||
virtual std::map<int, TargetPinState> getPinStates(int variantId) override;
|
||||
virtual void setPinState(
|
||||
std::map<int, TargetPinState> getPinStates(int variantId) override;
|
||||
void setPinState(
|
||||
int variantId,
|
||||
const TargetPinDescriptor& pinDescriptor,
|
||||
const TargetPinState& state
|
||||
) override;
|
||||
|
||||
virtual bool memoryAddressRangeClashesWithIoPortRegisters(
|
||||
bool memoryAddressRangeClashesWithIoPortRegisters(
|
||||
TargetMemoryType memoryType,
|
||||
std::uint32_t startAddress,
|
||||
std::uint32_t endAddress
|
||||
|
||||
@@ -9,9 +9,9 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
protected:
|
||||
|
||||
public:
|
||||
Mega(const Avr8& avr8): Avr8(avr8) {};
|
||||
explicit Mega(const Avr8& avr8): Avr8(avr8) {};
|
||||
|
||||
virtual bool supportsPromotion() override {
|
||||
bool supportsPromotion() override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -139,7 +139,7 @@ TargetSignature TargetDescriptionFile::getTargetSignature() const {
|
||||
}
|
||||
|
||||
Family TargetDescriptionFile::getFamily() const {
|
||||
static auto familyNameToEnums = this->getFamilyNameToEnumMapping();
|
||||
static auto familyNameToEnums = TargetDescriptionFile::getFamilyNameToEnumMapping();
|
||||
auto familyName = this->deviceElement.attributes().namedItem("family").nodeValue().toLower().toStdString();
|
||||
|
||||
if (familyName.empty()) {
|
||||
|
||||
@@ -65,35 +65,35 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
TargetSignature getTargetSignature() const;
|
||||
[[nodiscard]] TargetSignature getTargetSignature() const;
|
||||
|
||||
/**
|
||||
* Extracts the AVR8 target family from the target description XML.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Family getFamily() const;
|
||||
[[nodiscard]] Family getFamily() const;
|
||||
|
||||
std::optional<Targets::TargetDescription::MemorySegment> getFlashMemorySegment() const;
|
||||
std::optional<Targets::TargetDescription::MemorySegment> getRamMemorySegment() const;
|
||||
std::optional<Targets::TargetDescription::MemorySegment> getRegisterMemorySegment() const;
|
||||
std::optional<Targets::TargetDescription::MemorySegment> getEepromMemorySegment() const;
|
||||
std::optional<Targets::TargetDescription::MemorySegment> getFirstBootSectionMemorySegment() const;
|
||||
std::optional<Targets::TargetDescription::RegisterGroup> getCpuRegisterGroup() const;
|
||||
std::optional<Targets::TargetDescription::RegisterGroup> getBootLoadRegisterGroup() const;
|
||||
std::optional<Targets::TargetDescription::RegisterGroup> getEepromRegisterGroup() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getFlashMemorySegment() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getRamMemorySegment() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getRegisterMemorySegment() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getEepromMemorySegment() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getFirstBootSectionMemorySegment() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::RegisterGroup> getCpuRegisterGroup() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::RegisterGroup> getBootLoadRegisterGroup() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::RegisterGroup> getEepromRegisterGroup() const;
|
||||
|
||||
std::optional<Targets::TargetDescription::Register> getStatusRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getStackPointerRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getStackPointerHighRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getStackPointerLowRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getOscillatorCalibrationRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getSpmcsRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getSpmcRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getEepromAddressRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getEepromAddressLowRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getEepromAddressHighRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getEepromDataRegister() const;
|
||||
std::optional<Targets::TargetDescription::Register> getEepromControlRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getStatusRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getStackPointerRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getStackPointerHighRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getStackPointerLowRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getOscillatorCalibrationRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getSpmcsRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getSpmcRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getEepromAddressRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getEepromAddressLowRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getEepromAddressHighRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getEepromDataRegister() const;
|
||||
[[nodiscard]] std::optional<Targets::TargetDescription::Register> getEepromControlRegister() const;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
class Tiny: public Avr8
|
||||
{
|
||||
public:
|
||||
Tiny(const Avr8& avr8): Avr8(avr8) {};
|
||||
explicit Tiny(const Avr8& avr8): Avr8(avr8) {};
|
||||
|
||||
virtual bool supportsPromotion() override {
|
||||
bool supportsPromotion() override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,9 +7,9 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||
class XMega: public Avr8
|
||||
{
|
||||
public:
|
||||
XMega(const Avr8& avr8): Avr8(avr8) {};
|
||||
explicit XMega(const Avr8& avr8): Avr8(avr8) {};
|
||||
|
||||
virtual bool supportsPromotion() override {
|
||||
bool supportsPromotion() override {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,4 +26,4 @@ namespace Bloom::Targets::Microchip::Avr
|
||||
return this->getId().toHex();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,14 +30,14 @@ namespace Bloom::Targets::Microchip::Avr
|
||||
TargetSignature() = default;
|
||||
TargetSignature(unsigned char byteZero, unsigned char byteOne, unsigned char byteTwo) :
|
||||
byteZero(byteZero), byteOne(byteOne), byteTwo(byteTwo) {};
|
||||
TargetSignature(std::string hex) {
|
||||
explicit TargetSignature(const std::string& hex) {
|
||||
auto signature = static_cast<std::uint32_t>(std::stoul(hex, nullptr, 16));
|
||||
this->byteZero = static_cast<unsigned char>(signature >> 16);
|
||||
this->byteOne = static_cast<unsigned char>(signature >> 8);
|
||||
this->byteTwo = static_cast<unsigned char>(signature);
|
||||
}
|
||||
|
||||
std::string toHex() const {
|
||||
[[nodiscard]] std::string toHex() const {
|
||||
std::stringstream stream;
|
||||
stream << std::hex << std::setfill('0');
|
||||
stream << std::setw(2) << static_cast<unsigned int>(this->byteZero);
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
#include "Target.hpp"
|
||||
@@ -39,9 +39,9 @@ namespace Bloom::Targets
|
||||
bool activated = false;
|
||||
|
||||
public:
|
||||
explicit Target() {}
|
||||
explicit Target() = default;
|
||||
|
||||
bool isActivated() {
|
||||
bool isActivated() const {
|
||||
return this->activated;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,8 @@ namespace Bloom::Targets
|
||||
/**
|
||||
* Byte address of the breakpoint.
|
||||
*/
|
||||
TargetBreakpointAddress address;
|
||||
TargetBreakpointAddress address = 0;
|
||||
|
||||
bool disabled = false;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
namespace Bloom::Targets::TargetDescription
|
||||
{
|
||||
enum MemorySegmentType {
|
||||
enum MemorySegmentType
|
||||
{
|
||||
REGISTERS,
|
||||
IO,
|
||||
EEPROM,
|
||||
|
||||
@@ -6,10 +6,10 @@ Bloom will have an associated TDF in Bloom's codebase. They can be found in `src
|
||||
The data held by TDFs is fundamental to Bloom's operation. The following is an incomplete list of some of the
|
||||
data extracted from TDFs:
|
||||
|
||||
- Target signatures
|
||||
- Parameters for debug interfaces
|
||||
- Memory address space descriptions (including sections, offsets and sizes)
|
||||
- Register descriptions (including offsets and sizes)
|
||||
- Parameters for debug interfaces
|
||||
- Target signatures
|
||||
- Package variant descriptions
|
||||
- Package pinouts
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
@@ -19,8 +20,8 @@ namespace Bloom::Targets
|
||||
std::optional<IdType> id;
|
||||
TargetRegisterType type = TargetRegisterType::GENERAL_PURPOSE_REGISTER;
|
||||
|
||||
TargetRegisterDescriptor() {};
|
||||
TargetRegisterDescriptor(TargetRegisterType type): type(type) {};
|
||||
TargetRegisterDescriptor() = default;
|
||||
explicit TargetRegisterDescriptor(TargetRegisterType type): type(type) {};
|
||||
TargetRegisterDescriptor(IdType id, TargetRegisterType type): id(id), type(type) {};
|
||||
|
||||
bool operator==(const TargetRegisterDescriptor& other) const {
|
||||
@@ -30,27 +31,25 @@ namespace Bloom::Targets
|
||||
|
||||
struct TargetRegister
|
||||
{
|
||||
using IdType = size_t;
|
||||
using ValueType = std::vector<unsigned char>;
|
||||
std::optional<IdType> id;
|
||||
ValueType value;
|
||||
std::optional<size_t> id;
|
||||
std::vector<unsigned char> value;
|
||||
TargetRegisterDescriptor descriptor;
|
||||
|
||||
TargetRegister(const ValueType& value): value(value) {};
|
||||
explicit TargetRegister(std::vector<unsigned char> value): value(std::move(value)) {};
|
||||
|
||||
TargetRegister(TargetRegisterDescriptor descriptor, const ValueType& value): value(value),
|
||||
TargetRegister(TargetRegisterDescriptor descriptor, std::vector<unsigned char> value): value(std::move(value)),
|
||||
descriptor(descriptor) {};
|
||||
|
||||
TargetRegister(IdType id, const ValueType& value): id(id), value(value) {
|
||||
TargetRegister(size_t id, std::vector<unsigned char> value): id(id), value(std::move(value)) {
|
||||
this->descriptor.id = id;
|
||||
};
|
||||
|
||||
IdType size() const {
|
||||
[[nodiscard]] size_t size() const {
|
||||
return this->value.size();
|
||||
}
|
||||
};
|
||||
|
||||
using TargetRegisterMap = std::map<TargetRegister::IdType, TargetRegister>;
|
||||
using TargetRegisterMap = std::map<size_t, TargetRegister>;
|
||||
using TargetRegisters = std::vector<TargetRegister>;
|
||||
using TargetRegisterDescriptors = std::vector<TargetRegisterDescriptor>;
|
||||
}
|
||||
|
||||
@@ -13,4 +13,3 @@ namespace Bloom::Targets
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(Bloom::Targets::TargetState)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user