summaryrefslogtreecommitdiffstats
path: root/src/usr/hwpf/hwp/mvpd_accessors
diff options
context:
space:
mode:
Diffstat (limited to 'src/usr/hwpf/hwp/mvpd_accessors')
-rw-r--r--src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.C164
-rw-r--r--src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.H74
-rw-r--r--src/usr/hwpf/hwp/mvpd_accessors/mvpd.mk30
-rw-r--r--src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C164
-rw-r--r--src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.H68
-rw-r--r--src/usr/hwpf/hwp/mvpd_accessors/mvpd_errors.xml64
-rw-r--r--src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.C178
-rw-r--r--src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.H76
8 files changed, 818 insertions, 0 deletions
diff --git a/src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.C b/src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.C
new file mode 100644
index 000000000..e88a51001
--- /dev/null
+++ b/src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.C
@@ -0,0 +1,164 @@
+ /* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/hwpf/hwp/RepairRingFunc.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
+ */
+// $Id: RepairRingFunc.C,v 1.1 2012/07/19 22:00:40 mjjones Exp $
+/**
+ * @file getRepairRing.C
+ *
+ * @brief fetch repair rings from MVPD #R records
+ *
+ */
+
+#include <stdint.h>
+
+// fapi support
+#include <fapi.H>
+
+#include <getRepairRing.H>
+#include <mvpdRingFuncs.H>
+
+// pull in CompressedScanData def from proc_slw_build HWP
+#include <p8_scan_compression.H>
+extern "C"
+{
+using namespace fapi;
+
+
+fapi::ReturnCode getRepairRing( const fapi::Target &i_fapiTarget,
+ const uint8_t i_chipletId,
+ const uint8_t i_ringId,
+ uint8_t *io_pRingBuf,
+ uint32_t &io_rRingBufsize)
+{
+ fapi::ReturnCode l_fapirc;
+ uint8_t *l_pRing = NULL;
+ uint8_t *l_pdRRecord = NULL;
+ uint32_t l_pdRLen = 0;
+ uint32_t l_ringLen = 0;
+
+
+ FAPI_DBG(" getRepairRing: entry ringId=0x%x, chipletId=0x%x, size=0x%x ",
+ i_ringId,
+ i_chipletId,
+ io_rRingBufsize );
+
+ do {
+
+ // 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: fapiGetMvpdField failed to get buffer size");
+
+ io_rRingBufsize = 0;
+ // break out with fapirc
+ break;
+ }
+
+ FAPI_DBG( "getRepairRing: fapiGetMvpdField returned l_pdRLen=0x%x",
+ l_pdRLen );
+
+ // allocate buffer for the record. Always works.
+ l_pdRRecord = new uint8_t[l_pdRLen];
+
+ // load repair ring from MVPD for this target
+ l_fapirc = fapiGetMvpdField( fapi::MVPD_RECORD_CP00,
+ fapi::MVPD_KEYWORD_PDR,
+ i_fapiTarget,
+ l_pdRRecord,
+ l_pdRLen );
+ if ( l_fapirc )
+ {
+ FAPI_ERR("getRepairRing: fapiGetMvpdField failed");
+
+ io_rRingBufsize = 0;
+ // break out with fapirc
+ break;
+ }
+
+ // find ring in Field
+ l_fapirc = findMvpdRingField (i_chipletId,
+ i_ringId,
+ l_pdRRecord,
+ l_pdRLen,
+ l_pRing,
+ l_ringLen);
+ if ( l_fapirc )
+ {
+ FAPI_ERR("getRepairRing: findMvpdRing failed");
+
+ io_rRingBufsize = 0;
+ // break out with fapirc
+ break;
+ }
+ // return buffer pointer is NULL if just looking for the size
+ if ( io_pRingBuf == NULL )
+ {
+ io_rRingBufsize = l_ringLen;
+ // break out of do block with success rc
+ break;
+ }
+ // check if we have enough space
+ if ( io_rRingBufsize < l_ringLen )
+ {
+ FAPI_ERR( "getRepairRing: output buffer too small: 0x%x < 0x%x",
+ io_rRingBufsize,
+ l_ringLen
+ );
+
+ // return actual size of data, so caller can re-try with
+ // the correct value
+ io_rRingBufsize = l_ringLen;
+ FAPI_SET_HWP_ERROR(l_fapirc, RC_REPAIR_RING_INVALID_SIZE );
+
+ // break out of do block with fapi rc set
+ break;
+ }
+ // we're good, copy data into the passed-in buffer
+ memcpy( io_pRingBuf, l_pRing, l_ringLen );
+ io_rRingBufsize = l_ringLen;
+
+ FAPI_DBG( "getRepairRing: return record: 0x%x.0x%x %p, 0x%x",
+ i_ringId,
+ i_chipletId,
+ io_pRingBuf,
+ io_rRingBufsize );
+
+ } while ( 0 );
+
+ // unload the repair ring
+ delete[] l_pdRRecord;
+ l_pdRRecord = NULL;
+
+ FAPI_DBG(" getRepairRing: exit rc=0x%x",
+ static_cast<uint32_t>(l_fapirc) );
+
+ return l_fapirc;
+}
+
+} // extern "C"
diff --git a/src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.H b/src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.H
new file mode 100644
index 000000000..07fca40e4
--- /dev/null
+++ b/src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.H
@@ -0,0 +1,74 @@
+ /* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/include/usr/hwpf/hwp/getRepairRing.H $
+ *
+ * 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
+ */
+// $Id: RepairRingFunc.H,v 1.1 2012/07/19 22:00:38 mjjones Exp $
+/**
+ * @file getRepairRing.H
+ *
+ * @brief Prototype for getRepairRing() -
+ * get a repair ring from the MVPD #R record
+ */
+
+ #ifndef _HWP_GETREPAIRRING_
+ #define _HWP_GETREPAIRRING_
+
+ #include <fapi.H>
+
+// function pointer typedef definition for HWP call support
+typedef fapi::ReturnCode (*getRepairRing_FP_t) (const fapi::Target &, const uint8_t, const uint8_t, uint8_t *, uint32_t &);
+
+
+extern "C"
+{
+/**
+ * @brief get specified repair ring from MVPD #R record for the specified
+ * target CPU.
+ *
+ * @param i_fapiTarget - cpu target
+ * @param i_chipletId - Chiplet ID
+ * @param i_ringId - Ring ID
+ * @param io_pRingBuf - pointer to a buffer allocated by the caller
+ * if NULL, the size of the buffer required will
+ * be returned with FAPI_RC_SUCCESS.
+ * @param io_rRingBufsize - in: size of ring buffer that caller has
+ * allocated
+ * out: number of BYTES that were copied to the
+ * output buffer.
+ * If the ring was not found, an error
+ * will be returned and this will be 0.
+ * If the output buffer is not big enough,
+ * an error will be returned and this will
+ * be the size required.
+ *
+ * @return fapi::ReturnCode - FAPI_RC_SUCCESS if success,
+ * relevant error code for failure.
+ */
+fapi::ReturnCode getRepairRing( const fapi::Target &i_fapiTarget,
+ const uint8_t i_chipletId,
+ const uint8_t i_ringId,
+ uint8_t *io_pRingBuf,
+ uint32_t &io_rRingBufsize );
+
+}
+
+#endif
diff --git a/src/usr/hwpf/hwp/mvpd_accessors/mvpd.mk b/src/usr/hwpf/hwp/mvpd_accessors/mvpd.mk
new file mode 100644
index 000000000..995e8efc5
--- /dev/null
+++ b/src/usr/hwpf/hwp/mvpd_accessors/mvpd.mk
@@ -0,0 +1,30 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: src/usr/hwpf/hwp/mvpd_accessors/mvpd.mk $
+#
+# 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 otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# Origin: 30
+#
+# IBM_PROLOG_END_TAG
+EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/mvpd_accessors
+
+VPATH += mvpd_accessors
+
+OBJS += getRepairRing.o \
+ setRepairRing.o \
+ mvpdRingFuncs.o
+
diff --git a/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C b/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C
new file mode 100644
index 000000000..c42b9ffb5
--- /dev/null
+++ b/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C
@@ -0,0 +1,164 @@
+ /* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/hwpf/hwp/RepairRingFunc.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 mvpdRingFuncs.C
+ *
+ * @brief common routines
+ *
+ */
+
+#include <stdint.h>
+
+// fapi support
+#include <fapi.H>
+
+#include <mvpdRingFuncs.H>
+
+// pull in CompressedScanData def from proc_slw_build HWP
+#include <p8_scan_compression.H>
+
+extern "C"
+{
+using namespace fapi;
+
+fapi::ReturnCode findMvpdRingField( const uint8_t i_chipletId,
+ const uint8_t i_ringId,
+ uint8_t * const i_pFieldBuf,
+ uint32_t i_fieldBufsize,
+ uint8_t * &o_rRingBuf,
+ uint32_t &o_rRingBufsize)
+{
+ fapi::ReturnCode l_fapirc;
+ uint8_t *l_pRing = NULL;
+ uint32_t l_offset = 0;
+ CompressedScanData *l_pScanData = NULL;
+ bool l_foundflag = false;
+
+ // initialize return fields in case of an error.
+ o_rRingBuf=NULL;
+ o_rRingBufsize=0;
+
+ FAPI_DBG(" findMvpdRingField: entry chipletId=0x%x, ringId=0x%x ",
+ i_chipletId,
+ i_ringId );
+
+ do {
+ // point to #R record
+ l_pRing = i_pFieldBuf;
+
+ //
+ // Find first RSA data block in #R (fixed offset defined by
+ // MVPD spec)
+ //
+ // First byte in #R record should be the version number, skip
+ // over this.
+ //
+ FAPI_DBG( "findMvpdRingField: #R record version = 0x%x", *l_pRing );
+ l_pRing++;
+ l_offset = 0;
+
+ l_foundflag = false;
+ // be sure that data we will look at is within the passed buffer
+ while ( l_offset+sizeof(CompressedScanData) < i_fieldBufsize )
+ {
+ // point to header
+ l_pScanData =
+ reinterpret_cast<CompressedScanData *>( l_pRing+l_offset );
+
+ // Check magic key to make sure this is a valid record.
+ if ( l_pScanData->iv_magic != RS4_MAGIC )
+ {
+ FAPI_ERR( "findMvpdRingField: Header 0x%x at offset 0x%x,hit end of list",
+ l_pScanData->iv_magic,
+ l_offset );
+
+ // TODO: RTC 51917 how to tell the end of the list? Assume that
+ // finding a header without RS4_MAGIC is the end.
+ // TODO: RTC 51716 test image does not have correct header
+ //
+ // keep the following incase there is a different way to find
+ // the end.
+ // $$const uint32_t &MAGIC = l_pScanData->magic;
+ // $$FAPI_SET_HWP_ERROR(l_fapirc, RC_REPAIR_RING_INVALID_MAGIC );
+ // break out of scan loop, ring not found
+ break;
+ }
+ // dump record info for debug
+ FAPI_DBG( "findMvpdRingField: %d ringId=0x%x, chipletId=0x%x, size=0x%x",
+ l_offset,
+ l_pScanData->iv_ringId,
+ l_pScanData->iv_chipletId,
+ l_pScanData->iv_size );
+
+
+ if ( (l_pScanData->iv_ringId == i_ringId)
+ && (l_pScanData->iv_chipletId == i_chipletId) )
+ {
+ FAPI_DBG( "findMvpdRingField: Found it: 0x%x.0x%x, 0x%x",
+ i_ringId,
+ i_chipletId,
+ l_pScanData->iv_size );
+
+ if (l_offset+l_pScanData->iv_size > i_fieldBufsize)
+ {
+ // shouldn't happen, but does not all fit
+ FAPI_SET_HWP_ERROR(l_fapirc, RC_REPAIR_RING_INVALID_SIZE );
+ break;
+ }
+ l_foundflag = true;
+ o_rRingBuf = l_pRing+l_offset;
+ o_rRingBufsize=l_pScanData->iv_size;
+ // got it, break out of scan loop
+ break;
+ }
+
+ // being defensive.
+ if (l_pScanData->iv_size == 0)
+ {
+ // size of 0 is invalid, would loop forever.
+ break;
+ }
+ // bump to next ring
+ l_offset += l_pScanData->iv_size ;
+
+ } // end while scan loop
+
+ // foundflag not set, set error if no other error
+ if ( !l_fapirc && ! l_foundflag )
+ {
+ const uint8_t & RING_MODIFIER = i_ringId;
+ const uint8_t & CHIPLET_ID = i_chipletId;
+ FAPI_SET_HWP_ERROR(l_fapirc, RC_REPAIR_RING_NOT_FOUND );
+ }
+
+ } while ( 0 );
+
+
+ FAPI_DBG(" findMvpdRingField: exit RC=0x%x",
+ static_cast<uint32_t>(l_fapirc) );
+
+ return l_fapirc;
+}
+
+} // extern "C"
diff --git a/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.H b/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.H
new file mode 100644
index 000000000..14e6e40db
--- /dev/null
+++ b/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.H
@@ -0,0 +1,68 @@
+ /* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/include/usr/hwpf/hwp/RepairRingFunc.H $
+ *
+ * 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 mvpdRingFuncs.H
+ *
+ * @brief Prototype for getMvpdRingField() -
+ * return a buffer containing the entire field with a pointer to
+ * the requested ring.
+ */
+
+ #ifndef _HWP_MVPDRINGFUNCS_
+ #define _HWP_MVPDRINGFUNCS_
+
+ #include <fapi.H>
+
+
+
+extern "C"
+{
+
+/**
+ * @brief return mvpd field with pointer to requested ring
+ * for the specified target CPU.
+ * It is an error if the requested ring is not there.
+ * RC_REPAIR_RING_NOT_FOUND will be returned if the requested
+ * ring is not there.
+ *
+ * @param i_chipletId - Chiplet ID to search for
+ * @param i_ringId - Ring ID to search for
+ * @param i_pFieldBuf - The buffer containing the field to search
+ * @param i_fieldBufsize - Number of bytes in the field buffer
+ * @param o_pRingBuf - Pointer to ring in the field buffer
+ * @param o_rRingBufsize - Size of ring
+ *
+ * @return fapi::ReturnCode - FAPI_RC_SUCCESS if success,
+ * relevant error code for failure.
+ */
+
+fapi::ReturnCode findMvpdRingField( const uint8_t i_chipletId,
+ const uint8_t i_ringId,
+ uint8_t * const i_pFieldBuf,
+ uint32_t i_fieldBufsize,
+ uint8_t * &o_rRingBuf,
+ uint32_t &o_rRingBufsize);
+} // extern "C"
+
+#endif // _HWP_REPAIRRINGFUNC
diff --git a/src/usr/hwpf/hwp/mvpd_accessors/mvpd_errors.xml b/src/usr/hwpf/hwp/mvpd_accessors/mvpd_errors.xml
new file mode 100644
index 000000000..c042816c7
--- /dev/null
+++ b/src/usr/hwpf/hwp/mvpd_accessors/mvpd_errors.xml
@@ -0,0 +1,64 @@
+<!-- IBM_PROLOG_BEGIN_TAG
+ This is an automatically generated prolog.
+
+ $Source: src/usr/hwpf/hwp/mvpd_pdr_errors.xml $
+
+ 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 -->
+
+<hwpErrors>
+ <!-- *********************************************************************** -->
+ <hwpError>
+ <rc>RC_REPAIR_RING_INVALID_RINGBUF_PTR</rc>
+ <description>
+ Invalid input parameter: pointer to ringbuffer was NULL
+ </description>
+ </hwpError>
+ <!-- *********************************************************************** -->
+ <hwpError>
+ <rc>RC_REPAIR_RING_ALLOC_FAIL</rc>
+ <description>
+ Failed to allocate buffer space for repair ring data
+ </description>
+ </hwpError>
+ <!-- *********************************************************************** -->
+ <hwpError>
+ <rc>RC_REPAIR_RING_INVALID_MAGIC</rc>
+ <description>
+ Failed to allocate buffer space for repair ring data
+ </description>
+ <ffdc>MAGIC</ffdc>
+ </hwpError>
+ <!-- *********************************************************************** -->
+ <hwpError>
+ <rc>RC_REPAIR_RING_INVALID_SIZE</rc>
+ <description>
+ Invalid input parameter: size of buffer was not big enough to copy repair ring data
+ </description>
+ </hwpError>
+ <!-- *********************************************************************** -->
+ <hwpError>
+ <rc>RC_REPAIR_RING_NOT_FOUND</rc>
+ <description>
+ The repair ring specified was not found.
+ </description>
+ <ffdc>RING_MODIFIER</ffdc>
+ <ffdc>CHIPLET_ID</ffdc>
+ </hwpError>
+ <!-- *********************************************************************** -->
+</hwpErrors>
diff --git a/src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.C b/src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.C
new file mode 100644
index 000000000..4298c64e0
--- /dev/null
+++ b/src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.C
@@ -0,0 +1,178 @@
+ /* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/usr/hwpf/hwp/setRepairRing.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 setRepairRing.C
+ *
+ * @brief update repair rings in MVPD #R records
+ *
+ */
+
+#include <stdint.h>
+
+// fapi support
+#include <fapi.H>
+
+#include <setRepairRing.H>
+#include <mvpdRingFuncs.H>
+
+// pull in CompressedScanData def from proc_slw_build HWP
+#include <p8_scan_compression.H>
+extern "C"
+{
+using namespace fapi;
+
+
+fapi::ReturnCode setRepairRing( const fapi::Target &i_fapiTarget,
+ const uint8_t i_chipletId,
+ const uint8_t i_ringId,
+ uint8_t *io_pRingBuf,
+ uint32_t &io_rRingBufsize)
+{
+ fapi::ReturnCode l_fapirc;
+ uint8_t *l_pRing = NULL;
+ uint8_t *l_pdRRecord = NULL;
+ uint32_t l_pdRLen = 0;
+ uint32_t l_ringLen = 0;
+
+
+ FAPI_DBG(" setRepairRing: entry ringId=0x%x, chipletId=0x%x, size=0x%x ",
+ i_ringId,
+ i_chipletId,
+ io_rRingBufsize );
+
+ do {
+
+ // 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("setRepairRing: fapiGetMvpdField failed to get buffer size");
+
+ io_rRingBufsize = 0;
+ // break out with fapirc
+ break;
+ }
+
+ FAPI_DBG( "setRepairRing: fapiGetMvpdField returned l_pdRLen=0x%x",
+ l_pdRLen );
+
+ // allocate buffer for the record. Always works
+ l_pdRRecord = new uint8_t[l_pdRLen];
+
+ // load repair ring from MVPD for this target
+ l_fapirc = fapiGetMvpdField( fapi::MVPD_RECORD_CP00,
+ fapi::MVPD_KEYWORD_PDR,
+ i_fapiTarget,
+ l_pdRRecord,
+ l_pdRLen );
+ if ( l_fapirc )
+ {
+ FAPI_ERR("setRepairRing: fapiGetMvpdField failed");
+
+ io_rRingBufsize = 0;
+ // break out with fapirc
+ break;
+ }
+
+ // find ring in Field
+ l_fapirc = findMvpdRingField (i_chipletId,
+ i_ringId,
+ l_pdRRecord,
+ l_pdRLen,
+ l_pRing,
+ l_ringLen);
+ if ( l_fapirc )
+ {
+ FAPI_ERR("setRepairRing: findMvpdRingField failed");
+
+ io_rRingBufsize = 0;
+ // break out with fapirc
+ break;
+ }
+ // buffer pointer is NULL if just looking for the size
+ if ( io_pRingBuf == NULL )
+ {
+ io_rRingBufsize = l_ringLen;
+ // break out of do block with success rc
+ break;
+ }
+ // check if the ring passes is exactly the same size
+ if ( io_rRingBufsize != l_ringLen )
+ {
+ FAPI_ERR( "setRepairRing: buffer not exactly same size: 0x%x != 0x%x",
+ io_rRingBufsize,
+ l_ringLen
+ );
+
+ // return actual size of data, so caller can re-try with
+ // the correct value
+ io_rRingBufsize = l_ringLen;
+ FAPI_SET_HWP_ERROR(l_fapirc, RC_REPAIR_RING_INVALID_SIZE );
+
+ // break out of do block with fapi rc set
+ break;
+ }
+ // we're good, copy data from the passed-in buffer
+ memcpy( l_pRing, io_pRingBuf, l_ringLen );
+ io_rRingBufsize = l_ringLen;
+
+ FAPI_DBG( "setRepairRing: update record: 0x%x.0x%x %p, 0x%x",
+ i_ringId,
+ i_chipletId,
+ io_pRingBuf,
+ io_rRingBufsize );
+
+ // update repair ring from MVPD for this target
+ l_fapirc = fapiSetMvpdField( fapi::MVPD_RECORD_CP00,
+ fapi::MVPD_KEYWORD_PDR,
+ i_fapiTarget,
+ l_pdRRecord,
+ l_pdRLen );
+ if ( l_fapirc )
+ {
+ FAPI_ERR("setRepairRing: fapiSetMvpdField failed");
+
+ io_rRingBufsize = 0;
+ // break out with fapirc
+ break;
+ }
+
+ } while ( 0 );
+
+ // unload the repair ring
+ delete[] l_pdRRecord;
+ l_pdRRecord = NULL;
+
+ FAPI_DBG(" setRepairRing: exit rc=0x%x",
+ static_cast<uint32_t>(l_fapirc) );
+
+ return l_fapirc;
+}
+
+} // extern "C"
diff --git a/src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.H b/src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.H
new file mode 100644
index 000000000..8af07e53a
--- /dev/null
+++ b/src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.H
@@ -0,0 +1,76 @@
+ /* IBM_PROLOG_BEGIN_TAG
+ * This is an automatically generated prolog.
+ *
+ * $Source: src/include/usr/hwpf/hwp/setRepairRing.H $
+ *
+ * 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
+ */
+// $Id: RepairRingFunc.H,v 1.1 2012/07/19 22:00:38 mjjones Exp $
+/**
+ * @file setRepairRing.H
+ *
+ * @brief Prototype for setRepairRing() -
+ * get a repair ring from the MVPD #R record
+ */
+
+ #ifndef _HWP_SETREPAIRRING_
+ #define _HWP_SETREPAIRRING_
+
+ #include <fapi.H>
+
+// function pointer typedef definition for HWP call support
+typedef fapi::ReturnCode (*setRepairRing_FP_t) (const fapi::Target &, const uint8_t, const uint8_t, uint8_t *, uint32_t &);
+
+extern "C"
+{
+
+/**
+ * @brief update specified repair ring in MVPD #R record for the specified
+ * target CPU. The ring must already be present. This function can not
+ * be used to 'add' a ring. The size of the updated ring must exactly
+ * match the exiting ring, which is updated in place.
+ *
+ * @param i_fapiTarget - cpu target
+ * @param i_chipletId - Chiplet ID
+ * @param i_ringId - Ring ID
+ * @param io_pRingBuf - pointer to a buffer allocated by the caller
+ * if NULL, the size of the buffer required will
+ * be returned with FAPI_RC_SUCCESS.
+ * @param io_rRingBufsize - in: size of ring buffer that caller has
+ * allocated. The size must be the exact
+ * size of the existing ring.
+ * out: If the ring was not found, an error
+ * will be returned and this will be 0.
+ * If the passed ring size does not
+ * exactly match the existing ring,
+ * an error will be returned and this will
+ * be the size required.
+ *
+ * @return fapi::ReturnCode - FAPI_RC_SUCCESS if success,
+ * relevant error code for failure.
+ */
+fapi::ReturnCode setRepairRing( const fapi::Target &i_fapiTarget,
+ const uint8_t i_chipletId,
+ const uint8_t i_ringId,
+ uint8_t *io_pRingBuf,
+ uint32_t &io_rRingBufsize );
+
+}
+
+#endif
OpenPOWER on IntegriCloud