summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
diff options
context:
space:
mode:
authorMike Jones <mjjones@us.ibm.com>2011-10-17 10:33:13 -0500
committerMIKE J. JONES <mjjones@us.ibm.com>2011-10-17 10:52:16 -0500
commit0edaa15a20f8986a80d0c819dfa11648ef4f0d9e (patch)
tree482a1b424f650f01f4375cdbd87e90c52662818b /src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
parentd6ce3b30395982623494ad75c50e75c56fadcaca (diff)
downloadtalos-hostboot-0edaa15a20f8986a80d0c819dfa11648ef4f0d9e.tar.gz
talos-hostboot-0edaa15a20f8986a80d0c819dfa11648ef4f0d9e.zip
HWPF: Add fapiGetInitFileAttr function
Change-Id: I1fadb01b8f8e850fdc6c766138e8adb0ea2e0a51 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/436 Tested-by: Jenkins Server Reviewed-by: MIKE J. JONES <mjjones@us.ibm.com>
Diffstat (limited to 'src/usr/hwpf/fapi/fapiParseAttributeInfo.pl')
-rwxr-xr-xsrc/usr/hwpf/fapi/fapiParseAttributeInfo.pl194
1 files changed, 133 insertions, 61 deletions
diff --git a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
index 1f8ae4430..6ee3fbc8b 100755
--- a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
+++ b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl
@@ -40,6 +40,7 @@
# mjjones 06/23/11 Parse more info
# mjjones 07/05/11 Take output dir as parameter
# mjjones 09/06/11 Remove string/defaultVal support
+# mjjones 10/07/11 Create fapiAttributeService.C
#
# End Change Log ******************************************************
@@ -71,30 +72,49 @@ my $xml = new XML::Simple (KeyAttr=>[]);
#use Data::Dumper;
#------------------------------------------------------------------------------
-# Open output file for writing
+# Open output files for writing
#------------------------------------------------------------------------------
-my $outputFile = $ARGV[0];
-$outputFile .= "/";
-$outputFile .= "fapiAttributeIds.H";
-open(OUTFILE, ">", $outputFile);
+my $aiFile = $ARGV[0];
+$aiFile .= "/";
+$aiFile .= "fapiAttributeIds.H";
+open(AIFILE, ">", $aiFile);
+
+my $asFile = $ARGV[0];
+$asFile .= "/";
+$asFile .= "fapiAttributeService.C";
+open(ASFILE, ">", $asFile);
#------------------------------------------------------------------------------
-# Print Start of file information
+# Print Start of file information to fapiAttributeIds.H
#------------------------------------------------------------------------------
-print OUTFILE "// fapiAttributeIds.H\n";
-print OUTFILE "// This file is generated by perl script fapiParseAttributeInfo.pl\n\n";
-print OUTFILE "#ifndef FAPIATTRIBUTEIDS_H_\n";
-print OUTFILE "#define FAPIATTRIBUTEIDS_H_\n\n";
-print OUTFILE "namespace fapi\n";
-print OUTFILE "{\n\n";
+print AIFILE "// fapiAttributeIds.H\n";
+print AIFILE "// This file is generated by perl script fapiParseAttributeInfo.pl\n\n";
+print AIFILE "#ifndef FAPIATTRIBUTEIDS_H_\n";
+print AIFILE "#define FAPIATTRIBUTEIDS_H_\n\n";
+print AIFILE "namespace fapi\n";
+print AIFILE "{\n\n";
+print AIFILE "\/**\n";
+print AIFILE " * \@brief Enumeration of attribute IDs\n";
+print AIFILE " *\/\n";
+print AIFILE "enum AttributeId\n{\n";
#------------------------------------------------------------------------------
-# Print AttributeId enumeration start
+# Print Start of file information to fapiAttributeService.C
#------------------------------------------------------------------------------
-print OUTFILE "\/**\n";
-print OUTFILE " * \@brief Enumeration of attribute IDs\n";
-print OUTFILE " *\/\n";
-print OUTFILE "enum AttributeId\n{\n";
+print ASFILE "// fapiAttributeService.C\n";
+print ASFILE "// This file is generated by perl script fapiParseAttributeInfo.pl\n\n";
+print ASFILE "#include <fapiAttributeService.H>\n\n";
+print ASFILE "namespace fapi\n";
+print ASFILE "{\n\n";
+print ASFILE "ReturnCode fapiGetInitFileAttr(const AttributeId i_id,\n";
+print ASFILE " Target * i_pTarget,\n";
+print ASFILE " uint64_t & o_val,\n";
+print ASFILE " const uint32_t i_arrayIndex1,\n";
+print ASFILE " const uint32_t i_arrayIndex2,\n";
+print ASFILE " const uint32_t i_arrayIndex3,\n";
+print ASFILE " const uint32_t i_arrayIndex4)\n";
+print ASFILE "{\n";
+print ASFILE " ReturnCode l_rc;\n\n";
#------------------------------------------------------------------------------
# For each XML file
@@ -115,7 +135,7 @@ foreach my $argnum (1 .. $#ARGV)
foreach my $attr (@{$attributes->{attribute}})
{
#----------------------------------------------------------------------
- # Print the AttributeId
+ # Print the AttributeId to fapiAttributeIds.H
#----------------------------------------------------------------------
if (! exists $attr->{id})
{
@@ -123,49 +143,41 @@ foreach my $argnum (1 .. $#ARGV)
exit(1);
}
- print OUTFILE " ", $attr->{id}, ",\n";
+ print AIFILE " ", $attr->{id}, ",\n";
};
-}
-
-#------------------------------------------------------------------------------
-# Print AttributeId enumeration end
-#------------------------------------------------------------------------------
-print OUTFILE "};\n\n";
-#------------------------------------------------------------------------------
-# Print Attribute Information comment
-#------------------------------------------------------------------------------
-print OUTFILE "\/**\n";
-print OUTFILE " * \@brief Attribute Information\n";
-print OUTFILE " *\/\n";
-
-#------------------------------------------------------------------------------
-# For each XML file
-#------------------------------------------------------------------------------
-foreach my $argnum (1 .. $#ARGV)
-{
- my $infile = $ARGV[$argnum];
+ #--------------------------------------------------------------------------
+ # Print AttributeId enumeration end to fapiAttributeIds.H
+ #--------------------------------------------------------------------------
+ print AIFILE "};\n\n";
- # read XML file
- my $attributes = $xml->XMLin($infile);
+ #--------------------------------------------------------------------------
+ # Print Attribute Information comment to fapiAttributeIds.H
+ #--------------------------------------------------------------------------
+ print AIFILE "\/**\n";
+ print AIFILE " * \@brief Attribute Information\n";
+ print AIFILE " *\/\n";
#--------------------------------------------------------------------------
# For each Attribute
#--------------------------------------------------------------------------
+ my $attCount = 0;
+
foreach my $attr (@{$attributes->{attribute}})
{
#----------------------------------------------------------------------
- # Print a comment with the attribute description
+ # Print a comment with the attribute description to fapiAttributeIds.H
#----------------------------------------------------------------------
if ($attr->{description})
{
- print OUTFILE "// $attr->{id}: $attr->{description}\n";
+ print AIFILE "// $attr->{id}: $attr->{description}\n";
}
#----------------------------------------------------------------------
# Figure out the attribute array dimensions (if arry)
#----------------------------------------------------------------------
my $arrayDimensions = "";
+ my $numArrayDimensions = 0;
if ($attr->{array})
{
# Figure out the array dimensions
@@ -174,11 +186,12 @@ foreach my $argnum (1 .. $#ARGV)
foreach my $val (@vals)
{
$arrayDimensions .= "[${val}]";
+ $numArrayDimensions++;
}
}
#----------------------------------------------------------------------
- # Print the typedef for each attribute's value type
+ # Print the typedef for each attribute's val type to fapiAttributeIds.H
#----------------------------------------------------------------------
if (! exists $attr->{valueType})
{
@@ -188,15 +201,15 @@ foreach my $argnum (1 .. $#ARGV)
if ($attr->{valueType} eq 'uint8')
{
- print OUTFILE "typedef uint8_t $attr->{id}_Type$arrayDimensions;\n";
+ print AIFILE "typedef uint8_t $attr->{id}_Type$arrayDimensions;\n";
}
elsif ($attr->{valueType} eq 'uint32')
{
- print OUTFILE "typedef uint32_t $attr->{id}_Type$arrayDimensions;\n";
+ print AIFILE "typedef uint32_t $attr->{id}_Type$arrayDimensions;\n";
}
elsif ($attr->{valueType} eq 'uint64')
{
- print OUTFILE "typedef uint64_t $attr->{id}_Type$arrayDimensions;\n";
+ print AIFILE "typedef uint64_t $attr->{id}_Type$arrayDimensions;\n";
}
else
{
@@ -206,33 +219,33 @@ foreach my $argnum (1 .. $#ARGV)
}
#----------------------------------------------------------------------
- # Print if the platform initializes the value
+ # Print if the platform initializes the value to fapiAttributeIds.H
#----------------------------------------------------------------------
if (exists $attr->{platInit})
{
- print OUTFILE "#define $attr->{id}_PLATINIT true\n"
+ print AIFILE "#define $attr->{id}_PLATINIT true\n"
}
else
{
- print OUTFILE "#define $attr->{id}_PLATINIT false\n"
+ print AIFILE "#define $attr->{id}_PLATINIT false\n"
}
#----------------------------------------------------------------------
- # Print the value enumeration (if it is specified)
+ # Print the value enumeration (if specified) to fapiAttributeIds.H
#----------------------------------------------------------------------
if (exists $attr->{enum})
{
- print OUTFILE "enum $attr->{id}_Enum\n{\n";
+ print AIFILE "enum $attr->{id}_Enum\n{\n";
# Values must be separated by white space
my @vals = split(' ', $attr->{enum});
foreach my $val (@vals)
{
- print OUTFILE " $attr->{id}_${val},\n";
+ print AIFILE " $attr->{id}_${val},\n";
}
- print OUTFILE "};\n";
+ print AIFILE "};\n";
}
#----------------------------------------------------------------------
@@ -241,23 +254,82 @@ foreach my $argnum (1 .. $#ARGV)
#----------------------------------------------------------------------
if (! exists $attr->{writeable})
{
- print OUTFILE "#define $attr->{id}_SETMACRO ATTRIBUTE_NOT_WRITABLE\n";
+ print AIFILE "#define $attr->{id}_SETMACRO ATTRIBUTE_NOT_WRITABLE\n";
}
#----------------------------------------------------------------------
- # Print newline between each attribute's information
+ # Print newline between each attribute's info to fapiAttributeIds.H
#----------------------------------------------------------------------
- print OUTFILE "\n";
+ print AIFILE "\n";
+
+ #----------------------------------------------------------------------
+ # Print the attribute get code to fapiAttributeService.C
+ # *** TODO ***
+ # Currently, all attributes are supported in fapiGetInitFileAttr() in
+ # fapiAttributeService.C. Ideally only the initfile attributes should
+ # be supported to minimize code size. Need to figure out how to do this
+ #----------------------------------------------------------------------
+ if ($attCount > 0)
+ {
+ print ASFILE " else ";
+ }
+ else
+ {
+ print ASFILE " ";
+ }
+ $attCount++;
+
+ print ASFILE "if (i_id == $attr->{id})\n";
+ print ASFILE " {\n";
+ print ASFILE " $attr->{id}_Type l_attr;\n";
+ print ASFILE " l_rc = FAPI_ATTR_GET($attr->{id}, i_pTarget, l_attr);\n";
+ print ASFILE " o_val = l_attr";
+
+ if ($numArrayDimensions >= 5)
+ {
+ print ("fapiParseAttributeInfo.pl ERROR. More than 4 array dimensions!!\n");
+ exit(1);
+ }
+ else
+ {
+ for (my $i = 0; $i < $numArrayDimensions; $i++)
+ {
+ print ASFILE "[i_arrayIndex";
+ print ASFILE $i+1;
+ print ASFILE "]";
+ }
+ }
+
+ print ASFILE ";\n";
+ print ASFILE " }\n";
};
}
#------------------------------------------------------------------------------
-# Print End of file information
+# Print End of file information to fapiAttributeIds.H
#------------------------------------------------------------------------------
-print OUTFILE "}\n\n";
-print OUTFILE "#endif\n";
+print AIFILE "}\n\n";
+print AIFILE "#endif\n";
+
+#------------------------------------------------------------------------------
+# Print End of file information to fapiAttributeService.C
+#--------------------------------------------------------------------------
+print ASFILE " else\n";
+print ASFILE " {\n";
+print ASFILE " FAPI_ERR(\"fapiGetInitFileAttr: Unrecognized attr: %d\", i_id);\n";
+print ASFILE " l_rc = FAPI_RC_INVALID_ATTR_GET;\n";
+print ASFILE " }\n\n";
+print ASFILE " if (l_rc)\n";
+print ASFILE " {\n";
+print ASFILE " FAPI_ERR(\"fapiGetInitFileAttr: Error getting attr\");\n";
+print ASFILE " }\n\n";
+print ASFILE " return l_rc;\n";
+print ASFILE "}\n\n";
+print ASFILE "}\n";
+
#------------------------------------------------------------------------------
-# Close output file
+# Close output files
#------------------------------------------------------------------------------
-close(OUTFILE);
+close(AIFILE);
+close(ASFILE);
OpenPOWER on IntegriCloud