Corrected register group extraction from AVR8 TDFs
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
#include "TargetDescriptionFile.hpp"
|
||||
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include "TargetDescriptionFile.hpp"
|
||||
#include "src/Helpers/Paths.hpp"
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
#include "src/Targets/TargetDescription/Exceptions/TargetDescriptionParsingFailureException.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
#include "src/Helpers/Paths.hpp"
|
||||
|
||||
using namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription;
|
||||
using namespace Bloom::Targets::Microchip::Avr::Avr8Bit;
|
||||
@@ -467,8 +468,11 @@ void TargetDescriptionFile::loadTargetRegisterDescriptors() {
|
||||
auto& peripheralModulesByName = this->peripheralModulesMappedByName;
|
||||
|
||||
for (const auto& [moduleName, module] : modulesByName) {
|
||||
auto moduleRegisterAddressOffset = this->getRegisterAddressOffsetByModuleName(moduleName);
|
||||
for (const auto& [registerGroupName, registerGroup] : module.registerGroupsMappedByName) {
|
||||
if (this->peripheralRegisterGroupsMappedByModuleRegisterGroupName.contains(registerGroupName)) {
|
||||
auto& peripheralRegisterGroups = this->peripheralRegisterGroupsMappedByModuleRegisterGroupName
|
||||
.at(registerGroupName);
|
||||
for (const auto& peripheralRegisterGroup : peripheralRegisterGroups) {
|
||||
for (const auto& [moduleRegisterName, moduleRegister] : registerGroup.registersMappedByName) {
|
||||
if (moduleRegister.size < 1) {
|
||||
continue;
|
||||
@@ -477,9 +481,10 @@ void TargetDescriptionFile::loadTargetRegisterDescriptors() {
|
||||
auto registerDescriptor = TargetRegisterDescriptor();
|
||||
registerDescriptor.type = TargetRegisterType::OTHER;
|
||||
registerDescriptor.name = moduleRegisterName;
|
||||
registerDescriptor.groupName = registerGroupName;
|
||||
registerDescriptor.groupName = peripheralRegisterGroup.name;
|
||||
registerDescriptor.size = moduleRegister.size;
|
||||
registerDescriptor.startAddress = moduleRegister.offset + moduleRegisterAddressOffset;
|
||||
registerDescriptor.startAddress = moduleRegister.offset
|
||||
+ peripheralRegisterGroup.offset.value_or(0);
|
||||
|
||||
if (moduleRegister.caption.has_value() && !moduleRegister.caption->empty()) {
|
||||
registerDescriptor.description = moduleRegister.caption;
|
||||
@@ -490,6 +495,8 @@ void TargetDescriptionFile::loadTargetRegisterDescriptors() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::optional<MemorySegment> TargetDescriptionFile::getFlashMemorySegment() const {
|
||||
auto& addressMapping = this->addressSpacesMappedById;
|
||||
|
||||
@@ -169,9 +169,9 @@ RegisterGroup TargetDescriptionFile::generateRegisterGroupFromXml(const QDomElem
|
||||
throw Exception("Empty register group name");
|
||||
}
|
||||
|
||||
registerGroup.moduleName = xmlElement.hasAttribute("name-in-module")
|
||||
? xmlElement.attribute("name-in-module").toLower().toStdString()
|
||||
: registerGroup.name;
|
||||
if (xmlElement.hasAttribute("name-in-module")) {
|
||||
registerGroup.moduleName = xmlElement.attribute("name-in-module").toLower().toStdString();
|
||||
}
|
||||
|
||||
if (xmlElement.hasAttribute("offset")) {
|
||||
registerGroup.offset = xmlElement.attribute("offset").toInt(nullptr, 16);
|
||||
@@ -315,6 +315,11 @@ void TargetDescriptionFile::loadPeripheralModules() {
|
||||
);
|
||||
|
||||
module.registerGroupsMappedByName.insert(std::pair(registerGroup.name, registerGroup));
|
||||
|
||||
if (registerGroup.moduleName.has_value()) {
|
||||
this->peripheralRegisterGroupsMappedByModuleRegisterGroupName[registerGroup.moduleName.value()]
|
||||
.emplace_back(registerGroup);
|
||||
}
|
||||
}
|
||||
|
||||
auto instanceNodes = moduleElement.elementsByTagName("instance");
|
||||
|
||||
@@ -43,6 +43,7 @@ namespace Bloom::Targets::TargetDescription
|
||||
std::map<std::string, PropertyGroup> propertyGroupsMappedByName;
|
||||
std::map<std::string, Module> modulesMappedByName;
|
||||
std::map<std::string, Module> peripheralModulesMappedByName;
|
||||
std::map<std::string, std::vector<RegisterGroup>> peripheralRegisterGroupsMappedByModuleRegisterGroupName;
|
||||
std::vector<Variant> variants;
|
||||
std::map<std::string, Pinout> pinoutsMappedByName;
|
||||
std::map<std::string, Interface> interfacesByName;
|
||||
|
||||
Reference in New Issue
Block a user