summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorElizabeth Liner <eliner@us.ibm.com>2015-11-04 14:27:10 -0600
committerStephen Cprek <smcprek@us.ibm.com>2016-02-19 17:06:05 -0600
commit3fd70a51b397987f839af987287f5afbb2fc087f (patch)
tree1646db363a6b0101aa3cccb44acdff790396187d /src/usr
parent630c8445144892228a297278c5647222484e0563 (diff)
downloadtalos-hostboot-3fd70a51b397987f839af987287f5afbb2fc087f.tar.gz
talos-hostboot-3fd70a51b397987f839af987287f5afbb2fc087f.zip
Adding support for signed attributes.
Change-Id: I38d54a0d27346e73a7ba568df1cd47350cf56e33 RTC:137559 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/23058 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/targeting/common/xmltohb/attribute_types.xml16
-rwxr-xr-xsrc/usr/targeting/common/xmltohb/target_types.xml1
-rwxr-xr-xsrc/usr/targeting/common/xmltohb/xmltohb.pl27
-rw-r--r--src/usr/targeting/test/testtargeting.H41
4 files changed, 80 insertions, 5 deletions
diff --git a/src/usr/targeting/common/xmltohb/attribute_types.xml b/src/usr/targeting/common/xmltohb/attribute_types.xml
index 3aa09073e..85f8a930d 100644
--- a/src/usr/targeting/common/xmltohb/attribute_types.xml
+++ b/src/usr/targeting/common/xmltohb/attribute_types.xml
@@ -5,7 +5,7 @@
<!-- -->
<!-- OpenPOWER HostBoot Project -->
<!-- -->
-<!-- Contributors Listed Below - COPYRIGHT 2012,2015 -->
+<!-- Contributors Listed Below - COPYRIGHT 2012,2016 -->
<!-- [+] International Business Machines Corp. -->
<!-- -->
<!-- -->
@@ -10502,6 +10502,20 @@ Measured in GB</description>
<readable/>
</attribute>
+<attribute>
+ <id>TEST_NEGATIVE_FCN</id>
+ <description>Attribute to test signed attribute
+ functionality in the system</description>
+ <simpleType>
+ <int8_t>
+ <default>-6</default>
+ </int8_t>
+ </simpleType>
+ <persistency>non-volatile</persistency>
+ <writeable/>
+ <readable/>
+</attribute>
+
<!-- Note: This attribute is only used by FSP -->
<attribute>
<id>DMI_REFCLOCK_SWIZZLE</id>
diff --git a/src/usr/targeting/common/xmltohb/target_types.xml b/src/usr/targeting/common/xmltohb/target_types.xml
index 5186cb06d..75368904d 100755
--- a/src/usr/targeting/common/xmltohb/target_types.xml
+++ b/src/usr/targeting/common/xmltohb/target_types.xml
@@ -1867,6 +1867,7 @@
<default>43</default>
</attribute>
<attribute><id>MAX_MCS_PER_SYSTEM</id></attribute>
+ <attribute><id>TEST_NEGATIVE_FCN</id></attribute>
<!-- End max/min config attributes -->
<attribute><id>RECONFIGURE_LOOP</id></attribute>
<attribute><id>MULTI_SCOM_BUFFER_MAX_SIZE</id></attribute>
diff --git a/src/usr/targeting/common/xmltohb/xmltohb.pl b/src/usr/targeting/common/xmltohb/xmltohb.pl
index 709271bc0..d8b80dd64 100755
--- a/src/usr/targeting/common/xmltohb/xmltohb.pl
+++ b/src/usr/targeting/common/xmltohb/xmltohb.pl
@@ -6,7 +6,7 @@
#
# OpenPOWER HostBoot Project
#
-# Contributors Listed Below - COPYRIGHT 2012,2015
+# Contributors Listed Below - COPYRIGHT 2012,2016
# [+] International Business Machines Corp.
#
#
@@ -2367,7 +2367,7 @@ sub writeAttrErrlHFile {
elsif (exists $attribute->{simpleType}->{int8_t}) {
print $outFile " l_traceEntry.resize(10+offset + $total_count * 5);\n";
print $outFile " for (uint32_t i = 0;i<$total_count;i++) {\n";
- print $outFile " sprintf(&(l_traceEntry[offset+i*5]), \"0x%.2X \", *(((uint8_t *)l_ptr)+i));\n";
+ print $outFile " sprintf(&(l_traceEntry[offset+i*5]), \"0x%.2X \", *(((int8_t *)l_ptr)+i));\n";
print $outFile " }\n";
print $outFile " l_ptr += $total_count * sizeof(uint8_t);\n";
}
@@ -4283,6 +4283,13 @@ sub enumNameToValue {
. "enumerator value in \"$enumerationName\".");
}
+ if($enumeratorValue < 0)
+ {
+ # In C++ enumerations are unsigned, we do not support negative values.
+ fatal("Negative enumeration value found $enumeration->{id},"
+ ." $enumeratorValue");
+ }
+
return $enumeratorValue;
}
@@ -4644,6 +4651,7 @@ sub packSingleSimpleTypeAttribute {
$simpleTypeProperties->{$typeName}{specialPolicies}->($$attributeRef,
$value);
+ my $valueIsNegative = 'false';
if (ref($value) eq "HASH")
{
# value is a hash ref, XML::Simple represents an empty element with
@@ -4661,9 +4669,22 @@ sub packSingleSimpleTypeAttribute {
{
$value = 0;
}
+ elsif ($value =~ m/[^0-9]/)
+ {
+ # This section is looking for integer values that are incorrectly
+ # being interpreted as strings because of their negative sign (-).
+ # We ensure that the first thing in the String is a negative sign
+ # and that the rest of the String only contains numbers.
+ my $negSign = substr($value,0,1);
+ my $posVal = substr($value,1);
+ if(($negSign eq '-') && ($posVal =~ m/[0-9]/))
+ {
+ $valueIsNegative = 'true';
+ }
+ }
if( ($simpleTypeProperties->{$typeName}{complexTypeSupport}) &&
- ($value =~ m/[^0-9]/) )
+ ($value =~ m/[^0-9]/) && ($valueIsNegative eq 'false'))
{
# This is a type that supports complex types - i.e. an integer and
# the value is a string. Look for an enumeration named after the
diff --git a/src/usr/targeting/test/testtargeting.H b/src/usr/targeting/test/testtargeting.H
index fdd4702da..73f7c0d1b 100644
--- a/src/usr/targeting/test/testtargeting.H
+++ b/src/usr/targeting/test/testtargeting.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2012,2015 */
+/* Contributors Listed Below - COPYRIGHT 2012,2016 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -273,6 +273,45 @@ class TargetingTestSuite : public CxxTest::TestSuite
#endif
TS_TRACE(EXIT_MRK "testL4Target" );
}
+
+ /**
+ * @brief Testing Hostboot support for negative attributes
+ */
+ void testSignedAttribute()
+ {
+ TS_TRACE(ENTER_MRK "testSignedAttribute");
+
+ // TODO RTC 144142
+
+ TARGETING::Target* l_sys = NULL;
+ TARGETING::targetService().getTopLevelTarget(l_sys);
+ int8_t signedAttr = -5;
+
+ // Attempt to set the attribute to a negative number
+ if(l_sys->trySetAttr<TARGETING::ATTR_TEST_NEGATIVE_FCN>(signedAttr))
+ {
+ TS_TRACE("testSignedAttribute: Attribute is %d",signedAttr);
+ }
+ else
+ {
+ TS_FAIL("testSignedAttribute: Attribute failed during set");
+ }
+
+ signedAttr = 0;
+
+ l_sys->tryGetAttr<TARGETING::ATTR_TEST_NEGATIVE_FCN>(signedAttr);
+ if(signedAttr < 0)
+ {
+ TS_TRACE("testSignedAttribute: Attribute is %d",signedAttr);
+ }
+ else
+ {
+ TS_FAIL("testSignedAttribute: Attribute is incorrectly positive");
+ }
+
+ TS_TRACE(EXIT_MRK "testSignedAttribute");
+ }
+
};
#endif // End __TARGETING_TESTTARGETING_H
OpenPOWER on IntegriCloud