Added address space unit size to MemorySegment and MemorySegmentSection

Some recfactoring
This commit is contained in:
Nav
2024-12-27 01:53:02 +00:00
parent 7aeb2ddf08
commit 00c4cee6c2
11 changed files with 202 additions and 186 deletions

View File

@@ -72,21 +72,21 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
$programMemorySegment = $this->getProgramMemorySegment();
if ($programMemorySegment instanceof MemorySegment) {
$output->flashStartAddress = $programMemorySegment->startAddress;
$output->flashSize = $programMemorySegment->size;
$output->flashStartAddress = $programMemorySegment->addressRange->startAddress;
$output->flashSize = $programMemorySegment->size();
$output->flashPageSize = $programMemorySegment->pageSize;
}
$ramMemorySegment = $this->getRamSegment();
if ($ramMemorySegment instanceof MemorySegment) {
$output->ramStartAddress = $ramMemorySegment->startAddress;
$output->ramStartAddress = $ramMemorySegment->addressRange->startAddress;
}
$output->bootSectionOptions = $this->getBootSectionOptions();
$eepromMemorySegment = $this->getEepromSegment();
if ($eepromMemorySegment instanceof MemorySegment) {
$output->eepromSize = $eepromMemorySegment->size;
$output->eepromSize = $eepromMemorySegment->size();
$output->eepromPageSize = $eepromMemorySegment->pageSize;
}
@@ -218,21 +218,21 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
$programMemorySegment = $this->getProgramMemorySegment();
if ($programMemorySegment instanceof MemorySegment) {
$output->flashStartAddress = $programMemorySegment->startAddress;
$output->flashSize = $programMemorySegment->size;
$output->flashStartAddress = $programMemorySegment->addressRange->startAddress;
$output->flashSize = $programMemorySegment->size();
$output->flashPageSize = $programMemorySegment->pageSize;
}
$ramMemorySegment = $this->getRamSegment();
if ($ramMemorySegment instanceof MemorySegment) {
$output->ramStartAddress = $ramMemorySegment->startAddress;
$output->ramStartAddress = $ramMemorySegment->addressRange->startAddress;
}
$output->bootSectionOptions = $this->getBootSectionOptions();
$eepromMemorySegment = $this->getEepromSegment();
if ($eepromMemorySegment instanceof MemorySegment) {
$output->eepromSize = $eepromMemorySegment->size;
$output->eepromSize = $eepromMemorySegment->size();
$output->eepromPageSize = $eepromMemorySegment->pageSize;
}
@@ -344,18 +344,18 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
$appSection = $programMemorySegment->getSection('app_section');
if ($appSection instanceof MemorySegmentSection) {
$output->appSectionSize = $appSection->size;
$output->appSectionSize = $appSection->size();
}
$bootSection = $programMemorySegment->getSection('boot_section');
if ($bootSection instanceof MemorySegmentSection) {
$output->bootSectionSize = $bootSection->size;
$output->bootSectionSize = $bootSection->size();
}
}
$eepromMemorySegment = $this->getEepromSegment();
if ($eepromMemorySegment instanceof MemorySegment) {
$output->eepromSize = $eepromMemorySegment->size;
$output->eepromSize = $eepromMemorySegment->size();
$output->eepromPageSize = $eepromMemorySegment->pageSize;
}
@@ -381,14 +381,14 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
$programMemorySegment = $this->getProgramMemorySegment();
if ($programMemorySegment instanceof MemorySegment) {
$output->flashSize = $programMemorySegment->size;
$output->flashSize = $programMemorySegment->size();
$output->flashPageSize = $programMemorySegment->pageSize;
}
$eepromMemorySegment = $this->getEepromSegment();
if ($eepromMemorySegment instanceof MemorySegment) {
$output->eepromStartAddress = $eepromMemorySegment->startAddress;
$output->eepromSize = $eepromMemorySegment->size;
$output->eepromStartAddress = $eepromMemorySegment->addressRange->startAddress;
$output->eepromSize = $eepromMemorySegment->size();
$output->eepromPageSize = $eepromMemorySegment->pageSize;
}
@@ -410,7 +410,7 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
);
if ($signatureMemorySegment instanceof MemorySegment) {
$output->signatureSegmentStartAddress = $signatureMemorySegment->startAddress;
$output->signatureSegmentStartAddress = $signatureMemorySegment->addressRange->startAddress;
}
$fuseMemorySegment = $this->getMemorySegment(
@@ -422,8 +422,8 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
);
if ($fuseMemorySegment instanceof MemorySegment) {
$output->fuseSegmentSize = $fuseMemorySegment->size;
$output->fuseSegmentStartAddress = $fuseMemorySegment->startAddress;
$output->fuseSegmentSize = $fuseMemorySegment->size();
$output->fuseSegmentStartAddress = $fuseMemorySegment->addressRange->startAddress;
}
$lockbitsMemorySegment = $this->getMemorySegment(
@@ -435,7 +435,7 @@ class Avr8TargetDescriptionFile extends TargetDescriptionFile
);
if ($lockbitsMemorySegment instanceof MemorySegment) {
$output->lockbitsSegmentStartAddress = $lockbitsMemorySegment->startAddress;
$output->lockbitsSegmentStartAddress = $lockbitsMemorySegment->addressRange->startAddress;
}
return $output;

