diff options
author | Kahn Evans <kahnevan@us.ibm.com> | 2017-11-13 14:03:40 -0600 |
---|---|---|
committer | Christian R. Geddes <crgeddes@us.ibm.com> | 2017-11-16 17:57:36 -0500 |
commit | 0ef7c3c566afa9422549073dca09d836a98683dd (patch) | |
tree | ca042e15399cedb9d4a4e6707713c0ece1b88ab9 /src/import/hwpf | |
parent | 47c3bbe42264514a25e00820cac1c8488aed9073 (diff) | |
download | talos-hostboot-0ef7c3c566afa9422549073dca09d836a98683dd.tar.gz talos-hostboot-0ef7c3c566afa9422549073dca09d836a98683dd.zip |
Optional support to parse default attribute tags
Change-Id: I0bd282981e79c45a3f915e06f61c329ffadf7aab
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/49607
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: HWSV CI <hwsv-ci+hostboot@us.ibm.com>
Tested-by: Hostboot CI <hostboot-ci+hostboot@us.ibm.com>
Reviewed-by: Matt K. Light <mklight@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Dev-Ready: Kahn C. Evans <kahnevan@us.ibm.com>
Reviewed-by: Jennifer A. Stofer <stofer@us.ibm.com>
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/49611
Reviewed-by: Hostboot Team <hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Christian R. Geddes <crgeddes@us.ibm.com>
Diffstat (limited to 'src/import/hwpf')
-rwxr-xr-x | src/import/hwpf/fapi2/tools/parseAttributeInfo.pl | 92 |
1 files changed, 90 insertions, 2 deletions
diff --git a/src/import/hwpf/fapi2/tools/parseAttributeInfo.pl b/src/import/hwpf/fapi2/tools/parseAttributeInfo.pl index 061bd11d4..f645de8f4 100755 --- a/src/import/hwpf/fapi2/tools/parseAttributeInfo.pl +++ b/src/import/hwpf/fapi2/tools/parseAttributeInfo.pl @@ -31,17 +31,26 @@ use Getopt::Long; # Print Command Line Help #------------------------------------------------------------------------------ my $arg_output_dir = undef; +my $parse_defaults = ''; # Get the options from the command line - the rest of @ARGV will # be filenames -GetOptions( "output-dir=s" => \$arg_output_dir ); +GetOptions( + "output-dir=s" => \$arg_output_dir, + "parse_defaults" => \$parse_defaults +); my $numArgs = $#ARGV + 1; if ( ( $numArgs < 1 ) || ( $arg_output_dir eq undef ) ) { - print("Usage: parseAttributeInfo.pl --output-dir=<output dir> <attr-xml-file1> [<attr-xml-file2> ...]\n"); + print( + "Usage: parseAttributeInfo.pl --output-dir=<output dir> [--parse_defaults] <attr-xml-file1> [<attr-xml-file2> ...]\n" + ); print(" This perl script will parse attribute XML files and create the following files:\n"); print(" - attribute_ids.H. Contains IDs, type, value enums and other information\n"); + print( + " When --parse_defaults is specified, default tags are handled and added to this file too.\n" + ); print(" - fapi2_chip_ec_feature.H Contains a function to query chip EC features\n"); print(" - attribute_plat_check.H Contains compile time checks that all attributes are\n"); print(" handled by the platform\n"); @@ -587,6 +596,85 @@ foreach my $argnum ( 0 .. $#ARGV ) } #---------------------------------------------------------------------- + # Print if the attribute has a default value + #---------------------------------------------------------------------- + if ( $parse_defaults == 1 ) + { + if ( exists $attr->{default} ) + { + print AIFILE "const bool $attr->{id}_hasDefault = true;\n"; + + #---------------------------------------------------------------- + # Handle default attribute values and printing + #---------------------------------------------------------------- + + # Need to look for and convert ENUM values. + # Need to add ULL/LL to 64 bit values + # Need to handle array inits + my $defaultVal = $attr->{default}; + my @defaultVals = split( ',', $defaultVal ); + my @defaultArray = (); + + foreach my $defVal (@defaultVals) + { + # Remove leading/trailing whitespace + $defVal =~ s/^\s+//; + $defVal =~ s/\s+$//; + + # Determine if this is an enum. If it contains a character, and it doesn't start with "0x" + # then assume it's an enum + my $defaultIsEnum = ( ( $defVal =~ /[[:alpha:]]/ ) && ( substr( $defVal, 0, 2 ) ne "0x" ) ); + if ( $defaultIsEnum && ( exists $attr->{enum} ) ) + { + $defaultVal = "fapi2::ENUM_$attr->{id}_$defVal"; + } + else + { + $defaultVal = $defVal; + if ( $attr->{valueType} eq 'uint64' ) + { + $defaultVal = $defaultVal . "ULL"; + } + elsif ( $attr->{valueType} eq 'int64' ) + { + $defaultVal = $defaultVal . "LL"; + } + } + if ( $attr->{array} ) + { + push @defaultArray, $defaultVal; + } + } + + if ( $attr->{array} ) + { + for my $idx ( 0 .. $#defaultArray ) + { + if ( $idx == 0 ) + { + $defaultVal = "{" . @defaultArray[$idx]; + } + else + { + $defaultVal = $defaultVal . "," . @defaultArray[$idx]; + } + + } + $defaultVal = $defaultVal . "}"; + + } + + print AIFILE "const $attr->{id}_Type $attr->{id}_Default = $defaultVal;\n"; + + } + else + { + print AIFILE "const bool $attr->{id}_hasDefault = false;\n"; + } + + } + + #---------------------------------------------------------------------- # Print _GETMACRO and _SETMACRO where appropriate to attribute_ids.H #---------------------------------------------------------------------- if ( exists $attr->{chipEcFeature} ) |