diff options
author | Brad Bishop <bradleyb@us.ibm.com> | 2012-07-11 20:19:58 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-08-29 12:33:34 -0500 |
commit | ebf064b38b4f494f21913ed77808317909840464 (patch) | |
tree | 3a98c2f3de58c4fb77a925f48f7ed68dff411082 | |
parent | 988dacf944579556cca7f8aafbb4b7fda8b17176 (diff) | |
download | talos-hostboot-ebf064b38b4f494f21913ed77808317909840464.tar.gz talos-hostboot-ebf064b38b4f494f21913ed77808317909840464.zip |
Attention handler fake processor implementation.
Fake GFIR and IPOLL register behavior for unit testing.
RTC: 41445
Change-Id: Ic9e9cc018207904d4f25710bad9aa3b936f67985
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1360
Tested-by: Jenkins Server
Reviewed-by: Zane Shelley <zshelle@us.ibm.com>
Reviewed-by: LARINA M. DSOUZA <larsouza@in.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
-rw-r--r-- | src/usr/diag/attn/test/attnfakegfir.C | 141 | ||||
-rw-r--r-- | src/usr/diag/attn/test/attnfakegfir.H | 145 | ||||
-rw-r--r-- | src/usr/diag/attn/test/attnfakeipoll.C | 185 | ||||
-rw-r--r-- | src/usr/diag/attn/test/attnfakeipoll.H | 162 | ||||
-rw-r--r-- | src/usr/diag/attn/test/makefile | 2 |
5 files changed, 634 insertions, 1 deletions
diff --git a/src/usr/diag/attn/test/attnfakegfir.C b/src/usr/diag/attn/test/attnfakegfir.C new file mode 100644 index 000000000..e8f18d5fa --- /dev/null +++ b/src/usr/diag/attn/test/attnfakegfir.C @@ -0,0 +1,141 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/diag/attn/test/attnfakegfir.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 attnfakegfir.C + * + * @brief HBATTN fake global FIR class method definitions. + */ + +#include "attnfakegfir.H" +#include "attnfakesys.H" +#include "../attntarget.H" + +using namespace TARGETING; +using namespace PRDF; + +namespace ATTN +{ + +errlHndl_t FakeGfir::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 = 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, + iv_address, + iv_writebits, + SCOM_OR); + } + + return err; +} + +errlHndl_t FakeGfir::processPutAttention( + FakeSystem & i_sys, + const AttnData & i_attention, + uint64_t i_count) +{ + errlHndl_t err = 0; + + TargetHandle_t target = i_attention.targetHndl; + + uint64_t data = i_sys.getReg(target, iv_address); + + bool off = ~data & iv_writebits; + + // turn the fir bit on (if not already on) + + if(off) + { + err = i_sys.modifyReg( + target, + iv_address, + iv_writebits, + SCOM_OR); + } + + return err; +} + +errlHndl_t FakeGfir::processClearAttention( + FakeSystem & i_sys, + const AttnData & i_attention, + uint64_t i_count) +{ + errlHndl_t err = 0; + + TargetHandle_t target = i_attention.targetHndl; + + uint64_t data = i_sys.getReg(target, iv_address); + + bool on = data & iv_writebits; + + if(on && !i_count) + { + // there are no more instances of + // this attention being reported... + // turn the fir bit off + + err = i_sys.modifyReg( + target, + iv_address, + ~iv_writebits, + SCOM_AND); + } + + return err; +} + +void FakeGfir::install(FakeSystem & i_sys) +{ + i_sys.addReg(iv_address, *this); + i_sys.addSource(TYPE_PROC, iv_type, *this); +} + +FakeGfir::FakeGfir(ATTENTION_VALUE_TYPE i_type) : + iv_type(i_type), iv_address(0), iv_writebits(0) +{ + GFIR::getAddress(i_type, iv_address); + GFIR::getCheckbits(i_type, iv_writebits); +} +} diff --git a/src/usr/diag/attn/test/attnfakegfir.H b/src/usr/diag/attn/test/attnfakegfir.H new file mode 100644 index 000000000..638cdd46f --- /dev/null +++ b/src/usr/diag/attn/test/attnfakegfir.H @@ -0,0 +1,145 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/diag/attn/test/attnfakegfir.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_ATTNFAKEGFIR_H +#define __TEST_ATTNFAKEGFIR_H + +/** + * @file attnfakegfir.H + * + * @brief HBATTN fake global FIR class definitions. + */ + +#include "attnfakeelement.H" + +namespace ATTN +{ + +/** + * @brief FakeGfir Fake global FIR class definition. + * + * Attach logic to GFIR register modifications and + * Proc local fir attentions. + */ +class FakeGfir : public FakeReg, public FakeSource +{ + public: + + /** + * @brief ctor + * + * @param[in] i_type The type of the GFIR to be monitored. + */ + explicit FakeGfir(PRDF::ATTENTION_VALUE_TYPE i_type); + + /** + * @brief dtor + */ + ~FakeGfir() {} + + /** + * @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); + + /** + * @brief processPutReg Process modified register content. + * + * Fake implemenation of GFIR. Turns GFIR on when + * local 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 local Firs. Turns GFIR on. + * + * @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 local Firs. Clears GFIR + * 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); + + private: + + /** + * @brief iv_type The GFIR instance associated with this element. + */ + PRDF::ATTENTION_VALUE_TYPE iv_type; + + /** + * @brief iv_address GFIR address for type. + */ + uint64_t iv_address; + + /** + * @brief iv_writebits GFIR checkbits for type. + */ + uint64_t iv_writebits; +}; +} +#endif diff --git a/src/usr/diag/attn/test/attnfakeipoll.C b/src/usr/diag/attn/test/attnfakeipoll.C new file mode 100644 index 000000000..10b139518 --- /dev/null +++ b/src/usr/diag/attn/test/attnfakeipoll.C @@ -0,0 +1,185 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/diag/attn/test/attnfakeipoll.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 attnfakeipoll.C + * + * @brief HBATTN fake Ipoll mask register class method definitions. + */ + +#include "attnfakeipoll.H" +#include "attnfakesys.H" +#include "attnfakepresenter.H" +#include "../attntarget.H" + +using namespace PRDF; +using namespace TARGETING; +using namespace std; + +namespace ATTN +{ + +struct InterruptProperties +{ + FakeSystem * system; + + FakeIpoll * inst; +}; + +errlHndl_t FakeIpoll::processPutReg( + FakeSystem & i_sys, + TARGETING::TargetHandle_t i_target, + uint64_t i_address, + uint64_t i_new, + uint64_t i_old) +{ + // check for a gfir bit turning on, or + // if ipoll is unmasked while gfir is high + // then raise an interrupt + + uint64_t ipollContent = i_address == IPOLL::address + ? i_new + : i_sys.getReg(i_target, IPOLL::address); + + uint64_t content = i_address == iv_address + ? i_new + : i_sys.getReg(i_target, iv_address); + + bool masked = (ipollContent & iv_ipollbits); + bool hi = (content & iv_gfirbits); + + bool unmasked = i_address == IPOLL::address + ? ~ipollContent & i_old & iv_ipollbits + : false; + + bool set = i_address == IPOLL::address + ? false + : (content & iv_gfirbits) && !(i_old & iv_gfirbits); + + if((set && !masked) + || (unmasked && hi)) + { + interrupt(i_sys, i_target, ATTENTION); + } + + return 0; +} + +void FakeIpoll::processEoi( + FakeSystem & i_sys, + TARGETING::TargetHandle_t i_source, + MessageType i_type) +{ + // if gfir is still high and unmasked raise + // another interrupt... + + uint64_t ipollContent = i_sys.getReg(i_source, IPOLL::address); + uint64_t content = i_sys.getReg(i_source, iv_address); + + bool masked = ipollContent & iv_ipollbits; + bool high = content & iv_gfirbits; + + if(high && !masked) + { + interrupt(i_sys, i_source, ATTENTION); + } +} + +void FakeIpoll::callback( + TargetHandle_t i_source, + MessageType i_type, + void * i_properties) +{ + InterruptProperties * p = static_cast<InterruptProperties *>(i_properties); + + FakeSystem & f = *p->system; + FakeIpoll & inst = *p->inst; + + inst.processEoi(f, i_source, i_type); + + delete p; +} + +void FakeIpoll::interrupt( + FakeSystem & i_system, + TargetHandle_t i_source, + MessageType i_type) +{ + // instruct the presenter to raise an interrupt, using + // our callback + + InterruptProperties * p = new InterruptProperties; + + p->inst = this; + p->system = & i_system; + + iv_presenter->interrupt(i_source, i_type, p, &callback); +} + +void FakeIpoll::install(FakeSystem & i_sys) +{ + // monitor ipoll + i_sys.addReg(IPOLL::address, *this); + + // monitor signal being masked by ipoll + i_sys.addReg(iv_address, *this); +} + +void getMask(uint64_t i_pos, void * i_data) +{ + uint64_t & mask = *static_cast<uint64_t *>(i_data); + + uint64_t tmp = 0; + GP1::getCheckbits(i_pos, tmp); + + mask |= tmp; +} + +FakeIpoll::FakeIpoll( + uint64_t i_type, + FakePresenter & i_presenter) : + iv_address(0), + iv_gfirbits(0), + iv_ipollbits(0), + iv_presenter(&i_presenter) +{ + if(i_type == HOST) + { + // figure out what bits to monitor + // in the nest gp1 register, if + // this instance is monitoring + // HOST attentions. + + GP1::forEach(0xffffffffffffffffull, &iv_gfirbits, &getMask); + iv_address = GP1::address; + } + + else + { + GFIR::getAddress(i_type, iv_address); + GFIR::getCheckbits(i_type, iv_gfirbits); + } + + IPOLL::getCheckbits(i_type, iv_ipollbits); +} +} diff --git a/src/usr/diag/attn/test/attnfakeipoll.H b/src/usr/diag/attn/test/attnfakeipoll.H new file mode 100644 index 000000000..e8505410f --- /dev/null +++ b/src/usr/diag/attn/test/attnfakeipoll.H @@ -0,0 +1,162 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/diag/attn/test/attnfakeipoll.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_ATTNFAKEIPOLL_H +#define __TEST_ATTNFAKEIPOLL_H + +/** + * @file attnfakeipoll.H + * + * @brief HBATTN fake Ipoll mask register class definitions. + */ + +#include "attnfakeelement.H" + +namespace ATTN +{ + +/** + * @brief FakeIpoll Fake ipoll class definition. + * + * Attach logic to Ipoll and associated GFIR register modifications. + */ +class FakeIpoll : public FakeReg +{ + public: + + /** + * @brief ctor + * + * @param[in] i_type The bit in the ipoll mask register to implement. + * @param[in] i_presenter The presenter to which interrupts should + * be requested. + */ + FakeIpoll( + uint64_t i_type, + FakePresenter & i_presenter); + + /** + * @brief dtor + */ + ~FakeIpoll() {} + + /** + * @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); + + + /** + * @brief processPutReg Process modified register content. + * + * Fake implemenation of Ipoll mask. Generates interrupts when + * appropriate. + * + * @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); + + private: + + /** + * @brief processEoi Process end of interrupt. + * + * Generates interrupts when appropriate. + * + * @param[in] i_sys System associated with the interrupt. + * @param[in] i_source Target proc that generated the interrupt. + * @param[in] i_type Interrupt type of generated interrupt. + */ + void processEoi( + FakeSystem & i_sys, + TARGETING::TargetHandle_t i_source, + MessageType i_type); + + /** + * @brief callback FakePresenter EOI callback. + * + * Forwards to processEoi on ipoll instance that generated + * the interrupt. + * + * @param[in] i_source Target proc that generated the interrupt. + * @param[in] i_type Interrupt type of generated interrupt. + * @param[in] i_properties pointers to ipoll and system instances. + */ + static void callback( + TARGETING::TargetHandle_t i_source, + MessageType i_type, + void * i_properties); + + /** + * @brief interrupt FakePresenter interrupt wrapper. + * + * @param[in] i_sys System associated with the interrupt. + * @param[in] i_source Target proc that generated the interrupt. + * @param[in] i_type Interrupt type of generated interrupt. + */ + void interrupt( + FakeSystem & i_system, + TARGETING::TargetHandle_t i_source, + MessageType i_type); + + /** + * @brief iv_address Address of register to monitor for interrupt + * condition. + */ + uint64_t iv_address; + + /** + * @brief iv_gfirbits Filter watched bits in monitored register. + */ + uint64_t iv_gfirbits; + + /** + * @brief iv_ipollbits Ipoll mask bit being implemented. + */ + uint64_t iv_ipollbits; + + /** + * @brief iv_presenter Presenter from which interrupts should be + * requested. + */ + FakePresenter * iv_presenter; +}; +} +#endif diff --git a/src/usr/diag/attn/test/makefile b/src/usr/diag/attn/test/makefile index e5363a2eb..bb47c41db 100644 --- a/src/usr/diag/attn/test/makefile +++ b/src/usr/diag/attn/test/makefile @@ -25,7 +25,7 @@ ROOTPATH = ../../../../.. EXTRAINCDIR += ${ROOTPATH}/src/include/usr/diag OBJS = attnfakesys.o attntest.o attnrand.o attnfakepresenter.o attnfakeprd.o \ - attnfaketarget.o attnrandsource.o + attnfaketarget.o attnrandsource.o attnfakegfir.o attnfakeipoll.o MODULE = testattn |