Register bit fields in TDF validation script
This commit is contained in:
7
build/scripts/TargetDescriptionFiles/BitField.php
Normal file
7
build/scripts/TargetDescriptionFiles/BitField.php
Normal file
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
namespace Bloom\BuildScripts\TargetDescriptionFiles;
|
||||
|
||||
class BitField
|
||||
{
|
||||
public ?string $name = null;
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
<?php
|
||||
namespace Bloom\BuildScripts\TargetDescriptionFiles;
|
||||
|
||||
require_once __DIR__ . "/BitField.php";
|
||||
|
||||
class Register
|
||||
{
|
||||
public ?string $name = null;
|
||||
public ?int $offset = null;
|
||||
public ?int $size = null;
|
||||
|
||||
/** @var BitField[] */
|
||||
public array $bitFieldsByName = [];
|
||||
}
|
||||
|
||||
@@ -218,6 +218,19 @@ class TargetDescriptionFile
|
||||
$register->size = isset($registerAttrs['size'])
|
||||
? $this->rawValueToInt($registerAttrs['size']) : null;
|
||||
|
||||
$bitFieldElements = $registerElement->xpath('bitfield');
|
||||
foreach ($bitFieldElements as $bitFieldElement) {
|
||||
$bitFieldAttrs = $bitFieldElement->attributes();
|
||||
$bitField = new BitField();
|
||||
|
||||
$bitField->name = isset($bitFieldAttrs['name']) ? $bitFieldAttrs['name'] : null;
|
||||
if (empty($bitField->name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$register->bitFieldsByName[strtolower($bitField->name)] = $bitField;
|
||||
}
|
||||
|
||||
$registerGroup->registersMappedByName[strtolower($register->name)] = $register;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user