Tidied structure of all classes within the entire code base
Also some other small bits of tidying
This commit is contained in:
@@ -4,9 +4,10 @@
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "src/Helpers/Paths.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
#include "src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
using namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription;
|
||||
using namespace Bloom::Targets::Microchip::Avr::Avr8Bit;
|
||||
@@ -1127,36 +1128,3 @@ void TargetDescriptionFile::loadUpdiTargetParameters(TargetParameters& targetPar
|
||||
targetParameters.lockbitsSegmentStartAddress = lockbitsMemorySegment->startAddress;
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t TargetDescriptionFile::getRegisterAddressOffsetByModuleName(const std::string& moduleName) const {
|
||||
if (this->peripheralModulesMappedByName.contains(moduleName)) {
|
||||
auto& peripheralModule = this->peripheralModulesMappedByName.at(moduleName);
|
||||
|
||||
if (peripheralModule.instancesMappedByName.contains(moduleName)) {
|
||||
auto& moduleInstance = peripheralModule.instancesMappedByName.at(moduleName);
|
||||
|
||||
if (moduleInstance.registerGroupsMappedByName.contains(moduleName)) {
|
||||
auto& registerGroup = moduleInstance.registerGroupsMappedByName.at(moduleName);
|
||||
|
||||
if (!registerGroup.moduleName.has_value() || registerGroup.moduleName.value() == moduleName) {
|
||||
return registerGroup.offset.value_or(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If we get here, that means we couldn't find the right register group by module name. This will happen
|
||||
* if the register group name doesn't match the module name attribute ("name-in-module") against the
|
||||
* register group node, in the TDF.
|
||||
*
|
||||
* As a final attempt, we'll brute force search all register groups in the module instance.
|
||||
*/
|
||||
for (const auto& [registerGroupName, registerGroup] : moduleInstance.registerGroupsMappedByName) {
|
||||
if (registerGroup.moduleName.has_value() && registerGroup.moduleName.value() == moduleName) {
|
||||
return registerGroup.offset.value_or(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -27,6 +27,87 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
*/
|
||||
class TargetDescriptionFile: public Targets::TargetDescription::TargetDescriptionFile
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Will resolve the target description file using the target description JSON mapping and a given target signature.
|
||||
*
|
||||
* @param targetSignatureHex
|
||||
* @param targetName
|
||||
*/
|
||||
TargetDescriptionFile(const TargetSignature& targetSignature, std::optional<std::string> targetName);
|
||||
|
||||
/**
|
||||
* Extends TDF initialisation to include the loading of physical interfaces for debugging AVR8 targets, among
|
||||
* other things.
|
||||
*
|
||||
* @param xml
|
||||
*/
|
||||
void init(const QDomDocument& xml) override;
|
||||
|
||||
/**
|
||||
* Loads the AVR8 target description JSON mapping file.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static QJsonObject getTargetDescriptionMapping();
|
||||
|
||||
/**
|
||||
* Extracts the AVR8 target signature from the TDF.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] TargetSignature getTargetSignature() const;
|
||||
|
||||
/**
|
||||
* Extracts the AVR8 target family from the TDF.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] Family getFamily() const;
|
||||
|
||||
/**
|
||||
* Constructs an instance of TargetParameters, for the AVR8 target, with data from the TDF.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] TargetParameters getTargetParameters() const;
|
||||
|
||||
/**
|
||||
* Returns a set of all supported physical interfaces for debugging.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const auto& getSupportedDebugPhysicalInterfaces() const {
|
||||
return this->supportedDebugPhysicalInterfaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mapping of all pad descriptors extracted from TDF, mapped by name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const auto& getPadDescriptorsMappedByName() const {
|
||||
return this->padDescriptorsByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mapping of all target variants extracted from the TDF, mapped by ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const auto& getVariantsMappedById() const {
|
||||
return this->targetVariantsById;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mapping of all target register descriptors extracted from the TDF, by type.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const auto& getRegisterDescriptorsMappedByType() const {
|
||||
return this->targetRegisterDescriptorsByType;
|
||||
}
|
||||
|
||||
private:
|
||||
/**`
|
||||
* AVR8 target description files include the target family name. This method returns a mapping of part
|
||||
@@ -124,94 +205,5 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
* @param targetParameters
|
||||
*/
|
||||
virtual void loadUpdiTargetParameters(TargetParameters& targetParameters) const;
|
||||
|
||||
/**
|
||||
* Extracts the register address offset, for registers from a particular module.
|
||||
*
|
||||
* @param moduleName
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] virtual std::uint32_t getRegisterAddressOffsetByModuleName(const std::string& moduleName) const;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Will resolve the target description file using the target description JSON mapping and a given target signature.
|
||||
*
|
||||
* @param targetSignatureHex
|
||||
* @param targetName
|
||||
*/
|
||||
TargetDescriptionFile(const TargetSignature& targetSignature, std::optional<std::string> targetName);
|
||||
|
||||
/**
|
||||
* Extends TDF initialisation to include the loading of physical interfaces for debugging AVR8 targets, among
|
||||
* other things.
|
||||
*
|
||||
* @param xml
|
||||
*/
|
||||
void init(const QDomDocument& xml) override;
|
||||
|
||||
/**
|
||||
* Loads the AVR8 target description JSON mapping file.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
static QJsonObject getTargetDescriptionMapping();
|
||||
|
||||
/**
|
||||
* Extracts the AVR8 target signature from the TDF.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] TargetSignature getTargetSignature() const;
|
||||
|
||||
/**
|
||||
* Extracts the AVR8 target family from the TDF.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] Family getFamily() const;
|
||||
|
||||
/**
|
||||
* Constructs an instance of TargetParameters, for the AVR8 target, with data from the TDF.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] TargetParameters getTargetParameters() const;
|
||||
|
||||
/**
|
||||
* Returns a set of all supported physical interfaces for debugging.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const auto& getSupportedDebugPhysicalInterfaces() const {
|
||||
return this->supportedDebugPhysicalInterfaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mapping of all pad descriptors extracted from TDF, mapped by name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const auto& getPadDescriptorsMappedByName() const {
|
||||
return this->padDescriptorsByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mapping of all target variants extracted from the TDF, mapped by ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const auto& getVariantsMappedById() const {
|
||||
return this->targetVariantsById;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mapping of all target register descriptors extracted from the TDF, by type.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const auto& getRegisterDescriptorsMappedByType() const {
|
||||
return this->targetRegisterDescriptorsByType;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user