Refactored EEPROM TDF memory segment lookup and included a fallback
for cases where the eeprom segment is located in the data address space, as opposed to a dedicated address space for eeprom memory.
This commit is contained in:
@@ -131,10 +131,18 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
|
|||||||
$this->gpRegisterSize = $registerMemorySegment->size;
|
$this->gpRegisterSize = $registerMemorySegment->size;
|
||||||
$this->gpRegisterStartAddress = $registerMemorySegment->startAddress;
|
$this->gpRegisterStartAddress = $registerMemorySegment->startAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($dataAddressSpace->memorySegmentsByTypeAndName['eeprom']['eeprom'])) {
|
||||||
|
$eepromMemorySegment = $dataAddressSpace->memorySegmentsByTypeAndName['eeprom']['eeprom'];
|
||||||
|
$this->eepromSize = $eepromMemorySegment->size;
|
||||||
|
$this->eepromPageSize = $eepromMemorySegment->pageSize;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$eepromAddressSpace = $this->addressSpacesById['eeprom'] ?? null;
|
if ((is_null($this->eepromSize) || is_null($this->eepromPageSize))
|
||||||
if (!empty($eepromAddressSpace)) {
|
&& isset($this->addressSpacesById['eeprom'])
|
||||||
|
) {
|
||||||
|
$eepromAddressSpace = $this->addressSpacesById['eeprom'];
|
||||||
$eepromMemorySegments = $eepromAddressSpace->memorySegmentsByTypeAndName['eeprom'] ?? null;
|
$eepromMemorySegments = $eepromAddressSpace->memorySegmentsByTypeAndName['eeprom'] ?? null;
|
||||||
|
|
||||||
if (!empty($eepromMemorySegments)) {
|
if (!empty($eepromMemorySegments)) {
|
||||||
|
|||||||
@@ -434,19 +434,21 @@ std::optional<MemorySegment> TargetDescriptionFile::getRegisterMemorySegment() c
|
|||||||
std::optional<MemorySegment> TargetDescriptionFile::getEepromMemorySegment() const {
|
std::optional<MemorySegment> TargetDescriptionFile::getEepromMemorySegment() const {
|
||||||
auto addressMapping = this->getAddressSpacesMappedById();
|
auto addressMapping = this->getAddressSpacesMappedById();
|
||||||
|
|
||||||
// EEPROM attributes are usually found in the data address space
|
if (addressMapping.contains("eeprom")) {
|
||||||
auto eepromAddressSpaceIt = addressMapping.find("eeprom");
|
auto& eepromAddressSpace = addressMapping.at("eeprom");
|
||||||
|
|
||||||
if (eepromAddressSpaceIt != addressMapping.end()) {
|
|
||||||
auto& eepromAddressSpace = eepromAddressSpaceIt->second;
|
|
||||||
auto& eepromAddressSpaceSegments = eepromAddressSpace.memorySegmentsByTypeAndName;
|
auto& eepromAddressSpaceSegments = eepromAddressSpace.memorySegmentsByTypeAndName;
|
||||||
|
|
||||||
if (eepromAddressSpaceSegments.find(MemorySegmentType::EEPROM) != eepromAddressSpaceSegments.end()) {
|
if (eepromAddressSpaceSegments.contains(MemorySegmentType::EEPROM)) {
|
||||||
auto& eepromMemorySegments = eepromAddressSpaceSegments.find(MemorySegmentType::EEPROM)->second;
|
return eepromAddressSpaceSegments.at(MemorySegmentType::EEPROM).begin()->second;
|
||||||
auto eepromMemorySegmentIt = eepromMemorySegments.begin();
|
}
|
||||||
|
|
||||||
if (eepromMemorySegmentIt != eepromMemorySegments.end()) {
|
} else {
|
||||||
return eepromMemorySegmentIt->second;
|
// The EEPROM memory segment may be part of the data address space
|
||||||
|
if (addressMapping.contains("data")) {
|
||||||
|
auto dataAddressSpace = addressMapping.at("data");
|
||||||
|
|
||||||
|
if (dataAddressSpace.memorySegmentsByTypeAndName.contains(MemorySegmentType::EEPROM)) {
|
||||||
|
return dataAddressSpace.memorySegmentsByTypeAndName.at(MemorySegmentType::EEPROM).begin()->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user