diff options
Diffstat (limited to 'src/usr/targeting')
-rw-r--r-- | src/usr/targeting/makefile | 3 | ||||
-rw-r--r-- | src/usr/targeting/test/targetingtest.H | 15 | ||||
-rw-r--r-- | src/usr/targeting/xmltohb/attribute_types.xml | 3 | ||||
-rw-r--r-- | src/usr/targeting/xmltohb/makefile | 1 | ||||
-rwxr-xr-x | src/usr/targeting/xmltohb/xmltohb.pl | 147 |
5 files changed, 168 insertions, 1 deletions
diff --git a/src/usr/targeting/makefile b/src/usr/targeting/makefile index 9efa436ce..438955284 100644 --- a/src/usr/targeting/makefile +++ b/src/usr/targeting/makefile @@ -49,7 +49,10 @@ OTHER_OBJS = \ util.o OBJS = ${TARGET_OBJS} ${PREDICATES_OBJS} ${ITERATORS_OBJS} ${ATTR_RP_OBJS} ${OTHER_OBJS} +OBJS += attributestrings.o attributedump.o SUBDIRS = test.d xmltohb.d include ${ROOTPATH}/config.mk + +vpath %.C ${GENDIR} diff --git a/src/usr/targeting/test/targetingtest.H b/src/usr/targeting/test/targetingtest.H index 93e0aca4a..aaba63027 100644 --- a/src/usr/targeting/test/targetingtest.H +++ b/src/usr/targeting/test/targetingtest.H @@ -59,7 +59,14 @@ #include <targeting/targreasoncodes.H> #include <errl/errludtarget.H> #include "trace.H" -#include <kernel/console.H> //@fixme + +trace_desc_t* g_trac_targeting = NULL; +TRAC_INIT(&g_trac_targeting, "TARG", 4096); + + +namespace TARGETING { +extern void dumpAllAttributes(trace_desc_t*); +}; /** * @brief Struct to hold pointers to a mutex / protected value @@ -1755,6 +1762,12 @@ class TargetingTestSuite: public CxxTest::TestSuite TS_TRACE(EXIT_MRK "testStringAttributes" ); } + + void testDump() + { + //fixme-remove this completely when RTC:38386 is done + //TARGETING::dumpAllAttributes(g_trac_targeting); + } }; #endif // End __TESTTARGETING_H diff --git a/src/usr/targeting/xmltohb/attribute_types.xml b/src/usr/targeting/xmltohb/attribute_types.xml index 7bd2c63de..7d125b392 100644 --- a/src/usr/targeting/xmltohb/attribute_types.xml +++ b/src/usr/targeting/xmltohb/attribute_types.xml @@ -2943,6 +2943,7 @@ </enumeration> </simpleType> <persistency>non-volatile</persistency> + <hasStringConversion/> <readable/> <hwpfToHbAttrMap> <id>ATTR_PROC_EPS_TABLE_TYPE</id> @@ -2978,6 +2979,7 @@ </enumeration> </simpleType> <persistency>non-volatile</persistency> + <hasStringConversion/> <readable/> <hwpfToHbAttrMap> <id>ATTR_PROC_FABRIC_PUMP_MODE</id> @@ -3011,6 +3013,7 @@ </enumeration> </simpleType> <persistency>non-volatile</persistency> + <hasStringConversion/> <readable/> <hwpfToHbAttrMap> <id>ATTR_PROC_X_BUS_WIDTH</id> diff --git a/src/usr/targeting/xmltohb/makefile b/src/usr/targeting/xmltohb/makefile index 800d928bd..92f8beeea 100644 --- a/src/usr/targeting/xmltohb/makefile +++ b/src/usr/targeting/xmltohb/makefile @@ -32,6 +32,7 @@ XMLTOHB_HEADER_TARGETS = \ fapiplatattrmacros.H XMLTOHB_SOURCE_TARGETS = \ + attributedump.C \ attributestrings.C XMLTOHB_SYSTEM_BINARIES = \ diff --git a/src/usr/targeting/xmltohb/xmltohb.pl b/src/usr/targeting/xmltohb/xmltohb.pl index c67532047..b69d1fe0d 100755 --- a/src/usr/targeting/xmltohb/xmltohb.pl +++ b/src/usr/targeting/xmltohb/xmltohb.pl @@ -182,6 +182,15 @@ if( !($cfgSrcOutputDir =~ "none") ) writeFapiPlatAttrMacrosHeaderFileContent($attributes,$fapiAttributes,$fapiPlatAttrMacrosHeaderFile); writeFapiPlatAttrMacrosHeaderFileFooter ($fapiPlatAttrMacrosHeaderFile); close $fapiPlatAttrMacrosHeaderFile; + + #fixme-Remove when RTC:38197 is done + open(ATTR_DUMP_FILE,">$cfgSrcOutputDir"."attributedump.C") + or fatal ("Attribute dump file: \"$cfgSrcOutputDir" + . "attributedump.C\" could not be opened."); + my $dumpFile = *ATTR_DUMP_FILE; + writeDumpFile($attributes,$dumpFile); + close $dumpFile; + } if( !($cfgImgOutputDir =~ "none") ) @@ -1300,6 +1309,142 @@ sub writeTraitFileFooter { VERBATIM } +#fixme-Remove when RTC:38197 is done +###### +#Create a .C file to dump all possible attributes +##### +sub writeDumpFile { + my($attributes,$outFile) = @_; + + #First setup the includes and function definition + print $outFile "#include <targeting/targetservice.H>\n"; + print $outFile "#include <stdio.h>\n"; + print $outFile "\n"; + print $outFile "namespace TARGETING\n"; + print $outFile "{\n"; + print $outFile " void dumpAllAttributes( trace_desc_t* i_trac )\n"; + print $outFile " {\n"; + print $outFile " using namespace TARGETING;\n"; + print $outFile "\n"; + print $outFile " TargetService& l_targetService = targetService();\n"; + print $outFile "\n"; + print $outFile " // Loop through every Target\n"; + print $outFile " for( TargetIterator l_targ = l_targetService.begin();\n"; + print $outFile " l_targ != l_targetService.end();\n"; + print $outFile " ++l_targ )\n"; + print $outFile " {\n"; + + # add the physical path first so we know where we are + print $outFile " { //Physical Path\n"; + print $outFile " AttributeTraits<ATTR_PHYS_PATH>::Type tmp;\n"; + print $outFile " if( (*l_targ)->tryGetAttr<ATTR_PHYS_PATH>(tmp) ) {\n"; + print $outFile " char* tmpstring = tmp.toString();\n"; + print $outFile " TRACFCOMP( i_trac, \"DUMP: --ATTR_PHYS_PATH=%s--\", tmpstring );\n"; + print $outFile " free(tmpstring);\n"; + print $outFile " }\n"; + print $outFile " }\n"; + + # loop through every attribute + foreach my $attribute (@{$attributes->{attribute}}) + { + # skip write-only attributes + if(!(exists $attribute->{readable})) { + next; + } + + # skip the PHYS_PATH that we already added + if( $attribute->{id} =~ /PHYS_PATH/ ) { + next; + } + + # Enums have strings defined already, use them + if(exists $attribute->{simpleType} && (exists $attribute->{simpleType}->{enumeration}) ) { + print $outFile " { //simpleType:enum\n"; + print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n"; + print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n"; + print $outFile " const char* tmpstr = (*l_targ)->getAttrAsString<ATTR_",$attribute->{id},">();\n"; + print $outFile " TRACFCOMP( i_trac, \"DUMP: ",$attribute->{id},"=%s\", tmpstr );\n"; + print $outFile " }\n"; + print $outFile " }\n"; + } + # signed ints dump as decimals + elsif(exists $attribute->{simpleType} + && ( (exists $attribute->{simpleType}->{int8_t}) || + (exists $attribute->{simpleType}->{int16_t}) || + (exists $attribute->{simpleType}->{int32_t}) || + (exists $attribute->{simpleType}->{int64_t}) + ) + ) + { + print $outFile " { //simpleType:int\n"; + print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n"; + print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n"; + print $outFile " TRACFCOMP( i_trac, \"DUMP: ",$attribute->{id},"=%d\", tmp );\n"; + print $outFile " }\n"; + print $outFile " }\n"; + } + # unsigned ints dump as hex + elsif(exists $attribute->{simpleType} + && ( (exists $attribute->{simpleType}->{uint8_t}) || + (exists $attribute->{simpleType}->{uint16_t}) || + (exists $attribute->{simpleType}->{uint32_t}) || + (exists $attribute->{simpleType}->{uint64_t}) + ) + ) + { + print $outFile " { //simpleType:uint\n"; + print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n"; + print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n"; + print $outFile " TRACFCOMP( i_trac, \"DUMP: ",$attribute->{id},"=0x%X\", tmp );\n"; + print $outFile " }\n"; + print $outFile " }\n"; + } + # makes no sense to dump mutex attributes, so skipping + elsif(exists $attribute->{simpleType} && (exists $attribute->{simpleType}->{hbmutex}) ) { + print $outFile " //Skipping Mutex ",$attribute->{id},"\n"; + } + # use the built-in stringifier for EntityPaths + elsif(exists $attribute->{nativeType} && ($attribute->{nativeType}->{name} eq "EntityPath")) { + print $outFile " { //nativeType:EntityPath\n"; + print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n"; + print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n"; + print $outFile " char* tmpstring = tmp.toString();\n"; + print $outFile " TRACFCOMP( i_trac, \"DUMP: ",$attribute->{id},"=%s\", tmpstring );\n"; + print $outFile " free(tmpstring);\n"; + print $outFile " }\n"; + print $outFile " }\n"; + } + # any other nativeTypes are just decimals... (I never saw one) + elsif(exists $attribute->{nativeType}) { + print $outFile " { //nativeType\n"; + print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n"; + print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n"; + print $outFile " TRACFCOMP( i_trac, \"DUMP: ",$attribute->{id},"=%d\", tmp );\n"; + print $outFile " }\n"; + print $outFile " }\n"; + } + # any complicated types just get dumped as raw hex binary + elsif(exists $attribute->{complexType}) { + print $outFile " { //complexType\n"; + print $outFile " AttributeTraits<ATTR_",$attribute->{id},">::Type tmp;\n"; + print $outFile " if( (*l_targ)->tryGetAttr<ATTR_",$attribute->{id},">(tmp) ) {\n"; + print $outFile " TRACFBIN( i_trac, \"DUMP: ",$attribute->{id},"=\", &tmp, sizeof(tmp) );\n"; + print $outFile " }\n"; + print $outFile " }\n"; + } + # just in case, add a comment about missing types + else + { + print $outFile " //Skipping ",$attribute->{id},"\n"; + } + } + + print $outFile " }\n"; + print $outFile " }\n"; + print $outFile "}\n"; + print $outFile "\n"; +} + sub UTILITY_FUNCTIONS { } ################################################################################ @@ -1311,6 +1456,8 @@ sub getAttributeIdEnumeration { my $attributeValue = 0; my $enumeration = { } ; + + # add the N/A value $enumeration->{description} = "Internal enum for attribute IDs\n"; $enumeration->{default} = "NA"; $enumeration->{enumerator}->[0]->{name} = "NA"; |