diff options
author | Mike Jones <mjjones@us.ibm.com> | 2011-06-30 16:45:59 -0500 |
---|---|---|
committer | MIKE J. JONES <mjjones@us.ibm.com> | 2011-07-05 09:27:10 -0500 |
commit | 6c77e26e9454c6753d989f33430c4e361f6ff003 (patch) | |
tree | 063625734d8cf35214df22c0e1c76ac8a6c020d7 /src/usr | |
parent | a62f6ced825e39e2f96ea207818c6a75b75744ab (diff) | |
download | talos-hostboot-6c77e26e9454c6753d989f33430c4e361f6ff003.tar.gz talos-hostboot-6c77e26e9454c6753d989f33430c4e361f6ff003.zip |
Adding Attribute Support to HWPF and some minor HWPF updates.
Change-Id: I278c782f98439f26e8535dfda026542b7bbfd641
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/163
Tested-by: Jenkins Server
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
Reviewed-by: Andrew J. Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/hwpf/fapi/fapiAttributeService.C | 187 | ||||
-rwxr-xr-x | src/usr/hwpf/fapi/fapiParseAttributeInfo.pl | 255 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/fapiReturnCodeDataRef.C | 11 | ||||
-rw-r--r-- | src/usr/hwpf/fapi/makefile | 3 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml | 60 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/fapiTestHwp.C | 73 | ||||
-rwxr-xr-x | src/usr/hwpf/hwp/fapiTestHwpAttr.C | 513 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatUtil.C | 3 |
8 files changed, 777 insertions, 328 deletions
diff --git a/src/usr/hwpf/fapi/fapiAttributeService.C b/src/usr/hwpf/fapi/fapiAttributeService.C deleted file mode 100644 index c48557398..000000000 --- a/src/usr/hwpf/fapi/fapiAttributeService.C +++ /dev/null @@ -1,187 +0,0 @@ -/** - * @file fapiAttributeService.C - * - * @brief Implements the AttributeService functions. - */ - -#include <stdio.h> -#include <fapiAttributeService.H> -#include <fapiPlatTrace.H> - -namespace fapi -{ - -namespace AttributeService -{ - -//****************************************************************************** -// Get string -//****************************************************************************** -template<> -ReturnCode _get<char *> (const AttributeId i_id, - const Target * const i_pTarget, - char * & o_value) -{ - FAPI_ERR("Get string attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint8_t -//****************************************************************************** -template<> -ReturnCode _get<uint8_t> (const AttributeId i_id, - const Target * const i_pTarget, - uint8_t & o_value) -{ - FAPI_ERR("Get uint8 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint32_t -//****************************************************************************** -template<> -ReturnCode _get<uint32_t> (const AttributeId i_id, - const Target * const i_pTarget, - uint32_t & o_value) -{ - FAPI_ERR("Get uint32 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint64_t -//****************************************************************************** -template<> -ReturnCode _get<uint64_t> (const AttributeId i_id, - const Target * const i_pTarget, - uint64_t & o_value) -{ - FAPI_ERR("Get uint64 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint8_t array -//****************************************************************************** -template<> -ReturnCode _get<uint8_t *> (const AttributeId i_id, - const Target * const i_pTarget, - uint8_t * const o_pValues) -{ - FAPI_ERR("Get uint8 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint32_t array -//****************************************************************************** -template<> -ReturnCode _get<uint32_t *> (const AttributeId i_id, - const Target * const i_pTarget, - uint32_t * const o_pValues) -{ - FAPI_ERR("Get uint32 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Get uint64_t array -//****************************************************************************** -template<> -ReturnCode _get<uint64_t *> (const AttributeId i_id, - const Target * const i_pTarget, - uint64_t * const o_pValues) -{ - FAPI_ERR("Get uint64 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set string -//****************************************************************************** -template<> -ReturnCode _set<char *> (const AttributeId i_id, - const Target * const i_pTarget, - const char * const i_pValue) -{ - FAPI_ERR("Set string attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint8_t -//****************************************************************************** -template<> -ReturnCode _set<uint8_t> (const AttributeId i_id, - const Target * const i_pTarget, - const uint8_t i_value) -{ - FAPI_ERR("Set uint8 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint32_t -//****************************************************************************** -template<> -ReturnCode _set<uint32_t> (const AttributeId i_id, - const Target * const i_pTarget, - const uint32_t i_value) -{ - FAPI_ERR("Set uint32 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint64_t -//****************************************************************************** -template<> -ReturnCode _set<uint64_t> (const AttributeId i_id, - const Target * const i_pTarget, - const uint64_t i_value) -{ - FAPI_ERR("Set uint64 attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint8_t array -//****************************************************************************** -template<> -ReturnCode _set<uint8_t *> (const AttributeId i_id, - const Target * const i_pTarget, - const uint8_t * const i_pValues) -{ - FAPI_ERR("Set uint8 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint32_t array -//****************************************************************************** -template<> -ReturnCode _set<uint32_t *> (const AttributeId i_id, - const Target * const i_pTarget, - const uint32_t * const i_pValues) -{ - FAPI_ERR("Set uint32 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -//****************************************************************************** -// Set uint64_t array -//****************************************************************************** -template<> -ReturnCode _set<uint64_t *> (const AttributeId i_id, - const Target * const i_pTarget, - const uint64_t * const i_pValues) -{ - FAPI_ERR("Set uint64 array attribute not implemented"); - return FAPI_RC_NOT_IMPLEMENTED; -} - -} // namespace AttributeService - -} // namespace fapi diff --git a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl index 8151b0ef6..0153bfb2f 100755 --- a/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl +++ b/src/usr/hwpf/fapi/fapiParseAttributeInfo.pl @@ -1,144 +1,279 @@ #!/usr/bin/perl # +# Purpose: This perl script will parse HWP Attribute XML files +# and add attribute information to a file called fapiAttributeIds.H +# +# Author: CamVan Nguyen +# Last Updated: 06/23/2011 +# +# Version: 1.0 +# +# Change Log ********************************************************** +# +# Flag Track# Userid Date Description +# ---- -------- -------- -------- ----------- +# camvanng 06/03/11 Created +# mjjones 06/06/11 Minor updates for integration +# mjjones 06/10/11 Added "use strict;" +# mjjones 06/23/11 Parse more info +# +# End Change Log ****************************************************** + +# # Usage: # fapiParseAttributeInfo.pl <filename1> <filename2> .... <filenameN> use strict; +#------------------------------------------------------------------------------ +# Print Command Line Help +#------------------------------------------------------------------------------ my $numArgs = $#ARGV + 1; -#print $numArgs, "\n"; - if ($numArgs < 1) { print ("Usage: fapiParseAttributeInfo.pl <filename1> <filename2> .... <filenameN>\n"); - print (" This perl script will parse attribute XML files,\n"); - print (" pull out the attribute IDs/types and create a header file\n"); - print (" fapiAttributeIds.H containing the information.\n"); + print (" This perl script will parse attribute XML files and add\n"); + print (" attribute information to a file called fapiAttributeIds.H\n"); exit(1); } - - -# use module +#------------------------------------------------------------------------------ +# Specify perl modules to use +#------------------------------------------------------------------------------ use XML::Simple; +my $xml = new XML::Simple (KeyAttr=>[]); + +# Uncomment to enable debug output #use Data::Dumper; -#open output file for writing +#------------------------------------------------------------------------------ +# Open output file for writing +#------------------------------------------------------------------------------ open(OUTFILE, ">fapiAttributeIds.H"); + +#------------------------------------------------------------------------------ +# Print Start of file information +#------------------------------------------------------------------------------ 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 AttributeId enumeration start +#------------------------------------------------------------------------------ print OUTFILE "\/**\n"; print OUTFILE " * \@brief Enumeration of attribute IDs\n"; print OUTFILE " *\/\n"; -print OUTFILE "enum AttributeId\n"; -print OUTFILE "{\n"; +print OUTFILE "enum AttributeId\n{\n"; -# create object -my $xml = new XML::Simple (KeyAttr=>[]); - -#for each Hwp Attribute XML file +#------------------------------------------------------------------------------ +# For each XML file +#------------------------------------------------------------------------------ my $infile; foreach $infile(@ARGV) { - #print filename - #print $ifile, "\n\n"; - # read XML file my $attributes = $xml->XMLin($infile); - # print output - #print Dumper($attributes); - #print "\n"; + # Uncomment to get debug output of all attributes + #print "\nFile: ", $infile, "\n", Dumper($attributes), "\n"; - # print attribute id to file - my $attr; - foreach $attr (@{$attributes->{attribute}}) + #-------------------------------------------------------------------------- + # For each Attribute + #-------------------------------------------------------------------------- + foreach my $attr (@{$attributes->{attribute}}) { - if ($attr->{id}) - { - print OUTFILE " ", $attr->{id}, ",\n"; - } - else + #---------------------------------------------------------------------- + # Print the AttributeId + #---------------------------------------------------------------------- + if (!$attr->{id}) { - print ("fapiParseAttributeInfo.pl ERROR. Attribute ID missing\n"); + print ("fapiParseAttributeInfo.pl ERROR. Att 'id' missing\n"); exit(1); } + + print OUTFILE " ", $attr->{id}, ",\n"; }; } +#------------------------------------------------------------------------------ +# Print AttributeId enumeration end +#------------------------------------------------------------------------------ print OUTFILE "};\n\n"; +#------------------------------------------------------------------------------ +# Print Attribute Information comment +#------------------------------------------------------------------------------ print OUTFILE "\/**\n"; -print OUTFILE " * \@brief Typedefs for the attribute value types\n"; +print OUTFILE " * \@brief Attribute Information\n"; print OUTFILE " *\/\n"; -#for each Hwp Attribute XML file +#------------------------------------------------------------------------------ +# For each XML file +#------------------------------------------------------------------------------ foreach $infile(@ARGV) { # read XML file my $attributes = $xml->XMLin($infile); - # print attribute id to file - my $attr; - foreach $attr (@{$attributes->{attribute}}) + #-------------------------------------------------------------------------- + # For each Attribute + #-------------------------------------------------------------------------- + foreach my $attr (@{$attributes->{attribute}}) { - print OUTFILE "typedef "; + #---------------------------------------------------------------------- + # Print a comment with the attribute description + #---------------------------------------------------------------------- + if ($attr->{description}) + { + print OUTFILE "// ", $attr->{id}, ": ", $attr->{description}, "\n"; + } - if ($attr->{valueType} eq 'uint8') + #---------------------------------------------------------------------- + # Figure out the attribute array dimensions (if arry) + #---------------------------------------------------------------------- + my $arrayDimensions = ""; + if ($attr->{array}) { - if ($attr->{array}) + # Figure out the array dimensions + my @vals = split(' ', $attr->{array}); + + foreach my $val (@vals) { - print OUTFILE "uint8_t * "; + $arrayDimensions .= "["; + $arrayDimensions .= ${val}; + $arrayDimensions .= "]"; } - else + } + + #---------------------------------------------------------------------- + # Print the typedef for each attribute's value type + #---------------------------------------------------------------------- + if (!$attr->{valueType}) + { + print ("fapiParseAttributeInfo.pl ERROR. Att 'valueType' missing\n"); + exit(1); + } + + print OUTFILE "typedef "; + my $attrDefaultValType; + + if ($attr->{valueType} eq 'uint8') + { + $attrDefaultValType = "uint8_t"; + print OUTFILE "uint8_t ", $attr->{id}, "_Type", $arrayDimensions, ";\n"; + } + elsif ($attr->{valueType} eq 'uint32') + { + $attrDefaultValType = "uint32_t"; + print OUTFILE "uint32_t ", $attr->{id}, "_Type", $arrayDimensions, ";\n"; + } + elsif ($attr->{valueType} eq 'uint64') + { + $attrDefaultValType = "uint64_t"; + print OUTFILE "uint64_t ", $attr->{id}, "_Type", $arrayDimensions, ";\n"; + } + elsif ($attr->{valueType} eq 'string') + { + $attrDefaultValType = "char *"; + print OUTFILE "char * ", $attr->{id}, "_Type;\n"; + } + else + { + print ("fapiParseAttributeInfo.pl ERROR. valueType not recognized: "); + print $attr->{valueType}, "\n"; + exit(1); + } + + #---------------------------------------------------------------------- + # Print the value enumeration (if it is specified) + #---------------------------------------------------------------------- + if ($attr->{enum}) + { + print OUTFILE "enum ", $attr->{id}, "_Enum\n{\n"; + + # Values must be separated by white space + my @vals = split(' ', $attr->{enum}); + + foreach my $val (@vals) { - print OUTFILE "uint8_t "; + print OUTFILE " ", $attr->{id}, "_", ${val}, ",\n"; } + + print OUTFILE "};\n"; } - elsif ($attr->{valueType} eq 'uint32') + + #---------------------------------------------------------------------- + # Print the default value information + #---------------------------------------------------------------------- + print OUTFILE "const bool ", $attr->{id}, "_HASDEFAULTVAL = "; + + if ($attr->{defaultValue}) { - if ($attr->{array}) + print OUTFILE "true;\n"; + + if ($attr->{valueType} eq 'string') { - print OUTFILE "uint32_t * "; + print OUTFILE "const char * const ", $attr->{id}; + print OUTFILE "_DEFAULTVAL = \"", $attr->{defaultValue}; + print OUTFILE "\";\n"; + } + elsif ($attr->{enum}) + { + print OUTFILE "const ", $attrDefaultValType, " ", $attr->{id}; + print OUTFILE "_DEFAULTVAL = ", $attr->{id}, "_"; + print OUTFILE $attr->{defaultValue}, ";\n"; } else { - print OUTFILE "uint32_t "; + print OUTFILE "const ", $attrDefaultValType, " ", $attr->{id}; + print OUTFILE "_DEFAULTVAL = ", $attr->{defaultValue}, ";\n"; } } - elsif ($attr->{valueType} eq 'uint64') + else { - if ($attr->{array}) + print OUTFILE "false;\n"; + + if ($attr->{valueType} eq 'string') { - print OUTFILE "uint64_t * "; + print OUTFILE "const char * const ", $attr->{id}; + print OUTFILE "_DEFAULTVAL = \"\";\n"; } else { - print OUTFILE "uint64_t "; + print OUTFILE "const ", $attrDefaultValType, " ", $attr->{id}; + print OUTFILE "_DEFAULTVAL = 0;\n"; } } - elsif ($attr->{valueType} eq 'string') - { - print OUTFILE "char * "; - } - else + + #---------------------------------------------------------------------- + # If the attribute is read-only then define the _SETMACRO to something + # that will cause a compile failure + #---------------------------------------------------------------------- + if (!$attr->{writeable}) { - print ("fapiParseAttributeInfo.pl ERROR. valueType not recognized: "); - print $attr->{valueType}, "\n"; - exit(1); + print OUTFILE "#define ", $attr->{id}; + print OUTFILE "_SETMACRO ATTRIBUTE_NOT_WRITABLE\n"; } - print OUTFILE $attr->{id}, "_Type;\n"; + #---------------------------------------------------------------------- + # Print newline between each attribute's information + #---------------------------------------------------------------------- + print OUTFILE "\n"; }; } -print OUTFILE "\n}\n\n"; +#------------------------------------------------------------------------------ +# Print End of file information +#------------------------------------------------------------------------------ +print OUTFILE "}\n\n"; print OUTFILE "#endif\n"; -#close output file +#------------------------------------------------------------------------------ +# Close output file +#------------------------------------------------------------------------------ close(OUTFILE); diff --git a/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C b/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C index 910d1653e..9aaa16381 100644 --- a/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C +++ b/src/usr/hwpf/fapi/fapiReturnCodeDataRef.C @@ -4,8 +4,19 @@ * @brief Implements the FAPI part of the ReturnCodeDataRef class. */ +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/13/2011 Created. + * camvanng 05/31/2011 Added debug traces + * mjjones 06/30/2011 Added #include + * + */ + #include <fapiReturnCodeDataRef.H> #include <fapiUtil.H> +#include <fapiPlatTrace.H> namespace fapi { diff --git a/src/usr/hwpf/fapi/makefile b/src/usr/hwpf/fapi/makefile index 59df28b20..4e6e58995 100644 --- a/src/usr/hwpf/fapi/makefile +++ b/src/usr/hwpf/fapi/makefile @@ -5,8 +5,7 @@ EXTRAINCDIR += ${ROOTPATH}/src/include/usr/ecmddatabuffer EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat -OBJS = fapiAttributeService.o \ - fapiReturnCode.o \ +OBJS = fapiReturnCode.o \ fapiReturnCodeDataRef.o \ fapiTarget.o diff --git a/src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml b/src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml index d1316bc0f..ce0a63042 100644 --- a/src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml +++ b/src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml @@ -2,49 +2,77 @@ <!-- This is just the initial test version. HWPs will replace with an official version. --> <attributes> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT8</id> - <description>Test Attribute UINT8</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT8. DefaultVal 6</description> <valueType>uint8</valueType> + <defaultValue>6</defaultValue> + <writeable/> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT32</id> - <description>Test Attribute UINT32</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT32. PLAT (sets val to 3). RO</description> <valueType>uint32</valueType> + <platInit/> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT64</id> - <description>Test Attribute UINT64</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT64. Enum. DefaultVal VALB</description> <valueType>uint64</valueType> + <defaultValue>VALB</defaultValue> + <enum>VALA VALB VALC</enum> + <writeable/> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT8_ARRAY</id> - <description>Test Attribute UINT8 ARRAY</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT8 ARRAY[3]. DefaultVal 2</description> <valueType>uint8</valueType> + <defaultValue>2</defaultValue> <array>3</array> + <writeable/> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT32_ARRAY</id> - <description>Test Attribute UINT32 ARRAY</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT32 ARRAY[2][3][4]. DefaultVal 8</description> <valueType>uint32</valueType> - <array>4</array> + <defaultValue>8</defaultValue> + <array>2 3 4</array> + <writeable/> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> <id>ATTR_TEST_UINT64_ARRAY</id> - <description>Test Attribute UINT64 ARRAY</description> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr UINT64 ARRAY[5]. PLAT (sets vals to 4). RO</description> <valueType>uint64</valueType> + <platInit/> <array>5</array> </attribute> - <!-- *********************************************************************** --> + <!-- ********************************************************************* --> <attribute> - <id>ATTR_TEST_STRING</id> - <description>Test Attribute STRING</description> + <id>ATTR_TEST_STRING1</id> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr STRING1. DefaultVal 'mike'</description> <valueType>string</valueType> + <defaultValue>mike</defaultValue> + <writeable/> + </attribute> + <!-- ********************************************************************* --> + <attribute> + <id>ATTR_TEST_STRING2</id> + <targetType>TARGET_TYPE_SYSTEM</targetType> + <description>Test Attr STRING2. PLAT (sets val to 'platString')</description> + <valueType>string</valueType> + <writeable/> </attribute> </attributes> diff --git a/src/usr/hwpf/hwp/fapiTestHwp.C b/src/usr/hwpf/hwp/fapiTestHwp.C index 54dff5a66..14292864f 100644 --- a/src/usr/hwpf/hwp/fapiTestHwp.C +++ b/src/usr/hwpf/hwp/fapiTestHwp.C @@ -1,7 +1,17 @@ /** * @file fapiTestHwp.C * - * @brief Implements test Hardware Procedures. + * @brief Implements a simple test Hardware Procedure + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 04/21/2011 Created. + * mjjones 06/02/2011 Use ecmdDataBufferBase + * mjjones 06/28/2011 Removed attribute tests + * */ #include <fapiTestHwp.H> @@ -22,66 +32,6 @@ fapi::ReturnCode hwpIsP7EM0ChipletClockOn(const fapi::Target & i_chip, // Attempt to call the attribute get/set functions for the test attributes fapi::ReturnCode l_rc; - // Test getting and setting attributes - { - char * l_pString = NULL; - uint8_t l_uint8 = 0; - uint32_t l_uint32 = 0; - uint64_t l_uint64 = 0; - uint8_t l_pUint8Array[3] = {0}; - uint32_t l_pUint32Array[4] = {0}; - uint64_t l_pUint64Array[5] = {0}; - - // All of the following should currently compile (not checking RC which - // should be FAPI_RC_NOT_IMPLEMENTED). The get/set functions do not - // currently do anything so passing NULL will work. - l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING, &i_chip, l_pString); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, &i_chip, l_uint8); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32, &i_chip, l_uint32); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, &i_chip, l_uint64); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, &i_chip, l_pUint8Array); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, &i_chip, l_pUint32Array); - l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_pUint64Array); - - l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, l_pString); - l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, "test-string"); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8, &i_chip, l_uint8); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32, &i_chip, l_uint32); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, &i_chip, l_uint64); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8_ARRAY, &i_chip, l_pUint8Array); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32_ARRAY, &i_chip, l_pUint32Array); - l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_pUint64Array); - - // All of the following should not compile due to wrong types used - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING, &i_chip, l_uint8); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING, &i_chip, l_uint32); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING, &i_chip, l_uint64); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING, &i_chip, l_pUint8Array); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, &i_chip, l_pString); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32, &i_chip, l_uint8); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, &i_chip, l_pUint8Array); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, &i_chip, l_pUint64Array); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, &i_chip, l_pString); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, &i_chip, l_uint8); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_uint64); - //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_pUint32Array); - - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, l_uint8); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, l_uint32); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, l_uint64); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING, &i_chip, l_pUint64Array); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8, &i_chip, l_pString); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32, &i_chip, l_uint64); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, &i_chip, l_pUint32Array); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, &i_chip, l_pUint64Array); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8_ARRAY, &i_chip, l_pString); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32_ARRAY, &i_chip, l_uint8); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_uint64); - //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, &i_chip, l_pUint8Array); - - l_rc = fapi::FAPI_RC_SUCCESS; - } - // Constants const uint64_t EM_CLOCK_STATUS_MASK = 0xEEC0000000000000ULL; const uint32_t EM0_CHIPLET_BASE_ADDR = 0x06000000; @@ -117,5 +67,4 @@ fapi::ReturnCode hwpIsP7EM0ChipletClockOn(const fapi::Target & i_chip, return l_rc; } - } // extern "C" diff --git a/src/usr/hwpf/hwp/fapiTestHwpAttr.C b/src/usr/hwpf/hwp/fapiTestHwpAttr.C new file mode 100755 index 000000000..493bec8de --- /dev/null +++ b/src/usr/hwpf/hwp/fapiTestHwpAttr.C @@ -0,0 +1,513 @@ +/** + * @file fapiTestHwpAttr.C + * + * @brief Implements the test Hardware Procedure that exercises the test + * attributes + */ + +/* + * Change Log ****************************************************************** + * Flag Defect/Feature User Date Description + * ------ -------------- ---------- ----------- ---------------------------- + * mjjones 06/30/2011 Created. + * + */ + +#include <fapiTestHwpAttr.H> + +extern "C" +{ + +//****************************************************************************** +// hwpTestAttributes function +//****************************************************************************** +fapi::ReturnCode hwpTestAttributes() +{ + // Attempt to call the attribute get/set functions for the test attributes + fapi::ReturnCode l_rc; + + // Test getting and setting the test attributes + do + { + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT8 (DefaultVal 6) + //---------------------------------------------------------------------- + uint8_t l_uint8 = 0; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, NULL, l_uint8); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. Error from GET"); + break; + } + + // Check value + if (l_uint8 != 6) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. GET returned %d", + l_uint8); + break; + } + + // Test set + l_uint8 = 7; + l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8, NULL, l_uint8); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. Error from SET"); + break; + } + + // Test get + l_uint8 = 8; + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, NULL, l_uint8); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. Error from GET (2)"); + break; + } + + // Check value + if (l_uint8 != 7) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8. GET returned %d (2)", + l_uint8); + break; + } + + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT32 (PLAT (sets val to 3). RO) + //---------------------------------------------------------------------- + uint32_t l_uint32 = 0; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32, NULL, l_uint32); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32. Error from GET"); + break; + } + + // Check value + if (l_uint32 != 3) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32. GET returned %d", + l_uint32); + break; + } + + // Cannot set read-only attribute + + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT64 (Enum. DefaultVal VALB) + //---------------------------------------------------------------------- + uint64_t l_uint64 = 0; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint64); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. Error from GET"); + break; + } + + // Check value + if (l_uint64 != fapi::ATTR_TEST_UINT64_VALB) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. GET returned %d", + static_cast<uint32_t>(l_uint64)); + break; + } + + // Test set + l_uint64 = fapi::ATTR_TEST_UINT64_VALA; + l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, NULL, l_uint64); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. Error from SET"); + break; + } + + // Test get + l_uint64 = fapi::ATTR_TEST_UINT64_VALC; + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint64); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. Error from GET (2)"); + break; + } + + if (l_uint64 != fapi::ATTR_TEST_UINT64_VALA) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64. GET returned %d (2)", + static_cast<uint32_t>(l_uint64)); + break; + } + + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT8_ARRAY ([3], DefaultVal 2) + //---------------------------------------------------------------------- + uint8_t l_uint8Array[3]; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, NULL, l_uint8Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. Error from GET"); + break; + } + + // Check values + for (uint32_t i = 0; i < 3; i++) + { + if (l_uint8Array[i] != 2) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY GET " + "returned %d in index %d", l_uint8Array[i], i); + break; + } + } + + if (l_rc) + { + break; + } + + // Test set + l_uint8Array[0] = 0; + l_uint8Array[1] = 1; + l_uint8Array[2] = 2; + + l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8_ARRAY, NULL, l_uint8Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. Error from SET"); + break; + } + + // Test get + l_uint8Array[0] = 6; + l_uint8Array[1] = 7; + l_uint8Array[2] = 8; + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, NULL, l_uint8Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. Error from GET (2)"); + break; + } + + // Check values + for (uint32_t i = 0; i < 3; i++) + { + if (l_uint8Array[i] != i) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT8_ARRAY. GET " + "returned %d in index %d", l_uint8Array[i], i); + break; + } + } + + if (l_rc) + { + break; + } + + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT32_ARRAY ([2][3][4], DefaultVal 8) + //---------------------------------------------------------------------- + uint32_t l_uint32Array[2][3][4]; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint32Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. Error from GET"); + break; + } + + // Check values + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + for (uint32_t k = 0; k < 4; k++) + { + if (l_uint32Array[i][j][k] != 8) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. " + "GET returned %d in index %d:%d:%d", + l_uint32Array[i][j][j], i, j, k); + break; + } + } + + if (l_rc) + { + break; + } + } + + if (l_rc) + { + break; + } + } + + if (l_rc) + { + break; + } + + // Test set + uint32_t l_val = 0; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + for (uint32_t k = 0; k < 4; k++) + { + l_uint32Array[i][j][k] = l_val++; + } + } + } + + l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint32Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. Error from SET"); + break; + } + + // Test get + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + for (uint32_t k = 0; k < 4; k++) + { + l_uint32Array[i][j][k] = 32; + } + } + } + + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint32Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: Error from GET uint32 array (2)"); + break; + } + + // Check values + l_val = 0; + for (uint32_t i = 0; i < 2; i++) + { + for (uint32_t j = 0; j < 3; j++) + { + for (uint32_t k = 0; k < 4; k++) + { + if (l_uint32Array[i][j][k] != l_val) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT32_ARRAY. " + "GET returned %d in index %d:%d:%d (2)", + l_uint32Array[i][j][j], i, j, k); + break; + } + l_val++; + } + + if (l_rc) + { + break; + } + } + + if (l_rc) + { + break; + } + } + + if (l_rc) + { + break; + } + + //---------------------------------------------------------------------- + // Test ATTR_TEST_UINT64_ARRAY ([5]. PLAT (sets vals to 4). RO) + //---------------------------------------------------------------------- + uint64_t l_uint64Array[5]; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64Array); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64_ARRAY. Error from GET"); + break; + } + + // Check values + for (uint32_t i = 0; i < 5; i++) + { + if (l_uint64Array[i] != 4) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_UINT64_ARRAY. GET " + "returned %d in index %d", + static_cast<uint32_t>(l_uint64Array[i]), i); + break; + } + } + + if (l_rc) + { + break; + } + + // Cannot set read-only attribute + + //---------------------------------------------------------------------- + // Test ATTR_TEST_STRING1 (DefaultVal 'mike') + //---------------------------------------------------------------------- + char * l_pString1 = NULL; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_pString1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. Error from GET"); + break; + } + + // Check value + if (l_pString1 == NULL) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned NULL"); + break; + } + + if (strcmp(l_pString1, "mike") != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned %s", + l_pString1); + break; + } + + delete [] l_pString1; + + // Test set + l_pString1 = "test1"; + + l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING1, NULL, l_pString1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. Error from SET"); + break; + } + + l_pString1 = NULL; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_pString1); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. Error from GET (2)"); + break; + } + + // Check value + if (l_pString1 == NULL) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned NULL (2)"); + break; + } + + if (strcmp(l_pString1, "test1") != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING1. GET returned %s (2)", + l_pString1); + break; + } + + delete [] l_pString1; + + //---------------------------------------------------------------------- + // Test ATTR_TEST_STRING2 (PLAT (sets val to 'platString')) + //---------------------------------------------------------------------- + char * l_pString2 = NULL; + + // Test get + l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING2, NULL, l_pString2); + if (l_rc) + { + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING2. Error from GET"); + break; + } + + // Check value + if (l_pString2 == NULL) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING2. GET returned NULL"); + break; + } + + if (strcmp(l_pString2, "platString") != 0) + { + l_rc = fapi::FAPI_RC_ATTR_UNIT_TEST_FAIL; + FAPI_ERR("hwpTestAttributes: ATTR_TEST_STRING2. GET returned %s", + l_pString2); + break; + } + + + // All of the following should not compile due to setting read-only + // attributes + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32, NULL, l_uint32); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64Array); + + // All of the following should not compile due to wrong types used + //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_uint8); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING2, NULL, l_uint32); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING1, NULL, l_uint64); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_STRING2, NULL, l_uint8Array); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8, NULL, l_pString1); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32, NULL, l_uint8); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint8Array); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64, NULL, l_uint64Array); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT8_ARRAY, NULL, l_pString1); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint8); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64); + //l_rc = FAPI_ATTR_GET(ATTR_TEST_UINT64_ARRAY, NULL, &l_uint32Array[0][0][0]); + + //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING1, NULL, l_uint8); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING2, NULL, l_uint32); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING1, NULL, l_uint64); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_STRING2, NULL, l_uint64Array); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8, NULL, l_pString1); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32, NULL, l_uint64); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, NULL, &l_uint32Array[0][0][0]); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64, NULL, l_uint64Array); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT8_ARRAY, NULL, l_pString2); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT32_ARRAY, NULL, l_uint8); + //l_rc = FAPI_ATTR_SET(ATTR_TEST_UINT64_ARRAY, NULL, l_uint64); + + } while (0); + + return l_rc; +} + +} // extern "C" diff --git a/src/usr/hwpf/plat/fapiPlatUtil.C b/src/usr/hwpf/plat/fapiPlatUtil.C index b8d47619a..8a3e22bf9 100644 --- a/src/usr/hwpf/plat/fapiPlatUtil.C +++ b/src/usr/hwpf/plat/fapiPlatUtil.C @@ -6,8 +6,9 @@ * Note that platform code must provide the implementation. */ +#include <assert.h> #include <trace/interface.H> -#include <fapi.H> +#include <fapiPlatTrace.H> //****************************************************************************** // Trace descriptors |