Tidying TDF processing in preparation for RISC-V accomodation
This commit is contained in:
@@ -385,15 +385,13 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
}
|
||||
|
||||
void TargetDescriptionFile::loadPadDescriptors() {
|
||||
const auto& modules = this->getModulesMappedByName();
|
||||
const auto portModuleIt = this->modulesMappedByName.find("port");
|
||||
const auto portModule = (portModuleIt != this->modulesMappedByName.end())
|
||||
? std::optional(portModuleIt->second)
|
||||
: std::nullopt;
|
||||
|
||||
const auto portModuleIt = modules.find("port");
|
||||
const auto portModule = (portModuleIt != modules.end()) ? std::optional(portModuleIt->second) : std::nullopt;
|
||||
|
||||
const auto& peripheralModules = this->getPeripheralModulesMappedByName();
|
||||
|
||||
const auto portPeripheralModuleIt = peripheralModules.find("port");
|
||||
if (portPeripheralModuleIt == peripheralModules.end()) {
|
||||
const auto portPeripheralModuleIt = this->peripheralModulesMappedByName.find("port");
|
||||
if (portPeripheralModuleIt == this->peripheralModulesMappedByName.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -484,11 +482,7 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
}
|
||||
|
||||
void TargetDescriptionFile::loadTargetVariants() {
|
||||
auto tdVariants = this->getVariants();
|
||||
auto tdPinoutsByName = this->getPinoutsMappedByName();
|
||||
const auto& modules = this->getModulesMappedByName();
|
||||
|
||||
for (const auto& tdVariant : tdVariants) {
|
||||
for (const auto& tdVariant : this->variants) {
|
||||
if (tdVariant.disabled) {
|
||||
continue;
|
||||
}
|
||||
@@ -514,8 +508,8 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
targetVariant.package = TargetPackage::SSOP;
|
||||
}
|
||||
|
||||
const auto tdPinoutIt = tdPinoutsByName.find(tdVariant.pinoutName);
|
||||
if (tdPinoutIt == tdPinoutsByName.end()) {
|
||||
const auto tdPinoutIt = this->pinoutsMappedByName.find(tdVariant.pinoutName);
|
||||
if (tdPinoutIt == this->pinoutsMappedByName.end()) {
|
||||
// Missing pinouts in the target description file
|
||||
continue;
|
||||
}
|
||||
@@ -558,9 +552,7 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
}
|
||||
|
||||
void TargetDescriptionFile::loadTargetRegisterDescriptors() {
|
||||
const auto& modulesByName = this->modulesMappedByName;
|
||||
|
||||
for (const auto& [moduleName, module] : modulesByName) {
|
||||
for (const auto& [moduleName, module] : this->modulesMappedByName) {
|
||||
for (const auto& [registerGroupName, registerGroup] : module.registerGroupsMappedByName) {
|
||||
const auto peripheralRegisterGroupsIt = this->peripheralRegisterGroupsMappedByModuleRegisterGroupName.find(
|
||||
registerGroupName
|
||||
@@ -614,11 +606,10 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
const std::string& instanceName,
|
||||
const std::string& registerGroupName
|
||||
) const {
|
||||
const auto& peripheralModules = this->getPeripheralModulesMappedByName();
|
||||
Targets::TargetMemoryAddress addressOffset = 0;
|
||||
|
||||
const auto peripheralModuleIt = peripheralModules.find(moduleName);
|
||||
if (peripheralModuleIt != peripheralModules.end()) {
|
||||
const auto peripheralModuleIt = this->peripheralModulesMappedByName.find(moduleName);
|
||||
if (peripheralModuleIt != this->peripheralModulesMappedByName.end()) {
|
||||
const auto& peripheralModule = peripheralModuleIt->second;
|
||||
|
||||
const auto instanceIt = peripheralModule.instancesMappedByName.find(instanceName);
|
||||
@@ -1212,11 +1203,9 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
}
|
||||
|
||||
void TargetDescriptionFile::loadDebugWireAndJtagTargetParameters(TargetParameters& targetParameters) const {
|
||||
const auto& propertyGroups = this->getPropertyGroupsMappedByName();
|
||||
|
||||
// OCD attributes can be found in property groups
|
||||
const auto ocdPropertyGroupIt = propertyGroups.find("ocd");
|
||||
if (ocdPropertyGroupIt != propertyGroups.end()) {
|
||||
const auto ocdPropertyGroupIt = this->propertyGroupsMappedByName.find("ocd");
|
||||
if (ocdPropertyGroupIt != this->propertyGroupsMappedByName.end()) {
|
||||
const auto& ocdProperties = ocdPropertyGroupIt->second.propertiesMappedByName;
|
||||
|
||||
const auto ocdRevisionPropertyIt = ocdProperties.find("ocd_revision");
|
||||
@@ -1279,10 +1268,8 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
}
|
||||
|
||||
void TargetDescriptionFile::loadPdiTargetParameters(TargetParameters& targetParameters) const {
|
||||
const auto& propertyGroups = this->getPropertyGroupsMappedByName();
|
||||
|
||||
const auto pdiPropertyGroupIt = propertyGroups.find("pdi_interface");
|
||||
if (pdiPropertyGroupIt == propertyGroups.end()) {
|
||||
const auto pdiPropertyGroupIt = this->propertyGroupsMappedByName.find("pdi_interface");
|
||||
if (pdiPropertyGroupIt == this->propertyGroupsMappedByName.end()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1333,16 +1320,14 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
||||
}
|
||||
|
||||
void TargetDescriptionFile::loadUpdiTargetParameters(TargetParameters& targetParameters) const {
|
||||
const auto& propertyGroups = this->getPropertyGroupsMappedByName();
|
||||
|
||||
targetParameters.nvmModuleBaseAddress = this->getPeripheralModuleRegisterAddressOffset(
|
||||
"nvmctrl",
|
||||
"nvmctrl",
|
||||
"nvmctrl"
|
||||
);
|
||||
|
||||
const auto updiPropertyGroupIt = propertyGroups.find("updi_interface");
|
||||
if (updiPropertyGroupIt != propertyGroups.end()) {
|
||||
const auto updiPropertyGroupIt = this->propertyGroupsMappedByName.find("updi_interface");
|
||||
if (updiPropertyGroupIt != this->propertyGroupsMappedByName.end()) {
|
||||
const auto& updiInterfaceProperties = updiPropertyGroupIt->second.propertiesMappedByName;
|
||||
|
||||
const auto ocdBaseAddressPropertyIt = updiInterfaceProperties.find("ocd_base_addr");
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Targets::TargetDescription
|
||||
this->loadInterfaces(document);
|
||||
}
|
||||
|
||||
AddressSpace TargetDescriptionFile::generateAddressSpaceFromXml(const QDomElement& xmlElement) {
|
||||
AddressSpace TargetDescriptionFile::addressSpaceFromXml(const QDomElement& xmlElement) {
|
||||
if (
|
||||
!xmlElement.hasAttribute("id")
|
||||
|| !xmlElement.hasAttribute("name")
|
||||
@@ -90,7 +90,7 @@ namespace Targets::TargetDescription
|
||||
auto& memorySegments = addressSpace.memorySegmentsByTypeAndName;
|
||||
for (int segmentIndex = 0; segmentIndex < segmentNodes.count(); segmentIndex++) {
|
||||
try {
|
||||
auto segment = TargetDescriptionFile::generateMemorySegmentFromXml(
|
||||
auto segment = TargetDescriptionFile::memorySegmentFromXml(
|
||||
segmentNodes.item(segmentIndex).toElement()
|
||||
);
|
||||
|
||||
@@ -113,7 +113,7 @@ namespace Targets::TargetDescription
|
||||
return addressSpace;
|
||||
}
|
||||
|
||||
MemorySegment TargetDescriptionFile::generateMemorySegmentFromXml(const QDomElement& xmlElement) {
|
||||
MemorySegment TargetDescriptionFile::memorySegmentFromXml(const QDomElement& xmlElement) {
|
||||
if (
|
||||
!xmlElement.hasAttribute("type")
|
||||
|| !xmlElement.hasAttribute("name")
|
||||
@@ -163,7 +163,7 @@ namespace Targets::TargetDescription
|
||||
return segment;
|
||||
}
|
||||
|
||||
RegisterGroup TargetDescriptionFile::generateRegisterGroupFromXml(const QDomElement& xmlElement) {
|
||||
RegisterGroup TargetDescriptionFile::registerGroupFromXml(const QDomElement& xmlElement) {
|
||||
if (!xmlElement.hasAttribute("name")) {
|
||||
throw Exception("Missing register group name attribute");
|
||||
}
|
||||
@@ -191,7 +191,7 @@ namespace Targets::TargetDescription
|
||||
auto registerNodes = xmlElement.elementsByTagName("register");
|
||||
for (int registerIndex = 0; registerIndex < registerNodes.count(); registerIndex++) {
|
||||
try {
|
||||
auto reg = TargetDescriptionFile::generateRegisterFromXml(
|
||||
auto reg = TargetDescriptionFile::registerFromXml(
|
||||
registerNodes.item(registerIndex).toElement()
|
||||
);
|
||||
registers.insert(std::pair(reg.name, reg));
|
||||
@@ -205,7 +205,7 @@ namespace Targets::TargetDescription
|
||||
return registerGroup;
|
||||
}
|
||||
|
||||
Register TargetDescriptionFile::generateRegisterFromXml(const QDomElement& xmlElement) {
|
||||
Register TargetDescriptionFile::registerFromXml(const QDomElement& xmlElement) {
|
||||
if (
|
||||
!xmlElement.hasAttribute("name")
|
||||
|| !xmlElement.hasAttribute("offset")
|
||||
@@ -245,7 +245,7 @@ namespace Targets::TargetDescription
|
||||
auto bitFieldNodes = xmlElement.elementsByTagName("bitfield");
|
||||
for (int bitFieldIndex = 0; bitFieldIndex < bitFieldNodes.count(); bitFieldIndex++) {
|
||||
try {
|
||||
auto bitField = TargetDescriptionFile::generateBitFieldFromXml(
|
||||
auto bitField = TargetDescriptionFile::bitFieldFromXml(
|
||||
bitFieldNodes.item(bitFieldIndex).toElement()
|
||||
);
|
||||
bitFields.insert(std::pair(bitField.name, bitField));
|
||||
@@ -259,7 +259,7 @@ namespace Targets::TargetDescription
|
||||
return reg;
|
||||
}
|
||||
|
||||
BitField TargetDescriptionFile::generateBitFieldFromXml(const QDomElement& xmlElement) {
|
||||
BitField TargetDescriptionFile::bitFieldFromXml(const QDomElement& xmlElement) {
|
||||
if (!xmlElement.hasAttribute("name") || !xmlElement.hasAttribute("mask")) {
|
||||
throw Exception("Missing bit field name/mask attribute");
|
||||
}
|
||||
@@ -291,7 +291,7 @@ namespace Targets::TargetDescription
|
||||
|
||||
for (int addressSpaceIndex = 0; addressSpaceIndex < addressSpaceNodes.count(); addressSpaceIndex++) {
|
||||
try {
|
||||
auto addressSpace = TargetDescriptionFile::generateAddressSpaceFromXml(
|
||||
auto addressSpace = TargetDescriptionFile::addressSpaceFromXml(
|
||||
addressSpaceNodes.item(addressSpaceIndex).toElement()
|
||||
);
|
||||
this->addressSpacesMappedById.insert(std::pair(addressSpace.id, addressSpace));
|
||||
@@ -351,7 +351,7 @@ namespace Targets::TargetDescription
|
||||
|
||||
auto registerGroupNodes = moduleElement.elementsByTagName("register-group");
|
||||
for (int registerGroupIndex = 0; registerGroupIndex < registerGroupNodes.count(); registerGroupIndex++) {
|
||||
auto registerGroup = TargetDescriptionFile::generateRegisterGroupFromXml(
|
||||
auto registerGroup = TargetDescriptionFile::registerGroupFromXml(
|
||||
registerGroupNodes.item(registerGroupIndex).toElement()
|
||||
);
|
||||
|
||||
@@ -376,7 +376,7 @@ namespace Targets::TargetDescription
|
||||
|
||||
auto registerGroupNodes = moduleElement.elementsByTagName("register-group");
|
||||
for (int registerGroupIndex = 0; registerGroupIndex < registerGroupNodes.count(); registerGroupIndex++) {
|
||||
auto registerGroup = TargetDescriptionFile::generateRegisterGroupFromXml(
|
||||
auto registerGroup = TargetDescriptionFile::registerGroupFromXml(
|
||||
registerGroupNodes.item(registerGroupIndex).toElement()
|
||||
);
|
||||
|
||||
@@ -400,7 +400,7 @@ namespace Targets::TargetDescription
|
||||
registerGroupIndex < registerGroupNodes.count();
|
||||
registerGroupIndex++
|
||||
) {
|
||||
auto registerGroup = TargetDescriptionFile::generateRegisterGroupFromXml(
|
||||
auto registerGroup = TargetDescriptionFile::registerGroupFromXml(
|
||||
registerGroupNodes.item(registerGroupIndex).toElement()
|
||||
);
|
||||
|
||||
|
||||
@@ -69,51 +69,6 @@ namespace Targets::TargetDescription
|
||||
*/
|
||||
[[nodiscard]] const std::string& getFamilyName() const;
|
||||
|
||||
/**
|
||||
* Returns a mapping of all property groups, with the property group name being the key.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const std::map<std::string, PropertyGroup>& getPropertyGroupsMappedByName() const {
|
||||
return this->propertyGroupsMappedByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mapping of all modules, with the module name being the key.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const std::map<std::string, Module>& getModulesMappedByName() const {
|
||||
return this->modulesMappedByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mapping of all peripheral modules, with the peripheral module name being the key.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const std::map<std::string, Module>& getPeripheralModulesMappedByName() const {
|
||||
return this->peripheralModulesMappedByName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all variants found in the TDF.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const std::vector<Variant>& getVariants() const {
|
||||
return this->variants;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a mapping of pinouts, with the pinout name being the key.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
[[nodiscard]] const std::map<std::string, Pinout>& getPinoutsMappedByName() const {
|
||||
return this->pinoutsMappedByName;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string targetName;
|
||||
std::string familyName;
|
||||
@@ -145,7 +100,7 @@ namespace Targets::TargetDescription
|
||||
* @param xmlElement
|
||||
* @return
|
||||
*/
|
||||
static AddressSpace generateAddressSpaceFromXml(const QDomElement& xmlElement);
|
||||
static AddressSpace addressSpaceFromXml(const QDomElement& xmlElement);
|
||||
|
||||
/**
|
||||
* Constructs a MemorySegment object from an XML element.
|
||||
@@ -153,7 +108,7 @@ namespace Targets::TargetDescription
|
||||
* @param xmlElement
|
||||
* @return
|
||||
*/
|
||||
static MemorySegment generateMemorySegmentFromXml(const QDomElement& xmlElement);
|
||||
static MemorySegment memorySegmentFromXml(const QDomElement& xmlElement);
|
||||
|
||||
/**
|
||||
* Constructs a RegisterGroup object from an XML element.
|
||||
@@ -161,7 +116,7 @@ namespace Targets::TargetDescription
|
||||
* @param xmlElement
|
||||
* @return
|
||||
*/
|
||||
static RegisterGroup generateRegisterGroupFromXml(const QDomElement& xmlElement);
|
||||
static RegisterGroup registerGroupFromXml(const QDomElement& xmlElement);
|
||||
|
||||
/**
|
||||
* Constructs a Register object from an XML element.
|
||||
@@ -169,7 +124,7 @@ namespace Targets::TargetDescription
|
||||
* @param xmlElement
|
||||
* @return
|
||||
*/
|
||||
static Register generateRegisterFromXml(const QDomElement& xmlElement);
|
||||
static Register registerFromXml(const QDomElement& xmlElement);
|
||||
|
||||
/**
|
||||
* Consturcts a BitField object from an XML element.
|
||||
@@ -177,7 +132,7 @@ namespace Targets::TargetDescription
|
||||
* @param xmlElement
|
||||
* @return
|
||||
*/
|
||||
static BitField generateBitFieldFromXml(const QDomElement& xmlElement);
|
||||
static BitField bitFieldFromXml(const QDomElement& xmlElement);
|
||||
|
||||
/**
|
||||
* Extracts all address spaces and loads them into this->addressSpacesMappedById.
|
||||
|
||||
Reference in New Issue
Block a user