summaryrefslogtreecommitdiffstats
path: root/src/usr
diff options
context:
space:
mode:
authorMike Jones <mjjones@us.ibm.com>2012-07-19 17:05:38 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2012-07-30 17:15:51 -0500
commit0dbf0dfdd65a967045976979a33569db73fc0878 (patch)
treeed2fda18d7ac8213f3d2d660e8fccb645d5ffbfe /src/usr
parent0a7124143589d15b534f7f2384fecc5a5cd0725f (diff)
downloadtalos-hostboot-0dbf0dfdd65a967045976979a33569db73fc0878.tar.gz
talos-hostboot-0dbf0dfdd65a967045976979a33569db73fc0878.zip
HWPF: Update FAPI Module VPD field access function
In a design meeting, it was agreed that the FAPI Module VPD field access function would be changed to take a record and keyword enumerator, rather than having a separate function for each MVPD field. Change-Id: I0072f2010dbb85ca9edd390ebd5b3730826f3ed0 RTC: 43796 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/1404 Tested-by: Jenkins Server Reviewed-by: Van H. Lee <vanlee@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/usr')
-rw-r--r--src/usr/hwpf/hwp/RepairRingFunc.C28
-rw-r--r--src/usr/hwpf/plat/fapiMvpdAccess.C129
-rw-r--r--src/usr/hwpf/plat/fapiPlatMvpdAccess.C271
-rw-r--r--src/usr/hwpf/plat/makefile2
-rw-r--r--src/usr/hwpf/test/fapiwinkletest.H23
5 files changed, 302 insertions, 151 deletions
diff --git a/src/usr/hwpf/hwp/RepairRingFunc.C b/src/usr/hwpf/hwp/RepairRingFunc.C
index 2d63f4c60..3b84f19f6 100644
--- a/src/usr/hwpf/hwp/RepairRingFunc.C
+++ b/src/usr/hwpf/hwp/RepairRingFunc.C
@@ -21,7 +21,7 @@
*
* IBM_PROLOG_END_TAG
*/
-
+// $Id: RepairRingFunc.C,v 1.1 2012/07/19 22:00:40 mjjones Exp $
/**
* @file RepairRingFunc.C
*
@@ -99,21 +99,23 @@ fapi::ReturnCode getRepairRing( const fapi::Target &i_fapiTarget,
FAPI_DBG( "getRepairRing: get MVPD #R buffer" );
- // call fapiGetMvpdPdr once with a NULL pointer to get the buffer size
- // no error should be returned.
- l_fapirc = fapiGetMvpdPdr( i_fapiTarget,
- NULL,
- l_pdRLen );
+ // call fapiGetMvpdField once with a NULL pointer to get the buffer
+ // size no error should be returned.
+ l_fapirc = fapiGetMvpdField( fapi::MVPD_RECORD_CP00,
+ fapi::MVPD_KEYWORD_PDR,
+ i_fapiTarget,
+ NULL,
+ l_pdRLen );
if ( l_fapirc )
{
- FAPI_ERR("getRepairRing: fapiGetMvpdPdr failed to get buffer size");
+ FAPI_ERR("getRepairRing: fapiGetMvpdField failed to get buffer size");
io_rRingBufsize = 0;
// break out with fapirc
break;
}
- FAPI_DBG( "getRepairRing: fapiGetMvpdPdr returned l_pdRLen=0x%x",
+ FAPI_DBG( "getRepairRing: fapiGetMvpdField returned l_pdRLen=0x%x",
l_pdRLen );
// allocate buffer for the record
@@ -130,12 +132,14 @@ fapi::ReturnCode getRepairRing( const fapi::Target &i_fapiTarget,
}
// load repair ring from MVPD for this target
- l_fapirc = fapiGetMvpdPdr( i_fapiTarget,
- l_pdRRecord,
- l_pdRLen );
+ l_fapirc = fapiGetMvpdField( fapi::MVPD_RECORD_CP00,
+ fapi::MVPD_KEYWORD_PDR,
+ i_fapiTarget,
+ l_pdRRecord,
+ l_pdRLen );
if ( l_fapirc )
{
- FAPI_ERR("getRepairRing: fapiGetMvpdPdr failed");
+ FAPI_ERR("getRepairRing: fapiGetMvpdField failed");
io_rRingBufsize = 0;
// break out with fapirc
diff --git a/src/usr/hwpf/plat/fapiMvpdAccess.C b/src/usr/hwpf/plat/fapiMvpdAccess.C
deleted file mode 100644
index b7d57726b..000000000
--- a/src/usr/hwpf/plat/fapiMvpdAccess.C
+++ /dev/null
@@ -1,129 +0,0 @@
-/* IBM_PROLOG_BEGIN_TAG
- * This is an automatically generated prolog.
- *
- * $Source: src/usr/hwpf/plat/fapiMvpdAccess.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 fapiMvpdAccess.C
- *
- * @brief fetch #R records from MVPD
- *
- * More prototypes may be added later to fetch other records from MVPD
- *
- */
-
-#include <stdint.h>
-
-#include <errl/errlentry.H>
-
-// targeting support
-#include <targeting/common/commontargeting.H>
-
-// fapi support
-#include <fapi.H>
-#include <fapiPlatHwpInvoker.H>
-#include <hwpf/plat/fapiPlatReasonCodes.H>
-
-// MVPD
-#include <devicefw/userif.H>
-#include <mvpd/mvpdenums.H>
-
-#include <fapiMvpdAccess.H>
-
-
-extern "C"
-{
-using namespace TARGETING;
-using namespace fapi;
-using namespace DeviceFW;
-
-
-/**
- * @def Max length for #R record
- */
-const size_t MAX_pdR_RECORD = 0xffff;
-
-// *********************************************************************
-// fapiGetMvpdPdr - get #R record from MVPD
-//
-// @NOTE: The P8 module VPD specification, March 27, 2012,
-// section 5.30.1 is wrong - #R records are in CP00.
-// *********************************************************************
-fapi::ReturnCode fapiGetMvpdPdr( const fapi::Target &i_fapiTarget,
- uint8_t *i_pPdrRecord,
- uint32_t &io_rPdrSize )
-{
- fapi::ReturnCode l_fapirc( fapi::FAPI_RC_SUCCESS );
- errlHndl_t l_errl = NULL;
- size_t l_pdRLen = 0;
-
- FAPI_DBG( "fapiGetMvpdPdr entry" );
-
- // #R record looks like this:
- // Field Type length Value
- // Name ASCII 2 "#R"
- // Length HEX 2 -
- // Version HEX 1 0x10
- // Chiplet-max HEX 12288 -
-
- do
- {
- // pass the parameters through to deviceRead. If the pointer is NULL,
- // deviceRead will pass the correct size back to the caller with no
- // error. ( RTC 42489 )
-
- l_pdRLen = io_rPdrSize;
- // Try to read the data
- l_errl = deviceRead( reinterpret_cast< TARGETING::Target*>(i_fapiTarget.get()),
- i_pPdrRecord,
- l_pdRLen,
- DEVICE_MVPD_ADDRESS( MVPD::CP00,
- MVPD::pdR ) );
- if ( l_errl )
- {
- FAPI_ERR( "fapiGetMvpdPdr: ERROR: deviceRead : errorlog PLID=0x%x",
- l_errl->plid() );
-
- // set fapi error and commit errlog
- l_fapirc.setPlatError(reinterpret_cast<void *> (l_errl));
-
- // set returned size to 0
- io_rPdrSize = 0;
-
- // Return fapirc to caller
- break;
- }
-
- // made it all the way to the bottom with no errors,
- // return to caller with buffer and size filled in
- FAPI_DBG( "fapiGetMvpdPdr: returning #R record len=0x%x",
- l_pdRLen );
- io_rPdrSize = l_pdRLen;
-
- } while ( 0 );
-
-
- FAPI_DBG( "fapiGetMvpdPdr: exit" );
-
- return l_fapirc;
-}
-
-} // extern "C"
diff --git a/src/usr/hwpf/plat/fapiPlatMvpdAccess.C b/src/usr/hwpf/plat/fapiPlatMvpdAccess.C
new file mode 100644
index 000000000..5328145e9
--- /dev/null
+++ b/src/usr/hwpf/plat/fapiPlatMvpdAccess.C
@@ -0,0 +1,271 @@
+/* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/hwpf/plat/fapiPlatMvpdAccess.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 fapiPlatMvpdAccess.C
+ *
+ * @brief Implements the fapiMvpdAccess.H functions
+ */
+
+#include <stdint.h>
+#include <errl/errlentry.H>
+
+// fapi support
+#include <hwpf/plat/fapiPlatReasonCodes.H>
+#include <fapiMvpdAccess.H>
+
+// MVPD
+#include <devicefw/userif.H>
+#include <mvpd/mvpdenums.H>
+
+
+namespace fapi
+{
+
+//******************************************************************************
+// MvpdRecordXlate
+// Translates a FAPI MVPD Record enumerator into a Hostboot MVPD Record
+// enumerator
+//******************************************************************************
+fapi::ReturnCode MvpdRecordXlate(const fapi::MvpdRecord i_fapiRecord,
+ MVPD::mvpdRecord & o_hbRecord)
+{
+ // Create a lookup table for converting a FAPI MVPD record enumerator to a
+ // Hostboot MVPD record enumerator. This is a simple array and relies on
+ // the FAPI record enumerators starting at zero and incrementing.
+ const uint8_t NUM_MVPD_RECORDS = 0x1c;
+ static const MVPD::mvpdRecord mvpdFapiRecordToHbRecord[NUM_MVPD_RECORDS] =
+ {
+ MVPD::CRP0,
+ MVPD::CP00,
+ MVPD::VINI,
+ MVPD::LRP0,
+ MVPD::LRP1,
+ MVPD::LRP2,
+ MVPD::LRP3,
+ MVPD::LRP4,
+ MVPD::LRP5,
+ MVPD::LRP6,
+ MVPD::LRP7,
+ MVPD::LRP8,
+ MVPD::LRP9,
+ MVPD::LRPA,
+ MVPD::LRPB,
+ MVPD::LWP0,
+ MVPD::LWP1,
+ MVPD::LWP2,
+ MVPD::LWP3,
+ MVPD::LWP4,
+ MVPD::LWP5,
+ MVPD::LWP6,
+ MVPD::LWP7,
+ MVPD::LWP8,
+ MVPD::LWP9,
+ MVPD::LWPA,
+ MVPD::LWPB,
+ MVPD::VWML,
+ };
+
+ fapi::ReturnCode l_rc;
+
+ uint8_t l_index = static_cast<uint8_t>(i_fapiRecord);
+
+ if (l_index >= NUM_MVPD_RECORDS)
+ {
+ FAPI_ERR("MvpdRecordXlate: Invalid MVPD Record: 0x%x", i_fapiRecord);
+ /*@
+ * @errortype
+ * @moduleid MOD_MVPD_ACCESS
+ * @reasoncode RC_INVALID_RECORD
+ * @userdata1 Record enumerator
+ * @devdesc Attempt to read an MVPD field using an invalid record
+ */
+ errlHndl_t l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi::MOD_MVPD_ACCESS,
+ fapi::RC_INVALID_RECORD,
+ i_fapiRecord);
+
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatError(reinterpret_cast<void *> (l_errl));
+ }
+ else
+ {
+ o_hbRecord = mvpdFapiRecordToHbRecord[l_index];
+ }
+
+ return l_rc;
+}
+
+//******************************************************************************
+// MvpdKeywordXlate
+// Translates a FAPI MVPD Keyword enumerator into a Hostboot MVPD Keyword
+// enumerator
+//******************************************************************************
+fapi::ReturnCode MvpdKeywordXlate(const fapi::MvpdKeyword i_fapiKeyword,
+ MVPD::mvpdKeyword & o_hbKeyword)
+{
+ // Create a lookup table for converting a FAPI MVPD keyword enumerator to a
+ // Hostboot MVPD keyword enumerator. This is a simple array and relies on
+ // the FAPI record enumerators starting at zero and incrementing.
+ const uint8_t NUM_MVPD_KEYWORDS = 0x1f;
+ static const MVPD::mvpdKeyword
+ mvpdFapiKeywordToHbKeyword[NUM_MVPD_KEYWORDS] =
+ {
+ MVPD::VD,
+ MVPD::ED,
+ MVPD::TE,
+ MVPD::DD,
+ MVPD::pdP,
+ MVPD::ST,
+ MVPD::DN,
+ MVPD::PG,
+ MVPD::PK,
+ MVPD::pdR,
+ MVPD::pdV,
+ MVPD::pdH,
+ MVPD::SB,
+ MVPD::DR,
+ MVPD::VZ,
+ MVPD::CC,
+ MVPD::CE,
+ MVPD::FN,
+ MVPD::PN,
+ MVPD::SN,
+ MVPD::PR,
+ MVPD::HE,
+ MVPD::CT,
+ MVPD::HW,
+ MVPD::pdM,
+ MVPD::IN,
+ MVPD::pd2,
+ MVPD::pd3,
+ MVPD::OC,
+ MVPD::FO,
+ MVPD::pdI,
+ };
+
+ fapi::ReturnCode l_rc;
+
+ uint8_t l_index = static_cast<uint8_t>(i_fapiKeyword);
+
+ if (l_index >= NUM_MVPD_KEYWORDS)
+ {
+ FAPI_ERR("MvpdKeywordXlate: Invalid MVPD Keyword: 0x%x", i_fapiKeyword);
+ /*@
+ * @errortype
+ * @moduleid MOD_MVPD_ACCESS
+ * @reasoncode RC_INVALID_KEYWORD
+ * @userdata1 Keyword enumerator
+ * @devdesc Attempt to read an MVPD field using an invalid keyword
+ */
+ errlHndl_t l_errl = new ERRORLOG::ErrlEntry(
+ ERRORLOG::ERRL_SEV_UNRECOVERABLE,
+ fapi::MOD_MVPD_ACCESS,
+ fapi::RC_INVALID_KEYWORD,
+ i_fapiKeyword);
+
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatError(reinterpret_cast<void *> (l_errl));
+ }
+ else
+ {
+ o_hbKeyword = mvpdFapiKeywordToHbKeyword[l_index];
+ }
+
+ return l_rc;
+}
+
+}
+
+extern "C"
+{
+
+//******************************************************************************
+// fapiGetMvpdField
+//******************************************************************************
+fapi::ReturnCode fapiGetMvpdField(const fapi::MvpdRecord i_record,
+ const fapi::MvpdKeyword i_keyword,
+ const fapi::Target &i_procTarget,
+ uint8_t * const i_pBuffer,
+ uint32_t &io_fieldSize)
+{
+ fapi::ReturnCode l_rc;
+ FAPI_DBG("fapiGetMvpdField entry");
+
+ do
+ {
+ // Translate the FAPI record to a Hostboot record
+ MVPD::mvpdRecord l_hbRecord = MVPD::MVPD_INVALID_RECORD;
+
+ l_rc = fapi::MvpdRecordXlate(i_record, l_hbRecord);
+
+ if (l_rc)
+ {
+ break;
+ }
+
+ // Translate the FAPI keyword to a Hostboot keyword
+ MVPD::mvpdKeyword l_hbKeyword = MVPD::INVALID_MVPD_KEYWORD;
+
+ l_rc = fapi::MvpdKeywordXlate(i_keyword, l_hbKeyword);
+
+ if (l_rc)
+ {
+ break;
+ }
+
+ // Similarly to this function, deviceRead will return the size of the
+ // field if the pointer is NULL
+ size_t l_fieldLen = io_fieldSize;
+
+ errlHndl_t l_errl = deviceRead(
+ reinterpret_cast< TARGETING::Target*>(i_procTarget.get()),
+ i_pBuffer,
+ l_fieldLen,
+ DEVICE_MVPD_ADDRESS(l_hbRecord, l_hbKeyword));
+
+ if (l_errl)
+ {
+ FAPI_ERR("fapiGetMvpdField: ERROR: deviceRead : errorlog PLID=0x%x",
+ l_errl->plid());
+
+ // Add the error log pointer as data to the ReturnCode
+ l_rc.setPlatError(reinterpret_cast<void *> (l_errl));
+
+ break;
+ }
+
+ // Success, update callers io_fieldSize for the case where the pointer
+ // is NULL and deviceRead returned the actual size
+ io_fieldSize = l_fieldLen;
+ FAPI_DBG("fapiGetMvpdField: returning field len=0x%x", io_fieldSize);
+
+ } while(0);
+
+ FAPI_DBG( "fapiGetMvpdField: exit" );
+
+ return l_rc;
+}
+
+} // extern "C"
diff --git a/src/usr/hwpf/plat/makefile b/src/usr/hwpf/plat/makefile
index 1056e9ecd..4bb17e545 100644
--- a/src/usr/hwpf/plat/makefile
+++ b/src/usr/hwpf/plat/makefile
@@ -35,7 +35,7 @@ OBJS = fapiPlatHwAccess.o \
fapiPlatTarget.o \
fapiPlatUtil.o \
fapiPlatAttributeService.o \
- fapiMvpdAccess.o \
+ fapiPlatMvpdAccess.o \
fapiPlatTask.o \
fapiPlatAttrOverrideDirect.o
diff --git a/src/usr/hwpf/test/fapiwinkletest.H b/src/usr/hwpf/test/fapiwinkletest.H
index ceaff03ad..f9bd7c0c5 100644
--- a/src/usr/hwpf/test/fapiwinkletest.H
+++ b/src/usr/hwpf/test/fapiwinkletest.H
@@ -50,7 +50,7 @@ class FapiWinkleTest: public CxxTest::TestSuite
public:
/**
- * @brief call fapiGetMvpdPdr to fetch a #R record.
+ * @brief call fapiGetMvpdField to fetch a #R record.
*
*/
void testGetMvpdPdr()
@@ -86,16 +86,18 @@ public:
reinterpret_cast<void *>
(const_cast<TARGETING::Target*>(l_cpu_target)) );
- TS_TRACE( "call fapiGetMvpdPdr with NULL pointer" );
+ TS_TRACE( "call fapiGetMvpdField with NULL pointer" );
- // call fapiGetMvpdPdr once with a NULL pointer to get the buffer size
+ // call fapiGetMvpdField once with a NULL pointer to get the buffer size
// should return no error now.
- l_fapirc = fapiGetMvpdPdr( l_fapi_cpu_target,
+ l_fapirc = fapiGetMvpdField(fapi::MVPD_RECORD_CP00,
+ fapi::MVPD_KEYWORD_PDR,
+ l_fapi_cpu_target,
NULL,
l_pdRLen );
if ( l_fapirc != fapi::FAPI_RC_SUCCESS )
{
- TS_FAIL( "testGetMvpdPdr: expected FAPI_RC_SUCCESS" );
+ TS_FAIL( "fapiGetMvpdField: expected FAPI_RC_SUCCESS" );
fapiLogError(l_fapirc);
return;
}
@@ -104,7 +106,7 @@ public:
// above.
if ( l_pdRLen != MVPD_PDR_TEST_SIZE )
{
- TS_FAIL( "testGetMvpdPdr: expected size = 0x%x, received 0x%x",
+ TS_FAIL( "fapiGetMvpdField: expected size = 0x%x, received 0x%x",
MVPD_PDR_TEST_SIZE,
l_pdRLen );
fapiLogError(l_fapirc);
@@ -114,14 +116,17 @@ public:
// do a malloc instead of a new just for variety
l_pdRRecord = reinterpret_cast<uint8_t *>(malloc(l_pdRLen) );
- // call fapiGetMvpdPdr once with a NULL pointer to get the buffer size
- l_fapirc = fapiGetMvpdPdr( l_fapi_cpu_target,
+ // call fapiGetMvpdField once with a valid pointer
+ l_fapirc = fapiGetMvpdField(fapi::MVPD_RECORD_CP00,
+ fapi::MVPD_KEYWORD_PDR,
+ l_fapi_cpu_target,
l_pdRRecord,
l_pdRLen );
if ( l_fapirc != fapi::FAPI_RC_SUCCESS )
{
- TS_FAIL( "testGetMvpdPdr: expected FAPI_RC_SUCCESS" );
+ TS_FAIL( "fapiGetMvpdField: expected FAPI_RC_SUCCESS" );
fapiLogError(l_fapirc);
+ free( l_pdRRecord );
return;
}
OpenPOWER on IntegriCloud