summaryrefslogtreecommitdiffstats
path: root/src/usr/i2c/test/eepromddtest.H
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/i2c/test/eepromddtest.H')
-rwxr-xr-xsrc/usr/i2c/test/eepromddtest.H192
1 files changed, 148 insertions, 44 deletions
diff --git a/src/usr/i2c/test/eepromddtest.H b/src/usr/i2c/test/eepromddtest.H
index 5c622a7f5..71211c08a 100755
--- a/src/usr/i2c/test/eepromddtest.H
+++ b/src/usr/i2c/test/eepromddtest.H
@@ -1,25 +1,25 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/usr/i2c/test/eepromddtest.H $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2011
-//
-// p1
-//
-// Object Code Only (OCO) source materials
-// Licensed Internal Code Source Materials
-// IBM HostBoot Licensed Internal Code
-//
-// The source code for this program is not published or other-
-// wise divested of its trade secrets, irrespective of what has
-// been deposited with the U.S. Copyright Office.
-//
-// Origin: 30
-//
-// IBM_PROLOG_END
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/usr/i2c/test/eepromddtest.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2011,2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
#ifndef __EEPROMTEST_H
#define __EEPROMTEST_H
@@ -37,10 +37,18 @@
#include <i2c/eepromddreasoncodes.H>
#include <targeting/common/commontargeting.H>
#include "i2ctest.H"
+#include "../eepromdd.H"
extern trace_desc_t* g_trac_eeprom;
+// Easy macro replace for unit testing
+//#define TRACUCOMP(args...) TRACFCOMP(args)
+#define TRACUCOMP(args...)
+
using namespace TARGETING;
+using namespace EEPROM;
+
+
class EEPROMTest: public CxxTest::TestSuite
{
@@ -57,32 +65,47 @@ class EEPROMTest: public CxxTest::TestSuite
int fails = 0;
int num_ops = 0;
+ uint8_t* testBuffer = NULL;
+ uint8_t* testBuffer_read = NULL;
+
+
TRACFCOMP( g_trac_eeprom,
"testEEPROMReadWrite - Start" );
struct
{
- uint64_t addr; // Slave Device Address to access
+ uint64_t offset; // Internal Slave Device Offset to access
uint64_t chip; // Which EEPROM chip hung off of the target to access
uint64_t data; // Data to write or compare to
size_t size; // Number of bytes to read/write
bool rnw; // Read (true), Write (false)
} testData[] =
+
{
- { 0x1111, 0x0, 0xfedcba9876543210, 8, false }, // Write data
- { 0x1111, 0x0, 0xfedcba9876543210, 8, true }, // Read data
- { 0x2222, 0x0, 0xaabb000000000000, 2, false },
- { 0x2222, 0x0, 0xaabb000000000000, 2, true },
- { 0x1122, 0x0, 0x1122334400000000, 4, false },
- { 0x1122, 0x0, 0x1122334400000000, 4, true },
+
+
+ // MVPD of processor - chip 0
+ // Write:
+ { 0x0000, VPD_PRIMARY, 0xfedcba9876543210, 8, false },
+ // Read:
+ { 0x0000, VPD_PRIMARY, 0xfedcba9876543210, 8, true },
+
+ // SBE Primary of processor - chip 2
+ // Write:
+ { 0x0100, SBE_PRIMARY, 0xaabb000000000000, 2, false },
+ // Read:
+ { 0x0100, SBE_PRIMARY, 0xaabb000000000000, 2, true },
+
+ // SBE Backup of processor - chip 3
+ // Write:
+ { 0x00F0, SBE_BACKUP, 0x1122334400000000, 4, false },
+ // Read:
+ { 0x00F0, SBE_BACKUP, 0x1122334400000000, 4, true },
};
const uint32_t NUM_CMDS = sizeof(testData)/sizeof(testData[0]);
- //@TODO
- //@VBU workaround - Disable I2C test case on fake target
- //Test case use fake targets, which will fail when running
- //on VBU. Need to fix this.
+ // Skipping EEPROM test altogether in VBU/VPO environment
if( TARGETING::is_vpo() )
{
return;
@@ -98,13 +121,10 @@ class EEPROMTest: public CxxTest::TestSuite
TargetHandleList fullList;
fullList.push_back( testTarget );
- // TODO - The following is what I want to use... BUT, since we
- // can't target DIMMs yet, and only Proc 0 has a slave device
- // hung off of it, we can't do that yet. Uncomment the following
- // when it is supported.
+ // Uncomment the following code when other I2C devices
+ // are supported
// TARGETING::TargetService& tS = TARGETING::targetService();
// TARGETING::Target * sysTarget = NULL;
-// TargetHandleList fullList;
// // Get top level system target
// tS.getTopLevelTarget( sysTarget );
@@ -159,8 +179,9 @@ class EEPROMTest: public CxxTest::TestSuite
fullList[j],
&data,
testData[i].size,
- DEVICE_EEPROM_ADDRESS( testData[i].addr,
- testData[i].chip ) );
+ DEVICE_EEPROM_ADDRESS(
+ testData[i].chip,
+ testData[i].offset));
if( err )
{
@@ -189,8 +210,92 @@ class EEPROMTest: public CxxTest::TestSuite
}
}
}
+
+ // Test EEPROM Write of large size
+ // @todo RTC:69113 - will clean this up:
+ // 1) Make its own testcase function
+ // 2) Will use a larger data set: Plan on using 4K header of
+ // test_signed_container and putting it into un-used area of
+ // SBE_BACKUP
+ // 3) Will restore original data just in case
+ uint64_t testBufLen = 0xF1;
+ testBuffer = static_cast<uint8_t*>(malloc(testBufLen));
+ memset(testBuffer, 0xFE, testBufLen);
+
+ // Randomize the Data a bit
+ for (uint64_t i = 0;
+ i < ((testBufLen / 8) + 1);
+ i++)
+ testBuffer[i*8] = i;
+
+ for (uint64_t k = 0; k < 8; k++)
+ testBuffer[k] = k;
+
+ // do the Write operation
+ err = deviceOp( DeviceFW::WRITE,
+ fullList[0],
+ testBuffer,
+ testBufLen,
+ DEVICE_EEPROM_ADDRESS(SBE_BACKUP,0x0));
+ if( err )
+ {
+ TS_FAIL( "testEEPROMReadWrite - FAIL on large Data Write");
+ errlCommit( err,
+ EEPROM_COMP_ID );
+ delete err;
+ break;
+ }
+
+ // Read Back and Compare
+ testBuffer_read = static_cast<uint8_t*>(malloc( testBufLen ));
+
+ // clear read buffer
+ memset (testBuffer_read, 0, testBufLen);
+
+ // do the Read operation
+ err = deviceOp( DeviceFW::READ,
+ fullList[0],
+ testBuffer_read,
+ testBufLen,
+ DEVICE_EEPROM_ADDRESS(SBE_BACKUP,0x0));
+
+
+ if( err )
+ {
+ TS_FAIL( "testEEPROMReadWrite - FAIL on large Data Read");
+ errlCommit( err,
+ EEPROM_COMP_ID );
+ delete err;
+ break;
+ }
+
+
+ // Compare the data
+ if ( memcmp( testBuffer, testBuffer_read, testBufLen) )
+ {
+ TS_FAIL( "testEEPROMReadWrite - MISCOMPARE on large Data");
+ break;
+ }
+ else
+ {
+ TRACUCOMP( g_trac_eeprom, "testEEPROMReadWrite - large "
+ "Data R/W Successful");
+ }
+
} while( 0 );
+ // Clean up malloc'ed buffers
+ if ( testBuffer != NULL)
+ {
+ free(testBuffer);
+ }
+
+ if ( testBuffer_read != NULL)
+ {
+ free(testBuffer_read);
+ }
+
+
TRACFCOMP( g_trac_eeprom,
"testEEPROMReadWrite - %d/%d fails",
fails, num_ops );
@@ -260,7 +365,6 @@ class EEPROMTest: public CxxTest::TestSuite
uint64_t data = 0x0ull;
size_t dataSize = 8;
- const int64_t CHIP_NUM = 20;
do
{
@@ -283,14 +387,14 @@ class EEPROMTest: public CxxTest::TestSuite
testTarget,
&data,
dataSize,
- DEVICE_EEPROM_ADDRESS( 0x0,
- CHIP_NUM ) );
+ DEVICE_EEPROM_ADDRESS( LAST_CHIP_TYPE,
+ 0x0 ) );
if( NULL == err )
{
fails++;
TS_FAIL( "Error should've resulted in using EEPROM chip %d!",
- CHIP_NUM );
+ LAST_CHIP_TYPE );
}
else
{
OpenPOWER on IntegriCloud