summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@us.ibm.com>2012-07-10 21:17:32 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-08-15 12:43:58 -0500
commit63227ec1b2670c6e2eec5936607e8cd5f485933d (patch)
tree4d8758f4bed18a81649c8d9f5fb167bcbeaa5eb8 /src/usr
parent13682024ac1a36b7400c8619e87b88a5b182d132 (diff)
downloadtalos-hostboot-63227ec1b2670c6e2eec5936607e8cd5f485933d.tar.gz
talos-hostboot-63227ec1b2670c6e2eec5936607e8cd5f485933d.zip
Attention handler SCOM wrapper.
RTC: 41446 Change-Id: Ib5b8c6e3dd29b9b813c0e1bbdf797218f0a96c40 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1353 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/diag/attn/attnfwd.H73
-rw-r--r--src/usr/diag/attn/attnscom.C177
-rw-r--r--src/usr/diag/attn/attnscom.H220
-rw-r--r--src/usr/diag/attn/makefile3
-rw-r--r--src/usr/diag/attn/test/attnfakesys.C102
-rw-r--r--src/usr/diag/attn/test/attnfakesys.H68
-rw-r--r--src/usr/diag/attn/test/attntestscom.H240
7 files changed, 859 insertions, 24 deletions
diff --git a/src/usr/diag/attn/attnfwd.H b/src/usr/diag/attn/attnfwd.H
index 4ec84019e..3a6aaf780 100644
--- a/src/usr/diag/attn/attnfwd.H
+++ b/src/usr/diag/attn/attnfwd.H
@@ -42,6 +42,7 @@ class AttnTraceTest;
class AttnSvcTest;
class AttnListTest;
class AttnOpsTest;
+class AttScomTest;
namespace ATTN
{
@@ -55,6 +56,8 @@ class ResolverWrapper;
class Resolver;
class TargetService;
class TargetServiceImpl;
+class ScomWrapper;
+class ScomImpl;
enum
{
@@ -82,6 +85,76 @@ enum MessageType
};
/**
+ * @brief ScomOp ModifyScom operation types.
+ */
+enum ScomOp
+{
+ /**
+ * @brief SCOM_OR ModifyScom or operation.
+ */
+ SCOM_OR,
+
+ /**
+ * @brief SCOM_AND ModifyScom and operation.
+ */
+ SCOM_AND,
+};
+
+/**
+ * @brief getScom Read a register using SCOM.
+ *
+ * @param[in] i_target Target to read register from.
+ * @param[in] i_address Register address to read from.
+ * @param[in] i_data Buffer to write register content to.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+errlHndl_t getScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t & o_data);
+
+/**
+ * @brief putScom Write a register using SCOM.
+ *
+ * @param[in] i_target Target to write register on.
+ * @param[in] i_address Register address to write to.
+ * @param[in] i_data Data to write to register.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+errlHndl_t putScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data);
+
+/**
+ * @brief modifyScom Read/Modify/Write a register using SCOM.
+ *
+ * @param[in] i_target Target to write register on.
+ * @param[in] i_address Register address to write to.
+ * @param[in] i_data Data to write to register.
+ * @param[in] i_op And/Or specification.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+errlHndl_t modifyScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data,
+ ScomOp i_op);
+
+/**
+ * @brief getScomWrapper ScomWrapper singleton access.
+ *
+ * @return ScomWrapper Singleton instance.
+ */
+ScomWrapper & getScomWrapper();
+
+/**
* @brief getPrdWrapper PrdWrapper singleton access.
*
* @return PrdWrapper Singleton instance.
diff --git a/src/usr/diag/attn/attnscom.C b/src/usr/diag/attn/attnscom.C
new file mode 100644
index 000000000..32d992c5b
--- /dev/null
+++ b/src/usr/diag/attn/attnscom.C
@@ -0,0 +1,177 @@
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/diag/attn/attnscom.C $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2012
+ *
+ * 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_TAG
+ */
+/**
+ * @file attnscom.C
+ *
+ * @brief HBATTN ATTN SCOM abstraction layer function definitions.
+ */
+
+#include "attnscom.H"
+#include "attntrace.H"
+#include <devicefw/userif.H>
+
+using namespace TARGETING;
+using namespace DeviceFW;
+
+namespace ATTN
+{
+
+errlHndl_t getScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t & o_data)
+{
+ errlHndl_t err = getScomWrapper().getScom(i_target, i_address, o_data);
+
+ ATTN_DBG("getScom: tgt: %p, add: 0x%.16x, data: 0x%.16x",
+ i_target, i_address, o_data);
+
+ return err;
+}
+
+errlHndl_t putScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data)
+{
+ ATTN_DBG("putScom: tgt: %p, add: 0x%.16x, data: 0x%.16x",
+ i_target, i_address, i_data);
+
+ return getScomWrapper().putScom(i_target, i_address, i_data);
+}
+
+errlHndl_t modifyScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data,
+ ScomOp i_op)
+{
+ uint64_t data = 0;
+
+ errlHndl_t err = getScomWrapper().modifyScom(
+ i_target,
+ i_address,
+ i_data,
+ data,
+ i_op);
+
+ ATTN_DBG("getScom: tgt: %p, add: 0x%.16x, data: 0x%.16x",
+ i_target, i_address, data);
+
+ bool changed = (i_op == SCOM_OR
+ ? (data | i_data) != data
+ : (data & i_data) != data);
+
+ if(changed)
+ {
+ ATTN_DBG("putScom: tgt: %p, add: 0x%.16x, data: 0x%.16x",
+ i_target,
+ i_address,
+ i_op == SCOM_OR ? data | i_data : data & i_data);
+ }
+
+ return err;
+}
+
+errlHndl_t ScomImpl::putScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data)
+{
+ size_t size = sizeof(i_data);
+
+ return deviceWrite(i_target, &i_data, size, DEVICE_SCOM_ADDRESS(i_address));
+}
+
+errlHndl_t ScomImpl::getScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t & o_data)
+{
+ size_t size = sizeof(o_data);
+
+ return deviceRead(i_target, &o_data, size, DEVICE_SCOM_ADDRESS(i_address));
+}
+
+errlHndl_t ScomImpl::modifyScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data,
+ uint64_t & o_data,
+ ScomOp i_op)
+{
+ errlHndl_t err = 0;
+
+ err = getScom(i_target, i_address, o_data);
+
+ if(!err && i_op == SCOM_OR
+ ? (o_data | i_data) != o_data
+ : (o_data & i_data) != o_data)
+ {
+ err = putScom(i_target, i_address,
+ i_op == SCOM_OR ? o_data | i_data : o_data & i_data);
+ }
+
+ return err;
+}
+
+void ScomImpl::installScomImpl()
+{
+ getScomWrapper().setImpl(*this);
+}
+
+errlHndl_t ScomWrapper::putScom(TargetHandle_t i_target, uint64_t i_address,
+ uint64_t i_data)
+{
+ return iv_impl->putScom(i_target, i_address, i_data);
+}
+
+errlHndl_t ScomWrapper::getScom(TargetHandle_t i_target, uint64_t i_address,
+ uint64_t & o_data)
+{
+ return iv_impl->getScom(i_target, i_address, o_data);
+}
+
+errlHndl_t ScomWrapper::modifyScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data,
+ uint64_t & o_data,
+ ScomOp i_op)
+{
+ return iv_impl->modifyScom(i_target, i_address, i_data, o_data, i_op);
+}
+
+ScomWrapper::ScomWrapper()
+ : iv_impl(&Singleton<ScomImpl>::instance())
+{
+
+}
+
+ScomWrapper & getScomWrapper()
+{
+ static ScomWrapper w;
+ return w;
+}
+}
diff --git a/src/usr/diag/attn/attnscom.H b/src/usr/diag/attn/attnscom.H
new file mode 100644
index 000000000..0905b340d
--- /dev/null
+++ b/src/usr/diag/attn/attnscom.H
@@ -0,0 +1,220 @@
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/diag/attn/attnscom.H $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2012
+ *
+ * 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_TAG
+ */
+#ifndef __ATTN_ATTNSCOM_H
+#define __ATTN_ATTNSCOM_H
+
+/**
+ * @file attnscom.H
+ *
+ * @brief HBATTN SCOM abstraction layer definitions.
+ */
+
+#include "attnfwd.H"
+
+namespace ATTN
+{
+
+/**
+ * @brief ScomImpl SCOM interface requirement.
+ *
+ * This default implementation routes SCOM calls to real hardware.
+ */
+class ScomImpl
+{
+ public:
+
+ /**
+ * @brief putScom Write a register using SCOM.
+ *
+ * @param[in] i_target Target to write register on.
+ * @param[in] i_address Register address to write to.
+ * @param[in] i_data Data to write to register.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ virtual errlHndl_t putScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data);
+
+ /**
+ * @brief getScom Read a register using SCOM.
+ *
+ * @param[in] i_target Target to read register from.
+ * @param[in] i_address Register address to read from.
+ * @param[out] o_data Buffer to write register content to.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ virtual errlHndl_t getScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t & o_data);
+
+ /**
+ * @brief modifyScom RMW a register using SCOM.
+ *
+ * @param[in] i_target Target to update register on.
+ * @param[in] i_address Register address to update.
+ * @param[in] i_data Data to write to register.
+ * @param[out] o_data Data read from register.
+ * @param[in] i_op and/or behavior.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ virtual errlHndl_t modifyScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data,
+ uint64_t & o_data,
+ ScomOp i_op);
+
+ /**
+ * @brief installScomImpl
+ *
+ * Set this as the active scom implementation.
+ */
+ void installScomImpl();
+
+ /**
+ * @brief dtor
+ */
+ virtual ~ScomImpl() {}
+
+ /**
+ * @brief ctor
+ */
+ ScomImpl() {}
+
+ private:
+
+ /**
+ * @brief copy Disabled.
+ */
+ ScomImpl(const ScomImpl &);
+
+ /**
+ * @brief assignment Disabled.
+ */
+ ScomImpl & operator=(const ScomImpl &);
+};
+
+/**
+ * @brief ScomWrapper Holds the installed SCOM implementation.
+ */
+class ScomWrapper
+{
+ public:
+
+ /**
+ * @brief setImpl Change the SCOM implementation to be used.
+ *
+ * @param[in] i_impl The new implemenation to use.
+ */
+ void setImpl(ScomImpl & i_impl)
+ {
+ iv_impl = &i_impl;
+ }
+
+ /**
+ * @brief putScom Write a register using SCOM.
+ *
+ * Routes to the current SCOM implementation.
+ *
+ * @param[in] i_target Target to write register on.
+ * @param[in] i_address Register address to write to.
+ * @param[in] i_data Data to write to register.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t putScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data);
+
+ /**
+ * @brief getScom Read a register using SCOM.
+ *
+ * Routes to the current SCOM implementation.
+ *
+ * @param[in] i_target Target to read register from.
+ * @param[in] i_address Register address to read from.
+ * @param[out] o_data Buffer to write register content to.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t getScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t & o_data);
+
+ /**
+ * @brief modifyScom RMW a register using SCOM.
+ *
+ * @param[in] i_target Target to update register on.
+ * @param[in] i_address Register address to update.
+ * @param[in] i_data Data to write to register.
+ * @param[out] o_data Data read from register.
+ * @param[in] i_op and/or behavior.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t modifyScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data,
+ uint64_t & o_data,
+ ScomOp i_op);
+
+ /**
+ * @brief ctor
+ */
+ ScomWrapper();
+
+ private:
+
+ /**
+ * @brief iv_impl The SCOM implementation to
+ * which calls should be forwarded.
+ */
+ ScomImpl * iv_impl;
+
+ /**
+ * @brief copy Disabled.
+ */
+ ScomWrapper(const ScomWrapper &);
+
+ /**
+ * @brief assignment Disabled.
+ */
+ ScomWrapper & operator=(const ScomWrapper &);
+};
+}
+#endif
diff --git a/src/usr/diag/attn/makefile b/src/usr/diag/attn/makefile
index a91eda158..93234a8b3 100644
--- a/src/usr/diag/attn/makefile
+++ b/src/usr/diag/attn/makefile
@@ -26,7 +26,8 @@ EXTRAINCDIR += ${ROOTPATH}/src/include/usr/diag
MODULE = attn
-OBJS = attntrace.o attn.o attnsvc.o attnlist.o attnbits.o attntarget.o
+OBJS = attntrace.o attn.o attnsvc.o attnlist.o attnbits.o attntarget.o \
+ attnscom.o
SUBDIRS = test.d
diff --git a/src/usr/diag/attn/test/attnfakesys.C b/src/usr/diag/attn/test/attnfakesys.C
index a91f5f395..e93e264e3 100644
--- a/src/usr/diag/attn/test/attnfakesys.C
+++ b/src/usr/diag/attn/test/attnfakesys.C
@@ -1,25 +1,26 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/usr/diag/attn/test/attnfakesys.C $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2012
-//
-// 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/diag/attn/test/attnfakesys.C $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2012
+ *
+ * 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_TAG
+ */
/**
* @file attnfakesys.C
*
@@ -39,6 +40,63 @@ using namespace TARGETING;
namespace ATTN
{
+errlHndl_t FakeSystem::putScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data)
+{
+ mutex_lock(&iv_mutex);
+
+ iv_regs[i_target][i_address] = i_data;
+
+ mutex_unlock(&iv_mutex);
+
+ return 0;
+}
+
+errlHndl_t FakeSystem::getScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t & o_data)
+{
+ mutex_lock(&iv_mutex);
+
+ o_data = iv_regs[i_target][i_address];
+
+ mutex_unlock(&iv_mutex);
+
+ return 0;
+}
+
+errlHndl_t FakeSystem::modifyScom(
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data,
+ uint64_t & o_data,
+ ScomOp i_op)
+{
+ mutex_lock(&iv_mutex);
+
+ o_data = iv_regs[i_target][i_address];
+
+ uint64_t data = iv_regs[i_target][i_address];
+
+ bool changed = (i_op == SCOM_OR
+ ? (data | i_data) != data
+ : (data & i_data) != data);
+
+ if(changed)
+ {
+ iv_regs[i_target][i_address] = i_op == SCOM_OR
+ ? data | i_data
+ : data & i_data;
+ }
+
+ mutex_unlock(&iv_mutex);
+
+ return 0;
+}
+
errlHndl_t FakeSystem::mask(const PRDF::AttnData & i_data)
{
mutex_lock(&iv_mutex);
diff --git a/src/usr/diag/attn/test/attnfakesys.H b/src/usr/diag/attn/test/attnfakesys.H
index 2ab0c4ec7..34d0d29b2 100644
--- a/src/usr/diag/attn/test/attnfakesys.H
+++ b/src/usr/diag/attn/test/attnfakesys.H
@@ -34,6 +34,7 @@
#include "../attnops.H"
#include "../attnprd.H"
#include "../attnresolv.H"
+#include "../attnscom.H"
#include <map>
namespace ATTN
@@ -128,11 +129,61 @@ struct Comp
class FakeSystem :
public AttentionOps,
public Resolver,
- public PrdImpl
+ public PrdImpl,
+ public ScomImpl
{
public:
/**
+ * @brief putScom Write a register using SCOM.
+ *
+ * @param[in] i_target Target to write register on.
+ * @param[in] i_address Register address to write to.
+ * @param[in] i_data Data to write to register.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t putScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data);
+
+ /**
+ * @brief getScom Read a register using SCOM.
+ *
+ * @param[in] i_target Target to read register from.
+ * @param[in] i_address Register address to read from.
+ * @param[out] o_data Buffer to write register content to.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t getScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t & o_data);
+
+ /**
+ * @brief modifyScom RMW a register using SCOM.
+ *
+ * @param[in] i_target Target to update register on.
+ * @param[in] i_address Register address to update.
+ * @param[in] i_data Data to write to register.
+ * @param[out] o_data Data read from register.
+ * @param[in] i_op and/or behavior.
+ *
+ * @retval[0] No errors.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t modifyScom(
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_data,
+ uint64_t & o_data,
+ ScomOp i_op);
+
+ /**
* @brief mask Mask this attention.
*
* @param[in] i_data the attention to be masked.
@@ -253,6 +304,21 @@ class FakeSystem :
std::map<PRDF::AttnData, FakeSystemProperties, Comp> iv_map;
/**
+ * @brief Reg Register/address association alias.
+ */
+ typedef std::map<uint64_t, uint64_t> RegAddrDataAssoc;
+
+ /**
+ * @brief Regs Registers/target association alias.
+ */
+ typedef std::map<TARGETING::TargetHandle_t, RegAddrDataAssoc> Regs;
+
+ /**
+ * @brief iv_regs Current register content.
+ */
+ Regs iv_regs;
+
+ /**
* @brief iv_mutex iv_map protection.
*/
mutex_t iv_mutex;
diff --git a/src/usr/diag/attn/test/attntestscom.H b/src/usr/diag/attn/test/attntestscom.H
new file mode 100644
index 000000000..42ff51669
--- /dev/null
+++ b/src/usr/diag/attn/test/attntestscom.H
@@ -0,0 +1,240 @@
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/diag/attn/test/attntestscom.H $
+ *
+ * IBM CONFIDENTIAL
+ *
+ * COPYRIGHT International Business Machines Corp. 2012
+ *
+ * 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_TAG
+ */
+#ifndef __TEST_ATTNTESTSCOM_H
+#define __TEST_ATTNTESTSCOM_H
+
+/**
+ * @file attntestscom.H
+ *
+ * @brief Unit test for the attnscom module.
+ */
+
+#include "attnfakesys.H"
+#include "attntest.H"
+#include <cxxtest/TestSuite.H>
+
+using namespace ATTN;
+using namespace TARGETING;
+
+/**
+ * @brief AttnScomTest Unit test for the attnscom module.
+ */
+class AttnScomTest : public CxxTest::TestSuite
+{
+ public:
+
+ /**
+ * @brief testFakeScom Unit test for the
+ * getScom and putScom methods.
+ */
+ void testFakeScom(void)
+ {
+ static const uint64_t iterations = 100;
+ static const uint64_t targetPoolSize = 100;
+ static const TargetHandle_t targetPool = 0;
+
+ TS_TRACE(ENTER_MRK "testFakeScom");
+
+ errlHndl_t err = 0;
+
+ FakeSystem d;
+ d.installScomImpl();
+
+ TargetHandle_t t;
+ uint64_t data, address, exp;
+
+ for(uint64_t i = 0; i < iterations; ++i)
+ {
+ t = targetPool + randint(0, targetPoolSize -1);
+ data = randint(0, 0xffffffffffffffffull);
+ address = randint(0, 0xffffffffffffffffull);
+ exp = data;
+
+ err = putScom(t, address, data);
+
+ if(err)
+ {
+ TS_FAIL("Unexpected error calling putScom");
+ break;
+ }
+
+ data = 0;
+
+ err = getScom(t, address, data);
+
+ if(err)
+ {
+ TS_FAIL("Unexpected error calling getScom");
+ break;
+ }
+
+ if(data != exp)
+ {
+ TS_FAIL("Unexpected data from getScom %d, %d",
+ data, exp);
+ break;
+ }
+ }
+
+ TS_TRACE(EXIT_MRK "testFakeScom");
+ }
+
+ /**
+ * @brief testModifyScom Unit test for the modify scom method.
+ */
+ void testModifyScom()
+ {
+ static const uint64_t iterations = 100;
+ static const uint64_t targetPoolSize = 100;
+ static const TargetHandle_t targetPool = 0;
+
+ TS_TRACE(ENTER_MRK "testModifyScom");
+
+ errlHndl_t err = 0;
+
+ FakeSystem d;
+
+ d.installScomImpl();
+
+ uint64_t data, mask, exp, address, op;
+ TargetHandle_t t;
+
+ for(uint64_t i = 0; i<iterations; ++i)
+ {
+ t = targetPool + randint(0, targetPoolSize -1);
+ mask = randint(0, 0xffffffffffffffffull);
+ data = randint(0, 0xffffffffffffffffull);
+ address = randint(0, 0xffffffffffffffffull);
+ op = randint(0, 1);
+ exp = op ? mask & data : mask | data;
+
+ err = putScom(t, address, data);
+
+ if(err)
+ {
+ TS_FAIL("Unexpected error calling putScom");
+ break;
+ }
+
+ err = modifyScom(t, address, mask, op ? SCOM_AND : SCOM_OR);
+
+ if(err)
+ {
+ TS_FAIL("Unexpected error calling modifyScom");
+ break;
+ }
+
+ data = 0;
+
+ err = getScom(t, address, data);
+
+ if(err)
+ {
+ TS_FAIL("Unexpected error calling getScom");
+ break;
+ }
+
+ if(data != exp)
+ {
+ TS_FAIL("Unexpected data after modifyScom: 0x%.16x, 0x%.16x, 0x%.16x",
+ data, mask, exp);
+ break;
+ }
+ }
+
+ TS_TRACE(EXIT_MRK "testModifyScom");
+ }
+
+ /**
+ * @brief testSetDriver Unit test for the setDriver method.
+ */
+ void testSetDriver()
+ {
+ static const uint64_t targetPoolSize = 100;
+ static const TargetHandle_t targetPool = 0;
+
+ TS_TRACE(ENTER_MRK "testSetDriver");
+
+ errlHndl_t err = 0;
+
+ struct TestImpl : public ScomImpl
+ {
+ errlHndl_t putScom(TARGETING::TargetHandle_t i_target,
+ uint64_t i_address, uint64_t i_data)
+ {
+ called = true;
+ return 0;
+ }
+
+ bool called;
+
+ TestImpl() : called(false) {}
+ } td;
+
+ td.installScomImpl();
+
+ TargetHandle_t target = targetPool + randint(0, targetPoolSize -1);
+ uint64_t data = 0, address = 0;
+
+ do {
+
+ err = putScom(target, address,data);
+
+ if(err)
+ {
+ TS_FAIL("Unexpected error calling putScom");
+ break;
+ }
+
+ if(!td.called)
+ {
+ TS_FAIL("Failed to set driver");
+ break;
+ }
+
+ td.called = false;
+
+ FakeSystem d;
+ d.installScomImpl();
+
+ err = putScom(target, address,data);
+
+ if(err)
+ {
+ TS_FAIL("Unexpected error calling putScom");
+ break;
+ }
+
+ if(td.called)
+ {
+ TS_FAIL("Failed to set driver");
+ break;
+ }
+
+ } while(0);
+
+ TS_TRACE(EXIT_MRK "testSetDriver");
+ }
+};
+#endif
OpenPOWER on IntegriCloud