Corrected overlapping register detection in TDF validation script
This commit is contained in:
@@ -488,19 +488,6 @@ class ValidationService
|
|||||||
$failures[] = 'Duplicate register key ("' . $register->key . '") detected';
|
$failures[] = 'Duplicate register key ("' . $register->key . '") detected';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($register->alternative !== true) {
|
|
||||||
foreach ($registerGroup->registers as $registerOther) {
|
|
||||||
if ($register->key === $registerOther->key || $registerOther->alternative === true) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($register->intersectsWith($registerOther)) {
|
|
||||||
$failures[] = 'Register "' . $register->key . '" overlaps with register "'
|
|
||||||
. $registerOther->key . '"';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$processedChildKeys[] = $register->key;
|
$processedChildKeys[] = $register->key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1118,6 +1105,22 @@ class ValidationService
|
|||||||
. implode(',', $segmentKeys) . ')';
|
. implode(',', $segmentKeys) . ')';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$registerAddressRange = $register->addressRange($addressSpace->unitSize);
|
||||||
|
if ($register->alternative !== true) {
|
||||||
|
foreach ($registerGroup->registers as $registerOther) {
|
||||||
|
if ($register->key === $registerOther->key || $registerOther->alternative === true) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$registerOtherAddressRange = $registerOther->addressRange($addressSpace->unitSize);
|
||||||
|
if ($registerAddressRange->intersectsWith($registerOtherAddressRange)) {
|
||||||
|
$failures[] = 'Register "' . $register->key . '" overlaps with register "'
|
||||||
|
. $registerOther->key . '"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -412,6 +412,7 @@ class TargetDescriptionFile
|
|||||||
$register->initialValue,
|
$register->initialValue,
|
||||||
$register->description,
|
$register->description,
|
||||||
$register->access,
|
$register->access,
|
||||||
|
$register->alternative,
|
||||||
array_map(
|
array_map(
|
||||||
fn (BitField $bitField): TargetRegisterBitField => $this->targetRegisterBitFieldFromBitField($bitField),
|
fn (BitField $bitField): TargetRegisterBitField => $this->targetRegisterBitFieldFromBitField($bitField),
|
||||||
$register->bitFields
|
$register->bitFields
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Targets;
|
namespace Targets;
|
||||||
|
|
||||||
|
use Targets\TargetDescriptionFiles\AddressRange;
|
||||||
use Targets\TargetDescriptionFiles\TargetDescriptionFile;
|
use Targets\TargetDescriptionFiles\TargetDescriptionFile;
|
||||||
|
|
||||||
require_once __DIR__ . "/TargetRegisterBitField.php";
|
require_once __DIR__ . "/TargetRegisterBitField.php";
|
||||||
|
require_once __DIR__ . "/TargetDescriptionFiles/AddressRange.php";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not confuse this with `TargetDescriptionFiles\Register` - that class represents a <register> element in a TDF,
|
* Do not confuse this with `TargetDescriptionFiles\Register` - that class represents a <register> element in a TDF,
|
||||||
@@ -25,6 +27,7 @@ class TargetRegister
|
|||||||
public ?int $initialValue = null;
|
public ?int $initialValue = null;
|
||||||
public ?string $description = null;
|
public ?string $description = null;
|
||||||
public ?string $access = null;
|
public ?string $access = null;
|
||||||
|
public ?bool $alternative = null;
|
||||||
|
|
||||||
/** @var TargetRegisterBitField[] */
|
/** @var TargetRegisterBitField[] */
|
||||||
public array $bitFields;
|
public array $bitFields;
|
||||||
@@ -38,6 +41,7 @@ class TargetRegister
|
|||||||
?int $initialValue,
|
?int $initialValue,
|
||||||
?string $description,
|
?string $description,
|
||||||
?string $access,
|
?string $access,
|
||||||
|
?bool $alternative,
|
||||||
array $bitFields
|
array $bitFields
|
||||||
) {
|
) {
|
||||||
$this->key = $key;
|
$this->key = $key;
|
||||||
@@ -48,6 +52,17 @@ class TargetRegister
|
|||||||
$this->initialValue = $initialValue;
|
$this->initialValue = $initialValue;
|
||||||
$this->description = $description;
|
$this->description = $description;
|
||||||
$this->access = $access;
|
$this->access = $access;
|
||||||
|
$this->alternative = $alternative;
|
||||||
$this->bitFields = $bitFields;
|
$this->bitFields = $bitFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addressRange(?int $addressSpaceUnitSize): ?AddressRange
|
||||||
|
{
|
||||||
|
return $this->address !== null
|
||||||
|
? new AddressRange(
|
||||||
|
$this->address,
|
||||||
|
$this->address + ($this->size / ($addressSpaceUnitSize ?? 1)) - 1
|
||||||
|
)
|
||||||
|
: null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user