summaryrefslogtreecommitdiffstats
path: root/src/usr/pnor/test
diff options
context:
space:
mode:
authorDan Crowell <dcrowell@us.ibm.com>2014-06-17 10:27:07 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2014-10-14 08:49:13 -0500
commitf058c4b71a182364fd664f5a4d93cd1fe3e07d19 (patch)
tree348cab519fb07d2172fad68d1df689381c437793 /src/usr/pnor/test
parent4b16ee65fc46cb19aca69bd54b6024a948316315 (diff)
downloadblackbird-hostboot-f058c4b71a182364fd664f5a4d93cd1fe3e07d19.tar.gz
blackbird-hostboot-f058c4b71a182364fd664f5a4d93cd1fe3e07d19.zip
Split out SFC logic and add support for AST2400
Refactored the PNOR device driver to pull all SFC-specific code into a new set of classes. Any time a new type of serial flash controller (SFC) is introduced, a new subclass should be created to support it. Also added the full support for the AST2400 BMC that is being used on Palmetto. Change-Id: I9cdbf9b48bbf94615a39804920e170a3142ec386 Origin: Google Shared Technology RTC: 97493 Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/13229 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/pnor/test')
-rw-r--r--src/usr/pnor/test/makefile12
-rw-r--r--src/usr/pnor/test/pnorddtest.H662
-rw-r--r--src/usr/pnor/test/pnorrptest.H13
-rw-r--r--src/usr/pnor/test/sfc_ast2400test.H305
-rw-r--r--src/usr/pnor/test/sfc_ibmtest.H174
5 files changed, 503 insertions, 663 deletions
diff --git a/src/usr/pnor/test/makefile b/src/usr/pnor/test/makefile
index d67b232e0..2c13da7b1 100644
--- a/src/usr/pnor/test/makefile
+++ b/src/usr/pnor/test/makefile
@@ -5,7 +5,10 @@
#
# OpenPOWER HostBoot Project
#
-# COPYRIGHT International Business Machines Corp. 2011,2014
+# Contributors Listed Below - COPYRIGHT 2011,2014
+# [+] Google Inc.
+# [+] International Business Machines Corp.
+#
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -23,6 +26,11 @@
ROOTPATH = ../../../..
MODULE = testpnor
-TESTS = *.H
+
+TESTS = pnorddtest.H ecctest.H pnorrptest.H
+
+#SFC Implementations
+TESTS += $(if $(CONFIG_SFC_IS_IBM_DPSS),sfc_ibmtest.H)
+TESTS += $(if $(CONFIG_SFC_IS_AST2400),sfc_ast2400test.H)
include ${ROOTPATH}/config.mk
diff --git a/src/usr/pnor/test/pnorddtest.H b/src/usr/pnor/test/pnorddtest.H
index 97273cc34..3a38e88a6 100644
--- a/src/usr/pnor/test/pnorddtest.H
+++ b/src/usr/pnor/test/pnorddtest.H
@@ -6,6 +6,7 @@
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2014 */
+/* [+] Google Inc. */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -28,7 +29,7 @@
/**
* @file pnorddtest.H
*
- * @brief Test case for PNOR Resource Provider
+ * @brief Test case for PNOR Device Driver
*/
#include <cxxtest/TestSuite.H>
@@ -44,6 +45,10 @@
#include <list>
#include <targeting/common/attributes.H>
+#ifdef CONFIG_SFC_IS_IBM_DPSS
+#include "../sfc_ibm.H"
+#endif
+
extern trace_desc_t* g_trac_pnor;
/*
@@ -67,7 +72,7 @@ class PnorDdTest : public CxxTest::TestSuite
do{
- // Get SPD PNOR section info from PNOR RP
+ // Get TEST PNOR section info from PNOR RP
l_err = PNOR::getSectionInfo( PNOR::TEST,
info );
if(l_err)
@@ -449,659 +454,6 @@ class PnorDdTest : public CxxTest::TestSuite
TRACFCOMP(g_trac_pnor, "PnorDdTest::test_crossblock> %d/%d fails", fails, total );
}
- /**
- * @brief PNOR DD readWriteTest modes
- * Same as test_readwrite but forcing the use of all supported modes
- */
- void test_readwrite_modes(void)
- {
- PnorDD* pnordd = NULL;
- uint8_t* fake_space = NULL;
- size_t l_size = sizeof(uint64_t);
- errlHndl_t l_err = NULL;
- uint64_t fails = 0;
- uint64_t total = 0;
- uint64_t scratch_space = 0;
- uint64_t sect_size = 0;
-
- do{
- TS_TRACE("PnorDdTest::test_readwrite_modes: starting");
-
- // 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);
-
- if(!TARGETING::is_vpo())
- {
- TRACFCOMP(g_trac_pnor, "PnorDdTest::test_readwrite_modes> Adding REAL_CMD & MODEL_REAL_MMIO modes");
- supported_modes.push_back(PnorDD::MODEL_REAL_CMD);
- supported_modes.push_back(PnorDD::MODEL_REAL_MMIO);
- }
-
- // loop through all of the supported modes
- for( std::list<PnorDD::PnorMode_t>::iterator m
- = supported_modes.begin();
- m != supported_modes.end();
- ++m )
- {
- if( pnordd )
- {
- delete pnordd;
- }
-
- //Fake PNOR
- if( (PnorDD::MODEL_MEMCPY == *m) ||
- (PnorDD::MODEL_LPC_MEM == *m) )
- {
- //malloc some space to use as fake-PNOR
- if( fake_space )
- {
- delete fake_space;
- }
- fake_space = new uint8_t[4 * KILOBYTE];
- pnordd = new PnorDD(*m,
- reinterpret_cast<uint64_t>(fake_space),
- (4 * KILOBYTE));
- //Adjusting the address by an arbitrary multiplier to keep
- //successive tests from always using the same memory space.
- scratch_space = (*m)*0x20;
- }
- //Real PNOR
- else
- {
- pnordd = new PnorDD(*m);
-
- if(!getTestSection(scratch_space, sect_size))
- {
- TRACFCOMP(g_trac_pnor,
- "PnorDdTest::test_readwrite_modes> Skipped due to not finding test section in PNOR" );
- continue;
- }
- //Adjusting the address by an arbitrary multiplier to keep
- //successive tests from always using the same memory space.
- scratch_space += (*m)*0x20;
- }
-
- // 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,
- l_size,
- l_address);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_readwrite_modes: PNORDD write 1: writeFlash() failed! Error committed. mode=%d",
- *m);
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
- total++;
- if(l_size != sizeof(uint64_t))
- {
- TS_FAIL("PnorDdTest::test_readwrite_modes: PNORDD write 1: Write length not expected value. Addr: 0x%llx, Exp: %d, Act: %d, mode=%d",
- l_address, sizeof(uint64_t), l_size, *m);
- fails++;
- }
-
- // Perform PnorDD Write 2
- l_address = scratch_space+0x08;
- l_writeData = 0xFEEDBEEF000ABCDE;
- l_size = sizeof(uint64_t);
- l_err = pnordd->writeFlash(&l_writeData,
- l_size,
- l_address);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_readwrite_modes: PNORDD write 2: writeFlash() failed! Error committed. mode=%d",
- *m);
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
- total++;
- if(l_size != sizeof(uint64_t))
- {
- TS_FAIL("PnorDdTest::test_readwrite_modes: PNORDD write 2: Write length not expected value. Addr: 0x%llx, Exp: %d, Act: %d, mode=%d",
- l_address, sizeof(uint64_t), l_size, *m);
- fails++;
- }
-
- // Perform PnorDD read 1
- l_address = scratch_space;
- uint64_t l_readData = 0;
- l_size = sizeof(uint64_t);
- l_err = pnordd->readFlash(&l_readData,
- l_size,
- l_address);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_readwrite_modes: PNORDD read 1: readFlash() failed! Error committed. mode=%d",
- *m);
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
- total++;
- if(l_readData != 0x12345678FEEDB0B0)
- {
- TS_FAIL("PnorDdTest::test_readwrite_modes: PNORDD read 1: Read data not expected value. Addr: 0x%llx, ExpData: 0x12345678FEEDB0B0, ActData: 0x%llx, mode=%d",
- l_address, (long long unsigned)l_readData, *m);
- fails++;
- }
- total++;
- if(l_size != sizeof(uint64_t))
- {
- TS_FAIL("PnorDdTest::test_readwrite_modes: PNORDD read 1: Read length not expected value. Addr: 0x%llx, Exp: %d, Act: %d, mode=%d",
- l_address, sizeof(uint64_t), l_size, *m);
- fails++;
- }
-
- // Perform PnorDD read 2
- l_address = scratch_space+0x08;
- l_size = sizeof(uint64_t);
- l_err = pnordd->readFlash(&l_readData,
- l_size,
- l_address);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_readwrite_modes: PNORDD read 2: readFlash() failed! Error committed. mode=%d",
- *m);
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
- total++;
- if(l_readData != 0xFEEDBEEF000ABCDE)
- {
- TS_FAIL("PnorDdTest::test_readwrite_modes: PNORDD read 2: Read data not expected value. Addr: 0x%llx, ExpData: 0xFEEDBEEF000ABCDE, ActData: 0x%llx, mode=%d",
- l_address, (long long unsigned)l_readData, *m);
- fails++;
- }
- total++;
- if(l_size != sizeof(uint64_t))
- {
- TS_FAIL("PnorDdTest::test_readwrite_modes: PNORDD read 2: Read length not expected value. Addr: 0x%llx, Exp: %d, Act: %d, mode=%d",
- l_address, sizeof(uint64_t), l_size, *m);
- fails++;
- }
- }
-
- }while(0);
-
- TRACFCOMP(g_trac_pnor, "PnorDdTest::test_readwrite_modes> %d/%d fails", fails, total );
-
- if( pnordd )
- {
- delete pnordd;
- }
- if( fake_space )
- {
- delete fake_space;
- }
-
- }
-
- /**
- * @brief PNOR DD smart write/erase test
- * Same as test_smartwrite but forcing the use of all supported modes
- */
- void test_smartwrite_modes(void)
- {
- PnorDD* pnordd = NULL;
- uint8_t* fake_space = NULL;
- size_t l_size = sizeof(uint64_t);
- errlHndl_t l_err = NULL;
- uint64_t fails = 0;
- uint64_t total = 0;
- uint64_t scratch_space = 0;
- uint64_t sect_size = 0;
-
- do{
- TS_TRACE("PnorDdTest::test_smartwrite_modes: starting");
-
- // 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);
-
- if(!TARGETING::is_vpo())
- {
- TRACFCOMP(g_trac_pnor, "PnorDdTest::test_smartwrite_modes> Adding REAL_CMD & MODEL_REAL_MMIO modes");
- supported_modes.push_back(PnorDD::MODEL_REAL_CMD);
- supported_modes.push_back(PnorDD::MODEL_REAL_MMIO);
- }
-
- // loop through all of the supported modes
- for( std::list<PnorDD::PnorMode_t>::iterator m
- = supported_modes.begin();
- m != supported_modes.end();
- ++m )
- {
- if( pnordd )
- {
- delete pnordd;
- }
-
- //Fake PNOR
- if( (PnorDD::MODEL_MEMCPY == *m) ||
- (PnorDD::MODEL_LPC_MEM == *m) )
- {
- //malloc some space to use as fake-PNOR
- if( fake_space )
- {
- delete fake_space;
- }
- fake_space = new uint8_t[4 * KILOBYTE];
- pnordd = new PnorDD(*m,
- reinterpret_cast<uint64_t>(fake_space),
- (4 * KILOBYTE));
-
- //Adjusting the address by an arbitrary multiplier to keep
- //successive tests from always using the same memory space.
- scratch_space = (*m)*0x30;
-
- }
- //Real PNOR
- else
- {
- pnordd = new PnorDD(*m);
-
- if(!getTestSection(scratch_space, sect_size))
- {
- TRACFCOMP(g_trac_pnor,
- "PnorDdTest::test_readwrite_modes> Skipped due to not finding test section in PNOR" );
- continue;
- }
- //Adjusting the address by an arbitrary multiplier to keep
- //successive tests from always using the same memory space.
- scratch_space += (*m)*0x30;
- }
-
- // Perform PnorDD Write 1
- uint64_t l_address = scratch_space+0x20;
- uint64_t l_writeData = 0xAAAAAAAA55555555;
- l_size = sizeof(uint64_t);
- l_err = pnordd->writeFlash(&l_writeData,
- l_size,
- l_address);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_smartwrite_modes: PNORDD write 1: writeFlash() failed! Error committed.");
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
-
- // Perform PnorDD Write 2 - no erase
- l_writeData = 0xAAAAAAAAFFFFFFFF;
- l_size = sizeof(uint64_t);
- l_err = pnordd->writeFlash(&l_writeData,
- l_size,
- l_address);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_smartwrite_modes: PNORDD write 2: writeFlash() failed! Error committed.");
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
-
- // Perform PnorDD Write 3 - put some words after the next write
- l_writeData = 0x1234567887654321;
- l_size = sizeof(uint64_t);
- l_err = pnordd->writeFlash(&l_writeData,
- l_size,
- l_address+sizeof(uint64_t));
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_smartwrite_modes: PNORDD write 3: writeFlash() failed! Error committed.");
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
-
- // Perform PnorDD Write 4 - requires erase
- l_writeData = 0x8888888811111111;
- l_size = sizeof(uint64_t);
- l_err = pnordd->writeFlash(&l_writeData,
- l_size,
- l_address);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_smartwrite_modes: PNORDD write 4: writeFlash() failed! Error committed.");
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
-
- // Perform PnorDD read of the data we just wrote
- uint64_t l_readData = 0;
- l_size = sizeof(uint64_t);
- l_err = pnordd->readFlash(&l_readData,
- l_size,
- l_address);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_smartwrite_modes: PNORDD read: readFlash() failed! Error committed.");
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
- total++;
- if(l_readData != l_writeData)
- {
- TS_FAIL("PnorDdTest::test_smartwrite_modes: PNORDD read: Read data not expected value. Addr: 0x%llx, ExpData: 0x%llx, ActData: 0x%llx",
- l_address, l_writeData, l_readData);
- fails++;
- }
-
- // Perform PnorDD read of the data after what we just wrote
- // verifies that we restored the rest of the block
- l_readData = 0;
- l_size = sizeof(uint64_t);
- l_err = pnordd->readFlash(&l_readData,
- l_size,
- l_address+sizeof(uint64_t));
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_smartwrite_modes: PNORDD read: readFlash() failed! Error committed.");
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
- total++;
- if(l_readData != 0x1234567887654321)
- {
- TS_FAIL("PnorDdTest::test_smartwrite_modes: PNORDD read: Read data not expected value. Addr: 0x%llx, ExpData: 0x%llx, ActData: 0x%llx",
- l_address, 0x1234567887654321, l_readData);
- fails++;
- }
- }
-
- }while(0);
-
- if( pnordd )
- {
- delete pnordd;
- }
- if( fake_space )
- {
- delete fake_space;
- }
-
- TRACFCOMP(g_trac_pnor, "PnorDdTest::test_smartwrite> %d/%d fails", fails, total );
- }
-
- /**
- * @brief PNOR DD Cross-Block testcase
- * Same as test_crossblock but forcing the use of all supported modes
- */
- void test_crossblock_modes(void)
- {
- PnorDD* pnordd = NULL;
- uint8_t* fake_space = NULL;
- size_t l_size = sizeof(uint64_t);
- errlHndl_t l_err = NULL;
- uint64_t fails = 0;
- uint64_t total = 0;
- uint64_t scratch_space = 0;
- uint64_t sect_size = 0;
-
- do{
- TS_TRACE("PnorDdTest::test_crossblock_modes: starting");
-
- // 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);
-
- if(!TARGETING::is_vpo())
- {
- TRACFCOMP(g_trac_pnor, "PnorDdTest::test_crossblock_modes> Adding REAL_CMD & MODEL_REAL_MMIO mode");
- supported_modes.push_back(PnorDD::MODEL_REAL_CMD);
- supported_modes.push_back(PnorDD::MODEL_REAL_MMIO);
- }
-
- // loop through all of the supported modes
- for( std::list<PnorDD::PnorMode_t>::iterator m
- = supported_modes.begin();
- m != supported_modes.end();
- ++m )
- {
- if( pnordd )
- {
- delete pnordd;
- }
-
-
- //Fake PNOR
- if( (PnorDD::MODEL_MEMCPY == *m) ||
- (PnorDD::MODEL_LPC_MEM == *m) )
- {
- //malloc some space to use as fake-PNOR
- if( fake_space )
- {
- delete fake_space;
- }
- fake_space = new uint8_t[8 * KILOBYTE];
- pnordd = new PnorDD(*m,
- reinterpret_cast<uint64_t>(fake_space),
- (8 * KILOBYTE));
- scratch_space = 0;
- sect_size = 8 * KILOBYTE;
- }
- //Real PNOR
- else
- {
- pnordd = new PnorDD(*m);
-
- if(!getTestSection(scratch_space, sect_size))
- {
- TRACFCOMP(g_trac_pnor,
- "PnorDdTest::test_readwrite_modes> Skipped due to not finding test section in PNOR" );
- continue;
- }
- }
-
- // Find the nearest erase-block (4K) boundary
- uint64_t l_boundary = (scratch_space+4096)
- - (scratch_space%4096);
- uint64_t l_address = 0;
-
- //make sure we don't go past the end of the section
- if(l_boundary+0x4 > scratch_space+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, scratch_space=0x%X, sect_size=0x%X",
- l_boundary, scratch_space, 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;
- l_size = sizeof(uint64_t);
- l_err = pnordd->writeFlash(&l_writeData,
- l_size,
- l_address);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_crossblock_modes: PNORDD write 1: writeFlash() failed! Error committed.");
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
-
- // Perform PnorDD Read 1 - verify previous write
- l_address = l_boundary - sizeof(uint32_t);
- uint64_t l_readData = 0x0;
- l_size = sizeof(uint64_t);
- l_err = pnordd->readFlash(&l_readData,
- l_size,
- l_address);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_crossblock_modes: PNORDD Read 1: readFlash() failed! Error committed.");
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
- total++;
- if(l_readData != l_writeData)
- {
- TS_FAIL("PnorDdTest::test_crossblock_modes: PNORDD read: Read data not expected value. Addr: 0x%.llx, ExpData: 0x%.llx, ActData: 0x%llx", l_address, l_writeData, l_readData);
- fails++;
- }
- }
- }while(0);
-
- if( pnordd )
- {
- delete pnordd;
- }
- if( fake_space )
- {
- delete fake_space;
- }
-
- TRACFCOMP(g_trac_pnor, "PnorDdTest::test_crossblock_modes> %d/%d fails", fails, total );
- }
-
-
- /**
- * @brief PNOR DD Force Fails testcase
- */
-/****************************************************************************/
-/* NOTE: TEST DISABLED!!! remove "_" before test name to re-enable */
-/****************************************************************************/
- void _test_forceFails(void)
- {
- errlHndl_t l_err = NULL;
- uint64_t fails = 0;
- uint64_t total = 0;
- PnorDD* pnordd = new PnorDD();
- uint32_t l_poll = 0;
- PnorDD::SfcCmdReg_t sfc_cmd;
-
- do{
- TRACFCOMP(g_trac_pnor, "PnorDdTest::test_forceFails> starting - expect to see errors");
-
- /*******************************/
- /* Send in an invalid OP Code */
- /*******************************/
- sfc_cmd.opcode = PnorDD::SFC_OP_INVALID;
- sfc_cmd.length = 0;
-
- mutex_lock(pnordd->iv_mutex_ptr);
- l_err = pnordd->writeRegSfc(PnorDD::SFC_CMD_SPACE,
- PnorDD::SFC_REG_CMD,
- sfc_cmd.data32);
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_forceFails> Get Chip Id cmd failed! Error committed.");
- fails++;
-
- // Unlock mutex for Error Log to be commited
- mutex_unlock(pnordd->iv_mutex_ptr);
- errlCommit(l_err,PNOR_COMP_ID);
-
- // Lock mutex for next operation
- mutex_lock(pnordd->iv_mutex_ptr);
- }
-
- // Poll for complete status without waiting
- l_err = pnordd->pollSfcOpComplete();
- mutex_unlock(pnordd->iv_mutex_ptr);
-
- total++;
- if ( l_err == NULL )
- {
- TS_FAIL("PnorDdTest::test_forceFails> Failed to create illegal opcode error!");
- fails++;
- }
- else
- {
- // error correctly created - delete it
- delete l_err;
- }
-
- /*******************************************************/
- /* Issue a cmd but poll for completion without waiting */
- /*******************************************************/
- //Issue Get Chip ID command
- sfc_cmd.opcode = PnorDD::SFC_OP_CHIPID;
- sfc_cmd.length = 0;
-
- mutex_lock(pnordd->iv_mutex_ptr);
- l_err = pnordd->writeRegSfc(PnorDD::SFC_CMD_SPACE,
- PnorDD::SFC_REG_CMD,
- sfc_cmd.data32);
-
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_forceFails> Get Chip Id cmd failed! Error committed.");
- fails++;
-
- // Unlock mutex for Error Log to be commited
- mutex_unlock(pnordd->iv_mutex_ptr);
- errlCommit(l_err,PNOR_COMP_ID);
-
- // Lock mutex for next operation
- mutex_lock(pnordd->iv_mutex_ptr);
- }
-
- // Poll for complete status without waiting
- l_err = pnordd->pollSfcOpComplete(l_poll);
-
- total++;
- if ( l_err == NULL )
- {
- TS_FAIL("PnorDdTest::test_forceFails> pollSfcOpCompletel(l_poll=0) Failed to create an error!");
- fails++;
- }
- else
- {
- // error correctly created - delete it
- delete l_err;
- }
-
- /*******************************************************/
- /* Cleanup: poll to make sure last operation completes */
- /* before continuing */
- /*******************************************************/
- l_err = pnordd->pollSfcOpComplete();
- mutex_unlock(pnordd->iv_mutex_ptr);
-
- total++;
- if (l_err)
- {
- TS_FAIL("PnorDdTest::test_forceFails> Cleanup polling failed! Error committed.");
- errlCommit(l_err,PNOR_COMP_ID);
- fails++;
- }
-
-
- }while(0);
-
- if( pnordd )
- {
- delete pnordd;
- }
-
- TRACFCOMP(g_trac_pnor, "PnorDdTest::test_forceFails> %d/%d fails", fails, total );
-
- }
-
};
/*Not really a real test, just using to verify ext image is loading properly.
diff --git a/src/usr/pnor/test/pnorrptest.H b/src/usr/pnor/test/pnorrptest.H
index 6c90f2a99..6c43f9d4a 100644
--- a/src/usr/pnor/test/pnorrptest.H
+++ b/src/usr/pnor/test/pnorrptest.H
@@ -6,6 +6,7 @@
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2011,2014 */
+/* [+] Google Inc. */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -544,12 +545,12 @@ class PnorRpTest : public CxxTest::TestSuite
// 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);
+ 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");
+ TRACFCOMP(g_trac_pnor, "PnorRpTest::test_TOC> ERROR : TOC %d header is corrupted, did not use other TOC", cur_TOC);
+ TS_FAIL("PnorRpTest::test_TOC> ERROR : TOC %d header is corrupted, did not use other TOC");
}
// Fix cur_TOC header
@@ -571,12 +572,12 @@ class PnorRpTest : public CxxTest::TestSuite
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);
+ 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);
+ TRACFCOMP(g_trac_pnor, "PnorRpTest::test_TOC> ERROR : TOC %d entry is corrupted, did not use other TOC ENTRY", cur_TOC);
+ TS_FAIL("PnorRpTest::test_TOC> ERROR : TOC %d entry is corrupted, did not use other TOC", cur_TOC);
}
// Fix cur_TOC first entry
diff --git a/src/usr/pnor/test/sfc_ast2400test.H b/src/usr/pnor/test/sfc_ast2400test.H
new file mode 100644
index 000000000..4dc69e68e
--- /dev/null
+++ b/src/usr/pnor/test/sfc_ast2400test.H
@@ -0,0 +1,305 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/pnor/test/sfc_ast2400test.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] Google Inc. */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+#ifndef __SFC_AST2400TEST_H
+#define __SFC_AST2400TEST_H
+
+/**
+ * @file sfc_ast2400test.H
+ *
+ * @brief Test case for AST2400 Flash Controller
+*/
+
+#include <cxxtest/TestSuite.H>
+#include <errl/errlmanager.H>
+#include <errl/errlentry.H>
+#include <devicefw/userif.H>
+#include <sys/time.h>
+#include "../pnordd.H"
+#include <list>
+#include <targeting/common/attributes.H>
+#include <lpc/lpcif.H>
+#include "../sfc_ast2400.H"
+
+extern trace_desc_t* g_trac_pnor;
+
+class SfcAST2400Test : 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 TEST PNOR section info from PNOR RP
+ l_err = PNOR::getSectionInfo( PNOR::TEST,
+ 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 Test Flash Reads
+ * Verify that reads work in normal mode and then do
+ * not work in command mode
+ */
+ void test_FlashReads( void )
+ {
+ PnorDD& pnordd = Singleton<PnorDD>::instance();
+ SfcAST2400* sfc = reinterpret_cast<SfcAST2400*>(pnordd.iv_sfc );
+ mutex_t* l_mutex = pnordd.iv_mutex_ptr;
+ errlHndl_t l_err = NULL;
+
+ //Find some pnor to read
+ uint64_t base_address;
+ uint64_t sect_size;
+ if(!getTestSection(base_address, sect_size))
+ {
+ TRACFCOMP(g_trac_pnor, "SfcAST2400Test::test_FlashReads> Skipped due to not finding test section in PNOR" );
+ TS_FAIL("SfcAST2400Test::test_FlashReads> Skipped due to not finding test section in PNOR");
+ return;
+ }
+
+ mutex_lock(l_mutex);
+
+ //Prove reads work by default and that they fail in command mode
+ uint64_t l_readData = 0;
+ size_t l_size = sizeof(uint64_t);
+ l_err = pnordd._readFlash(base_address,
+ l_size,
+ &l_readData);
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_FlashReads> Basic read failed");
+ mutex_unlock(l_mutex);//unlock before commit
+ errlCommit(l_err,PNOR_COMP_ID);
+ return; //just give up if basic reads don't work
+ }
+
+ // Put controller into command mode (instead of read mode)
+ l_err = sfc->commandMode( true );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_FlashReads> Error entering command mode");
+ mutex_unlock(l_mutex);//unlock before commit
+ errlCommit(l_err,PNOR_COMP_ID);
+ mutex_lock(l_mutex);//lock again for next op
+ }
+
+ // Reads should fail
+ l_err = pnordd._readFlash(base_address,
+ l_size,
+ &l_readData);
+ if( !l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_FlashReads> Read did not fail in command mode");
+ }
+ else
+ {
+ delete l_err;
+ }
+
+ // Put controller back into read mode
+ l_err = sfc->commandMode( false );
+ mutex_unlock(l_mutex);
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_FlashReads> Error exiting command mode");
+ errlCommit(l_err,PNOR_COMP_ID);
+ }
+ }
+
+ /**
+ * @brief Test SIO access
+ * Use a SIO scratch register to verify reads and writes
+ */
+ void test_SIO(void)
+ {
+ SfcAST2400* sfc = reinterpret_cast<SfcAST2400*>(
+ Singleton<PnorDD>::instance().iv_sfc );
+ errlHndl_t l_err = NULL;
+
+ // Read SIO to BMC scratch reg 1,2 and save off values
+ uint8_t scratch1 = 0;
+ l_err = sfc->readRegSIO( 0x21, scratch1 );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SIO> readRegSIO failed");
+ errlCommit(l_err,PNOR_COMP_ID);
+ }
+ uint8_t scratch2 = 0;
+ l_err = sfc->readRegSIO( 0x22, scratch2 );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SIO> readRegSIO failed");
+ errlCommit(l_err,PNOR_COMP_ID);
+ }
+
+ // Write test patterns into registers
+ uint8_t testdata = 0xA5;
+ l_err = sfc->writeRegSIO( 0x21, testdata );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SIO> writeRegSIO failed");
+ errlCommit(l_err,PNOR_COMP_ID);
+ }
+ testdata = 0x12;
+ l_err = sfc->writeRegSIO( 0x22, testdata );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SIO> writeRegSIO failed");
+ errlCommit(l_err,PNOR_COMP_ID);
+ }
+
+ // Read the data back and compare to expected results
+ l_err = sfc->readRegSIO( 0x21, testdata );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SIO> readRegSIO failed");
+ errlCommit(l_err,PNOR_COMP_ID);
+ }
+ if( testdata != 0xA5 )
+ {
+ TS_FAIL("SfcAST2400Test::test_SIO> Data mismatch on SIO 0x21 : Exp=0xA5, Act=%.2X", testdata);
+ }
+ l_err = sfc->readRegSIO( 0x22, testdata );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SIO> readRegSIO failed");
+ errlCommit(l_err,PNOR_COMP_ID);
+ }
+ if( testdata != 0x12 )
+ {
+ TS_FAIL("SfcAST2400Test::test_SIO> Data mismatch on SIO 0x22 : Exp=0x12, Act=%.2X", testdata);
+ }
+
+ // Restore the original data
+ l_err = sfc->writeRegSIO( 0x21, scratch1 );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SIO> writeRegSIO failed");
+ errlCommit(l_err,PNOR_COMP_ID);
+ }
+ l_err = sfc->writeRegSIO( 0x22, scratch2 );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SIO> writeRegSIO failed");
+ errlCommit(l_err,PNOR_COMP_ID);
+ }
+ }
+
+ /**
+ * @brief Test SPIC access
+ * Read and write data to the SPI Control register
+ */
+ void test_SPIC( void )
+ {
+ SfcAST2400* sfc = reinterpret_cast<SfcAST2400*>(
+ Singleton<PnorDD>::instance().iv_sfc );
+ mutex_t* l_mutex = Singleton<PnorDD>::instance().iv_mutex_ptr;
+ errlHndl_t l_err = NULL;
+
+ mutex_lock(l_mutex);
+
+ uint32_t first = 0;
+ l_err = sfc->readRegSPIC( SfcAST2400::CTLREG_04, first );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SPIC> readRegSIO failed");
+ mutex_unlock(l_mutex);//unlock before commit
+ errlCommit(l_err,PNOR_COMP_ID);
+ mutex_lock(l_mutex);//lock again for next op
+ }
+ uint32_t data1 = 0x12345678;
+ l_err = sfc->writeRegSPIC( SfcAST2400::CTLREG_04, data1 );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SPIC> readRegSIO failed");
+ mutex_unlock(l_mutex);//unlock before commit
+ errlCommit(l_err,PNOR_COMP_ID);
+ mutex_lock(l_mutex);//lock again for next op
+ }
+ l_err = sfc->readRegSPIC( SfcAST2400::CTLREG_04, data1 );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SPIC> readRegSIO failed");
+ mutex_unlock(l_mutex);//unlock before commit
+ errlCommit(l_err,PNOR_COMP_ID);
+ mutex_lock(l_mutex);//lock again for next op
+ }
+ if( data1 != 0x12345678 )
+ {
+ TS_FAIL("SfcAST2400Test::test_SPIC> Unexpected result of %.8X (exp 0x12345678)",data1);
+ }
+ //put back the original
+ l_err = sfc->writeRegSPIC( SfcAST2400::CTLREG_04, first );
+ if( l_err )
+ {
+ TS_FAIL("SfcAST2400Test::test_SPIC> readRegSIO failed");
+ mutex_unlock(l_mutex);//unlock before commit
+ errlCommit(l_err,PNOR_COMP_ID);
+ }
+
+ mutex_unlock(l_mutex);
+ }
+};
+
+#endif
diff --git a/src/usr/pnor/test/sfc_ibmtest.H b/src/usr/pnor/test/sfc_ibmtest.H
new file mode 100644
index 000000000..967045ad0
--- /dev/null
+++ b/src/usr/pnor/test/sfc_ibmtest.H
@@ -0,0 +1,174 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/pnor/test/sfc_ibmtest.H $ */
+/* */
+/* OpenPOWER HostBoot Project */
+/* */
+/* Contributors Listed Below - COPYRIGHT 2014 */
+/* [+] Google Inc. */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+#ifndef __SFC_IBMTEST_H
+#define __SFC_IBMTEST_H
+
+/**
+ * @file sfc_ibmtest.H
+ *
+ * @brief Test case for IBM DPSS Flash Controller
+*/
+
+#include <cxxtest/TestSuite.H>
+#include <errl/errlmanager.H>
+#include <errl/errlentry.H>
+#include <devicefw/userif.H>
+#include <sys/time.h>
+#include "../pnordd.H"
+#include <list>
+#include <targeting/common/attributes.H>
+#include "../sfc_ibm.H"
+
+extern trace_desc_t* g_trac_pnor;
+
+class SfcIBMTest : public CxxTest::TestSuite
+{
+ public:
+
+ /*************************************************************************/
+ /* NOTE: TEST DISABLED!!! remove "_" before test name to re-enable */
+ /*************************************************************************/
+ /**
+ * @brief PNOR DD Force Fails testcase
+ */
+ void _test_forceFails(void)
+ {
+ errlHndl_t l_err = NULL;
+ uint64_t fails = 0;
+ uint64_t total = 0;
+ SfcIBM* sfcdd = reinterpret_cast<SfcIBM*>(
+ Singleton<PnorDD>::instance().iv_sfc );
+ mutex_t* l_mutex = Singleton<PnorDD>::instance().iv_mutex_ptr;
+ SfcIBM::SfcCmdReg_t sfc_cmd;
+
+ do{
+ TRACFCOMP(g_trac_pnor, "SfcIBMTest::test_forceFails> starting - expect to see errors");
+
+ /*******************************/
+ /* Send in an invalid OP Code */
+ /*******************************/
+ sfc_cmd.opcode = SfcIBM::SFC_OP_INVALID;
+ sfc_cmd.length = 0;
+
+ mutex_lock(l_mutex);
+ l_err = sfcdd->writeReg(SfcIBM::SFC_CMD_SPACE,
+ SfcIBM::SFC_REG_CMD,
+ sfc_cmd.data32);
+ total++;
+ if (l_err)
+ {
+ TS_FAIL("SfcIBMTest::test_forceFails> writeReg failed! Error committed.");
+ fails++;
+
+ // Unlock mutex for Error Log to be commited
+ mutex_unlock(l_mutex);
+ errlCommit(l_err,PNOR_COMP_ID);
+
+ // Lock mutex for next operation
+ mutex_lock(l_mutex);
+ }
+
+ // Poll for complete status without waiting
+ l_err = sfcdd->pollOpComplete();
+ mutex_unlock(l_mutex);
+
+ total++;
+ if ( l_err == NULL )
+ {
+ TS_FAIL("SfcIBMTest::test_forceFails> Failed to create illegal opcode error!");
+ fails++;
+ }
+ else
+ {
+ // error correctly created - delete it
+ delete l_err;
+ }
+
+ /*******************************************************/
+ /* Issue a cmd but poll for completion without waiting */
+ /*******************************************************/
+ //Issue Get Chip ID command
+ sfc_cmd.opcode = SfcIBM::SFC_OP_CHIPID;
+ sfc_cmd.length = 0;
+
+ mutex_lock(l_mutex);
+ l_err = sfcdd->writeReg(SfcIBM::SFC_CMD_SPACE,
+ SfcIBM::SFC_REG_CMD,
+ sfc_cmd.data32);
+
+ total++;
+ if (l_err)
+ {
+ TS_FAIL("SfcIBMTest::test_forceFails> Get Chip Id cmd failed! Error committed.");
+ fails++;
+
+ // Unlock mutex for Error Log to be commited
+ mutex_unlock(l_mutex);
+ errlCommit(l_err,PNOR_COMP_ID);
+
+ // Lock mutex for next operation
+ mutex_lock(l_mutex);
+ }
+
+ // Poll for complete status without waiting
+ l_err = sfcdd->pollOpComplete();
+
+ total++;
+ if ( l_err == NULL )
+ {
+ TS_FAIL("SfcIBMTest::test_forceFails> pollOpCompletel(l_poll=0) Failed to create an error!");
+ fails++;
+ }
+ else
+ {
+ // error correctly created - delete it
+ delete l_err;
+ }
+
+ /*******************************************************/
+ /* Cleanup: poll to make sure last operation completes */
+ /* before continuing */
+ /*******************************************************/
+ l_err = sfcdd->pollOpComplete();
+ mutex_unlock(l_mutex);
+
+ total++;
+ if (l_err)
+ {
+ TS_FAIL("SfcIBMTest::test_forceFails> Cleanup polling failed! Error committed.");
+ errlCommit(l_err,PNOR_COMP_ID);
+ fails++;
+ }
+
+
+ }while(0);
+
+ TRACFCOMP(g_trac_pnor, "SfcIBMTest::test_forceFails> %d/%d fails", fails, total );
+
+ }
+};
+
+#endif
OpenPOWER on IntegriCloud