diff options
-rwxr-xr-x | src/build/buildpnor/buildpnor.pl | 38 | ||||
-rw-r--r-- | src/build/buildpnor/makefile | 16 | ||||
-rw-r--r-- | src/build/buildpnor/pnorLayout.xml | 14 | ||||
-rw-r--r-- | src/include/usr/pnor/pnorif.H | 3 | ||||
-rw-r--r-- | src/usr/pnor/pnorrp.C | 9 | ||||
-rw-r--r-- | src/usr/pnor/pnorrp.H | 1 | ||||
-rw-r--r-- | src/usr/pnor/test/pnorddtest.H | 146 |
7 files changed, 181 insertions, 46 deletions
diff --git a/src/build/buildpnor/buildpnor.pl b/src/build/buildpnor/buildpnor.pl index b582822ba..94c0036d0 100755 --- a/src/build/buildpnor/buildpnor.pl +++ b/src/build/buildpnor/buildpnor.pl @@ -43,7 +43,7 @@ $XML::Simple::PREFERRED_PARSER = 'XML::Parser'; my $TRAC_ERR = 0; # 0=errors, >0 for more traces, leaving at 1 to keep key milestone traces. -my $g_trace = 1; +my $g_trace = 1; my $programName = File::Basename::basename $0; my %tocLayout; @@ -56,6 +56,7 @@ my $pnorBinName = ""; my $tocVersion = 0x1; my $genTocFlag = 0; my $g_TOCEyeCatch = "part"; +my $emitTestSections = 0; if ($#ARGV < 0) { usage(); @@ -90,6 +91,9 @@ for (my $i=0; $i < $#ARGV + 1; $i++) my $argVal = $ARGV[++$i]; saveInputFile("--binFile", $argName, $argVal, \%binFiles); } + elsif($ARGV[$i] =~ /--test/) { + $emitTestSections = 1; + } else { traceErr("Unrecognized Input: $ARGV[$i]"); exit 1; @@ -188,7 +192,7 @@ sub loadPnorLayout { traceErr("$this_func: File not found: $i_pnorFile"); return -1; - } + } #parse the input XML file my $xs = new XML::Simple(keyattr=>[], forcearray => 1); @@ -226,6 +230,11 @@ sub loadPnorLayout my $source = $sectionEl->{source}[0]; my $sideless = $sectionEl->{sideless}[0]; + if (($emitTestSections == 0) && ($sectionEl->{testonly}[0] eq "yes")) + { + next; + } + my $actualRegionSize = 0; if(exists($sectionEl->{actualRegionSize}[0])) { @@ -272,8 +281,8 @@ sub genToc #Insert FFS Header data #HEADER WORD 1: Magic Number - "PART" in ASCII - my @charArray = split //, 'PART'; - my $curChar; + my @charArray = split //, 'PART'; + my $curChar; foreach $curChar (@charArray) { print $FILEHANDLE pack('C', ord($curChar)); @@ -433,7 +442,7 @@ sub genToc { insertPadBytes($FILEHANDLE, 4); } - + #FFS User Word 2-3: Miscellaneous information. #User Word 2, bit 18 indicates sideless. my $miscInfo = 0x00000000; @@ -451,7 +460,7 @@ sub genToc #FFS Entry Word 31: Checksum - not currently implemented insertPadBytes($FILEHANDLE, 4); - + } return 0; @@ -486,7 +495,7 @@ sub fillTocActSize { $size=$size*(9/8); } - + trace(2, "$this_func: PNOR FFS contains $recordCount records, total Size=$size"); $$i_pnorLayoutRef{sections}{$tocLayoutKey}{actualRegionSize}=$size; @@ -557,7 +566,7 @@ sub findLayoutKeyByEyeCatch last; } } - + return $layoutKey; } @@ -694,8 +703,8 @@ sub assemblePnorImage trace(1, "$this_func: populating section $eyeCatch, filename=$if"); # my $ddCmd = `dd if=$if ibs=8c of=$i_pnorBinName obs=8c seek=$physicalOffset`; my $ddCmd = `dd if=$if ibs=1b of=$i_pnorBinName obs=1b seek=$blockSeek conv=notrunc`; - - + + } @@ -722,7 +731,7 @@ sub saveInputFile #no return code expected } - + ################################################# # getFFSEntrySize: Returns number of bytes in an ffs_entry based on specified version ################################################# @@ -735,7 +744,7 @@ sub getFFSEntrySize if($i_tocVersion == 0x1) { #16 char name + 12 fixed words + 16 user data words - $ffsEntrySize = 16+(12*4)+(16*4); + $ffsEntrySize = 16+(12*4)+(16*4); } else { @@ -747,7 +756,7 @@ sub getFFSEntrySize ################################################# # Insert specifed number of pad bytes into file -# +# ################################################# sub insertPadBytes { @@ -822,7 +831,7 @@ print <<"ENDUSAGE"; -h Print this help text --pnorlayout <file> PNOR Layout XML file --pnorOutBin <file> Name of output file for PNOR Binary - --genToc Indicates you wish to generate a table of contents. It will + --genToc Indicates you wish to generate a table of contents. It will write the file indicated by --binFile_TOC. --binFile_<Section> <file> This is a special paramater. It is used to specify @@ -833,6 +842,7 @@ print <<"ENDUSAGE"; --binFile_TOC murano.toc A section declared as Blank in the XML does not need to have a binFile specified + --test Output test-only sections. Current Limitations: --TOC Records must be 4 or 8 bytes in length diff --git a/src/build/buildpnor/makefile b/src/build/buildpnor/makefile index 2696a417a..0c8a94a09 100644 --- a/src/build/buildpnor/makefile +++ b/src/build/buildpnor/makefile @@ -34,6 +34,7 @@ ROOTPATH = ../../.. PNOR_TARGETS = simics_MURANO simics_VENICE TULETA PNOR_VBU_TARGETS = vbu +#Murano/Venice IPL PNOR images define PNOR_template $${IMGDIR}/$(1).pnor: $${IMGDIR}/hbicore_extended.bin $${IMGDIR}/$(1)_targeting.bin ./buildpnor.pl --pnorLayout ./pnorLayout.xml \ @@ -44,12 +45,14 @@ $${IMGDIR}/$(1).pnor: $${IMGDIR}/hbicore_extended.bin $${IMGDIR}/$(1)_targeting. --binFile_HBD $${IMGDIR}/$(1)_targeting.bin \ --binFile_HBB $${IMGDIR}/hbicore.bin endef + +#Murano/Venice Test case Pnor Image define PNOR_test_template $${IMGDIR}/$(1)_test.pnor: $${IMGDIR}/hbicore_extended.bin $${IMGDIR}/$(1)_targeting.bin - ./buildpnor.pl --pnorLayout ./pnorLayout.xml \ + ./buildpnor.pl --pnorLayout ./pnorLayout.xml --test \ --genToc \ --pnorOutBin $${IMGDIR}/$(1)_test.pnor \ - --binFile_part $${IMGDIR}/$(1)_pnor.toc \ + --binFile_part $${IMGDIR}/$(1)_test_pnor.toc \ --binFile_HBI $${IMGDIR}/hbicore_test_extended.bin \ --binFile_HBD $${IMGDIR}/$(1)_targeting.bin \ --binFile_HBB $${IMGDIR}/hbicore_test.bin @@ -66,10 +69,10 @@ $${IMGDIR}/$(1).pnor: $${IMGDIR}/hbicore_extended.bin $${IMGDIR}/$(1)_targeting. endef define PNOR_vbu_test_template $${IMGDIR}/$(1)_test.pnor: $${IMGDIR}/hbicore_extended.bin $${IMGDIR}/$(1)_targeting.bin - ./buildpnor.pl --pnorLayout ./pnorLayoutVpo.xml \ + ./buildpnor.pl --pnorLayout ./pnorLayoutVpo.xml --test \ --genToc \ --pnorOutBin $${IMGDIR}/$(1)_test.pnor \ - --binFile_part $${IMGDIR}/$(1)_pnor.toc \ + --binFile_part $${IMGDIR}/$(1)_test_pnor.toc \ --binFile_HBI $${IMGDIR}/hbicore_test_extended.bin \ --binFile_HBD $${IMGDIR}/$(1)_targeting.bin endef @@ -78,13 +81,14 @@ PNOR_IMAGES = $(addsuffix .pnor, $(addprefix $(IMGDIR)/, ${PNOR_TARGETS})) \ $(addsuffix _test.pnor, $(addprefix $(IMGDIR)/, ${PNOR_TARGETS})) PNOR_VBU_IMAGES = $(addsuffix .pnor, $(addprefix $(IMGDIR)/, ${PNOR_VBU_TARGETS})) \ - $(addsuffix .pnor, $(addprefix $(IMGDIR)/, ${PNOR_VBU_TARGETS})) \ + $(addsuffix _test.pnor, $(addprefix $(IMGDIR)/, ${PNOR_VBU_TARGETS})) \ EXTRA_CLEAN = ${PNOR_IMAGES} ${PNOR_IMAGES:.pnor=_pnor.toc} ${PNOR_VBU_IMAGES} ${PNOR_VBU_IMAGES:.pnor=_pnor.toc} include ${ROOTPATH}/config.mk -buildpnor: ${PNOR_IMAGES} +.PHONY: buildpnor +buildpnor: ${PNOR_IMAGES} ${PNOR_VBU_IMAGES} #Standard Images $(foreach pnor,$(PNOR_TARGETS),$(eval $(call PNOR_template,$(pnor)))) diff --git a/src/build/buildpnor/pnorLayout.xml b/src/build/buildpnor/pnorLayout.xml index 6fba782b4..f3bd5e59b 100644 --- a/src/build/buildpnor/pnorLayout.xml +++ b/src/build/buildpnor/pnorLayout.xml @@ -72,7 +72,7 @@ <ecc>no</ecc> <source>File</source> <sideless>no</sideless> - </section> + </section> <section> <description>Hostboot Base (512K)</description> <eyeCatch>HBB</eyeCatch> @@ -83,4 +83,16 @@ <source>File</source> <sideless>no</sideless> </section> + <section> + <description>Special PNOR Test Space (32K)</description> + <eyeCatch>TEST</eyeCatch> + <physicalOffset>0x441000</physicalOffset> + <physicalRegionSize>0x8000</physicalRegionSize> + <actualRegionSize>0x8000</actualRegionSize> + <ecc>no</ecc> + <source>Blank</source> + <sideless>no</sideless> + <testonly>yes</testonly> + </section> + </pnor> diff --git a/src/include/usr/pnor/pnorif.H b/src/include/usr/pnor/pnorif.H index 0c47210fb..35ef9bacb 100644 --- a/src/include/usr/pnor/pnorif.H +++ b/src/include/usr/pnor/pnorif.H @@ -42,6 +42,7 @@ enum SectionId DIMM_JEDEC_VPD, /**< DIMM JEDEC VPD */ MODULE_VPD, /**< Module VPD */ HB_BASE_CODE, /**< Hostboot Base Image */ + TEST, /**< Scratch space for PNOR test cases */ NUM_SECTIONS, /**< Number of defined sections */ //Not currently used @@ -52,7 +53,7 @@ enum SectionId // HB_ERRLOGS, /**< Hostboot Error log Repository */ FIRST_SECTION = TOC, /**< First section (for looping) */ - LAST_SECTION = HB_BASE_CODE, /**< Last section (for looping) */ + LAST_SECTION = TEST, /**< Last section (for looping) */ INVALID_SECTION = NUM_SECTIONS, /**< Used for error cases, initialization */ }; diff --git a/src/usr/pnor/pnorrp.C b/src/usr/pnor/pnorrp.C index 4d3c74648..d84c636e5 100644 --- a/src/usr/pnor/pnorrp.C +++ b/src/usr/pnor/pnorrp.C @@ -48,12 +48,13 @@ TRAC_INIT(&g_trac_pnor, "PNOR", 4096); //4K * Eyecatcher strings for PNOR TOC entries */ const char* cv_EYECATCHER[] = { //@todo - convert there to uint64_t - "part", /**< PNOR::TOC : Table of Contents */ + "part", /**< PNOR::TOC : Table of Contents */ "HBI", /**< PNOR::HB_EXT_CODE : Hostboot Extended Image */ "HBD", /**< PNOR::HB_DATA : Hostboot Data */ "DJVPD", /**< PNOR::DIMM_JEDEC_VPD: Dimm JEDEC VPD */ "MVPD", /**< PNOR::MODULE_VPD : Module VPD */ "HBB", /**< PNOR::HB_BASE_CODE : Hostboot Base Image */ + "TEST", /**< PNOR::TEST : Test space for PNOR*/ //Not currently used // "GLOBAL", /**< PNOR::GLOBAL_DATA : Global Data */ @@ -338,11 +339,11 @@ errlHndl_t PnorRP::readTOC() // Zero out my table for( uint64_t side = 0; side < NUM_SIDES; side++ ) { - for( PNOR::SectionId id = PNOR::FIRST_SECTION; + for( size_t id = PNOR::FIRST_SECTION; id <= PNOR::NUM_SECTIONS; //include extra entry for error paths - id = (PNOR::SectionId) (id + 1) ) + ++id ) { - iv_TOC[side][id].id = id; + iv_TOC[side][id].id = (PNOR::SectionId)id; iv_TOC[side][id].side = (PNOR::SideSelect)side; iv_TOC[side][id].chip = 0; iv_TOC[side][id].flashAddr = 0; diff --git a/src/usr/pnor/pnorrp.H b/src/usr/pnor/pnorrp.H index 61f230916..897d075a6 100644 --- a/src/usr/pnor/pnorrp.H +++ b/src/usr/pnor/pnorrp.H @@ -275,6 +275,7 @@ class PnorRP // allow testcase to see inside friend class PnorRpTest; + friend class PnorDdTest; /** * @brief Static instance function for testcase only diff --git a/src/usr/pnor/test/pnorddtest.H b/src/usr/pnor/test/pnorddtest.H index c984ee2b6..cdf7ccb92 100644 --- a/src/usr/pnor/test/pnorddtest.H +++ b/src/usr/pnor/test/pnorddtest.H @@ -34,15 +34,15 @@ #include <errl/errlmanager.H> #include <errl/errlentry.H> #include <pnor/pnorif.H> +#include <pnor/pnor_reasoncodes.H> #include <devicefw/userif.H> #include <kernel/console.H> #include <sys/time.h> #include "../pnordd.H" +#include "../pnorrp.H" #include <list> #include <targeting/common/attributes.H> -#define BASE_SCRATCH_SPACE (0x360000) // 3.5MB - 128K offset in fake PNOR - extern trace_desc_t* g_trac_pnor; /* @@ -56,6 +56,53 @@ class PnorDdTest : public CxxTest::TestSuite { public: + bool getTestSection(uint64_t &o_physAddr, uint64_t &o_size) + { + errlHndl_t l_err = NULL; + PNOR::SectionInfo_t info; + uint64_t chip_select = 0xF; + bool needs_ecc = false; + bool section_found = false; + + do{ + + // Get SPD PNOR section info from PNOR RP + l_err = PNOR::getSectionInfo( PNOR::TEST, + PNOR::CURRENT_SIDE, + info ); + if(l_err) + { + if(l_err->reasonCode() == PNOR::RC_INVALID_SECTION) + { + //This is expected in some configurations, so just delete it. + delete l_err; + } + else + { + //Any other type of error is not expected, so commit it. + errlCommit(l_err,PNOR_COMP_ID); + } + break; + } + + l_err = PnorRP::getInstance().computeDeviceAddr((void*)info.vaddr, + o_physAddr, + chip_select, + needs_ecc); + if(l_err) + { + errlCommit(l_err,PNOR_COMP_ID); + break; + } + + o_size = info.size; + section_found = true; + + }while(0); + + return section_found; + } + /** * @brief PNOR DD readWriteTest * Write some data to PNOR and read it back again @@ -73,8 +120,17 @@ class PnorDdTest : public CxxTest::TestSuite do{ TS_TRACE("PnorDdTest::test_readwrite: starting"); + uint64_t base_address; + uint64_t sect_size; + if(!getTestSection(base_address, sect_size)) + { + TRACFCOMP(g_trac_pnor, "PnorDdTest::test_readwrite> Skipped due to not finding test section in PNOR" ); + break; + } + // Perform PnorDD Write 1 - uint64_t l_address = BASE_SCRATCH_SPACE+0x100; + + uint64_t l_address = base_address+0x100; uint64_t l_writeData = 0x12345678FEEDB0B0; l_size = sizeof(uint64_t); l_err = deviceWrite(l_testTarget, @@ -97,7 +153,7 @@ class PnorDdTest : public CxxTest::TestSuite } // Perform PnorDD Write 2 - l_address = BASE_SCRATCH_SPACE+0x108; + l_address = base_address+0x108; l_writeData = 0xFEEDBEEF000ABCDE; l_size = sizeof(uint64_t); l_err = deviceWrite(l_testTarget, @@ -120,7 +176,7 @@ class PnorDdTest : public CxxTest::TestSuite } // Perform PnorDD read 1 - l_address = BASE_SCRATCH_SPACE+0x100; + l_address = base_address+0x100; uint64_t l_readData = 0; l_size = sizeof(uint64_t); l_err = deviceRead(l_testTarget, @@ -150,7 +206,7 @@ class PnorDdTest : public CxxTest::TestSuite } // Perform PnorDD read 2 - l_address = BASE_SCRATCH_SPACE+0x108; + l_address = base_address+0x108; l_size = sizeof(uint64_t); l_err = deviceRead(l_testTarget, &l_readData, @@ -201,7 +257,15 @@ class PnorDdTest : public CxxTest::TestSuite TS_TRACE("PnorDdTest::test_smartwrite: starting"); // Perform PnorDD Write 1 - uint64_t l_address = BASE_SCRATCH_SPACE+0x120; + uint64_t base_address; + uint64_t sect_size; + if(!getTestSection(base_address, sect_size)) + { + TRACFCOMP(g_trac_pnor, "PnorDdTest::test_smartwrite> Skipped due to not finding test section in PNOR" ); + break; + } + + uint64_t l_address = base_address+0x120; uint64_t l_writeData = 0xAAAAAAAA55555555; l_size = sizeof(uint64_t); l_err = deviceWrite(l_testTarget, @@ -327,9 +391,17 @@ class PnorDdTest : public CxxTest::TestSuite do{ TS_TRACE("PnorDdTest::test_crossblock: starting"); + uint64_t base_address; + uint64_t sect_size; + if(!getTestSection(base_address, sect_size)) + { + TRACFCOMP(g_trac_pnor, "PnorDdTest::test_readwrite> Skipped due to not finding test section in PNOR" ); + break; + } + // Find the nearest erase-block (4K) boundary - uint64_t l_boundary = (BASE_SCRATCH_SPACE+4096) - - (BASE_SCRATCH_SPACE%4096); + uint64_t l_boundary = (base_address+4096) + - (base_address%4096); uint64_t l_address = 0; // Perform PnorDD Write 1 - write through boundary @@ -390,10 +462,18 @@ class PnorDdTest : public CxxTest::TestSuite do{ TS_TRACE("PnorDdTest::test_readwrite_modes: starting"); + uint64_t base_address; + uint64_t sect_size; + if(!getTestSection(base_address, sect_size)) + { + TRACFCOMP(g_trac_pnor, "PnorDdTest::test_readwrite_modes> Skipped due to not finding test section in PNOR" ); + break; + } + // list of all modes to test std::list<PnorDD::PnorMode_t> supported_modes; - supported_modes.push_back(PnorDD::MODEL_MEMCPY); - supported_modes.push_back(PnorDD::MODEL_LPC_MEM); + //supported_modes.push_back(PnorDD::MODEL_MEMCPY); (Enable with RTC: 44938) + //supported_modes.push_back(PnorDD::MODEL_LPC_MEM); (Enable with RTC: 44938) if(!TARGETING::is_vpo()) { @@ -401,7 +481,7 @@ class PnorDdTest : public CxxTest::TestSuite supported_modes.push_back(PnorDD::MODEL_REAL_CMD); } - uint64_t scratch_space = BASE_SCRATCH_SPACE; + uint64_t scratch_space = base_address; // loop through all of the supported modes for( std::list<PnorDD::PnorMode_t>::iterator m @@ -419,6 +499,7 @@ class PnorDdTest : public CxxTest::TestSuite // Perform PnorDD Write 1 uint64_t l_address = scratch_space; + uint64_t l_writeData = 0x12345678FEEDB0B0; l_size = sizeof(uint64_t); l_err = pnordd->writeFlash(&l_writeData, @@ -548,10 +629,18 @@ class PnorDdTest : public CxxTest::TestSuite do{ TS_TRACE("PnorDdTest::test_smartwrite_modes: starting"); + uint64_t base_address; + uint64_t sect_size; + if(!getTestSection(base_address, sect_size)) + { + TRACFCOMP(g_trac_pnor, "PnorDdTest::test_smartwrite_modes> Skipped due to not finding test section in PNOR" ); + break; + } + // list of all modes to test std::list<PnorDD::PnorMode_t> supported_modes; - supported_modes.push_back(PnorDD::MODEL_MEMCPY); - supported_modes.push_back(PnorDD::MODEL_LPC_MEM); + //supported_modes.push_back(PnorDD::MODEL_MEMCPY); (Enable with RTC: 44938) + //supported_modes.push_back(PnorDD::MODEL_LPC_MEM); (Enable with RTC: 44938) if(!TARGETING::is_vpo()) { @@ -559,7 +648,7 @@ class PnorDdTest : public CxxTest::TestSuite supported_modes.push_back(PnorDD::MODEL_REAL_CMD); } - uint64_t scratch_space = BASE_SCRATCH_SPACE; + uint64_t scratch_space = base_address; // loop through all of the supported modes for( std::list<PnorDD::PnorMode_t>::iterator m @@ -701,10 +790,18 @@ class PnorDdTest : public CxxTest::TestSuite do{ TS_TRACE("PnorDdTest::test_crossblock_modes: starting"); + uint64_t base_address; + uint64_t sect_size; + if(!getTestSection(base_address, sect_size)) + { + TRACFCOMP(g_trac_pnor, "PnorDdTest::test_crossblock_modes> Skipped due to not finding test section in PNOR" ); + break; + } + // list of all modes to test std::list<PnorDD::PnorMode_t> supported_modes; - supported_modes.push_back(PnorDD::MODEL_MEMCPY); - supported_modes.push_back(PnorDD::MODEL_LPC_MEM); + //supported_modes.push_back(PnorDD::MODEL_MEMCPY); (Enable with RTC: 44938) + //supported_modes.push_back(PnorDD::MODEL_LPC_MEM); (Enable with RTC: 44938) if(!TARGETING::is_vpo()) { @@ -712,7 +809,7 @@ class PnorDdTest : public CxxTest::TestSuite supported_modes.push_back(PnorDD::MODEL_REAL_CMD); } - uint64_t scratch_space = BASE_SCRATCH_SPACE; + uint64_t scratch_space = base_address; // loop through all of the supported modes for( std::list<PnorDD::PnorMode_t>::iterator m @@ -729,10 +826,19 @@ class PnorDdTest : public CxxTest::TestSuite pnordd = new PnorDD(*m); // Find the nearest erase-block (4K) boundary - uint64_t l_boundary = (BASE_SCRATCH_SPACE+4096) - - (BASE_SCRATCH_SPACE%4096); + uint64_t l_boundary = (base_address+4096) + - (base_address%4096); uint64_t l_address = 0; + //make sure we don't go past the end of the section + if(l_boundary+0x4 > base_address+sect_size) + { + TS_FAIL("PnorDdTest::test_crossblock_modes: Test Case went beyond allocated space in test section."); + TRACFCOMP(g_trac_pnor, "PnorDdTest::test_crossblock_modes: Test Case went beyond allocated space in test section.l_boundary=0x%X, base_address=0x%X, sect_size=0x%X", l_boundary, base_address, sect_size); + TRACFCOMP(g_trac_pnor, "PnorDdTest::test_crossblock_modes: sect_size=0x%X", sect_size); + break; + } + // Perform PnorDD Write 1 - write through boundary l_address = l_boundary - sizeof(uint32_t); uint64_t l_writeData = 0x6666666699999999; |