summaryrefslogtreecommitdiffstats
path: root/src/usr/targeting/xmltohb/xmltohb.pl
diff options
context:
space:
mode:
authorMike Jones <mjjones@us.ibm.com>2012-02-22 17:09:18 -0600
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-02-28 11:26:58 -0600
commite4c32d91dc6100d9f9bac47855b3f0c675530b1f (patch)
treecd40b68b135376f8b2d294b7af371405831482bd /src/usr/targeting/xmltohb/xmltohb.pl
parentfec524004b0f9e15a8f8a9986e0415b4aa0f75b7 (diff)
downloadtalos-hostboot-e4c32d91dc6100d9f9bac47855b3f0c675530b1f.tar.gz
talos-hostboot-e4c32d91dc6100d9f9bac47855b3f0c675530b1f.zip
HWPF Attribute Support. DQ Attribute
Change-Id: I05e6f4f435574e25f65702c875e332e253927ff7 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/686 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/targeting/xmltohb/xmltohb.pl')
-rwxr-xr-xsrc/usr/targeting/xmltohb/xmltohb.pl107
1 files changed, 68 insertions, 39 deletions
diff --git a/src/usr/targeting/xmltohb/xmltohb.pl b/src/usr/targeting/xmltohb/xmltohb.pl
index 61b520f74..3fdcbd6e4 100755
--- a/src/usr/targeting/xmltohb/xmltohb.pl
+++ b/src/usr/targeting/xmltohb/xmltohb.pl
@@ -1997,7 +1997,44 @@ sub packEntityPath {
################################################################################
# Pack an attribute into a binary data stream
################################################################################
-
+sub packSingleSimpleTypeAttribute {
+ my($binaryDataRef,$attributesRef,$attributeRef,$typeName,$value) = @_;
+
+ my $simpleType = $$attributeRef->{simpleType};
+ my $simpleTypeProperties = simpleTypeProperties();
+
+ if($typeName eq "enumeration")
+ {
+ my $enumeration = getEnumerationType($$attributesRef,$simpleType->
+ {enumeration}->{id});
+
+ # Here $value is the enumerator name
+ my $enumeratorValue = enumNameToValue($enumeration,$value);
+ $$binaryDataRef .= packEnumeration($enumeration,$enumeratorValue);
+ }
+ else
+ {
+ if($simpleTypeProperties->{$typeName}{canBeHex})
+ {
+ $value = unhexify($value);
+ }
+
+ # Apply special policy enforcement, if any
+ $simpleTypeProperties->{$typeName}{specialPolicies}->($$attributeRef,$value);
+
+ if(ref ($simpleTypeProperties->{$typeName}{packfmt}) eq "CODE")
+ {
+ $$binaryDataRef .= $simpleTypeProperties->{$typeName}{packfmt}->
+ ($value);
+ }
+ else
+ {
+ $$binaryDataRef .= pack($simpleTypeProperties->{$typeName}{packfmt},
+ $value);
+ }
+ }
+}
+
sub packAttribute {
my($attributes,$attribute,$value) = @_;
@@ -2015,54 +2052,46 @@ sub packAttribute {
{
$alignment = $simpleTypeProperties->{$typeName}{alignment};
- if($typeName eq "enumeration")
- {
- my $enumeration = getEnumerationType($attributes,$simpleType->{enumeration}->{id});
-
- # Here $value is the enumerator name
- my $enumeratorValue = enumNameToValue($enumeration,$value);
- $binaryData = packEnumeration($enumeration,$enumeratorValue);
- }
- else
+ if (($simpleTypeProperties->{$typeName}{supportsArray}) &&
+ (exists $simpleType->{array}))
{
- if($simpleTypeProperties->{$typeName}{canBeHex})
- {
- $value = unhexify($value);
- }
+ # This is an array attribute, handle the value parameter as
+ # an array, if there are not enough values for the whole
+ # array then use the last value to fill in the remainder
- # Apply special policy enforcement, if any
- $simpleTypeProperties->
- {$typeName}{specialPolicies}->($attribute,$value);
-
- if(ref ($simpleTypeProperties->{$typeName}{packfmt}) eq "CODE")
- {
- $binaryData .=
- $simpleTypeProperties->{$typeName}{packfmt}->($value);
- }
- else
- {
- $binaryData .=
- pack($simpleTypeProperties->{$typeName}{packfmt},
- $value);
- }
- }
-
- my $arrayMultiplier = 1;
- if( ($simpleTypeProperties->{$typeName}{supportsArray})
- && (exists $simpleType->{array}) )
- {
+ # Figure out the array size (possibly multidimensional)
+ my $arraySize = 1;
my @bounds = split(/,/,$simpleType->{array});
foreach my $bound (@bounds)
{
- $arrayMultiplier *= $bound;
+ $arraySize *= $bound;
}
- my $tmpBinaryData = $binaryData;
- for( my $i = 1; $i < $arrayMultiplier; ++$i)
+ # Split the values into an array
+ my @values = split(/,/,$value);
+ my $valueArraySize = scalar(@values);
+
+ # Iterate over the entire array creating values
+ my $val = "";
+ for (my $i = 0; $i < $arraySize; $i++)
{
- $binaryData .= $tmpBinaryData;
+ if ($i < $valueArraySize)
+ {
+ # Get the value from the value array
+ $val = $values[$i];
+ }
+ # else use the last value
+
+ packSingleSimpleTypeAttribute(\$binaryData, \$attributes,
+ \$attribute, $typeName, $val);
}
}
+ else
+ {
+ # Not an array attribute
+ packSingleSimpleTypeAttribute(\$binaryData, \$attributes,
+ \$attribute,$typeName, $value);
+ }
last;
}
OpenPOWER on IntegriCloud