diff options
| author | Stephen Cprek <smcprek@us.ibm.com> | 2013-11-12 15:33:35 -0600 |
|---|---|---|
| committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-12-12 16:15:53 -0600 |
| commit | 07c9716fcf31ce5352ce412a643071ea89bd2ca1 (patch) | |
| tree | cab98e95ad2fa2a34bd122e21d5ba49c49675c56 /src/usr/pnor/test | |
| parent | 1fe455d3400fd80d99176ad7f60a630ac7ce1b76 (diff) | |
| download | blackbird-hostboot-07c9716fcf31ce5352ce412a643071ea89bd2ca1.tar.gz blackbird-hostboot-07c9716fcf31ce5352ce412a643071ea89bd2ca1.zip | |
Handle Multiple TOCs and removed side code
Also added Hostboot Base image version header
Change-Id: I0fc878a48b9449e5d4875fd14525faefe01b1ace
RTC: 34764
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/7276
Tested-by: Jenkins Server
Reviewed-by: Brian H. Horton <brianh@linux.ibm.com>
Reviewed-by: ADAM R. MUHLE <armuhle@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/pnor/test')
| -rw-r--r-- | src/usr/pnor/test/pnorddtest.H | 41 | ||||
| -rw-r--r-- | src/usr/pnor/test/pnorrptest.H | 104 |
2 files changed, 117 insertions, 28 deletions
diff --git a/src/usr/pnor/test/pnorddtest.H b/src/usr/pnor/test/pnorddtest.H index eccb24dd4..546240cb9 100644 --- a/src/usr/pnor/test/pnorddtest.H +++ b/src/usr/pnor/test/pnorddtest.H @@ -5,7 +5,7 @@ /* */ /* IBM CONFIDENTIAL */ /* */ -/* COPYRIGHT International Business Machines Corp. 2011,2012 */ +/* COPYRIGHT International Business Machines Corp. 2011,2013 */ /* */ /* p1 */ /* */ @@ -67,7 +67,6 @@ class PnorDdTest : public CxxTest::TestSuite // Get SPD PNOR section info from PNOR RP l_err = PNOR::getSectionInfo( PNOR::TEST, - PNOR::CURRENT_SIDE, info ); if(l_err) { @@ -111,7 +110,7 @@ class PnorDdTest : public CxxTest::TestSuite { TARGETING::Target* l_testTarget = TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; - size_t l_size = sizeof(uint64_t); + size_t l_size = sizeof(uint64_t); errlHndl_t l_err = NULL; uint64_t fails = 0; uint64_t total = 0; @@ -146,7 +145,7 @@ class PnorDdTest : public CxxTest::TestSuite total++; if(l_size != sizeof(uint64_t)) { - TS_FAIL("PnorDdTest::test_readwrite: PNORDD write 1: Write length not expected value. Addr: 0x%llx, Exp: %d, Act: %d", l_address, + TS_FAIL("PnorDdTest::test_readwrite: PNORDD write 1: Write length not expected value. Addr: 0x%llx, Exp: %d, Act: %d", l_address, sizeof(uint64_t), l_size); fails++; } @@ -169,7 +168,7 @@ class PnorDdTest : public CxxTest::TestSuite total++; if(l_size != sizeof(uint64_t)) { - TS_FAIL("PnorDdTest::test_readwrite: PNORDD write 2: Write length not expected value. Addr: 0x%llx, Exp: %d, Act: %d", l_address, + TS_FAIL("PnorDdTest::test_readwrite: PNORDD write 2: Write length not expected value. Addr: 0x%llx, Exp: %d, Act: %d", l_address, sizeof(uint64_t), l_size); fails++; } @@ -199,7 +198,7 @@ class PnorDdTest : public CxxTest::TestSuite total++; if(l_size != sizeof(uint64_t)) { - TS_FAIL("PnorDdTest::test_readwrite: PNORDD read 1: Read length not expected value. Addr: 0x%llx, Exp: %d, Act: %d", l_address, + TS_FAIL("PnorDdTest::test_readwrite: PNORDD read 1: Read length not expected value. Addr: 0x%llx, Exp: %d, Act: %d", l_address, sizeof(uint64_t), l_size); fails++; } @@ -228,7 +227,7 @@ class PnorDdTest : public CxxTest::TestSuite total++; if(l_size != sizeof(uint64_t)) { - TS_FAIL("PnorDdTest::test_readwrite: PNORDD read 2: Read length not expected value. Addr: 0x%llx, Exp: %d, Act: %d", l_address, + TS_FAIL("PnorDdTest::test_readwrite: PNORDD read 2: Read length not expected value. Addr: 0x%llx, Exp: %d, Act: %d", l_address, sizeof(uint64_t), l_size); fails++; } @@ -247,7 +246,7 @@ class PnorDdTest : public CxxTest::TestSuite { TARGETING::Target* l_testTarget = TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; - size_t l_size = sizeof(uint64_t); + size_t l_size = sizeof(uint64_t); errlHndl_t l_err = NULL; uint64_t fails = 0; uint64_t total = 0; @@ -382,7 +381,7 @@ class PnorDdTest : public CxxTest::TestSuite { TARGETING::Target* l_testTarget = TARGETING::MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; - size_t l_size = sizeof(uint64_t); + size_t l_size = sizeof(uint64_t); errlHndl_t l_err = NULL; uint64_t fails = 0; uint64_t total = 0; @@ -398,7 +397,7 @@ class PnorDdTest : public CxxTest::TestSuite break; } - // Find the nearest erase-block (4K) boundary + // Find the nearest erase-block (4K) boundary uint64_t l_boundary = (base_address+4096) - (base_address%4096); uint64_t l_address = 0; @@ -454,7 +453,7 @@ class PnorDdTest : public CxxTest::TestSuite { PnorDD* pnordd = NULL; uint8_t* fake_space = NULL; - size_t l_size = sizeof(uint64_t); + size_t l_size = sizeof(uint64_t); errlHndl_t l_err = NULL; uint64_t fails = 0; uint64_t total = 0; @@ -481,7 +480,7 @@ class PnorDdTest : public CxxTest::TestSuite = supported_modes.begin(); m != supported_modes.end(); ++m ) - { + { if( pnordd ) { delete pnordd; @@ -500,7 +499,7 @@ class PnorDdTest : public CxxTest::TestSuite pnordd = new PnorDD(*m, reinterpret_cast<uint64_t>(fake_space), (4 * KILOBYTE)); - //Adjusting the address by an arbitrary multiplier to keep + //Adjusting the address by an arbitrary multiplier to keep //successive tests from always using the same memory space. scratch_space = (*m)*0x20; } @@ -515,7 +514,7 @@ class PnorDdTest : public CxxTest::TestSuite "PnorDdTest::test_readwrite_modes> Skipped due to not finding test section in PNOR" ); continue; } - //Adjusting the address by an arbitrary multiplier to keep + //Adjusting the address by an arbitrary multiplier to keep //successive tests from always using the same memory space. scratch_space += (*m)*0x20; } @@ -650,7 +649,7 @@ class PnorDdTest : public CxxTest::TestSuite { PnorDD* pnordd = NULL; uint8_t* fake_space = NULL; - size_t l_size = sizeof(uint64_t); + size_t l_size = sizeof(uint64_t); errlHndl_t l_err = NULL; uint64_t fails = 0; uint64_t total = 0; @@ -696,8 +695,8 @@ class PnorDdTest : public CxxTest::TestSuite pnordd = new PnorDD(*m, reinterpret_cast<uint64_t>(fake_space), (4 * KILOBYTE)); - - //Adjusting the address by an arbitrary multiplier to keep + + //Adjusting the address by an arbitrary multiplier to keep //successive tests from always using the same memory space. scratch_space = (*m)*0x30; @@ -713,7 +712,7 @@ class PnorDdTest : public CxxTest::TestSuite "PnorDdTest::test_readwrite_modes> Skipped due to not finding test section in PNOR" ); continue; } - //Adjusting the address by an arbitrary multiplier to keep + //Adjusting the address by an arbitrary multiplier to keep //successive tests from always using the same memory space. scratch_space += (*m)*0x30; } @@ -841,7 +840,7 @@ class PnorDdTest : public CxxTest::TestSuite { PnorDD* pnordd = NULL; uint8_t* fake_space = NULL; - size_t l_size = sizeof(uint64_t); + size_t l_size = sizeof(uint64_t); errlHndl_t l_err = NULL; uint64_t fails = 0; uint64_t total = 0; @@ -904,7 +903,7 @@ class PnorDdTest : public CxxTest::TestSuite } } - // Find the nearest erase-block (4K) boundary + // Find the nearest erase-block (4K) boundary uint64_t l_boundary = (scratch_space+4096) - (scratch_space%4096); uint64_t l_address = 0; @@ -981,7 +980,7 @@ Leaving it commented out because the test-case will not dynamically find the ext { TARGETING::Target* l_testTarget = MASTER_PROCESSOR_CHIP_TARGET_SENTINEL; - size_t l_size = sizeof(uint64_t); + size_t l_size = sizeof(uint64_t); errlHndl_t l_err = NULL; do{ diff --git a/src/usr/pnor/test/pnorrptest.H b/src/usr/pnor/test/pnorrptest.H index 71766fea0..d96379a8c 100644 --- a/src/usr/pnor/test/pnorrptest.H +++ b/src/usr/pnor/test/pnorrptest.H @@ -40,6 +40,7 @@ #include <devicefw/userif.H> #include <pnor/ecc.H> #include "../pnorrp.H" +#include "../ffs.h" extern trace_desc_t* g_trac_pnor; @@ -75,7 +76,7 @@ class PnorRpTest : public CxxTest::TestSuite for( uint64_t idx = 0; idx < numSections; idx++) { total++; - errhdl = PNOR::getSectionInfo( testSections[idx], PNOR::CURRENT_SIDE, info ); + errhdl = PNOR::getSectionInfo( testSections[idx], info ); if( errhdl ) { TRACFCOMP(g_trac_pnor, "PnorRpTest::test_sectionInfo> ERROR : getSectionInfo returned error for %d : RC=%X", @@ -131,7 +132,7 @@ class PnorRpTest : public CxxTest::TestSuite // use the TEST partition as scratch space PNOR::SectionInfo_t info; - errhdl = PNOR::getSectionInfo( PNOR::TEST, PNOR::SIDE_A, info ); + errhdl = PNOR::getSectionInfo( PNOR::TEST, info ); if( errhdl ) { TRACFCOMP( g_trac_pnor, "PnorRpTest::test_ECC> ERROR : getSectionInfo returned error for PNOR::TEST : RC=%X", errhdl->reasonCode() ); @@ -247,10 +248,9 @@ class PnorRpTest : public CxxTest::TestSuite fails++; } } - //Enable this to test the UE handling, not turning on by default // because it causes a shutdown -#if 0 +#if 0 TRACFCOMP(g_trac_pnor, "PnorRpTest::test_ECC: Attempting UE" ); // flush the page to make sure it gets out to the device totals++; @@ -290,7 +290,6 @@ class PnorRpTest : public CxxTest::TestSuite TS_FAIL("PnorRpTest::test_ECC: UE did not kill the task!."); #endif - TRACFCOMP(g_trac_pnor, "PnorRpTest::test_ECC> %d/%d fails", fails, total ); }; @@ -316,7 +315,7 @@ class PnorRpTest : public CxxTest::TestSuite // use the TEST partition as scratch space PNOR::SectionInfo_t info; - PNOR::getSectionInfo( PNOR::TEST, PNOR::SIDE_A, info ); + PNOR::getSectionInfo( PNOR::TEST, info ); msg_t* msg = msg_allocate(); @@ -496,8 +495,99 @@ class PnorRpTest : public CxxTest::TestSuite TRACFCOMP(g_trac_pnor, "PnorRpTest::test_AddrReadWrite> %d/%d fails", fails, total ); }; - //@todo - import config data from build and compare to section info + /** + * @brief PNOR RP test - TOC + * Verify TOC checksum errors for both TOC's fail silently and + * pick up data from the other TOC. Test corrupts both header and + * first entry because they are checked separately in pnorrp.C + * + */ + void test_TOC(void) + { + TRACFCOMP(g_trac_pnor, "PnorRpTest::test_TOC Start" ); + + bool fatal_error = false; + uint64_t offset = 0; + uint8_t* tocHeader = new uint8_t[PAGESIZE]; + uint8_t* tocEntry = new uint8_t[PAGESIZE]; + uint8_t* corruptBuffer = new uint8_t[PAGESIZE]; + + // Corrupt both ffs header and first entry for each TOC + for (uint32_t cur_TOC = 0; cur_TOC < PnorRP::NUM_TOCS; ++cur_TOC) + { + uint32_t TOC_used = cur_TOC; + + if (cur_TOC == 0) + { + offset = PnorRP::TOC_0_OFFSET; + } + else + { + offset = PnorRP::TOC_1_OFFSET; + } + + // Read cur_TOC header data + PnorRP::getInstance().readFromDevice( offset, 0, false, tocHeader, + fatal_error ); + + // Corrupt cur_TOC header data + memcpy(corruptBuffer, tocHeader, PAGESIZE); + corruptBuffer[0] = 0xFF; + corruptBuffer[1] = 0xFF; + PnorRP::getInstance().writeToDevice( offset, 0, false, + corruptBuffer ); + // Check if cur_TOC failed that other TOC is used + PnorRP::getInstance().readTOC(); + TOC_used = PnorRP::getInstance().iv_TOC_used; + TRACFCOMP(g_trac_pnor, "PnorRpTest::test_TOC : TOC %d Corrupt Header Toc_used = %d", cur_TOC, TOC_used); + + if (TOC_used == cur_TOC) + { + TRACFCOMP(g_trac_pnor, "PnorRpTest::test_TOC> ERROR : TOC %d is corrupted, did not use other TOC", cur_TOC); + TS_FAIL("PnorRpTest::test_TOC> ERROR : TOC %d is corrupted, did not use other TOC"); + } + + // Fix cur_TOC header + PnorRP::getInstance().writeToDevice( offset, 0, false, tocHeader ); + + // Read cur_TOC first entry data + PnorRP::getInstance().readFromDevice( offset + FFS_HDR_SIZE, 0, + false, tocEntry, + fatal_error ); + + // Corrupt cur_TOC header data + memcpy(corruptBuffer, tocEntry, PAGESIZE); + corruptBuffer[0] = 0xFF; + corruptBuffer[1] = 0xFF; + PnorRP::getInstance().writeToDevice( offset + FFS_HDR_SIZE, 0, + false, corruptBuffer ); + + // Check if cur_TOC failed that other TOC is used + TOC_used = cur_TOC; + PnorRP::getInstance().readTOC(); + TOC_used = PnorRP::getInstance().iv_TOC_used; + TRACFCOMP(g_trac_pnor, "PnorRpTest::test_TOC : TOC %d Corrupt Entry Toc_used = %d", cur_TOC, TOC_used); + + if (TOC_used == cur_TOC) + { + TRACFCOMP(g_trac_pnor, "PnorRpTest::test_TOC> ERROR : TOC %d is corrupted, did not use other TOC ENTRY", cur_TOC); + TS_FAIL("PnorRpTest::test_TOC> ERROR : TOC %d is corrupted, did not use other TOC", cur_TOC); + } + + // Fix cur_TOC first entry + PnorRP::getInstance().writeToDevice( offset + FFS_HDR_SIZE, 0, + false, tocEntry ); + } + + delete tocHeader; + delete tocEntry; + delete corruptBuffer; + + TRACFCOMP(g_trac_pnor, "PnorRpTest::test_TOC End"); + } + + //@todo - import config data from build and compare to section info }; |

