summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@us.ibm.com>2012-07-11 21:15:50 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-09-04 10:32:05 -0500
commitbc96bf7d92d34132310545037845d8f93fa4d953 (patch)
treeff0ecda95aecc711d84d93b0de02a275333a3826 /src/usr
parentf2bc28f73b48e96f776a66fbec7d3f071ea9bc62 (diff)
downloadtalos-hostboot-bc96bf7d92d34132310545037845d8f93fa4d953.tar.gz
talos-hostboot-bc96bf7d92d34132310545037845d8f93fa4d953.zip
Attention handler fake MCS and GP1 implementations.
Fake hw implementations for unit testing. RTC: 41423 Change-Id: Ie1f99632fdd9986a4f0ea21dc694f3e392fd4007 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1362 Reviewed-by: Zane Shelley <zshelle@us.ibm.com> Tested-by: Jenkins Server Reviewed-by: LARINA M. DSOUZA <larsouza@in.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/diag/attn/test/attnfakegp1.C135
-rw-r--r--src/usr/diag/attn/test/attnfakegp1.H87
-rw-r--r--src/usr/diag/attn/test/attnfakemcs.C139
-rw-r--r--src/usr/diag/attn/test/attnfakemcs.H141
-rw-r--r--src/usr/diag/attn/test/attntest.C2
-rw-r--r--src/usr/diag/attn/test/attntest.H1
-rw-r--r--src/usr/diag/attn/test/makefile2
7 files changed, 505 insertions, 2 deletions
diff --git a/src/usr/diag/attn/test/attnfakegp1.C b/src/usr/diag/attn/test/attnfakegp1.C
new file mode 100644
index 000000000..1b93fbf42
--- /dev/null
+++ b/src/usr/diag/attn/test/attnfakegp1.C
@@ -0,0 +1,135 @@
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/diag/attn/test/attnfakegp1.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 attnfakegp1.C
+ *
+ * @brief HBATTN fake GP1 class method definitions.
+ */
+
+#include "attnfakegp1.H"
+#include "attnfakesys.H"
+#include "../attntarget.H"
+
+using namespace TARGETING;
+using namespace PRDF;
+using namespace std;
+
+namespace ATTN
+{
+
+void setFlag(uint64_t i_type, void * i_data)
+{
+ bool * f = static_cast<bool *>(i_data);
+
+ *f = true;
+}
+
+struct FindMcsArgs
+{
+ bool reporting;
+ uint64_t pos;
+};
+
+void findMcs(uint64_t i_pos, void * i_data)
+{
+ FindMcsArgs * args = static_cast<FindMcsArgs *>(i_data);
+
+ if(i_pos == args->pos)
+ {
+ args->reporting = true;
+ }
+}
+
+errlHndl_t FakeGp1::processPutReg(
+ FakeSystem & i_sys,
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_new,
+ uint64_t i_old)
+{
+ errlHndl_t err = 0;
+ uint64_t mcsPos;
+
+ TargetHandle_t membuf = getTargetService().getMembuf(i_target);
+ TargetHandle_t proc = getTargetService().getProc(membuf);
+
+ getTargetService().getMcsPos(i_target, mcsPos);
+
+ uint64_t gp1Content = i_sys.getReg(proc, GP1::address);
+
+ bool set = false, cleared = false, on = false;
+
+ // these mci bits turned on
+ MCI::forEach(i_new & ~i_old, &set, &setFlag);
+
+ // these mci bits turned off
+ MCI::forEach(~i_new & i_old, &cleared, &setFlag);
+
+ // these mci bits are on
+ MCI::forEach(i_new, &on, &setFlag);
+
+ // whether or not the mcs is reporting
+
+ FindMcsArgs args;
+
+ args.reporting = false;
+ args.pos = mcsPos;
+ GP1::forEach(gp1Content, &args, &findMcs);
+
+ uint64_t writebits;
+ GP1::getCheckbits(mcsPos, writebits);
+
+ if(args.reporting && cleared && !on)
+ {
+ // this mcs is reporting, but all the bits in the MCI FIR
+ // have turned off.
+
+ err = i_sys.modifyReg(
+ proc,
+ GP1::address,
+ ~writebits,
+ SCOM_AND);
+ }
+
+ else if(!args.reporting && set)
+ {
+ // this mcs wasn't reporting before, but now a bit is on
+
+ err = i_sys.modifyReg(
+ proc,
+ GP1::address,
+ writebits,
+ SCOM_OR);
+ }
+
+ return err;
+}
+
+void FakeGp1::install(FakeSystem & i_sys)
+{
+ // monitor changes to mci firs
+
+ i_sys.addReg(MCI::address, *this);
+}
+}
diff --git a/src/usr/diag/attn/test/attnfakegp1.H b/src/usr/diag/attn/test/attnfakegp1.H
new file mode 100644
index 000000000..3362f5b12
--- /dev/null
+++ b/src/usr/diag/attn/test/attnfakegp1.H
@@ -0,0 +1,87 @@
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/diag/attn/test/attnfakegp1.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_ATTNFAKEGP1_H
+#define __TEST_ATTNFAKEGP1_H
+
+/**
+ * @file attnfakegp1.H
+ *
+ * @brief HBATTN fake Gp1 register class definitions.
+ */
+
+#include "attnfakeelement.H"
+
+namespace ATTN
+{
+
+/**
+ * @brief FakeGp1 Fake GP1 class definition.
+ *
+ * Attach logic to MCI FIR register modifications.
+ */
+class FakeGp1 : public FakeReg
+{
+ public:
+
+ /**
+ * @brief dtor
+ */
+ ~FakeGp1() {}
+
+ /**
+ * @brief install
+ *
+ * Register this object with the provided system for
+ * the appropriate callbacks.
+ *
+ * @param[in] i_system The system in which to register callbacks.
+ */
+ void install(FakeSystem & i_system);
+
+ private:
+
+ /**
+ * @brief processPutReg Process modified register content.
+ *
+ * Fake implemenation of gp1. Turns bits on in GP1 when
+ * MCI firs report attentions.
+ *
+ * @param[in] i_sys System that modified register content.
+ * @param[in] i_target Target whose registers were modified.
+ * @param[in] i_address Address of register that was modified.
+ * @param[in] i_new Register content after modification.
+ * @param[in] i_old Register content before modification.
+ *
+ * @retval[0] No error occurred.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t processPutReg(
+ FakeSystem & i_sys,
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_new,
+ uint64_t i_old);
+};
+}
+#endif
diff --git a/src/usr/diag/attn/test/attnfakemcs.C b/src/usr/diag/attn/test/attnfakemcs.C
new file mode 100644
index 000000000..b1322adef
--- /dev/null
+++ b/src/usr/diag/attn/test/attnfakemcs.C
@@ -0,0 +1,139 @@
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/diag/attn/test/attnfakemcs.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 attnfakemcs.C
+ *
+ * @brief HBATTN fake MCS class method definitions.
+ */
+
+#include "attnfakemcs.H"
+#include "attnfakesys.H"
+#include "../attntarget.H"
+
+using namespace TARGETING;
+using namespace PRDF;
+using namespace std;
+
+namespace ATTN
+{
+
+errlHndl_t FakeMcs::processPutReg(
+ FakeSystem & i_sys,
+ TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_new,
+ uint64_t i_old)
+{
+ errlHndl_t err = 0;
+
+ AttnData d;
+
+ d.targetHndl = getTargetService().getMembuf(i_target);
+ d.attnType = iv_type;
+
+ // see if the error was cleared but should
+ // be turned back on (because of other attentions)
+
+ bool cleared = i_old & ~i_new & iv_writebits;
+
+ if(cleared && i_sys.count(d))
+ {
+ // turn it back on...
+
+ err = i_sys.modifyReg(
+ i_target,
+ i_address,
+ iv_writebits,
+ SCOM_OR);
+ }
+
+ return err;
+}
+
+errlHndl_t FakeMcs::processPutAttention(
+ FakeSystem & i_sys,
+ const AttnData & i_attention,
+ uint64_t i_count)
+{
+ errlHndl_t err = 0;
+
+ TargetHandle_t mcs = getTargetService().getMcs(
+ i_attention.targetHndl);
+
+ // turn the fir bit on (if not already on)
+
+ uint64_t content = i_sys.getReg(mcs, MCI::address);
+
+ if(!(content & iv_writebits))
+ {
+ err = i_sys.modifyReg(
+ mcs,
+ MCI::address,
+ iv_writebits,
+ SCOM_OR);
+ }
+
+ return err;
+}
+
+errlHndl_t FakeMcs::processClearAttention(
+ FakeSystem & i_sys,
+ const AttnData & i_attention,
+ uint64_t i_count)
+{
+ errlHndl_t err = 0;
+
+ TargetHandle_t mcs = getTargetService().getMcs(
+ i_attention.targetHndl);
+
+ if(!i_count)
+ {
+ // there are no more instances of
+ // this attention being reported...
+ // turn the fir bit off
+
+ err = i_sys.modifyReg(
+ mcs,
+ MCI::address,
+ ~iv_writebits,
+ SCOM_AND);
+ }
+
+ return err;
+}
+
+void FakeMcs::install(FakeSystem & i_sys)
+{
+ // monitor all the mci firs
+
+ i_sys.addReg(MCI::address, *this);
+ i_sys.addSource(TYPE_MEMBUF, iv_type, *this);
+}
+
+FakeMcs::FakeMcs(PRDF::ATTENTION_VALUE_TYPE i_type) :
+ iv_type(i_type), iv_writebits(0)
+{
+ MCI::getCheckbits(i_type, iv_writebits);
+}
+}
diff --git a/src/usr/diag/attn/test/attnfakemcs.H b/src/usr/diag/attn/test/attnfakemcs.H
new file mode 100644
index 000000000..e52c8c99f
--- /dev/null
+++ b/src/usr/diag/attn/test/attnfakemcs.H
@@ -0,0 +1,141 @@
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/diag/attn/test/attnfakemcs.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_ATTNFAKEMCS_H
+#define __TEST_ATTNFAKEMCS_H
+
+/**
+ * @file attnfakemcs.H
+ *
+ * @brief HBATTN fake MCS class definitions.
+ */
+
+#include "attnfakeelement.H"
+
+namespace ATTN
+{
+
+/**
+ * @brief FakeMcs Fake MCS class definition.
+ *
+ * Attach logic to MCI FIR register modifications, and membuf
+ * local fir attentions.
+ */
+class FakeMcs : public FakeReg, public FakeSource
+{
+ public:
+
+ /**
+ * @brief ctor
+ *
+ * @param[in] i_type The type of the membuf local
+ * FIR to be monitored.
+ */
+ explicit FakeMcs(PRDF::ATTENTION_VALUE_TYPE i_type);
+
+ /**
+ * @brief dtor
+ */
+ ~FakeMcs() {}
+
+ /**
+ * @brief install
+ *
+ * Register this object with the provided system for
+ * the appropriate callbacks.
+ *
+ * @param[in] i_system The system in which to register callbacks.
+ */
+ void install(FakeSystem & i_system);
+
+ private:
+
+ /**
+ * @brief processPutReg Process modified register content.
+ *
+ * Fake implemenation of MCS. Turns on MCS bits when attentions
+ * are present.
+ *
+ * @param[in] i_sys System that modified register content.
+ * @param[in] i_target Target whose registers were modified.
+ * @param[in] i_address Address of register that was modified.
+ * @param[in] i_new Register content after modification.
+ * @param[in] i_old Register content before modification.
+ *
+ * @retval[0] No error occurred.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t processPutReg(
+ FakeSystem & i_sys,
+ TARGETING::TargetHandle_t i_target,
+ uint64_t i_address,
+ uint64_t i_new,
+ uint64_t i_old);
+
+ /**
+ * @brief processPutAttention Process injected attention.
+ *
+ * Fake implemenation of membuf local Firs. Sets the MCI Fir.
+ *
+ * @param[in] i_sys System on which attention was injected.
+ * @param[in] i_attn Attention that was injected.
+ * @param[in] i_count number of attentions currently present.
+ *
+ * @retval[0] No error occurred.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t processPutAttention(
+ FakeSystem & i_sys,
+ const PRDF::AttnData & i_attn,
+ uint64_t i_count);
+
+ /**
+ * @brief processClearAttention Process cleared attention.
+ *
+ * Fake implemenation of membuf local Firs. Clears the MCI Fir.
+ * when appropriate.
+ *
+ * @param[in] i_sys System on which attention was cleared.
+ * @param[in] i_attn Attention that was cleared.
+ * @param[in] i_count number of attentions currently present.
+ *
+ * @retval[0] No error occurred.
+ * @retval[!0] Unexpected error occurred.
+ */
+ errlHndl_t processClearAttention(
+ FakeSystem & i_sys,
+ const PRDF::AttnData & i_attn,
+ uint64_t i_count);
+
+ /**
+ * @brief iv_type The attention type associated with this element.
+ */
+ PRDF::ATTENTION_VALUE_TYPE iv_type;
+
+ /**
+ * @brief iv_writebits Filter for type.
+ */
+ uint64_t iv_writebits;
+};
+}
+#endif
diff --git a/src/usr/diag/attn/test/attntest.C b/src/usr/diag/attn/test/attntest.C
index 69af786f9..1be9647c6 100644
--- a/src/usr/diag/attn/test/attntest.C
+++ b/src/usr/diag/attn/test/attntest.C
@@ -31,9 +31,11 @@
#include <algorithm>
#include "attntest.H"
#include "../attntrace.H"
+#include "../attntarget.H"
using namespace std;
using namespace PRDF;
+using namespace TARGETING;
namespace ATTN
{
diff --git a/src/usr/diag/attn/test/attntest.H b/src/usr/diag/attn/test/attntest.H
index 8f6ce38f1..21e5964ca 100644
--- a/src/usr/diag/attn/test/attntest.H
+++ b/src/usr/diag/attn/test/attntest.H
@@ -82,6 +82,5 @@ template <typename T>
* @return The generated attention type.
*/
PRDF::ATTENTION_VALUE_TYPE getRandomAttentionType();
-
}
#endif
diff --git a/src/usr/diag/attn/test/makefile b/src/usr/diag/attn/test/makefile
index 905760162..74d7b1777 100644
--- a/src/usr/diag/attn/test/makefile
+++ b/src/usr/diag/attn/test/makefile
@@ -26,7 +26,7 @@ EXTRAINCDIR += ${ROOTPATH}/src/include/usr/diag
OBJS = attnfakesys.o attntest.o attnrand.o attnfakepresenter.o attnfakeprd.o \
attnfaketarget.o attnrandsource.o attnfakegfir.o attnfakeipoll.o \
- attnvalidate.o
+ attnvalidate.o attnfakemcs.o attnfakegp1.o
MODULE = testattn
OpenPOWER on IntegriCloud