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