diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2013-10-29 16:50:08 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2013-11-07 14:58:22 -0600 |
commit | c46a0d9db4701cca885329a29adf589da75f0ba7 (patch) | |
tree | 06acb104a582182de2c0093d1eb04310df7a735f /src/usr/util | |
parent | 61716e5c9f9ffd3acc5169688739d223c0344a93 (diff) | |
download | talos-hostboot-c46a0d9db4701cca885329a29adf589da75f0ba7.tar.gz talos-hostboot-c46a0d9db4701cca885329a29adf589da75f0ba7.zip |
Runtime LidMgr.
Change-Id: Ib456f3a41d79775a2af027e0bf80e36ce1d49232
RTC: 76679
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/6971
Tested-by: Jenkins Server
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr/util')
-rw-r--r-- | src/usr/util/makefile | 2 | ||||
-rw-r--r-- | src/usr/util/runtime/makefile | 32 | ||||
-rw-r--r-- | src/usr/util/runtime/test/makefile | 30 | ||||
-rw-r--r-- | src/usr/util/runtime/test/testlidmgr.H | 44 | ||||
-rw-r--r-- | src/usr/util/runtime/utillidmgr_rt.C | 145 |
5 files changed, 252 insertions, 1 deletions
diff --git a/src/usr/util/makefile b/src/usr/util/makefile index 33f61e90d..f8018dcd9 100644 --- a/src/usr/util/makefile +++ b/src/usr/util/makefile @@ -26,6 +26,6 @@ MODULE = util OBJS = threadpool.o utilbase.o utilstream.o utilmem.o utilfile.o \ utillidmgr.o -SUBDIRS = test.d +SUBDIRS = test.d runtime.d include ${ROOTPATH}/config.mk diff --git a/src/usr/util/runtime/makefile b/src/usr/util/runtime/makefile new file mode 100644 index 000000000..b27eaf55f --- /dev/null +++ b/src/usr/util/runtime/makefile @@ -0,0 +1,32 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/util/runtime/makefile $ +# +# IBM CONFIDENTIAL +# +# COPYRIGHT International Business Machines Corp. 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 +HOSTBOOT_RUNTIME = 1 +ROOTPATH = ../../../.. +MODULE = util_rt + +OBJS = utilbase.o utilstream.o utilmem.o utillidmgr_rt.o + +SUBDIRS = test.d + +VPATH += .. +include $(ROOTPATH)/config.mk diff --git a/src/usr/util/runtime/test/makefile b/src/usr/util/runtime/test/makefile new file mode 100644 index 000000000..ead555514 --- /dev/null +++ b/src/usr/util/runtime/test/makefile @@ -0,0 +1,30 @@ +# IBM_PROLOG_BEGIN_TAG +# This is an automatically generated prolog. +# +# $Source: src/usr/util/runtime/test/makefile $ +# +# IBM CONFIDENTIAL +# +# COPYRIGHT International Business Machines Corp. 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 +HOSTBOOT_RUNTIME = 1 +ROOTPATH = ../../../../.. + +MODULE = testutil_rt + +TESTS = *.H + +include $(ROOTPATH)/config.mk diff --git a/src/usr/util/runtime/test/testlidmgr.H b/src/usr/util/runtime/test/testlidmgr.H new file mode 100644 index 000000000..f76e9af13 --- /dev/null +++ b/src/usr/util/runtime/test/testlidmgr.H @@ -0,0 +1,44 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/util/runtime/test/testlidmgr.H $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 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 */ +#include <util/utillidmgr.H> + +class LidMgrTest : public CxxTest::TestSuite +{ + public: + void testMissingLid() + { + UtilLidMgr lidmgr(-1); + + size_t l_size = 0; + errlHndl_t l_errl = lidmgr.getLidSize(l_size); + + if (NULL == l_errl) + { + TS_FAIL("Found missing lid -1."); + } + else + { + delete l_errl; + } + } +}; diff --git a/src/usr/util/runtime/utillidmgr_rt.C b/src/usr/util/runtime/utillidmgr_rt.C new file mode 100644 index 000000000..397cc6074 --- /dev/null +++ b/src/usr/util/runtime/utillidmgr_rt.C @@ -0,0 +1,145 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/util/runtime/utillidmgr_rt.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 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 */ +#include <stdio.h> +#include <algorithm> + +#include <util/utillidmgr.H> +#include <util/util_reasoncodes.H> +#include <errl/errlmanager.H> +#include <vfs/vfs.H> +#include <runtime/interface.h> + +UtilLidMgr::UtilLidMgr(uint32_t i_lidId) : + iv_isPnor(false), iv_lidBuffer(NULL), iv_lidSize(0) +{ + updateLid(i_lidId); +} + +UtilLidMgr::~UtilLidMgr() +{ + errlHndl_t l_err = NULL; + + l_err = cleanup(); + if(l_err) + { + //cleanup errors are extermely rare + ERRORLOG::errlCommit( l_err, UTIL_COMP_ID ); + } +} + +errlHndl_t UtilLidMgr::setLidId(uint32_t i_lidId) +{ + errlHndl_t l_err = NULL; + + //must call cleanup before updateLid + l_err = cleanup(); + + updateLid(i_lidId); + + return l_err; +} + +errlHndl_t UtilLidMgr::getLidSize(size_t& o_lidSize) +{ + errlHndl_t l_err = loadLid(); + o_lidSize = iv_lidSize; + + return l_err; +} + +errlHndl_t UtilLidMgr::getLid(void* i_dest, size_t i_destSize) +{ + errlHndl_t l_err = loadLid(); + + if (iv_lidBuffer != NULL) + { + memcpy(i_dest, iv_lidBuffer, std::min(i_destSize, iv_lidSize)); + } + + return l_err; +} + +errlHndl_t UtilLidMgr::loadLid() +{ + // Check if it is already loaded. + if (NULL != iv_lidBuffer) return NULL; + + const char* l_addr = NULL; + size_t l_size = 0; + errlHndl_t l_errl = VFS::module_address(iv_lidFileName, l_addr, l_size); + + if (l_errl) + { + delete l_errl; + int rc = + g_hostInterfaces->lid_load(iv_lidId, &iv_lidBuffer, &iv_lidSize); + + if (0 != rc) + { + /*@ + * @errortype ERRL_SEV_INFORMATIONAL + * @moduleid Util::UTIL_LIDMGR_RT + * @reasoncode Util::UTIL_LIDMGR_RC_FAIL + * @userdata1 Return code from lid_load call. + * @devdesc Unable to load LID via host interface. + */ + l_errl = new ERRORLOG::ErrlEntry( + ERRORLOG::ERRL_SEV_INFORMATIONAL, + Util::UTIL_LIDMGR_RT, + Util::UTIL_LIDMGR_RC_FAIL, + rc); + } + } + else + { + iv_isPnor = true; + iv_lidBuffer = const_cast<void*>(reinterpret_cast<const void*>(l_addr)); + iv_lidSize = l_size; + } + + return l_errl; +} + +errlHndl_t UtilLidMgr::cleanup() +{ + if ((!iv_isPnor) && (NULL != iv_lidBuffer)) + { + g_hostInterfaces->lid_unload(iv_lidBuffer); + } + iv_lidBuffer = NULL; + + iv_lidSize = 0; + iv_isPnor = false; + return NULL; +} + +void UtilLidMgr::updateLid(uint32_t i_lidId) +{ + iv_lidId = i_lidId; + + //if it's in PNOR, it's not technically lid, so use a slightly + //different extension. + sprintf(iv_lidFileName, "%x.lidbin", iv_lidId); + + return; +} |