summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorStephen Cprek <smcprek@us.ibm.com>2017-03-20 13:07:42 -0500
committerWilliam G. Hoffa <wghoffa@us.ibm.com>2017-03-23 10:05:07 -0400
commitd87aceae2d5e5cb66201af5f897b06fa1471d90e (patch)
tree8ca50bf550c1b460d9dc686aed5839901ba5d3e8 /src/usr
parent98de8e60e8395033bf1deed9ede0929ecb796841 (diff)
downloadtalos-hostboot-d87aceae2d5e5cb66201af5f897b06fa1471d90e.tar.gz
talos-hostboot-d87aceae2d5e5cb66201af5f897b06fa1471d90e.zip
Add PNOR SectionIdToString to replace direct access to cv_EYECATCHER
This catches if the const array size does not match the number of pnor sections and out of range index errors Also it adds genErrlParsing for bootloader files Change-Id: I0a90816a7620022dec16bc7358a68ffbdade0083 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/38159 Reviewed-by: Martin Gloff <mgloff@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Reviewed-by: Michael Baiocchi <mbaiocch@us.ibm.com> Reviewed-by: Nicholas E. Bofferding <bofferdn@us.ibm.com> Reviewed-by: William G. Hoffa <wghoffa@us.ibm.com>
Diffstat (limited to 'src/usr')
-rwxr-xr-xsrc/usr/errl/parser/genErrlParsers.pl5
-rw-r--r--src/usr/pnor/pnor_common.C9
-rw-r--r--src/usr/pnor/pnor_utils.C121
-rw-r--r--src/usr/pnor/pnor_utils.H16
-rw-r--r--src/usr/pnor/pnorrp.C10
-rw-r--r--src/usr/pnor/runtime/rt_pnor.C11
-rw-r--r--src/usr/pnor/test/pnorutilsTest.H4
-rw-r--r--src/usr/testcore/rtloader/loader.H4
-rw-r--r--src/usr/testcore/rtloader/makefile6
9 files changed, 120 insertions, 66 deletions
diff --git a/src/usr/errl/parser/genErrlParsers.pl b/src/usr/errl/parser/genErrlParsers.pl
index c24df2f34..0316db383 100755
--- a/src/usr/errl/parser/genErrlParsers.pl
+++ b/src/usr/errl/parser/genErrlParsers.pl
@@ -76,6 +76,8 @@ while( $ARGV = shift )
my $compIdFile = $base."/src/include/usr/hbotcompid.H";
my $compPath = $base."/src/usr";
my $compIncPath = $base."/src/include/usr";
+my $compBlPath = $base."/src/bootloader";
+my $compBlIncPath = $base."/src/include/bootloader";
my $genFilesPath = $base."/obj/genfiles";
my $hbfwTermRcFile = $genFilesPath."/hbfw_term_rc.H";
my $srcFileName = $genFilesPath."/srcListing";
@@ -91,9 +93,12 @@ my @reasonCodeFiles;
my @filesToParse;
my @pluginDirsToParse;
getReasonCodeFiles($compIncPath);
+getReasonCodeFiles($compBlIncPath);
getFilesToParse($compPath);
getFilesToParse($compIncPath);
getFilesToParse($genFilesPath);
+getFilesToParse($compBlPath);
+getFilesToParse($compBlIncPath);
getPluginDirsToParse($compPath);
#Add kernel/lib files for TI SRC descriptions
diff --git a/src/usr/pnor/pnor_common.C b/src/usr/pnor/pnor_common.C
index 93978c277..f766e3937 100644
--- a/src/usr/pnor/pnor_common.C
+++ b/src/usr/pnor/pnor_common.C
@@ -46,11 +46,6 @@ TRAC_INIT(&g_trac_pnor, PNOR_COMP_NAME, 4*KILOBYTE, TRACE::BUFFER_SLOW); //4K
//#define TRACUCOMP(args...) TRACFCOMP(args)
#define TRACUCOMP(args...)
-/**
- * Eyecatcher strings for PNOR TOC entries
- */
-extern const char* cv_EYECATCHER[];
-
/*
* @brief determine the physical offset of the ffs entry
@@ -319,7 +314,7 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC)
addr -= headerSize;
l_errhdl = PNOR::extendHash(addr, headerSize,
- cv_EYECATCHER[l_secId]);
+ PNOR::SectionIdToString(l_secId));
if (l_errhdl)
{
break;
@@ -333,7 +328,7 @@ errlHndl_t PNOR::parseTOC( uint8_t* i_tocBuffer,SectionData_t * o_TOC)
tmpId ++ )
{
TRACFCOMP(g_trac_pnor, "%s: size=0x%.8X flash=0x%.8X ",
- cv_EYECATCHER[tmpId], o_TOC[tmpId].size,
+ PNOR::SectionIdToString(tmpId), o_TOC[tmpId].size,
o_TOC[tmpId].flashAddr);
}
diff --git a/src/usr/pnor/pnor_utils.C b/src/usr/pnor/pnor_utils.C
index 5af2993cb..c7e77cbb7 100644
--- a/src/usr/pnor/pnor_utils.C
+++ b/src/usr/pnor/pnor_utils.C
@@ -34,13 +34,16 @@
#include "pnor_utils.H"
#include <pnor/pnor_const.H>
-#if !defined(__BOOT_LOADER_H)
+#ifndef BOOTLOADER
#include <errl/errlmanager.H>
+#include <assert.h>
extern trace_desc_t* g_trac_pnor;
#define PNOR_UTIL_TRACE(arg0, args...) TRACFCOMP(g_trac_pnor, args)
#define PNOR_UTIL_TRACE_W_BRK(arg0, args...) TRACFCOMP(g_trac_pnor, args)
#else
#include <bootloader/bootloader_trace.H>
+#include <bootloader/bootloader.H>
+#include <bootloader/hbblreasoncodes.H>
#define PNOR_UTIL_TRACE(arg0, args...) BOOTLOADER_TRACE(arg0)
#define PNOR_UTIL_TRACE_W_BRK(arg0, args...) BOOTLOADER_TRACE_W_BRK(arg0)
#endif
@@ -49,42 +52,7 @@ extern trace_desc_t* g_trac_pnor;
#include "common/ffs_hb.H"
#include <util/align.H>
-/**
- * Eyecatcher strings for PNOR TOC entries
- */
-const char* cv_EYECATCHER[] = {
- "part", /**< PNOR::TOC : Table of Contents */
- "HBI", /**< PNOR::HB_EXT_CODE : Hostboot Extended Image */
- "GLOBAL", /**< PNOR::GLOBAL_DATA : Global Data */
- "HBB", /**< PNOR::HB_BASE_CODE : Hostboot Base Image */
- "SBEC", /**< PNOR::CENTAUR_SBE : Centaur Self-Boot Engine image */
- "SBE", /**< PNOR::SBE_IPL : Self-Boot Enginer IPL image */
- "HCODE", /**< PNOR::HCODE : HCODE Reference image */
- "PAYLOAD", /**< PNOR::PAYLOAD : HAL/OPAL */
- "HBRT", /**< PNOR::HB_RUNTIME : Hostboot Runtime(for Sapphire)*/
- "HBD", /**< PNOR::HB_DATA : Hostboot Data */
- "GUARD", /**< PNOR::GUARD_DATA : Hostboot Data */
- "HBEL", /**< PNOR::HB_ERRLOGS : Hostboot Error log Repository */
- "DJVPD", /**< PNOR::DIMM_JEDEC_VPD : Dimm JEDEC VPD */
- "MVPD", /**< PNOR::MODULE_VPD : Module VPD */
- "CVPD", /**< PNOR::CENTAUR_VPD : Centaur VPD */
- "NVRAM", /**< PNOR::NVRAM : OPAL Storage */
- "OCC", /**< PNOR::OCC : OCC LID */
- "FIRDATA", /**< PNOR::FIRDATA : FIRs for checkstop analysis */
- "ATTR_TMP", /**< PNOR::ATTR_TMP : Temporary Attribute Overrides */
- "ATTR_PERM", /**< PNOR::ATTR_PERM : Permanent Attribute Overrides */
- "CAPP", /**< PNOR::CAPP : CAPP LID */
- "VERSION", /**< PNOR::VERSION : PNOR Version string */
- "HBBL", /**<PNOR::HB_BOOTLOADER : Hostboot Bootloader image */
- "TEST", /**< PNOR::TEST : Test space for PNOR*/
- "TESTRO", /**< PNOR::TESTRO : ReadOnly Test space for PNOR */
- "BACKUP_PART", /**PNOR::BACKUP_PART : Backup of PART*/
- "POWERVM", /**< PNOR::POWERVM : Power VM data */
- "RINGOVD", /**< PNOR::RINGOVD : Ring overrides */
- "WOFDATA", /**< PNOR::WOFDATA : VFRT data tables for WOF */
-};
-
-/**
+/*
* @brief calculates the checksum on data(ffs header/entry) and will return
* 0 if the checksums match
*/
@@ -248,7 +216,7 @@ void PNOR::getSectionEnum (ffs_entry* i_entry,
for(uint32_t eyeIndex=PNOR::TOC;eyeIndex<PNOR::NUM_SECTIONS;
eyeIndex++)
{
- if(strcmp(cv_EYECATCHER[eyeIndex],i_entry->name) == 0)
+ if(strcmp(PNOR::SectionIdToString(eyeIndex),i_entry->name) == 0)
{
*o_secId = eyeIndex;
break;
@@ -382,3 +350,80 @@ bool PNOR::isSecureSection(const uint32_t i_section)
#endif
}
+const char * PNOR::SectionIdToString( uint32_t i_secIdIndex )
+{
+ /**
+ * Eyecatcher strings for PNOR TOC entries
+ * Use an array vs switch statement for O(1) lookup
+ * Not using std::array so we can check the actual size filled in vs N
+ * in std:array<const char*, N>.
+ */
+ static const char* SectionIdToStringArr[] =
+ {
+ "part", /**< PNOR::TOC : Table of Contents */
+ "HBI", /**< PNOR::HB_EXT_CODE : Hostboot Extended Image */
+ "GLOBAL", /**< PNOR::GLOBAL_DATA : Global Data */
+ "HBB", /**< PNOR::HB_BASE_CODE : Hostboot Base Image */
+ "SBEC", /**< PNOR::CENTAUR_SBE : Centaur Self-Boot Engine image */
+ "SBE", /**< PNOR::SBE_IPL : Self-Boot Enginer IPL image */
+ "HCODE", /**< PNOR::HCODE : HCODE Reference image */
+ "PAYLOAD", /**< PNOR::PAYLOAD : HAL/OPAL */
+ "HBRT", /**< PNOR::HB_RUNTIME : Hostboot Runtime(for Sapphire)*/
+ "HBD", /**< PNOR::HB_DATA : Hostboot Data */
+ "GUARD", /**< PNOR::GUARD_DATA : Hostboot Data */
+ "HBEL", /**< PNOR::HB_ERRLOGS : Hostboot Error log Repository */
+ "DJVPD", /**< PNOR::DIMM_JEDEC_VPD : Dimm JEDEC VPD */
+ "MVPD", /**< PNOR::MODULE_VPD : Module VPD */
+ "CVPD", /**< PNOR::CENTAUR_VPD : Centaur VPD */
+ "NVRAM", /**< PNOR::NVRAM : OPAL Storage */
+ "OCC", /**< PNOR::OCC : OCC LID */
+ "FIRDATA", /**< PNOR::FIRDATA : FIRs for checkstop analysis */
+ "ATTR_TMP", /**< PNOR::ATTR_TMP : Temporary Attribute Overrides */
+ "ATTR_PERM", /**< PNOR::ATTR_PERM : Permanent Attribute Overrides */
+ "CAPP", /**< PNOR::CAPP : CAPP LID */
+ "VERSION", /**< PNOR::VERSION : PNOR Version string */
+ "HBBL", /**<PNOR::HB_BOOTLOADER : Hostboot Bootloader image */
+ "TEST", /**< PNOR::TEST : Test space for PNOR*/
+ "TESTRO", /**< PNOR::TESTRO : ReadOnly Test space for PNOR */
+ "BACKUP_PART", /**PNOR::BACKUP_PART : Backup of PART*/
+ "POWERVM", /**< PNOR::POWERVM : Power VM data */
+ "RINGOVD", /**< PNOR::RINGOVD : Ring overrides */
+ "WOFDATA", /**< PNOR::WOFDATA : VFRT data tables for WOF */
+ "SBKT", /**< PNOR::SBKT : SecureBoot Key Transition */
+ };
+
+ // Get actual number of entries of array.
+ const size_t numEntries = sizeof(SectionIdToStringArr)/sizeof(char*);
+
+ // Assert that the number of entries equals PNOR::NUM_SECTIONS
+ static_assert (numEntries == (PNOR::NUM_SECTIONS),
+ "Mismatch between number of SectionIds and correlating strings");
+
+ // Bootloader does not support asserts
+#ifdef BOOTLOADER
+ if(i_secIdIndex >= (PNOR::NUM_SECTIONS))
+ {
+ PNOR_UTIL_TRACE(BTLDR_TRC_UTILS_PARSE_PNOR_SECID_OUT_OF_RANGE);
+ /*@
+ * @errortype
+ * @moduleid Bootloader::MOD_BOOTLOADER_PNOR_SECID_TO_STR
+ * @reasoncode Bootloader::RC_PNOR_SECID_OUT_OF_RANGE
+ * @userdata1 Section ID requested
+ * @userdata2 Max index of Section id to string array
+ * @devdesc No String associated with PNOR section ID
+ * @custdesc A problem occurred while running processor
+ * boot code.
+ */
+ bl_terminate(Bootloader::MOD_BOOTLOADER_PNOR_SECID_TO_STR,
+ Bootloader::RC_PNOR_SECID_OUT_OF_RANGE,
+ i_secIdIndex,
+ numEntries);
+ }
+#else
+ // Assert if accessing index out of array.
+ assert(i_secIdIndex < (PNOR::NUM_SECTIONS), "SectionIdToString PNOR section id out of range");
+#endif
+
+ return SectionIdToStringArr[i_secIdIndex];
+}
+
diff --git a/src/usr/pnor/pnor_utils.H b/src/usr/pnor/pnor_utils.H
index 75d85d77b..8bb4504f1 100644
--- a/src/usr/pnor/pnor_utils.H
+++ b/src/usr/pnor/pnor_utils.H
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2011,2016 */
+/* Contributors Listed Below - COPYRIGHT 2011,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -229,6 +229,20 @@ void parseEntries (ffs_hdr* i_ffs_hdr,
*/
bool isSecureSection(const uint32_t i_section);
+/**
+ * @brief Returns string representation of a PNOR SectionId.
+ * If id requested is out of range of known string array
+ * - Hostboot asserts
+ * - Bootloader terminates
+ *
+ * @param[in] i_secIdIndex PNOR section id which also represents the index
+ * into the string array.
+ *
+ * @return const char* - String associated with Section ID
+ *
+*/
+const char * SectionIdToString( uint32_t i_secIdIndex );
+
} // End namespace PNOR
diff --git a/src/usr/pnor/pnorrp.C b/src/usr/pnor/pnorrp.C
index b3f394e51..329e3cac9 100644
--- a/src/usr/pnor/pnorrp.C
+++ b/src/usr/pnor/pnorrp.C
@@ -66,10 +66,6 @@ extern trace_desc_t* g_trac_pnor;
using namespace PNOR;
-/**
- * Eyecatcher strings for PNOR TOC entries
- */
-extern const char* cv_EYECATCHER[];
/**
* @brief set up _start() task entry procedure for PNOR daemon
@@ -528,7 +524,7 @@ errlHndl_t PnorRP::getSectionInfo( PNOR::SectionId i_section,
// copy my data into the external format
o_info.id = iv_TOC[id].id;
- o_info.name = cv_EYECATCHER[id];
+ o_info.name = SectionIdToString(id);
#ifdef CONFIG_SECUREBOOT
o_info.secureProtectedPayloadSize = 0; // for non secure sections
@@ -1737,7 +1733,7 @@ errlHndl_t PnorRP::setVirtAddrs(void)
if (rc)
{
TRACFCOMP(g_trac_pnor, "E>PnorRP::readTOC: Failed to set block permissions to WRITABLE for section %s.",
- cv_EYECATCHER[i]);
+ SectionIdToString(i));
/*@
* @errortype
* @moduleid PNOR::MOD_PNORRP_READTOC
@@ -1770,7 +1766,7 @@ errlHndl_t PnorRP::setVirtAddrs(void)
if (rc)
{
TRACFCOMP(g_trac_pnor, "E>PnorRP::readTOC: Failed to set block permissions to WRITABLE/WRITE_TRACKED for section %s.",
- cv_EYECATCHER[i]);
+ SectionIdToString(i));
/*@
* @errortype
* @moduleid PNOR::MOD_PNORRP_READTOC
diff --git a/src/usr/pnor/runtime/rt_pnor.C b/src/usr/pnor/runtime/rt_pnor.C
index dc5adb7f7..484d47e7d 100644
--- a/src/usr/pnor/runtime/rt_pnor.C
+++ b/src/usr/pnor/runtime/rt_pnor.C
@@ -43,11 +43,6 @@
extern trace_desc_t* g_trac_pnor;
/**
- * Eyecatcher strings for PNOR TOC entries
- */
-extern const char* cv_EYECATCHER[];
-
-/**
* @brief set up _start() task entry procedure for PNOR daemon
*/
TASK_ENTRY_MACRO( RtPnor::init );
@@ -214,7 +209,7 @@ errlHndl_t RtPnor::getSectionInfo(PNOR::SectionId i_section,
}
//return the data in the struct
o_info.id = i_section;
- o_info.name = cv_EYECATCHER[i_section];
+ o_info.name = SectionIdToString(i_section);
o_info.vaddr = (uint64_t)l_pWorking;
o_info.flashAddr = iv_TOC[i_section].flashAddr;
o_info.size = l_sizeBytes;
@@ -365,7 +360,7 @@ errlHndl_t RtPnor::readFromDevice (uint64_t i_procId,
do
{
- const char* l_partitionName = cv_EYECATCHER[i_section];
+ const char* l_partitionName = SectionIdToString(i_section);
void* l_dataToRead = o_data;
size_t l_readSize = i_size;
size_t l_readSizePlusECC = (i_size * 9)/8;
@@ -581,7 +576,7 @@ errlHndl_t RtPnor::writeToDevice( uint64_t i_procId,
l_offset = (i_offset * 9)/8;
}
- const char* l_partitionName = cv_EYECATCHER[i_section];
+ const char* l_partitionName = SectionIdToString(i_section);
if (g_hostInterfaces && g_hostInterfaces->pnor_write)
{
//make call into opal to write the data
diff --git a/src/usr/pnor/test/pnorutilsTest.H b/src/usr/pnor/test/pnorutilsTest.H
index c71f90e54..a2258c622 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,2016 */
+/* Contributors Listed Below - COPYRIGHT 2014,2017 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -39,7 +39,7 @@
*
* @brief unit tests for pnor utils
*/
-extern const char* cv_EYECATCHER[];
+
extern trace_desc_t* g_trac_pnor;
class pnorutilsTest : public CxxTest::TestSuite
{
diff --git a/src/usr/testcore/rtloader/loader.H b/src/usr/testcore/rtloader/loader.H
index 417009992..f131d9a7e 100644
--- a/src/usr/testcore/rtloader/loader.H
+++ b/src/usr/testcore/rtloader/loader.H
@@ -42,10 +42,10 @@
#include <devicefw/userif.H>
#include <pnor/ecc.H>
#include <ipmi/ipmiif.H>
+#include <pnor_utils.H>
trace_desc_t* g_trac_hbrt = NULL;
TRAC_INIT(&g_trac_hbrt, "HBRT_TEST", 2*KILOBYTE);
-extern const char* cv_EYECATCHER[];
class RuntimeLoaderTest : public CxxTest::TestSuite
{
@@ -347,7 +347,7 @@ class RuntimeLoaderTest : public CxxTest::TestSuite
for (size_t i=PNOR::FIRST_SECTION; i<=PNOR::NUM_SECTIONS;
++i)
{
- if (0 == strcmp(cv_EYECATCHER[i], i_partitionName))
+ if (0 == strcmp(PNOR::SectionIdToString(i), i_partitionName))
{
l_id = (PNOR::SectionId)i;
break;
diff --git a/src/usr/testcore/rtloader/makefile b/src/usr/testcore/rtloader/makefile
index c75e71933..d253d3f06 100644
--- a/src/usr/testcore/rtloader/makefile
+++ b/src/usr/testcore/rtloader/makefile
@@ -5,7 +5,9 @@
#
# OpenPOWER HostBoot Project
#
-# COPYRIGHT International Business Machines Corp. 2011,2014
+# Contributors Listed Below - COPYRIGHT 2011,2017
+# [+] 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.
@@ -22,6 +24,8 @@
# IBM_PROLOG_END_TAG
ROOTPATH = ../../../..
+EXTRAINCDIR += ${ROOTPATH}/src/usr/pnor/
+
MODULE = testrtloader
TESTS = *.H
OpenPOWER on IntegriCloud