Register bit fields in TDF validation script

This commit is contained in:
Nav
2022-03-12 15:41:01 +00:00
parent f6b331c447
commit f17b2e1c35
3 changed files with 25 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
<?php
namespace Bloom\BuildScripts\TargetDescriptionFiles;
class BitField
{
public ?string $name = null;
}

View File

@@ -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 = [];
}

View File

@@ -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;
}