summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorRoland Veloz <rveloz@us.ibm.com>2019-04-30 23:22:00 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2019-05-07 08:51:08 -0500
commitd935c5c94a9e1c23325f3dcd4ed113a6985412db (patch)
tree83f05f240b8f65eb506d4f9a9d03abea6b8563ff /src/usr
parente4b279cb88d769dd7167b35d0d6f51d9c5500bd3 (diff)
downloadtalos-hostboot-d935c5c94a9e1c23325f3dcd4ed113a6985412db.tar.gz
talos-hostboot-d935c5c94a9e1c23325f3dcd4ed113a6985412db.zip
Added more error reporting to HWSV when PNOR fails, removed superfluous code
- Replaced the terminate (terminateExecuteTI) raw calls with bl_terminate. Returning descriptive RC codes with bl_terminate call. - Module ID MOD_PNORACC_FINDTOC(=0x08) was added to hbblModuleId enums. - Return codes RC_LPC_ERR(HBBL_COMP_ID | 0x10) and RC_TOC_NOT_FOUND_ERR(HBBL_COMP_ID | 0x11) added to hbblReasonCode enums. - Freed up space in bootoloader: - Removed unnecessary calls to the method PNOR::checkForNullBuffer, because the call is always guaranteed to return with no error. - Once the calls to PNOR::checkForNullBuffer were dropped, the method PNOR::checkForNullBuffer is no longer necessary - removed it from production code. - The unit tests relied heavily on the call to PNOR::checkForNullBuffer, was not sure if the call could be removed from the unit tests, so relocated the PNOR::checkForNullBuffer method to the unit tests, out of production code. Change-Id: I1e3f8915ee4ed9b75ad74c57627ca1d2bc3a458d CQ:SW464040 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/76787 Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com> Tested-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/pnor/pnor_common.C12
-rw-r--r--src/usr/pnor/pnor_utils.C24
-rw-r--r--src/usr/pnor/test/pnorutilsTest.H43
3 files changed, 41 insertions, 38 deletions
diff --git a/src/usr/pnor/pnor_common.C b/src/usr/pnor/pnor_common.C
index 3b642a6e6..0bdb3ebcb 100644
--- a/src/usr/pnor/pnor_common.C
+++ b/src/usr/pnor/pnor_common.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2014,2018 */
+/* Contributors Listed Below - COPYRIGHT 2014,2019 */
/* [+] Google Inc. */
/* [+] International Business Machines Corp. */
/* */
@@ -144,12 +144,16 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC,
// Zero out my table
PNOR::initializeSections(o_TOC);
- uint32_t l_errCode = 0;
- ffs_hdr* l_ffs_hdr = NULL;
+ uint32_t l_errCode(0);
+ ffs_hdr* l_ffs_hdr(reinterpret_cast<ffs_hdr*>(i_tocBuffer));
TRACDCOMP(g_trac_pnor, "PNOR::parseTOC verifying TOC");
+ if (!l_ffs_hdr)
+ {
+ l_errCode = PNOR::BUFF_IS_NULL;
+ l_ffs_hdr = nullptr;
+ }
- PNOR::checkForNullBuffer(i_tocBuffer, l_errCode, l_ffs_hdr);
//Check if the buffer is null
if(l_errCode != NO_ERROR)
{
diff --git a/src/usr/pnor/pnor_utils.C b/src/usr/pnor/pnor_utils.C
index 134bb8113..8858d6826 100644
--- a/src/usr/pnor/pnor_utils.C
+++ b/src/usr/pnor/pnor_utils.C
@@ -110,30 +110,6 @@ void PNOR::initializeSections(PNOR::SectionData_t io_toc[NUM_SECTIONS])
}
}
-
-
-/**
- * @brief Ensure the buffer is not NULL, if it is, then return
- * the appropriate err code from the o_errCode param.
- * if the buffer is not NULL then cast it to a ffs_hdr
- * and return that out through the respective o_param
- */
-void PNOR::checkForNullBuffer(uint8_t* i_tocBuffer,
- uint32_t& o_errCode,
- ffs_hdr*& o_ffs_hdr)
-{
- if(!i_tocBuffer)
- {
- o_errCode |= BUFF_IS_NULL;
- o_ffs_hdr = NULL;
- }
- else
- {
- o_ffs_hdr = (ffs_hdr*)i_tocBuffer;
- }
-}
-
-
/**
* @brief Perform a series of checks on the header of the table of contents
* These checks include: looking for valid magic #, valid block size,
diff --git a/src/usr/pnor/test/pnorutilsTest.H b/src/usr/pnor/test/pnorutilsTest.H
index a2258c622..b273665c7 100644
--- a/src/usr/pnor/test/pnorutilsTest.H
+++ b/src/usr/pnor/test/pnorutilsTest.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2014,2017 */
+/* Contributors Listed Below - COPYRIGHT 2014,2019 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -62,7 +62,7 @@ class pnorutilsTest : public CxxTest::TestSuite
l_tocBuffer[17] = 0x41;
ffs_hdr* l_ffs_hdr = NULL;
- PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
+ checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
PNOR::checkHeader(l_ffs_hdr, l_errCode);
if((l_errCode & PNOR::INVALID_MAGIC) == PNOR::INVALID_MAGIC)
@@ -92,7 +92,7 @@ class pnorutilsTest : public CxxTest::TestSuite
l_tocBuffer[7] = 0x0;
ffs_hdr* l_ffs_hdr = NULL;
- PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
+ checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
PNOR::checkHeader(l_ffs_hdr, l_errCode);
@@ -122,7 +122,7 @@ class pnorutilsTest : public CxxTest::TestSuite
l_tocBuffer[31] = 0x80;
ffs_hdr* l_ffs_hdr = NULL;
- PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
+ checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
PNOR::checkHeader(l_ffs_hdr, l_errCode);
@@ -153,7 +153,7 @@ class pnorutilsTest : public CxxTest::TestSuite
l_tocBuffer[35] = 0x12;
ffs_hdr* l_ffs_hdr = NULL;
- PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
+ checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
PNOR::checkHeader(l_ffs_hdr, l_errCode);
@@ -183,7 +183,7 @@ class pnorutilsTest : public CxxTest::TestSuite
l_tocBuffer[38] = 0x10;
ffs_hdr* l_ffs_hdr = NULL;
- PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
+ checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
PNOR::checkHeader(l_ffs_hdr, l_errCode);
@@ -213,7 +213,7 @@ class pnorutilsTest : public CxxTest::TestSuite
l_tocBuffer[42] = 0x40;
ffs_hdr* l_ffs_hdr = NULL;
- PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
+ checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
PNOR::checkHeader(l_ffs_hdr, l_errCode);
@@ -246,7 +246,7 @@ class pnorutilsTest : public CxxTest::TestSuite
l_tocBuffer[39] = 0x33;
ffs_hdr* l_ffs_hdr = NULL;
- PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
+ checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
PNOR::checkHeader(l_ffs_hdr, l_errCode);
@@ -276,7 +276,7 @@ class pnorutilsTest : public CxxTest::TestSuite
l_tocBuffer[208] = 0xFF;
PNOR::SectionData_t l_TOC[PNOR::NUM_SECTIONS];
ffs_hdr* l_ffs_hdr = NULL;
- PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
+ checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
PNOR::checkHeader(l_ffs_hdr, l_errCode);
//parse through the entries and check for any errors
ffs_entry* l_err_entry = NULL;
@@ -317,7 +317,7 @@ class pnorutilsTest : public CxxTest::TestSuite
PNOR::SectionData_t l_TOC[PNOR::NUM_SECTIONS];
ffs_hdr* l_ffs_hdr = NULL;
- PNOR::checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
+ checkForNullBuffer(l_tocBuffer, l_errCode, l_ffs_hdr);
PNOR::checkHeader(l_ffs_hdr, l_errCode);
//parse through the entries and check for any errors
ffs_entry* l_err_entry = NULL;
@@ -336,6 +336,29 @@ class pnorutilsTest : public CxxTest::TestSuite
TRACFCOMP(g_trac_pnor, "pnorutilsTest::test_entryExtendsBeyondFlash: complete, Failed = %d", l_failed);
}
+
+ private:
+
+ /**
+ * @brief Ensure the buffer is not NULL, if it is, then return
+ * the appropriate err code from the o_errCode param.
+ * If the buffer is not NULL then cast it to a ffs_hdr
+ * and return that out through the o_ffs_hdr param.
+ */
+ void checkForNullBuffer(uint8_t* i_tocBuffer,
+ uint32_t& o_errCode,
+ ffs_hdr*& o_ffs_hdr)
+ {
+ if(!i_tocBuffer)
+ {
+ o_errCode |= PNOR::BUFF_IS_NULL;
+ o_ffs_hdr = NULL;
+ }
+ else
+ {
+ o_ffs_hdr = reinterpret_cast<ffs_hdr*>(i_tocBuffer);
+ }
+ }
};
#endif
OpenPOWER on IntegriCloud