diff options
author | Nick Bofferding <bofferdn@us.ibm.com> | 2011-10-20 22:47:21 -0500 |
---|---|---|
committer | Nicholas E. Bofferding <bofferdn@us.ibm.com> | 2011-10-25 21:03:25 -0500 |
commit | 446e41da2bde65a199853230e235b0ffa631b0a8 (patch) | |
tree | 307a0bd52dae6220526dbe86c67433dc7660010d | |
parent | 0f6e334655d2eb7026e9f992a1b32b6d37915563 (diff) | |
download | talos-hostboot-446e41da2bde65a199853230e235b0ffa631b0a8.tar.gz talos-hostboot-446e41da2bde65a199853230e235b0ffa631b0a8.zip |
Add support for targeting features
- Support enums inside of complex types
- Support native types (EntityPath) inside complex types
- Support integer types (int8,int16,int32,int64)
- Determine PNOR virtual base address from host boot code
- Allow reuse of enums across multiple attributes
Change-Id: I56501b79f354c83310e86854d27de8ce9be61952
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/454
Tested-by: Jenkins Server
Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com>
-rw-r--r-- | src/include/stdint.h | 2 | ||||
-rw-r--r-- | src/include/usr/vmmconst.h | 4 | ||||
-rw-r--r-- | src/usr/targeting/targetservice.C | 15 | ||||
-rw-r--r-- | src/usr/targeting/test/targetingtest.H | 80 | ||||
-rw-r--r-- | src/usr/targeting/xmltohb/attribute_types.xml | 438 | ||||
-rw-r--r-- | src/usr/targeting/xmltohb/makefile | 9 | ||||
-rw-r--r-- | src/usr/targeting/xmltohb/target_types.xml | 1 | ||||
-rwxr-xr-x | src/usr/targeting/xmltohb/xmltohb.pl | 326 |
8 files changed, 590 insertions, 285 deletions
diff --git a/src/include/stdint.h b/src/include/stdint.h index c3e708b25..1f9ed95b9 100644 --- a/src/include/stdint.h +++ b/src/include/stdint.h @@ -25,7 +25,7 @@ #include <stddef.h> -typedef char int8_t; +typedef signed char int8_t; typedef short int int16_t; typedef int int32_t; typedef long int int64_t; diff --git a/src/include/usr/vmmconst.h b/src/include/usr/vmmconst.h index ac5ee40be..51a933edf 100644 --- a/src/include/usr/vmmconst.h +++ b/src/include/usr/vmmconst.h @@ -53,7 +53,9 @@ #define VMM_VADDR_PNOR_RP (2 * GIGABYTE) /** Attribute Resource Provider */ -#define VMM_VADDR_ATTR_RP (3 * GIGABYTE) +// Note: Not simplified to make it easier to extract with the PNOR targeting +// image generator script +#define VMM_VADDR_ATTR_RP (3ul * 1024ul * 1024ul * 1024ul) /** diff --git a/src/usr/targeting/targetservice.C b/src/usr/targeting/targetservice.C index 166fb34f8..9397a3ec0 100644 --- a/src/usr/targeting/targetservice.C +++ b/src/usr/targeting/targetservice.C @@ -40,7 +40,7 @@ #include <sys/task.h> #include <trace/interface.H> #include <initservice/taskargs.H> -#include <pnor/pnorif.H> +#include <vmmconst.h> // This component #include <targeting/targetservice.H> @@ -178,19 +178,8 @@ void TargetService::init() // Get+save pointer to beginning of targeting's swappable config in // PNOR. - //@TODO Fully account for the attribute resource provider - PNOR::SectionInfo_t l_sectionInfo; - errlHndl_t l_pElog = PNOR::getSectionInfo( - PNOR::HB_DATA, PNOR::SIDE_A, l_sectionInfo ); - if(l_pElog) - { - l_pElog->setSev(ERRORLOG::ERRL_SEV_UNRECOVERABLE); - errlCommit(l_pElog); - assert("Failed to get handle to targeting data"); - } - TargetingHeader* l_pHdr = reinterpret_cast<TargetingHeader*>( - l_sectionInfo.vaddr); + VMM_VADDR_ATTR_RP); assert(l_pHdr->eyeCatcher == PNOR_TARG_EYE_CATCHER); iv_pPnor = reinterpret_cast<uint32_t*>( diff --git a/src/usr/targeting/test/targetingtest.H b/src/usr/targeting/test/targetingtest.H index 1101bcb58..8357d90d7 100644 --- a/src/usr/targeting/test/targetingtest.H +++ b/src/usr/targeting/test/targetingtest.H @@ -1210,9 +1210,87 @@ class TargetingTestSuite: public CxxTest::TestSuite errlHndl_t l_pErrLog = static_cast<ERRORLOG::ErrlEntry*>(l_rc.releasePlatData()); ERRORLOG::errlCommit(l_pErrLog); } - } + void testPodNumericalTypes() + { + TS_TRACE(ENTER_MRK "testPodNumericalTypes" ); + + using namespace TARGETING; + using namespace fapi; + + TargetService& l_targetService = targetService(); + + TARGETING::Target* l_pTarget = NULL; + (void) l_targetService.getTopLevelTarget(l_pTarget); + if (l_pTarget == NULL) + { + TS_FAIL("Top level handle was NULL when initialization " + "complete"); + } + + NUMERIC_POD_TYPE_TEST_ATTR l_pod; + memset(&l_pod,0x00,sizeof(l_pod)); + if(!l_pTarget->tryGetAttr<TARGETING::ATTR_NUMERIC_POD_TYPE_TEST>(l_pod)) + { + TS_FAIL("Numeric POD type not found"); + } + if( (l_pod.fsiPath.type() != EntityPath::PATH_PHYSICAL) + || (l_pod.fsiPath[0].type != TYPE_SYS) + || (l_pod.fsiPath[0].instance != 0) + || (l_pod.fsiPath.size() != 1 ) ) + { + TS_FAIL("Expected physical:sys-0, got a different result"); + + } + if(l_pod.className != CLASS_CHIP) + { + TS_FAIL("Expected CLASS value of 0x%08X, got 0x%08X", + CLASS_CHIP,l_pod.className); + } + if(l_pod.uint8 != 0xAB) + { + TS_FAIL("Expected uint8_t value of 0xAB, got 0x%02X", + l_pod.uint8); + } + if (l_pod.uint16 != 0xABCD) + { + TS_FAIL("Expected uint16_t value of 0xABCD, got 0x%04X", + l_pod.uint16); + } + if (l_pod.uint32 != 0xABCDEF01) + { + TS_FAIL("Expected uint32_t value of 0xABCDEF01, got 0x%08X", + l_pod.uint32); + } + if (l_pod.uint64 != 0xABCDEF0123456789ULL) + { + TS_FAIL("Expected uint64_t value of 0xABCDEF0123456789, got 0x%016lX", + l_pod.uint64); + } + if(l_pod.int8 != -124) + { + TS_FAIL("Expected int8_t value of -124, got %d", + l_pod.int8); + } + if (l_pod.int16 != -32764) + { + TS_FAIL("Expected int16_t value of -32764, got %d", + l_pod.int16); + } + if (l_pod.int32 != -2147483644) + { + TS_FAIL("Expected int32_t value of -2147483644, got %d", + l_pod.int32); + } + if (l_pod.int64 != -9223372036854775804LL) + { + TS_FAIL("Expected int64_t value of -9223372036854775804, got %ld", + l_pod.int64); + } + + TS_TRACE(EXIT_MRK "testPodNumericalTypes" ); + } }; #endif // End __TESTTARGETING_H diff --git a/src/usr/targeting/xmltohb/attribute_types.xml b/src/usr/targeting/xmltohb/attribute_types.xml index 6adc8037a..343d791ce 100644 --- a/src/usr/targeting/xmltohb/attribute_types.xml +++ b/src/usr/targeting/xmltohb/attribute_types.xml @@ -28,45 +28,200 @@ Contains the definition of all hostboot attributes ================================================================= --> +<enumerationType> + <id>CLASS</id> + <description>Enumeration indicating the target's class</description> + <enumerator> + <name>NA</name> + <value>0</value> + </enumerator> + <enumerator> + <name>CARD</name> + <value>1</value> + </enumerator> + <enumerator> + <name>ENC</name> + <value>2</value> + </enumerator> + <enumerator> + <name>CHIP</name> + <value>3</value> + </enumerator> + <enumerator> + <name>UNIT</name> + <value>4</value> + </enumerator> + <enumerator> + <name>DEV</name> + <value>5</value> + </enumerator> + <enumerator> + <name>SYS</name> + <value>6</value> + </enumerator> + <enumerator> + <name>MAX</name> + <value>7</value> + </enumerator> + <default>NA</default> +</enumerationType> + +<enumerationType> + <id>TYPE</id> + <description>Enumeration indicating the target's type</description> + <enumerator> + <name>NA</name> + <value>0</value> + </enumerator> + <enumerator> + <name>SYS</name> + </enumerator> + <enumerator> + <name>NODE</name> + </enumerator> + <enumerator> + <name>DIMM</name> + </enumerator> + <enumerator> + <name>SCM</name> + </enumerator> + <enumerator> + <name>DCM</name> + </enumerator> + <enumerator> + <name>MEMBUF</name> + </enumerator> + <enumerator> + <name>PROC</name> + </enumerator> + <enumerator> + <name>MEMVRM</name> + </enumerator> + <enumerator> + <name>PROCVRM</name> + </enumerator> + <enumerator> + <name>EX</name> + </enumerator> + <enumerator> + <name>CORE</name> + </enumerator> + <enumerator> + <name>L2</name> + </enumerator> + <enumerator> + <name>L3</name> + </enumerator> + <enumerator> + <name>L4</name> + </enumerator> + <enumerator> + <name>MCS</name> + </enumerator> + <enumerator> + <name>MBS</name> + </enumerator> + <enumerator> + <name>MBA</name> + </enumerator> + <enumerator> + <name>MEM_PORT</name> + </enumerator> + <enumerator> + <name>PERVASIVE</name> + </enumerator> + <enumerator> + <name>POWERBUS</name> + </enumerator> + <enumerator> + <name>XBUS</name> + </enumerator> + <enumerator> + <name>ABUS</name> + </enumerator> + <enumerator> + <name>PCI</name> + </enumerator> + <enumerator> + <name>LAST_IN_RANGE</name> + </enumerator> + <default>NA</default> +</enumerationType> + +<enumerationType> + <id>MODEL</id> + <description>Enumeration indicating the target's model</description> + <enumerator> + <name>NA</name> + <value>0</value> + </enumerator> + <enumerator> + <name>SALERNO</name> + <value>16</value> + </enumerator> + <enumerator> + <name>VENICE</name> + </enumerator> + <enumerator> + <name>CENTAUR</name> + <value>48</value> + </enumerator> + <enumerator> + <name>JEDEC</name> + <value>80</value> + </enumerator> + <enumerator> + <name>CDIMM</name> + </enumerator> + <enumerator> + <name>POWER8</name> + <value>112</value> + </enumerator> + <default>NA</default> +</enumerationType> + +<enumerationType> + <id>ENGINE_TYPE</id> + <description>Enumeration indicating the target's engine type</description> + <enumerator> + <name>NA</name> + <value>0</value> + </enumerator> + <enumerator> + <name>ENGINE_IIC</name> + <value>1</value> + </enumerator> + <enumerator> + <name>ENGINE_SCOM</name> + <value>2</value> + </enumerator> + <default>NA</default> +</enumerationType> + +<enumerationType> + <id>FSI_MASTER_TYPE</id> + <description>Enumeration indicating the master's FSI type</description> + <enumerator> + <name>MFSI</name> + <value>0</value> + </enumerator> + <enumerator> + <name>CMFSI</name> + <value>1</value> + </enumerator> + <enumerator> + <name>NO_MASTER</name> + <value>2</value> + </enumerator> + <default>NO_MASTER</default> +</enumerationType> + <attribute> <id>CLASS</id> <description>Attribute indicating the target's class</description> <simpleType> <enumeration> - <description>Enumeration indicating the target's class</description> - <enumerator> - <name>NA</name> - <value>0</value> - </enumerator> - <enumerator> - <name>CARD</name> - <value>1</value> - </enumerator> - <enumerator> - <name>ENC</name> - <value>2</value> - </enumerator> - <enumerator> - <name>CHIP</name> - <value>3</value> - </enumerator> - <enumerator> - <name>UNIT</name> - <value>4</value> - </enumerator> - <enumerator> - <name>DEV</name> - <value>5</value> - </enumerator> - <enumerator> - <name>SYS</name> - <value>6</value> - </enumerator> - <enumerator> - <name>MAX</name> - <value>7</value> - </enumerator> - <default>NA</default> + <id>CLASS</id> </enumeration> </simpleType> <persistency>non-volatile</persistency> @@ -79,84 +234,7 @@ <description>Attribute indicating the target's type</description> <simpleType> <enumeration> - <description>Attribute indicating the target's type</description> - <enumerator> - <name>NA</name> - <value>0</value> - </enumerator> - <enumerator> - <name>SYS</name> - </enumerator> - <enumerator> - <name>NODE</name> - </enumerator> - <enumerator> - <name>DIMM</name> - </enumerator> - <enumerator> - <name>SCM</name> - </enumerator> - <enumerator> - <name>DCM</name> - </enumerator> - <enumerator> - <name>MEMBUF</name> - </enumerator> - <enumerator> - <name>PROC</name> - </enumerator> - <enumerator> - <name>MEMVRM</name> - </enumerator> - <enumerator> - <name>PROCVRM</name> - </enumerator> - <enumerator> - <name>EX</name> - </enumerator> - <enumerator> - <name>CORE</name> - </enumerator> - <enumerator> - <name>L2</name> - </enumerator> - <enumerator> - <name>L3</name> - </enumerator> - <enumerator> - <name>L4</name> - </enumerator> - <enumerator> - <name>MCS</name> - </enumerator> - <enumerator> - <name>MBS</name> - </enumerator> - <enumerator> - <name>MBA</name> - </enumerator> - <enumerator> - <name>MEM_PORT</name> - </enumerator> - <enumerator> - <name>PERVASIVE</name> - </enumerator> - <enumerator> - <name>POWERBUS</name> - </enumerator> - <enumerator> - <name>XBUS</name> - </enumerator> - <enumerator> - <name>ABUS</name> - </enumerator> - <enumerator> - <name>PCI</name> - </enumerator> - <enumerator> - <name>LAST_IN_RANGE</name> - </enumerator> - <default>NA</default> + <id>TYPE</id> </enumeration> </simpleType> <persistency>non-volatile</persistency> @@ -169,34 +247,7 @@ <description>Attribute indicating the target's model</description> <simpleType> <enumeration> - <description>Enumeration indicating the target's model</description> - <enumerator> - <name>NA</name> - <value>0</value> - </enumerator> - <enumerator> - <name>SALERNO</name> - <value>16</value> - </enumerator> - <enumerator> - <name>VENICE</name> - </enumerator> - <enumerator> - <name>CENTAUR</name> - <value>48</value> - </enumerator> - <enumerator> - <name>JEDEC</name> - <value>80</value> - </enumerator> - <enumerator> - <name>CDIMM</name> - </enumerator> - <enumerator> - <name>POWER8</name> - <value>112</value> - </enumerator> - <default>NA</default> + <id>MODEL</id> </enumeration> </simpleType> <persistency>non-volatile</persistency> @@ -209,20 +260,7 @@ <description>Attribute indicating the target's engine type</description> <simpleType> <enumeration> - <description>Enumeration indicating the target's engine type</description> - <enumerator> - <name>NA</name> - <value>0</value> - </enumerator> - <enumerator> - <name>ENGINE_IIC</name> - <value>1</value> - </enumerator> - <enumerator> - <name>ENGINE_SCOM</name> - <value>2</value> - </enumerator> - <default>NA</default> + <id>ENGINE_TYPE</id> </enumeration> </simpleType> <persistency>non-volatile</persistency> @@ -235,7 +273,7 @@ <description>Scratch attribute that can be used for dev/test</description> <simpleType> <uint8_t> - <default>0</default> + <default>0</default> </uint8_t> </simpleType> <persistency>volatile-zeroed</persistency> @@ -699,23 +737,11 @@ <description>Type of Master FSI connection to this slave (MFSI or cMFSI)</description> <simpleType> <enumeration> - <description>Enumeration indicating the master's FSI type</description> - <enumerator> - <name>MFSI</name> - <value>0</value> - </enumerator> - <enumerator> - <name>CMFSI</name> - <value>1</value> - </enumerator> - <enumerator> - <name>NO_MASTER</name> - <value>2</value> - </enumerator> - <default>NO_MASTER</default> + <id>FSI_MASTER_TYPE</id> </enumeration> </simpleType> <persistency>non-volatile</persistency> + <hasStringConversion/> <readable/> </attribute> @@ -766,6 +792,7 @@ <persistency>non-volatile</persistency> <readable/> </attribute> + <attribute> <id>HWAS_STATE</id> <description>HardWare Availability Service State Attribute. @@ -818,6 +845,7 @@ <persistency>volatile</persistency> <readable/> </attribute> + <attribute> <id>MSS_EFF_PRIMARY_RANK</id> <description>The effective rank group on each port (0 to 3) for each group 0-3</description> @@ -835,5 +863,77 @@ <macro>DIRECT</macro> </hwpfToHbAttrMap> </attribute> + +<!-- For POD Testing --> +<attribute> + <id>NUMERIC_POD_TYPE_TEST</id> + <description>Attribute which tests numeric POD types</description> + <complexType> + <description>Numeric POD type test structure</description> + <field> + <name>fsiPath</name> + <description>Entity path for testing purposes</description> + <type>EntityPath</type> + <default>physical:sys-0</default> + </field> + <field> + <name>className</name> + <description>Class for testing purposes</description> + <type>CLASS</type> + <default>CHIP</default> + </field> + <field> + <name>uint8</name> + <description>Test uint8</description> + <type>uint8_t</type> + <default>0xAB</default> + </field> + <field> + <name>uint16</name> + <description>Test uint16</description> + <type>uint16_t</type> + <default>0xABCD</default> + </field> + <field> + <name>uint32</name> + <description>Test uint32</description> + <type>uint32_t</type> + <default>0xABCDEF01</default> + </field> + <field> + <name>uint64</name> + <description>Test uint64</description> + <type>uint64_t</type> + <default>0xABCDEF0123456789</default> + </field> + <field> + <name>int8</name> + <description>Test int8</description> + <type>int8_t</type> + <default>-124</default> + </field> + <field> + <name>int16</name> + <description>Test int16</description> + <type>int16_t</type> + <default>-32764</default> + </field> + <field> + <name>int32</name> + <description>Test int32</description> + <type>int32_t</type> + <default>-2147483644</default> + </field> + <field> + <name>int64</name> + <description>Test int64</description> + <type>int64_t</type> + <default>-9223372036854775804</default> + </field> + </complexType> + <persistency>non-volatile</persistency> + <readable/> +</attribute> + </attributes> diff --git a/src/usr/targeting/xmltohb/makefile b/src/usr/targeting/xmltohb/makefile index d4e28dab7..b6234fc60 100644 --- a/src/usr/targeting/xmltohb/makefile +++ b/src/usr/targeting/xmltohb/makefile @@ -48,6 +48,9 @@ XMLTOHB_GENERIC_SOURCES = attribute_types.xml target_types.xml XMLTOHB_FAPIATTR_SOURCES = \ ${ROOTPATH}/src/usr/hwpf/hwp/fapiHwpAttributeInfo.xml +VMM_CONSTS_FILE = \ + ${ROOTPATH}/src/include/usr/vmmconst.h + GENFILES = ${XMLTOHB_TARGETS} EXTRA_PARTS = $(addprefix $(IMGDIR)/, $(XMLTOHB_SYSTEM_BINARIES)) @@ -81,14 +84,14 @@ $(call GENTARGET,$(XMLTOHB_TARGETS)) : \ ${GENDIR}/%.hb.xml: %.system.xml ${XMLTOHB_GENERIC_SOURCES} ./mergexml.sh $^ > $@ - # create the binary files -${GENDIR}/%_targeting.bin: xmltohb.pl ${GENDIR}/%.hb.xml ${XMLTOHB_FAPIATTR_SOURCES} +${GENDIR}/%_targeting.bin: xmltohb.pl ${GENDIR}/%.hb.xml ${XMLTOHB_FAPIATTR_SOURCES} ${VMM_CONSTS_FILE} ./$< $(addprefix --hb-xml-file=,${GENDIR}/$*.hb.xml) \ $(addprefix --fapi-attributes-xml-file=,\ ${XMLTOHB_FAPIATTR_SOURCES}) \ --src-output-dir=none --img-output-dir=$(dir $@) \ - --img-output-file=$(notdir $@) + --img-output-file=$(notdir $@) \ + --vmm-consts-file=$(VMM_CONSTS_FILE) diff --git a/src/usr/targeting/xmltohb/target_types.xml b/src/usr/targeting/xmltohb/target_types.xml index 5cd23608d..2b0cbfe6c 100644 --- a/src/usr/targeting/xmltohb/target_types.xml +++ b/src/usr/targeting/xmltohb/target_types.xml @@ -59,6 +59,7 @@ <attribute><id>SCRATCH_UINT32_ARRAY_2</id></attribute> <attribute><id>SCRATCH_UINT64_ARRAY_1</id></attribute> <attribute><id>SCRATCH_UINT64_ARRAY_2</id></attribute> + <attribute><id>NUMERIC_POD_TYPE_TEST</id></attribute> <attribute><id>DUMMY_RW</id></attribute> <attribute> <id>XSCOM_BASE_ADDRESS</id> diff --git a/src/usr/targeting/xmltohb/xmltohb.pl b/src/usr/targeting/xmltohb/xmltohb.pl index c0eb36949..266f2b522 100755 --- a/src/usr/targeting/xmltohb/xmltohb.pl +++ b/src/usr/targeting/xmltohb/xmltohb.pl @@ -46,6 +46,8 @@ use Text::Wrap; use Data::Dumper; use POSIX; + + ################################################################################ # Process command line parameters, issue help text if needed ################################################################################ @@ -54,6 +56,7 @@ sub main{ } my $cfgSrcOutputDir = "."; my $cfgImgOutputDir = "."; my $cfgHbXmlFile = "./hb.xml"; +my $cfgVmmConstsFile = "../../../include/usr/vmmconst.h"; my $cfgFapiAttributesXmlFile = "../../hwpf/hwp/fapiHwpAttributeInfo.xml"; my $cfgImgOutputFile = "./targeting.bin"; my $cfgHelp = 0; @@ -65,6 +68,7 @@ GetOptions("hb-xml-file:s" => \$cfgHbXmlFile, "img-output-dir:s" => \$cfgImgOutputDir, "fapi-attributes-xml-file:s" => \$cfgFapiAttributesXmlFile, "img-output-file:s" => \$cfgImgOutputFile, + "vmm-consts-file:s" => \$cfgVmmConstsFile, "help" => \$cfgHelp, "man" => \$cfgMan, "verbose" => \$cfgVerbose ) || pod2usage(-verbose => 0); @@ -89,6 +93,7 @@ if($cfgVerbose) print STDOUT "Fapi attributes XML file = $cfgFapiAttributesXmlFile\n"; print STDOUT "Source output dir = $cfgSrcOutputDir\n"; print STDOUT "Image output dir = $cfgImgOutputDir\n"; + print STDOUT "VMM constants file = $cfgVmmConstsFile\n"; } ################################################################################ @@ -100,7 +105,7 @@ my $xml = new XML::Simple (KeyAttr=>[]); # Until full machine parseable workbook parsing splits out all the input files, # use the intermediate representation containing the full host boot model. # Aborts application if file name not found. -my $attributes = $xml->XMLin($cfgHbXmlFile, forcearray => ['attribute','hwpfToHbAttrMap']); +my $attributes = $xml->XMLin($cfgHbXmlFile, forcearray => ['enumerationType','attribute','hwpfToHbAttrMap']); my $fapiAttributes = $xml->XMLin($cfgFapiAttributesXmlFile, forcearray => ['attribute']); # Perform some sanity validation of the model (so we don't have to later) @@ -180,7 +185,7 @@ if( !($cfgImgOutputDir =~ "none") ) or fatal ("Targeting image file: \"$cfgImgOutputDir" . "$cfgImgOutputFile\" could not be opened."); my $pnorFile = *PNOR_TARGETING_FILE; - writeTargetingImage($pnorFile,$attributes); + writeTargetingImage($pnorFile,$cfgVmmConstsFile,$attributes); close $pnorFile; } @@ -677,8 +682,9 @@ sub writeStringImplementationFileStrings { print $outFile "{\n"; print $outFile " switch(i_attrValue)\n"; print $outFile " {\n"; + my $enumerationType = getEnumerationType($attributes,$enumeration->{id}); - foreach my $enumerator (@{$enumeration->{enumerator}}) + foreach my $enumerator (@{$enumerationType->{enumerator}}) { print $outFile " case ", $attribute->{id}, "_", $enumerator->{name},":\n"; @@ -697,6 +703,32 @@ sub writeStringImplementationFileStrings { } ################################################################################ +# Locate generic attribute definition, given an enumeration ID +################################################################################ + +sub getEnumerationType { + + my($attributes,$id) = @_; + my $matchingEnumeration; + + foreach my $enumerationType (@{$attributes->{enumerationType}}) + { + if($id eq $enumerationType->{id}) + { + $matchingEnumeration = $enumerationType; + last; + } + } + + if(!exists $matchingEnumeration->{id}) + { + fatal("Could not find enumeration with ID of " . $id . "\n"); + } + + return $matchingEnumeration; +} + +################################################################################ # Writes the string implementation file footer ################################################################################ @@ -1011,31 +1043,23 @@ sub writeEnumFileAttrEnums { select($outFile); $~ = 'ENUMFORMAT'; - foreach my $attribute (@{$attributes->{attribute}}) + foreach my $enumerationType (@{$attributes->{enumerationType}}) { - if(exists $attribute->{simpleType}) - { - my $simpleType = $attribute->{simpleType}; - if(exists $simpleType->{enumeration}) - { - my $enumeration = $simpleType->{enumeration}; - print $outFile "/**\n"; - print $outFile wrapBrief( $enumeration->{description} ); - print $outFile " */\n"; - print $outFile "enum ", $attribute->{id}, "\n"; - print $outFile "{\n"; - - foreach my $enumerator (@{$enumeration->{enumerator}}) - { - $enumHex = sprintf "0x%08X", - enumNameToValue($enumeration,$enumerator->{name}); - $enumName = $attribute->{id} . "_" . $enumerator->{name}; - write; - } + print $outFile "/**\n"; + print $outFile wrapBrief( $enumerationType->{description} ); + print $outFile " */\n"; + print $outFile "enum ", $enumerationType->{id}, "\n"; + print $outFile "{\n"; - print $outFile "};\n\n"; - } + foreach my $enumerator (@{$enumerationType->{enumerator}}) + { + $enumHex = sprintf "0x%08X", + enumNameToValue($enumerationType,$enumerator->{name}); + $enumName = $enumerationType->{id} . "_" . $enumerator->{name}; + write; } + + print $outFile "};\n\n"; } } @@ -1265,7 +1289,7 @@ sub getAttributeIdEnumeration { sub unhexify { my($val) = @_; - if($val =~ m/^0[xX][0123456790A-Fa-f]+$/) + if($val =~ m/^0[xX][01234567890A-Fa-f]+$/) { $val = hex($val); } @@ -1279,9 +1303,9 @@ sub unhexify { sub packQuad{ my($quad) = @_; - unhexify($quad); + my $value = unhexify($quad); - return pack("NN" , $quad >> 32, $quad); + return pack("NN" , (($value >> 32) & 0xFFFFFFFF), ($value & 0xFFFFFFFF)); } ################################################################################ @@ -1408,6 +1432,35 @@ sub getInstantiatedTargetTypes { } ################################################################################ +# Return default value of zero for an attribute which is a POD numerical type +################################################################################ + +sub defaultZero { + my($attributes,$typeInstance) = @_; + + # print STDOUT "Attribute's default value is 0\n"; + + return 0; +} + +################################################################################ +# Return default value for an attribute whose type is 'enumeration' +################################################################################ + +sub defaultEnum { + my($attributes,$enumerationInstance) = @_; + + my $enumerationType = getEnumerationType( + $attributes,$enumerationInstance->{id}); + + # print STDOUT "Attribute enumeration's " . + # "(\"$enumerationType->{id}\") default is: " . + # $enumerationType->{default} . "\n"; + + return $enumerationType->{default}; +} + +################################################################################ # Get hash ref to supported simple types and their properties ################################################################################ @@ -1417,11 +1470,15 @@ sub simpleTypeProperties { # Intentionally didn't wrap these to 80 columns to keep them lined up and # more readable/editable - $typesHoH{"uint8_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "uint8_t" , bytes => 1, bits => 8 , packfmt => "C" }; - $typesHoH{"uint16_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "uint16_t" , bytes => 2, bits => 16, packfmt => "S" }; - $typesHoH{"uint32_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "uint32_t" , bytes => 4, bits => 32, packfmt => "L" }; - $typesHoH{"uint64_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "uint64_t" , bytes => 8, bits => 64, packfmt =>\&packQuad }; - $typesHoH{"enumeration"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 0, typeName => "XMLTOHB_USE_PARENT_ATTR_ID" , bytes => 0, bits => 0 , packfmt => "packEnumeration" }; + $typesHoH{"int8_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "int8_t" , bytes => 1, bits => 8 , default => \&defaultZero, packfmt => "C" }; + $typesHoH{"int16_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "int16_t" , bytes => 2, bits => 16, default => \&defaultZero, packfmt => "n" }; + $typesHoH{"int32_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "int32_t" , bytes => 4, bits => 32, default => \&defaultZero, packfmt => "N" }; + $typesHoH{"int64_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "int64_t" , bytes => 8, bits => 64, default => \&defaultZero, packfmt =>\&packQuad}; + $typesHoH{"uint8_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "uint8_t" , bytes => 1, bits => 8 , default => \&defaultZero, packfmt => "C" }; + $typesHoH{"uint16_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "uint16_t" , bytes => 2, bits => 16, default => \&defaultZero, packfmt => "n" }; + $typesHoH{"uint32_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "uint32_t" , bytes => 4, bits => 32, default => \&defaultZero, packfmt => "N" }; + $typesHoH{"uint64_t"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 1, typeName => "uint64_t" , bytes => 8, bits => 64, default => \&defaultZero, packfmt =>\&packQuad}; + $typesHoH{"enumeration"} = { supportsArray => 1, canBeHex => 1, complexTypeSupport => 0, typeName => "XMLTOHB_USE_PARENT_ATTR_ID" , bytes => 0, bits => 0 , default => \&defaultEnum, packfmt => "packEnumeration"}; return \%typesHoH; } @@ -1446,10 +1503,18 @@ sub getAttributeDefault { { # Note: must check for 'type' before 'default', otherwise # might add value to the hash - if( exists $attribute->{simpleType}->{$type} - && exists $attribute->{simpleType}->{$type}->{default}) + if(exists $attribute->{simpleType}->{$type} ) { - $default = $attribute->{simpleType}->{$type}->{default}; + if(exists $attribute->{simpleType}->{$type}->{default}) + { + $default = + $attribute->{simpleType}->{$type}->{default}; + } + else + { + $default = $simpleTypeProperties->{$type}{default}->( + $attributes,$attribute->{simpleType}->{$type} ); + } last; } } @@ -1730,7 +1795,7 @@ sub releaseAndClear { ################################################################################ sub packComplexType { - my ($complexType,$attributeDefault) = @_; + my ($attributes,$complexType,$attributeDefault) = @_; my $binaryData; my $simpleTypeProperties = simpleTypeProperties(); @@ -1761,10 +1826,23 @@ sub packComplexType { else { $binaryData .= $accumulator->releaseAndClear(); - + + # If native "EntityPath" type, process accordingly + if($field->{type} eq "EntityPath") + { + $binaryData .= packEntityPath($attributes,$default->{value}); + } + # If not a defined simple type, process as an enumeration + elsif(!exists $simpleTypeProperties->{$field->{type}}) + { + my $enumerationType = getEnumerationType( + $attributes,$field->{type}); + my $enumeratorValue = enumNameToValue($enumerationType,$default->{value}); + $binaryData .= packEnumeration($enumerationType,$enumeratorValue); + } # Pack easy types using 'pack', otherwise invoke appropriate # (possibly workaround) callback function - if(exists $simpleTypeProperties->{$field->{type}} + elsif(exists $simpleTypeProperties->{$field->{type}} && $simpleTypeProperties->{$field->{type}} {complexTypeSupport}) { @@ -1811,6 +1889,68 @@ sub packComplexType { } ################################################################################ +# Pack an entity path into a binary data stream +################################################################################ + +sub packEntityPath { + my($attributes,$value) = @_; + + my $binaryData; + + my $maxPathElements = 8; + my ($typeStr,$path) = split(/:/,$value); + my (@paths) = split(/\//,$path); + + my $type = 0; + if($typeStr eq "physical") + { + $type = 2; + } + elsif($typeStr eq "affinity") + { + $type = 1; + } + else + { + fatal("Unsupported enity path type."); + } + + if( (scalar @paths) > $maxPathElements) + { + fatal("Path elements cannot be greater than $maxPathElements."); + } + + $binaryData .= pack("C", (0xF0 & ($type << 4)) + + (0x0F & (scalar @paths))); + + foreach my $pathElement (@paths) + { + my ($pathType,$pathInstance) = split(/-/,$pathElement); + $pathType = uc($pathType); + + foreach my $attr (@{$attributes->{attribute}}) + { + if($attr->{id} eq "TYPE") + { + $pathType = + enumNameToValue( + getEnumerationType($attributes, + $attr->{simpleType}->{enumeration}->{id}),$pathType); + $binaryData .= pack ("CC", $pathType, $pathInstance); + last; + } + } + } + + if($maxPathElements > (scalar @paths)) + { + $binaryData .= pack("C".(($maxPathElements - scalar @paths)*2)); + } + + return $binaryData; +} + +################################################################################ # Pack an attribute into a binary data stream ################################################################################ @@ -1830,7 +1970,7 @@ sub packAttribute { { if($typeName eq "enumeration") { - my $enumeration = $simpleType->{enumeration}; + my $enumeration = getEnumerationType($attributes,$simpleType->{enumeration}->{id}); # Here $value is the enumerator name my $enumeratorValue = enumNameToValue($enumeration,$value); @@ -1887,7 +2027,7 @@ sub packAttribute { { if(ref ($value) eq "HASH" ) { - $binaryData = packComplexType($attribute->{complexType},$value); + $binaryData = packComplexType($attributes,$attribute->{complexType},$value); } else { @@ -1898,54 +2038,7 @@ sub packAttribute { { if($attribute->{nativeType}->{name} eq "EntityPath") { - my $maxPathElements = 8; - my ($typeStr,$path) = split(/:/,$value); - my (@paths) = split(/\//,$path); - - my $type = 0; - if($typeStr eq "physical") - { - $type = 2; - } - elsif($typeStr eq "affinity") - { - $type = 1; - } - else - { - fatal("Unsupported enity path type."); - } - - if( (scalar @paths) > $maxPathElements) - { - fatal("Path elements cannot be greater than $maxPathElements."); - } - - $binaryData .= pack("C", (0xF0 & ($type << 4)) + - (0x0F & (scalar @paths))); - - foreach my $pathElement (@paths) - { - my ($pathType,$pathInstance) = split(/-/,$pathElement); - $pathType = uc($pathType); - - foreach my $attr (@{$attributes->{attribute}}) - { - if($attr->{id} eq "TYPE") - { - $pathType = - enumNameToValue( - $attr->{simpleType}->{enumeration},$pathType); - $binaryData .= pack ("CC", $pathType, $pathInstance); - last; - } - } - } - - if($maxPathElements > (scalar @paths)) - { - $binaryData .= pack("C".(($maxPathElements - scalar @paths)*2)); - } + $binaryData = packEntityPath($attributes,$value); } else { @@ -1967,11 +2060,41 @@ sub packAttribute { } ################################################################################ +# Get the PNOR base address from host boot code +################################################################################ + +sub getPnorBaseAddress { + my($vmmConstsFile) = @_; + my $pnorBaseAddress = 0; + + open(VMM_CONSTS_FILE,"<$vmmConstsFile") + or fatal ("VMM Constants file: \"$vmmConstsFile\" could not be opened."); + + foreach my $line (<VMM_CONSTS_FILE>) + { + chomp($line); + if( $line =~ /VMM_VADDR_ATTR_RP/) + { + $line =~ s/[^0-9\*]//g; + $pnorBaseAddress = eval $line; + last; + } + } + + if($pnorBaseAddress == 0) + { + fatal("PNOR base address was zero!"); + } + + return $pnorBaseAddress; +} + +################################################################################ # Write the PNOR targeting image ################################################################################ sub writeTargetingImage { - my($outFile, $attributes) = @_; + my($outFile, $vmmConstsFile, $attributes) = @_; # 128 MB virtual memory offset between sections #@TODO Need the final value after full host boot support is implemented. @@ -1980,9 +2103,7 @@ sub writeTargetingImage { # Virtual memory addresses corresponding to the start of the targeting image # PNOR/heap sections - #@TODO Need the final value of the base address after full host boot support - # is implemented. - my $pnorRoBaseAddress = 0xC0000000; # 3GB - See vmmconst.H. + my $pnorRoBaseAddress = getPnorBaseAddress($vmmConstsFile); my $pnorRwBaseAddress = $pnorRoBaseAddress + $vmmSectionOffset; my $heapPnorInitBaseAddr = $pnorRwBaseAddress + $vmmSectionOffset; my $heapZeroInitBaseAddr = $heapPnorInitBaseAddr + $vmmSectionOffset; @@ -2068,7 +2189,7 @@ sub writeTargetingImage { # Reserve # pointers * sizeof(pointer) my $startOfAttributePointers = $offset; - print "Total attributes = $numAttributes\n"; + # print "Total attributes = $numAttributes\n"; $offset += ($numAttributes * (length packQuad(0) )); # Now we can determine the pointer to the number of targets @@ -2197,8 +2318,9 @@ sub writeTargetingImage { my $rwdata = packAttribute($attributes,$attributeDef, $attrhash{$attributeId}->{default}); - print "Wrote to pnor-rw value ",$attributeDef->{id}, ", - ", $attrhash{$attributeId}->{default}," \n"; + #print "Wrote to pnor-rw value ",$attributeDef->{id}, ", + #", $attrhash{$attributeId}->{default}," \n"; + $attributePointerBinData .= packQuad( $rwOffset + $pnorRwBaseAddress); @@ -2255,7 +2377,6 @@ sub writeTargetingImage { } # Build header data - #@TODO Need header file for host boot which lays out the header my $headerBinData; my $blockSize = 4*1024; @@ -2391,6 +2512,17 @@ directory) Sets the output directory for generated binary files (default is the current directory) +=item B<--img-output-file>=FILE + +Sets the file to receive the PNOR targeting image output (default +./targeting.bin). Only used when generating the PNOR targeting image + +=item B<--vmm-consts-file>=FILE + +Indicates the file containing the base virtual address of the attributes +(default is src/include/usr/vmmconst.h). Only used when generating the PNOR +targeting image + =item B<--verbose> Prints out some internal workings |