DWEN & SPIEN fuse bit descriptor extraction from AVR8 TDFs
This commit is contained in:
@@ -376,6 +376,14 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<FuseBitDescriptor> TargetDescriptionFile::getDwenFuseBitDescriptor() const {
|
||||||
|
return this->getFuseBitDescriptorByName("dwen");
|
||||||
|
}
|
||||||
|
|
||||||
|
std::optional<FuseBitDescriptor> TargetDescriptionFile::getSpienFuseBitDescriptor() const {
|
||||||
|
return this->getFuseBitDescriptorByName("spien");
|
||||||
|
}
|
||||||
|
|
||||||
void TargetDescriptionFile::loadDebugPhysicalInterfaces() {
|
void TargetDescriptionFile::loadDebugPhysicalInterfaces() {
|
||||||
auto interfaceNamesToInterfaces = std::map<std::string, PhysicalInterface>({
|
auto interfaceNamesToInterfaces = std::map<std::string, PhysicalInterface>({
|
||||||
{"updi", PhysicalInterface::UPDI},
|
{"updi", PhysicalInterface::UPDI},
|
||||||
@@ -619,6 +627,45 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<FuseBitDescriptor> TargetDescriptionFile::getFuseBitDescriptorByName(
|
||||||
|
const std::string& fuseBitName
|
||||||
|
) const {
|
||||||
|
if (!this->modulesMappedByName.contains("fuse")) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& fuseModule = this->modulesMappedByName.at("fuse");
|
||||||
|
|
||||||
|
if (!fuseModule.registerGroupsMappedByName.contains("fuse")) {
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto& fuseRegisterGroup = fuseModule.registerGroupsMappedByName.at("fuse");
|
||||||
|
|
||||||
|
static const auto fuseTypesByName = std::map<std::string, FuseType>(
|
||||||
|
{
|
||||||
|
{"low", FuseType::LOW},
|
||||||
|
{"high", FuseType::HIGH},
|
||||||
|
{"extended", FuseType::EXTENDED},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const auto&[fuseTypeName, fuse] : fuseRegisterGroup.registersMappedByName) {
|
||||||
|
if (!fuseTypesByName.contains(fuseTypeName)) {
|
||||||
|
// Unknown fuse type name
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fuse.bitFieldsMappedByName.contains(fuseBitName)) {
|
||||||
|
return FuseBitDescriptor(
|
||||||
|
fuseTypesByName.at(fuseTypeName),
|
||||||
|
fuse.bitFieldsMappedByName.at(fuseBitName).mask
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::nullopt;
|
||||||
|
}
|
||||||
std::optional<MemorySegment> TargetDescriptionFile::getFlashMemorySegment() const {
|
std::optional<MemorySegment> TargetDescriptionFile::getFlashMemorySegment() const {
|
||||||
auto& addressMapping = this->addressSpacesMappedById;
|
auto& addressMapping = this->addressSpacesMappedById;
|
||||||
auto programAddressSpaceIt = addressMapping.find("prog");
|
auto programAddressSpaceIt = addressMapping.find("prog");
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "src/Targets/Microchip/AVR/TargetSignature.hpp"
|
#include "src/Targets/Microchip/AVR/TargetSignature.hpp"
|
||||||
#include "src/Targets/Microchip/AVR/IspParameters.hpp"
|
#include "src/Targets/Microchip/AVR/IspParameters.hpp"
|
||||||
|
#include "src/Targets/Microchip/AVR/Fuse.hpp"
|
||||||
|
|
||||||
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
|
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
|
||||||
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
|
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
|
||||||
@@ -82,6 +83,24 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
|||||||
*/
|
*/
|
||||||
[[nodiscard]] IspParameters getIspParameters() const;
|
[[nodiscard]] IspParameters getIspParameters() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a FuseBitDescriptor for the debugWire enable (DWEN) fuse bit, with information extracted from
|
||||||
|
* the TDF.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* std::nullopt if the DWEN bit field could not be found in the TDF.
|
||||||
|
*/
|
||||||
|
[[nodiscard]] std::optional<FuseBitDescriptor> getDwenFuseBitDescriptor() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a FuseBitDescriptor for the SPI enable (SPIEN) fuse bit, with information extracted from
|
||||||
|
* the TDF.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* std::nullopt if the SPIEN bit field could not be found in the TDF.
|
||||||
|
*/
|
||||||
|
[[nodiscard]] std::optional<FuseBitDescriptor> getSpienFuseBitDescriptor() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a set of all supported physical interfaces for debugging.
|
* Returns a set of all supported physical interfaces for debugging.
|
||||||
*
|
*
|
||||||
@@ -169,6 +188,8 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription
|
|||||||
*/
|
*/
|
||||||
void loadTargetRegisterDescriptors();
|
void loadTargetRegisterDescriptors();
|
||||||
|
|
||||||
|
[[nodiscard]] std::optional<FuseBitDescriptor> getFuseBitDescriptorByName(const std::string& fuseBitName) const;
|
||||||
|
|
||||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getFlashMemorySegment() const;
|
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getFlashMemorySegment() const;
|
||||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getRamMemorySegment() const;
|
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getRamMemorySegment() const;
|
||||||
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getIoMemorySegment() const;
|
[[nodiscard]] std::optional<Targets::TargetDescription::MemorySegment> getIoMemorySegment() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user