View File

@@ -27,7 +27,7 @@ class ValidationService extends \Targets\TargetDescriptionFiles\Services\Validat
if ($progAddressSpace === null) {
$failures[] = 'Missing program memory address space';
} elseif ($progAddressSpace->size > 1000000) {
} elseif ($progAddressSpace->size() > 1000000) {
/*
* For program memory cache, Bloom currently allocates a buffer equal to the size of the program memory
* address space. This can become a problem if the address space is huge.
@@ -53,7 +53,7 @@ class ValidationService extends \Targets\TargetDescriptionFiles\Services\Validat
$failures[] = 'Missing "internal_ram" memory segment';
} else {
$sramEndAddress = $sramSegment->startAddress + $sramSegment->size - 1;
$sramEndAddress = $sramSegment->addressRange->startAddress + $sramSegment->size() - 1;
/*
* The GPR and IO segments must not come after the SRAM segment in the data address space.
@@ -61,11 +61,11 @@ class ValidationService extends \Targets\TargetDescriptionFiles\Services\Validat
* There are some places in Bloom's codebase where we have made this assumption, which is why we confirm
* it here as part of TDF validation.
*/
if ($gprSegment !== null && $gprSegment->startAddress > $sramEndAddress) {
if ($gprSegment !== null && $gprSegment->addressRange->startAddress > $sramEndAddress) {
$failures[] = 'The GPR memory segment comes after the SRAM segment';
}
if ($ioSegment !== null && $ioSegment->startAddress > $sramEndAddress) {
if ($ioSegment !== null && $ioSegment->addressRange->startAddress > $sramEndAddress) {
$failures[] = 'The IO memory segment comes after the SRAM segment';
}
}
@@ -390,23 +390,23 @@ class ValidationService extends \Targets\TargetDescriptionFiles\Services\Validat
* we assume that the offset has already been applied to the params. We confirm this here.
*/
if (($ioMemorySegment = $tdf->getIoMemorySegment()) instanceof MemorySegment) {
if ($parameters->osccalAddress < $ioMemorySegment->startAddress) {
if ($parameters->osccalAddress < $ioMemorySegment->addressRange->startAddress) {
$failures[] = 'OSCCAL address does not have IO memory segment offset applied';
}
if ($parameters->eearAddressLow < $ioMemorySegment->startAddress) {
if ($parameters->eearAddressLow < $ioMemorySegment->addressRange->startAddress) {
$failures[] = 'EEARL address does not have IO memory segment offset applied';
}
if ($parameters->eearAddressHigh < $ioMemorySegment->startAddress) {
if ($parameters->eearAddressHigh < $ioMemorySegment->addressRange->startAddress) {
$failures[] = 'EEARH address does not have IO memory segment offset applied';
}
if ($parameters->eecrAddress < $ioMemorySegment->startAddress) {
if ($parameters->eecrAddress < $ioMemorySegment->addressRange->startAddress) {
$failures[] = 'EECR address does not have IO memory segment offset applied';
}
if ($parameters->eedrAddress < $ioMemorySegment->startAddress) {
if ($parameters->eedrAddress < $ioMemorySegment->addressRange->startAddress) {
$failures[] = 'EEDR address does not have IO memory segment offset applied';
}
@@ -580,23 +580,23 @@ class ValidationService extends \Targets\TargetDescriptionFiles\Services\Validat
* we assume that the offset has already been applied to the params. We confirm this here.
*/
if (($ioMemorySegment = $tdf->getIoMemorySegment()) instanceof MemorySegment) {
if ($parameters->osccalAddress < $ioMemorySegment->startAddress) {
if ($parameters->osccalAddress < $ioMemorySegment->addressRange->startAddress) {
$failures[] = 'OSCCAL address does not have IO memory segment offset applied';
}
if ($parameters->eearAddressLow < $ioMemorySegment->startAddress) {
if ($parameters->eearAddressLow < $ioMemorySegment->addressRange->startAddress) {
$failures[] = 'EEARL address does not have IO memory segment offset applied';
}
if ($parameters->eearAddressHigh < $ioMemorySegment->startAddress) {
if ($parameters->eearAddressHigh < $ioMemorySegment->addressRange->startAddress) {
$failures[] = 'EEARH address does not have IO memory segment offset applied';
}
if ($parameters->eecrAddress < $ioMemorySegment->startAddress) {
if ($parameters->eecrAddress < $ioMemorySegment->addressRange->startAddress) {
$failures[] = 'EECR address does not have IO memory segment offset applied';
}
if ($parameters->eedrAddress < $ioMemorySegment->startAddress) {
if ($parameters->eedrAddress < $ioMemorySegment->addressRange->startAddress) {
$failures[] = 'EEDR address does not have IO memory segment offset applied';
}