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);
|
||||
|
||||
Reference in New Issue
Block a user