diff options
author | Prachi Gupta <pragupta@us.ibm.com> | 2014-12-19 14:16:51 -0600 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2015-01-22 17:19:04 -0600 |
commit | 32c1363b48266e3c10a37345225d35f06c863073 (patch) | |
tree | 37161ddaf45dad2f26dbfb17dac015e05beb4eb3 /src/usr/util | |
parent | f8569146fb30162c9bc9d4730d0476f209071fac (diff) | |
download | talos-hostboot-32c1363b48266e3c10a37345225d35f06c863073.tar.gz talos-hostboot-32c1363b48266e3c10a37345225d35f06c863073.zip |
allow lid to be read from pnor at runtime
RTC:116595
Change-Id: I446c314e6675227293e50121b47d091276b817b0
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/15000
Tested-by: Jenkins Server
Reviewed-by: STEPHEN M. CPREK <smcprek@us.ibm.com>
Reviewed-by: Brian H. Horton <brianh@linux.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 | 5 | ||||
-rw-r--r-- | src/usr/util/runtime/makefile | 3 | ||||
-rw-r--r-- | src/usr/util/runtime/test/makefile | 6 | ||||
-rw-r--r-- | src/usr/util/runtime/test/testlidmgr_rt.H | 57 | ||||
-rw-r--r-- | src/usr/util/runtime/utillidmgr_rt.C | 77 | ||||
-rw-r--r-- | src/usr/util/test/testlidmgr.H | 11 | ||||
-rw-r--r-- | src/usr/util/utillidmgr.C | 40 | ||||
-rw-r--r-- | src/usr/util/utillidpnor.C | 65 |
8 files changed, 181 insertions, 83 deletions
diff --git a/src/usr/util/makefile b/src/usr/util/makefile index 0fec5cf9e..7a5aa7651 100644 --- a/src/usr/util/makefile +++ b/src/usr/util/makefile @@ -5,7 +5,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2012,2014 +# Contributors Listed Below - COPYRIGHT 2012,2015 +# [+] International Business Machines Corp. +# # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,6 +31,7 @@ OBJS += utilstream.o OBJS += utilmem.o OBJS += utilfile.o OBJS += utillidmgr.o +OBJS += utillidpnor.o SUBDIRS += test.d SUBDIRS += runtime.d diff --git a/src/usr/util/runtime/makefile b/src/usr/util/runtime/makefile index f481e5171..8947811ef 100644 --- a/src/usr/util/runtime/makefile +++ b/src/usr/util/runtime/makefile @@ -5,7 +5,7 @@ # # OpenPOWER HostBoot Project # -# Contributors Listed Below - COPYRIGHT 2013,2014 +# Contributors Listed Below - COPYRIGHT 2013,2015 # [+] International Business Machines Corp. # # @@ -31,6 +31,7 @@ OBJS += utilstream.o OBJS += utilmem.o OBJS += utillidmgr_rt.o OBJS += utilfile.o +OBJS += utillidpnor.o SUBDIRS += test.d diff --git a/src/usr/util/runtime/test/makefile b/src/usr/util/runtime/test/makefile index 34fb0964c..1dd45b135 100644 --- a/src/usr/util/runtime/test/makefile +++ b/src/usr/util/runtime/test/makefile @@ -5,7 +5,9 @@ # # OpenPOWER HostBoot Project # -# COPYRIGHT International Business Machines Corp. 2013,2014 +# Contributors Listed Below - COPYRIGHT 2013,2015 +# [+] International Business Machines Corp. +# # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -24,7 +26,7 @@ HOSTBOOT_RUNTIME = 1 ROOTPATH = ../../../../.. MODULE = testutil_rt - +EXTRAINCDIR += ${ROOTPATH}/src/usr/util/ TESTS = *.H include $(ROOTPATH)/config.mk diff --git a/src/usr/util/runtime/test/testlidmgr_rt.H b/src/usr/util/runtime/test/testlidmgr_rt.H index 47b16605c..451468422 100644 --- a/src/usr/util/runtime/test/testlidmgr_rt.H +++ b/src/usr/util/runtime/test/testlidmgr_rt.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -23,6 +23,9 @@ /* */ /* IBM_PROLOG_END_TAG */ #include <util/utillidmgr.H> +#include <cxxtest/TestSuite.H> +#include <errl/errlmanager.H> +#include <utilbase.H> class LidMgrRtTest : public CxxTest::TestSuite { @@ -44,4 +47,56 @@ class LidMgrRtTest : public CxxTest::TestSuite l_errl = NULL; } } + + /** + * @brief Test to check if the structure that maps lidID's to pnor + * sections is working correctly + */ + void testLidInPnor(void) + { + errlHndl_t l_errl = NULL; + + do + { + size_t l_lidSize = 0; + + UtilLidMgr l_lidMgr(Util::TEST_LIDID); + + PNOR::SectionInfo_t l_lidPnorInfo; + l_errl = PNOR::getSectionInfo(PNOR::TEST, l_lidPnorInfo); + // Section only present in openPOWER systems + if (l_errl) + { + delete l_errl; + l_errl = NULL; + break; + } + + l_errl = l_lidMgr.getLidSize(l_lidSize); + if(l_errl) + { + errlCommit(l_errl,UTIL_COMP_ID); + TS_FAIL("testLidInPnor: Error getting lidId=0x%.8x", + Util::TEST_LIDID); + break; + } + + if (l_lidSize != l_lidPnorInfo.size) + { + TS_FAIL("testLidInPnor: lidSize does not match pnor TEST" + " section size 0x%.8X != 0x%.8X", + l_lidSize, l_lidPnorInfo.size); + break; + } + + char * l_ptr = new char[l_lidPnorInfo.size]; + l_errl = l_lidMgr.getLid(l_ptr, l_lidPnorInfo.size); + if(l_errl) + { + errlCommit(l_errl, UTIL_COMP_ID); + TS_FAIL("testLidInPnor: failed to get lid from PNOR"); + } + delete[] l_ptr; + }while(0); + } }; diff --git a/src/usr/util/runtime/utillidmgr_rt.C b/src/usr/util/runtime/utillidmgr_rt.C index 3b87d4879..6c433200e 100644 --- a/src/usr/util/runtime/utillidmgr_rt.C +++ b/src/usr/util/runtime/utillidmgr_rt.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2014 */ +/* Contributors Listed Below - COPYRIGHT 2013,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -33,7 +33,8 @@ #include <hwpf/hwp/occ/occ_common.H> UtilLidMgr::UtilLidMgr(uint32_t i_lidId) : - iv_isPnor(false), iv_lidBuffer(NULL), iv_lidSize(0) + iv_isLidInPnor(false), iv_lidBuffer(NULL), iv_lidSize(0), + iv_isLidInVFS(false) { updateLid(i_lidId); } @@ -84,57 +85,65 @@ errlHndl_t UtilLidMgr::getLid(void* i_dest, size_t i_destSize) errlHndl_t UtilLidMgr::loadLid() { - //@TODO RTC:108836 - figure out how to read lid from pnor with OPAL - // 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); + errlHndl_t l_errl = NULL; - if (l_errl) + if(iv_isLidInPnor) { - delete l_errl; - l_errl = NULL; - int rc = - g_hostInterfaces->lid_load(iv_lidId, &iv_lidBuffer, &iv_lidSize); + iv_lidSize = iv_lidPnorInfo.size; + iv_lidBuffer = reinterpret_cast<char *>(iv_lidPnorInfo.vaddr); + } + else if (iv_isLidInVFS) + { + l_errl = VFS::module_address(iv_lidFileName, l_addr, l_size); + if (l_errl) + { + delete l_errl; + l_errl = NULL; + 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); + } + } - if (0 != rc) + else { - /*@ - * @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); + iv_isLidInVFS = true; + iv_lidBuffer = const_cast<void*>(reinterpret_cast<const void*> + (l_addr)); + iv_lidSize = l_size; } } - 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)) + if ((iv_isLidInVFS) && (NULL != iv_lidBuffer)) { g_hostInterfaces->lid_unload(iv_lidBuffer); } iv_lidBuffer = NULL; iv_lidSize = 0; - iv_isPnor = false; + iv_isLidInPnor = false; return NULL; } @@ -145,8 +154,8 @@ void UtilLidMgr::updateLid(uint32_t 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; + iv_isLidInPnor = getLidPnorSection(iv_lidId, iv_lidPnorInfo); + iv_isLidInVFS = VFS::module_exists(iv_lidFileName); } const uint32_t * UtilLidMgr::getLidList(size_t * o_num) diff --git a/src/usr/util/test/testlidmgr.H b/src/usr/util/test/testlidmgr.H index 6980c5a64..69932fe7d 100644 --- a/src/usr/util/test/testlidmgr.H +++ b/src/usr/util/test/testlidmgr.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2014 */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -88,7 +88,7 @@ public: if (l_lidSize != l_lidPnorInfo.size) { - TS_FAIL("testLidInPnor: lidSize does not match pnor test section size 0x%.8X > 0x%.8X", + TS_FAIL("testLidInPnor: lidSize does not match pnor test section size 0x%.8X != 0x%.8X", l_lidSize, l_lidPnorInfo.size); break; } @@ -139,13 +139,14 @@ public: { errlCommit(l_errl,UTIL_COMP_ID); TS_FAIL("testLidInPnorOcc: Error getting lidId=0x%.8x", - Util::TEST_LIDID); + Util::OCC_LIDID); break; } if (l_lidSize != l_lidPnorInfo.size) { - TS_FAIL("testLidInPnorOcc: lidSize does not match pnor OCC section size 0x%.8X > 0x%.8X", + TS_FAIL("testLidInPnorOcc: lidSize does not match pnor OCC" + " section size 0x%.8X != 0x%.8X", l_lidSize, l_lidPnorInfo.size); break; } @@ -162,4 +163,4 @@ public: } }; -#endif
\ No newline at end of file +#endif diff --git a/src/usr/util/utillidmgr.C b/src/usr/util/utillidmgr.C index 9b8ef828c..037be7ec1 100644 --- a/src/usr/util/utillidmgr.C +++ b/src/usr/util/utillidmgr.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2013,2014 */ +/* Contributors Listed Below - COPYRIGHT 2013,2015 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -33,7 +33,6 @@ #include "utillidmgrdefs.H" #include "utilbase.H" #include <initservice/initserviceif.H> -#include "utillidpnor.H" using namespace ERRORLOG; mutex_t UtilLidMgr::cv_mutex = MUTEX_INITIALIZER; @@ -683,40 +682,3 @@ void UtilLidMgr::updateLid(uint32_t i_lidId) return; } -/////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////// -bool UtilLidMgr::getLidPnorSection(uint32_t i_lidId, - PNOR::SectionInfo_t &o_lidPnorInfo) -{ - errlHndl_t l_err = NULL; - bool l_lidInPnor = false; - - const std::pair<uint32_t, PNOR::SectionId> l_lid(i_lidId, - PNOR::INVALID_SECTION); - - const std::pair<uint32_t, PNOR::SectionId>* l_result = - std::lower_bound (Util::lidToPnor, - Util::lidToPnor + Util::NUM_LID_TO_PNOR, - l_lid, - Util::cmpLidToPnor); - - if (l_result != (Util::lidToPnor + Util::NUM_LID_TO_PNOR) && - l_result->first == l_lid.first && - l_result->second != PNOR::INVALID_SECTION) - { - l_err = PNOR::getSectionInfo(l_result->second, o_lidPnorInfo); - // Section is optional or lid is not in PNOR, so just delete error - if (l_err) - { - o_lidPnorInfo.id = PNOR::INVALID_SECTION; - l_lidInPnor = false; - delete l_err; - l_err = NULL; - } - else - { - l_lidInPnor = true; - } - } - return l_lidInPnor; -} diff --git a/src/usr/util/utillidpnor.C b/src/usr/util/utillidpnor.C new file mode 100644 index 000000000..bd178d85a --- /dev/null +++ b/src/usr/util/utillidpnor.C @@ -0,0 +1,65 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/util/utillidpnor.C $ */ +/* */ +/* OpenPOWER HostBoot Project */ +/* */ +/* Contributors Listed Below - COPYRIGHT 2014,2015 */ +/* [+] International Business Machines Corp. */ +/* */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); */ +/* you may not use this file except in compliance with the License. */ +/* You may obtain a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */ +/* implied. See the License for the specific language governing */ +/* permissions and limitations under the License. */ +/* */ +/* IBM_PROLOG_END_TAG */ + +#include <util/utillidmgr.H> +#include <utility> +#include "utillidpnor.H" + +bool UtilLidMgr::getLidPnorSection(uint32_t i_lidId, + PNOR::SectionInfo_t &o_lidPnorInfo) +{ + errlHndl_t l_err = NULL; + bool l_lidInPnor = false; + + const std::pair<uint32_t, PNOR::SectionId> l_lid(i_lidId, + PNOR::INVALID_SECTION); + + const std::pair<uint32_t, PNOR::SectionId>* l_result = + std::lower_bound (Util::lidToPnor, + Util::lidToPnor + Util::NUM_LID_TO_PNOR, + l_lid, + Util::cmpLidToPnor); + + if (l_result != (Util::lidToPnor + Util::NUM_LID_TO_PNOR) && + l_result->first == l_lid.first && + l_result->second != PNOR::INVALID_SECTION) + { + l_err = PNOR::getSectionInfo(l_result->second, o_lidPnorInfo); + // Section is optional or lid is not in PNOR, so just delete error + if (l_err) + { + o_lidPnorInfo.id = PNOR::INVALID_SECTION; + l_lidInPnor = false; + delete l_err; + l_err = NULL; + } + else + { + l_lidInPnor = true; + } + } + return l_lidInPnor; + +}
\ No newline at end of file |