diff options
author | Brad Bishop <bradleyb@us.ibm.com> | 2012-07-11 19:51:49 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2012-08-27 16:54:47 -0500 |
commit | bd410617968d5c1a6e2ab800e401c5daff3f9ecd (patch) | |
tree | 38f207e2726109cc7366ac6c0cb3b0dfbf995d2c /src/usr/diag/attn | |
parent | f0474c846c82e55454b4d5809d67eaa6f0045265 (diff) | |
download | talos-hostboot-bd410617968d5c1a6e2ab800e401c5daff3f9ecd.tar.gz talos-hostboot-bd410617968d5c1a6e2ab800e401c5daff3f9ecd.zip |
Attention handler fake targeting service.
Fake target service implementations for unit testing.
RTC: 43205
Change-Id: I86850bb2e2516e47fe90f87c84aad19933616b4b
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1358
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>
Diffstat (limited to 'src/usr/diag/attn')
-rw-r--r-- | src/usr/diag/attn/test/attnfaketarget.C | 197 | ||||
-rw-r--r-- | src/usr/diag/attn/test/attnfaketarget.H | 394 | ||||
-rw-r--r-- | src/usr/diag/attn/test/makefile | 3 |
3 files changed, 593 insertions, 1 deletions
diff --git a/src/usr/diag/attn/test/attnfaketarget.C b/src/usr/diag/attn/test/attnfaketarget.C new file mode 100644 index 000000000..0e34b52d7 --- /dev/null +++ b/src/usr/diag/attn/test/attnfaketarget.C @@ -0,0 +1,197 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/diag/attn/test/attnfaketarget.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 attnfaketarget.C + * + * @brief HBATTN fake targeting class method definitions. + */ + +#include "attnfaketarget.H" +#include "../attntrace.H" + +using namespace TARGETING; +using namespace std; + +namespace ATTN +{ + +TargetHandle_t FakeProcTargetService::getProcFromPos(uint64_t i_pos) +{ + return i_pos < iv_procs.size() ? iv_procs[i_pos] : 0; +} + +uint64_t FakeProcTargetService::getProcFromTarget(TargetHandle_t i_proc) +{ + return distance( + iv_procs.begin(), + find(iv_procs.begin(), iv_procs.end(), i_proc)); +} + +FakeProcTargetService::FakeProcTargetService(uint64_t i_count) +{ + for(uint64_t i = 0; i < i_count; ++i) + { + iv_procs.push_back(reinterpret_cast<TargetHandle_t>(i)); + } +} + +void FakeProcTargetService::getAllChips( + TargetHandleList & o_list, + TYPE i_type, + bool i_functional) +{ + switch (i_type) + { + case TYPE_PROC: + + o_list = iv_procs; + break; + + default: + break; + } +} + +void FakeMemTargetService::getAllChips( + TargetHandleList & o_list, + TYPE i_type, + bool i_functional) +{ + switch (i_type) + { + case TYPE_PROC: + + FakeProcTargetService::getAllChips(o_list, i_type, i_functional); + break; + + case TYPE_MEMBUF: + + o_list = iv_membufs; + break; + + default: + break; + }; +} + +void FakeMemTargetService::getMcsList( + TargetHandle_t i_proc, + TargetHandleList & o_list) +{ + TargetHandleList::iterator mcsBegin = iv_mcses.begin() + + getProcFromTarget(i_proc) * cv_membufsPerProc; + + o_list.insert(o_list.end(), mcsBegin, mcsBegin + cv_membufsPerProc); +} + +TargetHandle_t FakeMemTargetService::getProc( + TargetHandle_t i_membuf) +{ + return getProcFromPos( + distance( + iv_membufs.begin(), + find(iv_membufs.begin(), iv_membufs.end(), i_membuf)) + / cv_membufsPerProc); +} + +TargetHandle_t FakeMemTargetService::getMcs( + TargetHandle_t i_membuf) +{ + return *(iv_mcses.begin() + distance( + iv_membufs.begin(), + find(iv_membufs.begin(), iv_membufs.end(), i_membuf))); +} + +TargetHandle_t FakeMemTargetService::getMcs( + TargetHandle_t i_proc, + uint64_t i_pos) +{ + return *(iv_mcses.begin() + i_pos + getProcFromTarget(i_proc) * cv_membufsPerProc); +} + +void FakeMemTargetService::getMcsPos( + TARGETING::TargetHandle_t i_mcs, + uint64_t & o_pos) +{ + o_pos = distance( + iv_mcses.begin(), + find(iv_mcses.begin(), iv_mcses.end(), i_mcs)) + % cv_membufsPerProc; +} + +TargetHandle_t FakeMemTargetService::getMembuf( + TargetHandle_t i_mcs) +{ + return *(iv_membufs.begin() + distance( + iv_mcses.begin(), + find(iv_mcses.begin(), iv_mcses.end(), i_mcs))); +} + +TYPE FakeMemTargetService::getType(TargetHandle_t i_target) +{ + return find(iv_mcses.begin(), iv_mcses.end(), i_target) != iv_mcses.end() + ? TYPE_MCS + : (find(iv_membufs.begin(), iv_membufs.end(), i_target) != iv_membufs.end() + ? TYPE_MEMBUF + : FakeProcTargetService::getType(i_target)); +} + +void FakeMemTargetService::dump() +{ + for(uint64_t i = 0; i < iv_membufs.size() / cv_membufsPerProc; ++i) + { + TargetHandle_t proc = getProcFromPos(i); + + ATTN_DBG("FakeMemTargetService::dump: proc: %p", proc); + + for(uint64_t j = 0; j < cv_membufsPerProc; ++j) + { + TargetHandle_t mcs = getMcs(proc, j); + TargetHandle_t membuf = getMembuf(mcs); + + if(mcs && membuf) + { + ATTN_DBG("FakeMemTargetService::dump: mcs%d: %p", j, mcs); + ATTN_DBG("FakeMemTargetService::dump: membuf%d: %p", j, membuf); + } + } + } +} + +FakeMemTargetService::~FakeMemTargetService() +{ + +} + +FakeMemTargetService::FakeMemTargetService( + uint64_t i_count) : + FakeProcTargetService(i_count) +{ + for(uint64_t i = 0; i < i_count * cv_membufsPerProc; ++i) + { + iv_mcses.push_back(reinterpret_cast<TargetHandle_t>(i + i_count)); + iv_membufs.push_back(reinterpret_cast<TargetHandle_t>(i + i_count * cv_membufsPerProc + i_count)); + } +} +} diff --git a/src/usr/diag/attn/test/attnfaketarget.H b/src/usr/diag/attn/test/attnfaketarget.H new file mode 100644 index 000000000..4f893a643 --- /dev/null +++ b/src/usr/diag/attn/test/attnfaketarget.H @@ -0,0 +1,394 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/diag/attn/test/attnfaketarget.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_ATTNFAKETARGET_H +#define __TEST_ATTNFAKETARGET_H + +/** + * @file attnfaketarget.H + * + * @brief HBATTN fake targeting class definitions. + */ + +#include "attntest.H" +#include "../attntarget.H" + +namespace ATTN +{ + +/** + * @brief FakeProcTargetService + * + * A fake service for supporting processor only configurations. + */ +class FakeProcTargetService : public TargetServiceImpl +{ + public: + + /** + * @brief getProc + * + * @param[in] i_pos + * + * @return + */ + TARGETING::TargetHandle_t getProcFromPos(uint64_t i_pos); + + /** + * @brief getProcPos + * + * @param[in] i_proc + * + * @return + */ + uint64_t getProcFromTarget(TARGETING::TargetHandle_t i_proc); + + /** + * @brief getAllChips Get a list of chips. + * + * @param[out] o_list The populated list of chips. + * @param[in] i_type The type of chip for which a list + * should be obtained. + * @param[in] i_functional functional chip filter. + */ + virtual void getAllChips( + TARGETING::TargetHandleList & o_list, + TARGETING::TYPE i_type, + bool i_functional = true); + + /** + * @brief getMcsList Obtain the list of MCS unit targets + * for the given proc chip target. + * + * Not implemented for processor only configurations. + * + * @param[in] i_proc The proc chip target for which a + * list of MCS unit targets should be obtained. + * @param[out] o_list The populated list of MCS unit targets. + */ + virtual void getMcsList( + TARGETING::TargetHandle_t i_proc, + TARGETING::TargetHandleList & o_list) + { + + } + + /** + * @brief getProc Find the requested membuf chip + * target parent proc chip target. + * + * @param[in] i_membuf The membuf chip target + * for which the parent proc chip target + * should be found. + * + * Not implemented for processor only configurations. + * + * @retval[0] Did not find any associated proc chip target. + * @retval[!0] Associated proc chip parent target. + */ + virtual TARGETING::TargetHandle_t getProc( + TARGETING::TargetHandle_t i_membuf) + { + return 0; + } + + /** + * @brief getMcs Find the requested membuf chip + * target parent MCS unit target. + * + * @param[in] i_membuf The membuf chip target + * for which the parent MCS unit target + * should be found. + * + * Not implemented for processor only configurations. + * + * @retval[0] Did not find any associated MCS unit target. + * @retval[!0] Associated MCS unit parent target. + */ + virtual TARGETING::TargetHandle_t getMcs( + TARGETING::TargetHandle_t i_membuf) + { + return 0; + } + + /** + * @brief getMcs Find the MCS unit target given + * the proc chip parent target and MCS position. + * + * @param[in] i_proc The proc chip target for which the + * MCS unit target should be found. + * @param[in] i_pos The MCS unit position for which the MCS + * unit target should be found. + * + * Not implemented for processor only configurations. + * + * @retval[0] Did not find any associated MCS unit target. + * @retval[!0] Associated MCS unit target. + */ + virtual TARGETING::TargetHandle_t getMcs( + TARGETING::TargetHandle_t i_proc, + uint64_t i_pos) + { + return 0; + } + + /** + * @brief getMcsPos Find the MCS unit position given + * the MCS unit target. + * + * Not implemented for processor only configurations. + * + * @param[in] i_mcs The MCS unit target for which the + * MCS unit position should be found. + * @param[out] o_pos The MCS unit position. + */ + virtual void getMcsPos( + TARGETING::TargetHandle_t i_mcs, + uint64_t & o_pos) + { + + } + + /** + * @brief getMembuf Find the requested MCS unit target + * child membuf chip target. + * + * @param[in] i_mcs The MCS unit target + * for which the child membuf chip target + * should be found. + * + * Not implemented for processor only configurations. + * + * @retval[0] Did not find any associated membuf chip target. + * @retval[!0] Associated membuf chip target. + */ + virtual TARGETING::TargetHandle_t getMembuf( + TARGETING::TargetHandle_t i_mcs) + { + return 0; + } + + /** + * @brief getType Obtain the type of the provided target. + * + * Returns Hardcoded to TYPE_PROC for anything passed in. + * + * @param[in] i_target The target for which the type + * should be obtained. + * + * @return The type of the provided target. + */ + virtual TARGETING::TYPE getType(TARGETING::TargetHandle_t i_target) + { + return TARGETING::TYPE_PROC; + } + + /** + * @brief dtor + */ + virtual ~FakeProcTargetService() {} + + /** + * @brief ctor + * + * @param[in] i_count The number of processor targets. + */ + explicit FakeProcTargetService(uint64_t i_count); + + private: + + /** + * @brief iv_procs The fake processor targets. + */ + TARGETING::TargetHandleList iv_procs; +}; + +/** + * @brief FakeProcTargetService + * + * A fake service for supporting processor and membuf configurations. + * Provides a hardcoded number of fake membuf targets, and a mapping + * between them and an externally provided array of processor targets. + */ +class FakeMemTargetService : public FakeProcTargetService +{ + public: + + /** + * @brief getAllChips Get a list of chips. + * + * @param[out] o_list The populated list of chips. + * @param[in] i_type The type of chip for which a list + * should be obtained. + * @param[in] i_functional functional chip filter. + */ + void getAllChips( + TARGETING::TargetHandleList & o_list, + TARGETING::TYPE i_type, + bool i_functional = true); + + /** + * @brief getMcsList Obtain the list of MCS unit targets + * for the given proc chip target. + * + * @param[in] i_proc The proc chip target for which a + * list of MCS unit targets should be obtained. + * @param[out] o_list The populated list of MCS unit targets. + */ + void getMcsList( + TARGETING::TargetHandle_t i_proc, + TARGETING::TargetHandleList & o_list); + + /** + * @brief getProc Find the requested membuf chip + * target parent proc chip target. + * + * @param[in] i_membuf The membuf chip target + * for which the parent proc chip target + * should be found. + * + * @retval[0] Did not find any associated proc chip target. + * @retval[!0] Associated proc chip parent target. + */ + TARGETING::TargetHandle_t getProc( + TARGETING::TargetHandle_t i_membuf); + + /** + * @brief getMcs Find the requested membuf chip + * target parent MCS unit target. + * + * @param[in] i_membuf The membuf chip target + * for which the parent MCS unit target + * should be found. + * + * @retval[0] Did not find any associated MCS unit target. + * @retval[!0] Associated MCS unit parent target. + */ + TARGETING::TargetHandle_t getMcs( + TARGETING::TargetHandle_t i_membuf); + + /** + * @brief getMcs Find the MCS unit target given + * the proc chip parent target and MCS position. + * + * @param[in] i_proc The proc chip target for which the + * MCS unit target should be found. + * @param[in] i_pos The MCS unit position for which the MCS + * unit target should be found. + * + * @retval[0] Did not find any associated MCS unit target. + * @retval[!0] Associated MCS unit target. + */ + TARGETING::TargetHandle_t getMcs( + TARGETING::TargetHandle_t i_proc, + uint64_t i_pos); + + /** + * @brief getMcsPos Find the MCS unit position given + * the MCS unit target. + * + * @param[in] i_mcs The MCS unit target for which the + * MCS unit position should be found. + * @param[out] o_pos The MCS unit position. + */ + void getMcsPos( + TARGETING::TargetHandle_t i_mcs, + uint64_t & o_pos); + + /** + * @brief getMembuf Find the requested MCS unit target + * child membuf chip target. + * + * @param[in] i_mcs The MCS unit target + * for which the child membuf chip target + * should be found. + * + * @retval[0] Did not find any associated membuf chip target. + * @retval[!0] Associated membuf chip target. + */ + TARGETING::TargetHandle_t getMembuf( + TARGETING::TargetHandle_t i_mcs); + + /** + * @brief getType Obtain the type of the provided target. + * + * @param[in] i_target The target for which the type + * should be obtained. + * + * @return The type of the provided target. + */ + TARGETING::TYPE getType( + TARGETING::TargetHandle_t i_target); + + /** + * @brief dump print configuration to trace. + */ + void dump(); + + /** + * @brief dtor + */ + ~FakeMemTargetService(); + + /** + * @brief ctor + * + * @param[in] i_firstProc The first proc target for + * which to generate membuf mappings. + * @param[in] i_lastProc Past the last proc target for which + * to generate membuf mappings. + */ + explicit FakeMemTargetService(uint64_t i_count); + + private: + + TARGETING::TargetHandleList iv_mcses; + TARGETING::TargetHandleList iv_membufs; + + /** + * @brief iv_first The first proc target for which to + * generate mappings. + */ + TARGETING::TargetHandle_t iv_first; + + /** + * @brief iv_firstMcs The first mcs target for + * which to generate mappings. + */ + TARGETING::TargetHandle_t iv_firstMcs; + + /** + * @brief iv_firstMcs The first membuf target for + * which to generate mappings. + */ + TARGETING::TargetHandle_t iv_firstMembuf; + + /** + * @brief cv_membufsPerProc The number of membuf targets + * per proc target for which mappings should + * be generated. + */ + static const uint64_t cv_membufsPerProc = 8; +}; +} +#endif diff --git a/src/usr/diag/attn/test/makefile b/src/usr/diag/attn/test/makefile index f8f75e9a6..cd3b4449a 100644 --- a/src/usr/diag/attn/test/makefile +++ b/src/usr/diag/attn/test/makefile @@ -24,7 +24,8 @@ ROOTPATH = ../../../../.. EXTRAINCDIR += ${ROOTPATH}/src/include/usr/diag -OBJS = attnfakesys.o attntest.o attnrand.o attnfakepresenter.o attnfakeprd.o +OBJS = attnfakesys.o attntest.o attnrand.o attnfakepresenter.o attnfakeprd.o \ + attnfaketarget.o MODULE = testattn |