diff options
Diffstat (limited to 'src/usr')
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/getMvpdRing.C | 77 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/getMvpdRing.H | 95 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.C | 164 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.H | 74 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/mvpd.mk | 4 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C | 575 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.H | 50 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/mvpd_errors.xml | 14 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/setMvpdRing.C | 76 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/setMvpdRing.H | 95 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.C | 178 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.H | 76 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiPlatMvpdAccess.C | 3 | ||||
-rw-r--r-- | src/usr/hwpf/test/fapiwinkletest.H | 412 | ||||
-rw-r--r-- | src/usr/hwpf/test/makefile | 3 | ||||
-rwxr-xr-x | src/usr/mvpd/mvpd.H | 1 | ||||
-rwxr-xr-x | src/usr/mvpd/test/mvpdtest.H | 1 |
17 files changed, 1209 insertions, 689 deletions
diff --git a/src/usr/hwpf/hwp/mvpd_accessors/getMvpdRing.C b/src/usr/hwpf/hwp/mvpd_accessors/getMvpdRing.C new file mode 100644 index 000000000..8273d70cc --- /dev/null +++ b/src/usr/hwpf/hwp/mvpd_accessors/getMvpdRing.C @@ -0,0 +1,77 @@ + /* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/hwp/getMvpdRing.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: getMvpdRing.C,v 1.1 2012/07/19 22:00:40 mjjones Exp $ +/** + * @file getMvpdRing.C + * + * @brief fetch repair rings from MVPD records + * + */ + +#include <stdint.h> + +// fapi support +#include <fapi.H> + +#include <getMvpdRing.H> +#include <mvpdRingFuncs.H> + +extern "C" +{ +using namespace fapi; + +// getMvpdRing: Wrapper to call common function mvpdRingFunc +fapi::ReturnCode getMvpdRing( fapi::MvpdRecord i_record, + fapi::MvpdKeyword i_keyword, + const fapi::Target &i_fapiTarget, + const uint8_t i_chipletId, + const uint8_t i_ringId, + uint8_t *i_pRingBuf, + uint32_t &io_rRingBufsize) +{ + fapi::ReturnCode l_fapirc; + + FAPI_DBG("getMvpdRing: entry ringId=0x%x, chipletId=0x%x, size=0x%x ", + i_ringId, + i_chipletId, + io_rRingBufsize ); + + // common get and set processing + l_fapirc = mvpdRingFunc(MVPD_RING_GET, + i_record, + i_keyword, + i_fapiTarget, + i_chipletId, + i_ringId, + i_pRingBuf, + io_rRingBufsize); + + + FAPI_DBG("getMvpdRing: exit rc=0x%x", + static_cast<uint32_t>(l_fapirc) ); + + return l_fapirc; +} + +} // extern "C" diff --git a/src/usr/hwpf/hwp/mvpd_accessors/getMvpdRing.H b/src/usr/hwpf/hwp/mvpd_accessors/getMvpdRing.H new file mode 100644 index 000000000..2f7fb9f2c --- /dev/null +++ b/src/usr/hwpf/hwp/mvpd_accessors/getMvpdRing.H @@ -0,0 +1,95 @@ + /* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/include/usr/hwpf/hwp/getMvpdRing.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 getMvpdRing.H + * + * @brief Prototype for getMvpdRing() - + * get a repair ring from a MVPD record + */ + + #ifndef _HWP_GETMVPDRING_ + #define _HWP_GETMVPDRING_ + + #include <fapi.H> + +// function pointer typedef definition for HWP call support +typedef fapi::ReturnCode (*getMvpdRing_FP_t) + (fapi::MvpdRecord,fapi::MvpdKeyword,const fapi::Target &, + const uint8_t, const uint8_t, uint8_t *, uint32_t &); + + +extern "C" +{ +/** + * @brief get specified ring from MVPD for the specified target CPU. + * + * A Ring Id Chiplet Id should be unique in the mvpd Record. + * The code does not validate. No assumption should be made on which would + * be returned if there are multiple. + * + * @param i_record - Record enumerator + * @param i_keyword - Keyword enumerator + * Supported Rings are: + * MVPD_RECORD_CP00 - MVPD_KEYWORD_PDR + * MVPD_RECORD_CP00 - MVPD_KEYWORD_PDG + * @param i_fapiTarget - cpu target + * @param i_chipletId - Chiplet ID + * @param i_ringId - Ring ID + * @param i_pRingBuf - pointer to a buffer allocated by the caller + * to receive the ring header and data. + * if NULL, the size of the min buffer required + * buffer will be returned in io_rRingBufsize + * with rc 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 minimum size required. + * The buffer contains the CompressedScanData + * structure followed by compressed data. The + * caller does compression and decompression. + * Buffer: io_rRingBufsize returns xNN. + * byte x0 CompressedScanData structure (rs4 header) + * byte x18 compressed data (sizeof CompressedScanData is 0x18) + * byte xNN last byte of compressed data + * + * @return fapi::ReturnCode - FAPI_RC_SUCCESS if success, + * relevant error code for failure. + */ +fapi::ReturnCode getMvpdRing( fapi::MvpdRecord i_record, + fapi::MvpdKeyword i_keyword, + 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/getRepairRing.C b/src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.C deleted file mode 100644 index e88a51001..000000000 --- a/src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.C +++ /dev/null @@ -1,164 +0,0 @@ - /* 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 deleted file mode 100644 index 07fca40e4..000000000 --- a/src/usr/hwpf/hwp/mvpd_accessors/getRepairRing.H +++ /dev/null @@ -1,74 +0,0 @@ - /* 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 index 995e8efc5..70aee6912 100644 --- a/src/usr/hwpf/hwp/mvpd_accessors/mvpd.mk +++ b/src/usr/hwpf/hwp/mvpd_accessors/mvpd.mk @@ -24,7 +24,7 @@ EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/mvpd_accessors VPATH += mvpd_accessors -OBJS += getRepairRing.o \ - setRepairRing.o \ +OBJS += getMvpdRing.o \ + setMvpdRing.o \ mvpdRingFuncs.o diff --git a/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C b/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C index c42b9ffb5..47b1e4c65 100644 --- a/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C +++ b/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.C @@ -1,7 +1,7 @@ /* IBM_PROLOG_BEGIN_TAG * This is an automatically generated prolog. * - * $Source: src/usr/hwpf/hwp/RepairRingFunc.C $ + * $Source: src/usr/hwpf/hwp/mvpdRingFuncs.C $ * * IBM CONFIDENTIAL * @@ -32,7 +32,7 @@ // fapi support #include <fapi.H> - +#include <fapiUtil.H> #include <mvpdRingFuncs.H> // pull in CompressedScanData def from proc_slw_build HWP @@ -42,12 +42,285 @@ extern "C" { using namespace fapi; -fapi::ReturnCode findMvpdRingField( const uint8_t i_chipletId, +// functions internal to this file +fapi::ReturnCode mvpdValidateRingHeader( CompressedScanData * i_pRing, + uint8_t i_chipletId, + uint8_t i_ringId, + uint32_t i_ringBufsize); + +fapi::ReturnCode mvpdRingFuncFind( const uint8_t i_chipletId, const uint8_t i_ringId, - uint8_t * const i_pFieldBuf, - uint32_t i_fieldBufsize, + uint8_t * i_pRecordBuf, + uint32_t i_recordBufLen, uint8_t * &o_rRingBuf, - uint32_t &o_rRingBufsize) + uint32_t &o_rRingBufsize); + +fapi::ReturnCode mvpdRingFuncGet ( uint8_t *i_pRing, + uint32_t i_ringLen, + uint8_t *i_pCallerRingBuf, + uint32_t &io_rCallerRingBufLen); + +fapi::ReturnCode mvpdRingFuncSet ( uint8_t *i_pRecordBuf, + uint32_t i_recordLen, + uint8_t *i_pRing, + uint32_t i_ringLen, + uint8_t *i_pCallerRingBuf, + uint32_t i_callerRingBufLen); + +//****************************************************************************** +// mvpdValidateRecordKeyword +// Check for supported combinations of Record and Keyword. +// The record needs to contain rings of RS4 header (CompressedScanData) format +// note: "getting" data not in RS4 header format would likely just fail to find +// the ring harmlessly. "Setting" data could make a mess looking for the end +// to append a new ring. The result could be invalid vpd. +// note: place first in the file to make finding the supported list easier. +//****************************************************************************** +fapi::ReturnCode mvpdValidateRecordKeyword( fapi::MvpdRecord i_record, + fapi::MvpdKeyword i_keyword) +{ + // add record/keywords with rings with RS4 header here. + struct _supportedRecordKeywords { + fapi::MvpdRecord record; + fapi::MvpdKeyword keyword; + } supportedRecordKeywords [] = { + { MVPD_RECORD_CP00, MVPD_KEYWORD_PDR }, + { MVPD_RECORD_CP00, MVPD_KEYWORD_PDG }, + }; + fapi::ReturnCode l_fapirc; + bool l_validPair = false; + const uint32_t numPairs = + sizeof(supportedRecordKeywords)/sizeof(supportedRecordKeywords[0]); + + for (uint32_t curPair = 0; curPair < numPairs; curPair++ ) + { + if (supportedRecordKeywords[curPair].record == i_record && + supportedRecordKeywords[curPair].keyword == i_keyword) + { + l_validPair = true; + break; + } + } + if ( !l_validPair ) { + FAPI_SET_HWP_ERROR(l_fapirc, RC_MVPD_RING_FUNC_INVALID_PARAMETER ); + } + return l_fapirc; + +}; + +//****************************************************************************** +// mvpdRingFunc: the getMvpdRing and setMvpdRing wrappers call this function +// to do all the processing. +// note: io_rRingBufsize is only 'output' for get. +//****************************************************************************** +fapi::ReturnCode mvpdRingFunc( const mvpdRingFuncOp i_mvpdRingFuncOp, + fapi::MvpdRecord i_record, + fapi::MvpdKeyword i_keyword, + const fapi::Target &i_fapiTarget, + const uint8_t i_chipletId, + const uint8_t i_ringId, + uint8_t *i_pRingBuf, + uint32_t &io_rRingBufsize) +{ + fapi::ReturnCode l_fapirc; + uint32_t l_recordLen = 0; + uint8_t *l_recordBuf = NULL; + uint8_t *l_pRing = NULL; + uint32_t l_ringLen = 0; + + FAPI_DBG("mvpdRingFunc:entry op=0x%x ringId=0x%x chipletId=0x%x size=0x%x ", + i_mvpdRingFuncOp, + i_ringId, + i_chipletId, + io_rRingBufsize ); + + do { + // do common get and set input parameter error checks + // check for supported combination of Record and Keyword + l_fapirc = mvpdValidateRecordKeyword( i_record, + i_keyword); + if ( l_fapirc ) + { + FAPI_ERR(" mvpdRingFunc: unsupported record keyword pair "); + + // break out with fapirc + break; + } + + // do set specific input parameter checks + if (i_mvpdRingFuncOp == MVPD_RING_SET ) + { + // passing NULL pointer to receive needed size is only for get. + if (i_pRingBuf == NULL ) + { + FAPI_SET_HWP_ERROR(l_fapirc, + RC_MVPD_RING_FUNC_INVALID_PARAMETER ); + // break out with fapirc + break; + } + + // Validate ring header to protect vpd + l_fapirc = mvpdValidateRingHeader( + reinterpret_cast<CompressedScanData *>(i_pRingBuf), + i_chipletId, + i_ringId, + io_rRingBufsize); + if ( l_fapirc ) + { + FAPI_ERR(" mvpdRingFunc: invalid ring header "); + // break out with fapirc + break; + } + + } + + // call fapiGetMvpdField once with a NULL pointer to get the buffer + // size no error should be returned. + l_fapirc = fapiGetMvpdField( i_record, + i_keyword, + i_fapiTarget, + NULL, + l_recordLen ); + if ( l_fapirc ) + { + FAPI_ERR("mvpdRingFunc:fapiGetMvpdField failed to get buffer size"); + + // break out with fapirc + break; + } + + FAPI_DBG( "mvpdRingFunc: fapiGetMvpdField returned record len=0x%x", + l_recordLen ); + + // allocate buffer for the record. Always works + l_recordBuf = new uint8_t[l_recordLen]; + + // load ring from MVPD for this target + l_fapirc = fapiGetMvpdField( i_record, + i_keyword, + i_fapiTarget, + l_recordBuf, + l_recordLen ); + if ( l_fapirc ) + { + FAPI_ERR("mvpdRingFunc: fapiGetMvpdField failed rc=0x%x", + static_cast<uint32_t>(l_fapirc)); + // break out with fapirc + break; + } + + // find ring in the record. It is an error if not there for a "get". + // Its ok if not there for a "set". The ring will be added. + // l_ringLen set to 0 if not there with l_pRing at the start of padding. + l_fapirc = mvpdRingFuncFind (i_chipletId, + i_ringId, + l_recordBuf, + l_recordLen, + l_pRing, + l_ringLen); + if ( l_fapirc ) + { + FAPI_ERR("mvpdRingFunc: mvpdRingFuncFind failed rc=0x%x", + static_cast<uint32_t>(l_fapirc)); + // break out with fapirc + break; + } + // do the get or set specific operations + if (i_mvpdRingFuncOp == MVPD_RING_GET ) // do the get operation + { + // ensure ring was found. Must be there for "get" + if (l_ringLen == 0) //not found + { + 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 ); + // break out with fapirc + break; + } + + // copy ring back to caller's buffer + l_fapirc = mvpdRingFuncGet ( l_pRing, + l_ringLen, + i_pRingBuf, + io_rRingBufsize); + if ( l_fapirc ) + { + FAPI_ERR("mvpdRingFunc: mvpdRingFuncGet failed rc=0x%x", + static_cast<uint32_t>(l_fapirc)); + // break out with fapirc + break; + } + + } else { // set operation + + // update record with caller's ring + l_fapirc = mvpdRingFuncSet ( l_recordBuf, + l_recordLen, + l_pRing, + l_ringLen, + i_pRingBuf, + io_rRingBufsize); + if ( l_fapirc ) + { + FAPI_ERR("mvpdRingFunc: mvpdRingFuncSet failed rc=0x%x", + static_cast<uint32_t>(l_fapirc)); + // break out with fapirc + break; + } + // update record back to the mvpd + l_fapirc = fapiSetMvpdField(i_record, + i_keyword, + i_fapiTarget, + l_recordBuf, + l_recordLen ); +#if 0 // TODO remove once DD supports write RTC 39177,enable for unit test + if (l_fapirc == FAPI_RC_PLAT_ERR_SEE_DATA) + { + FAPI_DBG( "mvpdRingFunc: Fake that fapiSetMvpdField worked" ); + TRACDBIN( g_fapiImpTd, "mvpdRingFunc: Dump Ring Buffer:", + l_recordBuf, + 0x100 ); + l_fapirc=FAPI_RC_SUCCESS; + } +#endif // RTC 39177 + if ( l_fapirc ) + { + FAPI_ERR("mvpdRingFunc: fapiSetMvpdField failed"); + + io_rRingBufsize = 0; + // break out with fapirc + break; + } + } + + + } while ( 0 ); + + // unload the repair ring + delete[] l_recordBuf; + l_recordBuf = NULL; + + FAPI_DBG( "mvpdRingFunc: exit bufsize= 0x%x rc= 0x%x", + io_rRingBufsize, + static_cast<uint32_t>(l_fapirc) ); + return l_fapirc; +} + + +//****************************************************************************** +// mvpdRingFuncFind: step through the record looking at rings for a match. +// o_rpRing returns a pointer to the ring if it is there in the record +// if not there, returns a pointer to the start of the padding after +// the last ring. +// o_rRingLen returns the number of bytes in the ring (header and data) +// Will be 0 if ring not found. +//****************************************************************************** +fapi::ReturnCode mvpdRingFuncFind( const uint8_t i_chipletId, + const uint8_t i_ringId, + uint8_t * i_pRecordBuf, + uint32_t i_recordBufLen, + uint8_t * &o_rpRing, + uint32_t &o_rRingLen) { fapi::ReturnCode l_fapirc; uint8_t *l_pRing = NULL; @@ -56,109 +329,339 @@ fapi::ReturnCode findMvpdRingField( const uint8_t i_chipletId, bool l_foundflag = false; // initialize return fields in case of an error. - o_rRingBuf=NULL; - o_rRingBufsize=0; + o_rpRing=NULL; + o_rRingLen=0; - FAPI_DBG(" findMvpdRingField: entry chipletId=0x%x, ringId=0x%x ", + FAPI_DBG("mvpdRingFuncFind: entry chipletId=0x%x, ringId=0x%x ", i_chipletId, i_ringId ); do { // point to #R record - l_pRing = i_pFieldBuf; + l_pRing = i_pRecordBuf; - // - // Find first RSA data block in #R (fixed offset defined by + // Find first RSA data block in ring (fixed offset defined by // MVPD spec) // - // First byte in #R record should be the version number, skip + // First byte in record should be the version number, skip // over this. // - FAPI_DBG( "findMvpdRingField: #R record version = 0x%x", *l_pRing ); + FAPI_DBG( "mvpdRingFuncFind: 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 ) + while ( l_offset+sizeof(CompressedScanData) < i_recordBufLen ) { // 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 ) + if ( FAPI_BE32TOH(l_pScanData->iv_magic) != RS4_MAGIC ) { - FAPI_ERR( "findMvpdRingField: Header 0x%x at offset 0x%x,hit end of list", - l_pScanData->iv_magic, + FAPI_DBG("mvpdRingFuncFind:Header 0x%x offset 0x%x,end of list", + FAPI_BE32TOH(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 ); + // $$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", + FAPI_DBG("mvpdRingFuncFind:%d ringId=0x%x chipletId=0x%x size=0x%x", l_offset, l_pScanData->iv_ringId, l_pScanData->iv_chipletId, - l_pScanData->iv_size ); + FAPI_BE32TOH(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", + FAPI_DBG( "mvpdRingFuncFind: Found it: 0x%x.0x%x, 0x%x", i_ringId, i_chipletId, - l_pScanData->iv_size ); + FAPI_BE32TOH(l_pScanData->iv_size) ); - if (l_offset+l_pScanData->iv_size > i_fieldBufsize) + if (l_offset+FAPI_BE32TOH(l_pScanData->iv_size)>i_recordBufLen) { // 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; + o_rpRing = l_pRing+l_offset; + o_rRingLen=FAPI_BE32TOH(l_pScanData->iv_size); // got it, break out of scan loop break; } // being defensive. - if (l_pScanData->iv_size == 0) + if (FAPI_BE32TOH(l_pScanData->iv_size) == 0) { // size of 0 is invalid, would loop forever. break; } // bump to next ring - l_offset += l_pScanData->iv_size ; + l_offset += FAPI_BE32TOH(l_pScanData->iv_size) ; } // end while scan loop - // foundflag not set, set error if no other error + // if no other error and not found, indicate with 0 size. 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 ); + o_rpRing = l_pRing+l_offset; //return pointer to end of list + //incase needed for appending + o_rRingLen=0; //indicate not found } } while ( 0 ); - FAPI_DBG(" findMvpdRingField: exit RC=0x%x", + FAPI_DBG("mvpdRingFuncFind: exit *ring= 0x%x size=0x%x RC=0x%x", + o_rpRing, + o_rRingLen, static_cast<uint32_t>(l_fapirc) ); return l_fapirc; } +//****************************************************************************** +// mvpdValidateRingHeader +//****************************************************************************** +fapi::ReturnCode mvpdValidateRingHeader( CompressedScanData * i_pRingBuf, + uint8_t i_chipletId, + uint8_t i_ringId, + uint32_t i_ringBufsize) +{ + fapi::ReturnCode l_fapirc; + + if ( i_ringBufsize <= sizeof(CompressedScanData) || + FAPI_BE32TOH(i_pRingBuf->iv_magic) != RS4_MAGIC || + i_pRingBuf->iv_ringId != i_ringId || + i_pRingBuf->iv_chipletId != i_chipletId || + FAPI_BE32TOH(i_pRingBuf->iv_size) != i_ringBufsize) + { + FAPI_SET_HWP_ERROR(l_fapirc, RC_MVPD_RING_FUNC_INVALID_PARAMETER ); + } + return l_fapirc; +} + +//****************************************************************************** +// mvpdRingFuncGet: copy the ring back to the caller +//****************************************************************************** +fapi::ReturnCode mvpdRingFuncGet ( uint8_t *i_pRing, + uint32_t i_ringLen, + uint8_t *i_pCallerRingBuf, + uint32_t &io_rCallerRingBufLen) +{ + fapi::ReturnCode l_fapirc; + + do { + // return buffer pointer is NULL if just looking for the size + if ( i_pCallerRingBuf == NULL ) + { + io_rCallerRingBufLen = i_ringLen; + // break out of do block with success rc + break; + } + // check if we have enough space + if ( io_rCallerRingBufLen < i_ringLen ) + { + FAPI_ERR( "mpvdRingFuncGet: output buffer too small: 0x%x < 0x%x", + io_rCallerRingBufLen, + i_ringLen + ); + + // return actual size of data, so caller can re-try with + // the correct value + io_rCallerRingBufLen = i_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 + FAPI_DBG( "mvpdRingFuncGet: memcpy 0x%x 0x%x 0x%x", + i_pCallerRingBuf, + i_pRing, + i_ringLen ); + memcpy( i_pCallerRingBuf, i_pRing, i_ringLen ); + io_rCallerRingBufLen = i_ringLen; + + } while (0); + + FAPI_DBG( "mvpdRingFuncGet: exit bufsize= 0x%x rc= 0x%x", + io_rCallerRingBufLen, + static_cast<uint32_t>(l_fapirc) ); + + return l_fapirc; +} + +//****************************************************************************** +// mvpdRingFuncSet: update the record with the caller's ring. +//****************************************************************************** +fapi::ReturnCode mvpdRingFuncSet ( uint8_t *i_pRecordBuf, + uint32_t i_recordLen, + uint8_t *i_pRing, + uint32_t i_ringLen, + uint8_t *i_pCallerRingBuf, + uint32_t i_callerRingBufLen) +{ + fapi::ReturnCode l_fapirc; + uint8_t *l_to = NULL; + uint8_t *l_fr = NULL; + uint32_t l_len = 0; + uint8_t *l_pRingEnd; // pointer into record to start of pad at end + + FAPI_DBG( "mvpdRingFuncSet: pRing=0x%x Len=0x%x pCaller=0x%x Len=0x%x", + i_pRing, + i_ringLen, + i_pCallerRingBuf, + i_callerRingBufLen); + + do { + // if exact fit, update in place + if (i_callerRingBufLen == i_ringLen) + { + l_to = i_pRing; + l_fr = i_pCallerRingBuf; + l_len = i_callerRingBufLen; + FAPI_DBG( "mvpdRingFuncSet: update in place-memcpy 0x%x 0x%x 0x%x", + l_to, + l_fr, + l_len); + memcpy (l_to, l_fr, l_len); + + // break out successful + break; + } + + // will need the end for shifting... look for something invalid + l_fapirc = mvpdRingFuncFind (0x00, + 0x00, + i_pRecordBuf, + i_recordLen, + l_pRingEnd, // find start of padding + l_len); + if ( l_fapirc ) + { + FAPI_ERR("mvpdRingFuncSet: mvpdRingFuncFind failed rc=0x%x", + static_cast<uint32_t>(l_fapirc)); + // break out with fapirc + break; + } + FAPI_DBG( "mvpdRingFuncSet: end= 0x%x", + l_pRingEnd); + + // if not there, then append if it fits + if (i_ringLen == 0 ) //is not currently in record (0 len from find) + { + if (l_pRingEnd+i_callerRingBufLen > i_pRecordBuf+i_recordLen) + { + FAPI_ERR( "mvpdRingFuncSet: not enough room to append "); + FAPI_SET_HWP_ERROR(l_fapirc, + RC_MVPD_RING_FUNC_INSUFFICIENT_RECORD_SPACE ); + // break out of do block with fapi rc set + break; + } + l_to = i_pRing; + l_fr = i_pCallerRingBuf; + l_len = i_callerRingBufLen; + FAPI_DBG( "mvpdRingFuncSet: append-memcpy 0x%x 0x%x 0x%x", + l_to, + l_fr, + l_len); + memcpy (l_to, l_fr, l_len); + + // break out successful + break; + } + + // if smaller, then shift left and zero fill + if (i_callerRingBufLen < i_ringLen) + { + l_to = i_pRing; + l_fr = i_pCallerRingBuf; + l_len = i_callerRingBufLen; + FAPI_DBG( "mvpdRingFuncSet: shrink-memcpy 0x%x 0x%x 0x%x", + l_to, + l_fr, + l_len); + memcpy (l_to, l_fr, l_len); + + l_to = i_pRing+i_callerRingBufLen; + l_fr = i_pRing+i_ringLen; + l_len = (l_pRingEnd)-(i_pRing+i_ringLen); + FAPI_DBG( "mvpdRingFuncSet: shrink-memmove 0x%x 0x%x 0x%x", + l_to, + l_fr, + l_len); + memmove (l_to, l_fr, l_len); //use memmove, always overlaps. + + l_to = (l_pRingEnd)-(i_ringLen-i_callerRingBufLen); + l_len = i_ringLen-i_callerRingBufLen; + FAPI_DBG( "mvpdRingFuncSet: shrink-memset 0x%x 0x%x 0x%x", + l_to, + 0x00, + l_len); + memset (l_to, 0x00, l_len); + + // break out successful + break; + + } + + // if larger, then shift right, if it fits + if (i_callerRingBufLen > i_ringLen) + { + // ensure the padding can contain the growth + if ( (i_callerRingBufLen - i_ringLen) > + ((i_pRecordBuf+i_recordLen)-l_pRingEnd)) + { + FAPI_ERR( "mvpdRingFuncSet: not enough room to insert "); + FAPI_SET_HWP_ERROR(l_fapirc, + RC_MVPD_RING_FUNC_INSUFFICIENT_RECORD_SPACE ); + // break out of do block with fapi rc set + break; + } + + l_to = i_pRing+i_callerRingBufLen; + l_fr = i_pRing+i_ringLen; + l_len = l_pRingEnd-(i_pRing+i_ringLen); + FAPI_DBG( "mvpdRingFuncSet: insert-memmove 0x%x 0x%x 0x%x", + l_to, + l_fr, + l_len); + memmove (l_to, l_fr, l_len); + + l_to = i_pRing; + l_fr = i_pCallerRingBuf; + l_len = i_callerRingBufLen; + FAPI_DBG( "mvpdRingFuncSet: insert-memcpy 0x%x 0x%x 0x%x", + l_to, + l_fr, + l_len); + memcpy (l_to, l_fr, l_len); + + // break out successful + break; + } + FAPI_ERR( "mvpdRingFuncSet: shouldn't get to here" ); + + } while (0); + + FAPI_DBG( "mvpdRingFuncSet: 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 index 14e6e40db..d4f1e3c4e 100644 --- a/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.H +++ b/src/usr/hwpf/hwp/mvpd_accessors/mvpdRingFuncs.H @@ -1,7 +1,7 @@ /* IBM_PROLOG_BEGIN_TAG * This is an automatically generated prolog. * - * $Source: src/include/usr/hwpf/hwp/RepairRingFunc.H $ + * $Source: src/include/usr/hwpf/hwp/mvpdRingFuncs.H $ * * IBM CONFIDENTIAL * @@ -24,9 +24,7 @@ /** * @file mvpdRingFuncs.H * - * @brief Prototype for getMvpdRingField() - - * return a buffer containing the entire field with a pointer to - * the requested ring. + * @brief Prototype for mvpdRingFuncs() */ #ifndef _HWP_MVPDRINGFUNCS_ @@ -34,35 +32,45 @@ #include <fapi.H> - +// mvpdRingFunc can be used for get and set +enum mvpdRingFuncOp +{ + MVPD_RING_GET, + MVPD_RING_SET, +}; extern "C" { /** - * @brief return mvpd field with pointer to requested ring + * @brief get or set the requested ring for the record and keyword * 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 + * detailed comments on get and set are in the + * getMvpdRing.H and setMvpdRing.H and apply here as well. + * + * @param i_mvpdRingFuncOp - indicate get or set via enum mvpdRingFuncOp + * @param i_record - Record enumerator + * @param i_keyword - Keyword enumerator + * @param i_fapiTarget - cpu target + * @param i_chipletId - Chiplet ID + * @param i_ringId - Ring ID + * @param i_pRingBuf - The buffer to receive or send the ring + * @param io_rRingBufsize - Size of ring / ring buffer * * @return fapi::ReturnCode - FAPI_RC_SUCCESS if success, * relevant error code for failure. */ +fapi::ReturnCode mvpdRingFunc( mvpdRingFuncOp i_mvpdRingFuncOp, + fapi::MvpdRecord i_record, + fapi::MvpdKeyword i_keyword, + const fapi::Target &i_fapiTarget, + const uint8_t i_chipletId, + const uint8_t i_ringId, + uint8_t *i_pRingBuf, + uint32_t &io_rRingBufsize); + -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 index c042816c7..40a1410be 100644 --- a/src/usr/hwpf/hwp/mvpd_accessors/mvpd_errors.xml +++ b/src/usr/hwpf/hwp/mvpd_accessors/mvpd_errors.xml @@ -61,4 +61,18 @@ <ffdc>CHIPLET_ID</ffdc> </hwpError> <!-- *********************************************************************** --> + <hwpError> + <rc>RC_MVPD_RING_FUNC_INVALID_PARAMETER</rc> + <description> + An invalid parameter was passed to a mvpd ring function. + </description> + </hwpError> + <!-- *********************************************************************** --> + <hwpError> + <rc>RC_MVPD_RING_FUNC_INSUFFICIENT_RECORD_SPACE</rc> + <description> + Insufficient room in the record to set the requested ring. + </description> + </hwpError> + <!-- *********************************************************************** --> </hwpErrors> diff --git a/src/usr/hwpf/hwp/mvpd_accessors/setMvpdRing.C b/src/usr/hwpf/hwp/mvpd_accessors/setMvpdRing.C new file mode 100644 index 000000000..17fd56be2 --- /dev/null +++ b/src/usr/hwpf/hwp/mvpd_accessors/setMvpdRing.C @@ -0,0 +1,76 @@ + /* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/hwp/setMvpdRing.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 setMvpdRing.C + * + * @brief update rings in MVPD records + * + */ + +#include <stdint.h> + +// fapi support +#include <fapi.H> + +#include <setMvpdRing.H> +#include <mvpdRingFuncs.H> + +extern "C" +{ +using namespace fapi; + +// setMvpdRing: Wrapper to call common function mvpdRingFunc +fapi::ReturnCode setMvpdRing( fapi::MvpdRecord i_record, + fapi::MvpdKeyword i_keyword, + const fapi::Target &i_fapiTarget, + const uint8_t i_chipletId, + const uint8_t i_ringId, + uint8_t *i_pRingBuf, + uint32_t i_rRingBufsize) +{ + fapi::ReturnCode l_fapirc; + + FAPI_DBG("setMvpdRing: entry ringId=0x%x, chipletId=0x%x, size=0x%x ", + i_ringId, + i_chipletId, + i_rRingBufsize ); + + // common get and set processing + l_fapirc = mvpdRingFunc(MVPD_RING_SET, + i_record, + i_keyword, + i_fapiTarget, + i_chipletId, + i_ringId, + i_pRingBuf, + i_rRingBufsize); //in and out for common code. + //in only for set. + + FAPI_DBG("setMvpdRing: exit rc=0x%x", + static_cast<uint32_t>(l_fapirc) ); + + return l_fapirc; +} + +} // extern "C" diff --git a/src/usr/hwpf/hwp/mvpd_accessors/setMvpdRing.H b/src/usr/hwpf/hwp/mvpd_accessors/setMvpdRing.H new file mode 100644 index 000000000..599b8c857 --- /dev/null +++ b/src/usr/hwpf/hwp/mvpd_accessors/setMvpdRing.H @@ -0,0 +1,95 @@ + /* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/include/usr/hwpf/hwp/setMvpdRing.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 setMvpdRing.H + * + * @brief Prototype for setMvpdRing() - + * get a repair ring from a MVPD record + */ + + #ifndef _HWP_SETMVPDRING_ + #define _HWP_SETMVPDRING_ + + #include <fapi.H> + +// function pointer typedef definition for HWP call support +typedef fapi::ReturnCode (*setMvpdRing_FP_t) + (fapi::MvpdRecord,fapi::MvpdKeyword, const fapi::Target &, + const uint8_t, const uint8_t, uint8_t *, uint32_t &); + +extern "C" +{ + +/** + * @brief set specified ring from MVPD for the specified target CPU. + * + * A Ring Id Chiplet Id should be unique in the mvpd Record. + * The code does not validate. No assumption should be made on which would + * be updated if there are multiple. + * + * The set ring can be the same size or smaller than an existing ring. + * The ring can be larger than the existing ring or can be added (was + * not there before) if there is room in the record. + * + * @param i_record - Record enumerator + * @param i_keyword - Keyword enumerator + * Supported Rings are: + * MVPD_RECORD_CP00 - MVPD_KEYWORD_PDR + * MVPD_RECORD_CP00 - MVPD_KEYWORD_PDG + * @param i_fapiTarget - cpu target + * @param i_chipletId - Chiplet ID + * @param i_ringId - Ring ID + * @param i_pRingBuf - pointer to a buffer allocated by the caller + * to with the ring header and data to set. + * Can not be NULL. + * @param i_rRingBufsize - size of ring buffer that the caller has + * allocated. + * The buffer contains the CompressedScanData + * structure followed by compressed data. The + * caller does compression and decompression. + * The header needs to include the RS4 magic + * number. The ring ID and chiplet ID must match + * the passed parameters. The size must match the + * parameter size. + * + * Buffer: io_rRingBufsize returns xNN. + * byte x0 CompressedScanData structure (rs4 header) + * byte x18 compressed data (sizeof CompressedScanData is 0x18) + * byte xNN last byte of compressed data* + * + * @return fapi::ReturnCode - FAPI_RC_SUCCESS if success, + * relevant error code for failure. + */ +fapi::ReturnCode setMvpdRing( fapi::MvpdRecord i_record, + fapi::MvpdKeyword i_keyword, + const fapi::Target &i_fapiTarget, + const uint8_t i_chipletId, + const uint8_t i_ringId, + uint8_t *i_pRingBuf, + uint32_t i_rRingBufsize ); + +} + +#endif diff --git a/src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.C b/src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.C deleted file mode 100644 index 4298c64e0..000000000 --- a/src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.C +++ /dev/null @@ -1,178 +0,0 @@ - /* 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 deleted file mode 100644 index 8af07e53a..000000000 --- a/src/usr/hwpf/hwp/mvpd_accessors/setRepairRing.H +++ /dev/null @@ -1,76 +0,0 @@ - /* 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 diff --git a/src/usr/hwpf/plat/fapiPlatMvpdAccess.C b/src/usr/hwpf/plat/fapiPlatMvpdAccess.C index 977a9a7cc..e7faf46ef 100644 --- a/src/usr/hwpf/plat/fapiPlatMvpdAccess.C +++ b/src/usr/hwpf/plat/fapiPlatMvpdAccess.C @@ -128,7 +128,7 @@ fapi::ReturnCode MvpdKeywordXlate(const fapi::MvpdKeyword i_fapiKeyword, // 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; + const uint8_t NUM_MVPD_KEYWORDS = 0x20; static const MVPD::mvpdKeyword mvpdFapiKeywordToHbKeyword[NUM_MVPD_KEYWORDS] = { @@ -163,6 +163,7 @@ fapi::ReturnCode MvpdKeywordXlate(const fapi::MvpdKeyword i_fapiKeyword, MVPD::OC, MVPD::FO, MVPD::pdI, + MVPD::pdG, }; fapi::ReturnCode l_rc; diff --git a/src/usr/hwpf/test/fapiwinkletest.H b/src/usr/hwpf/test/fapiwinkletest.H index d6af59615..31687607b 100644 --- a/src/usr/hwpf/test/fapiwinkletest.H +++ b/src/usr/hwpf/test/fapiwinkletest.H @@ -25,6 +25,9 @@ #ifndef __FAPIWINKLETEST_H #define __FAPIWINKLETEST_H +// set to 1 for doing unit tests, set to 0 for production +#define RTC51716 0 +#define RTC39177 0 /** * @file fapiwinkletest.H * @@ -40,8 +43,11 @@ #include <targeting/common/commontargeting.H> #include <targeting/common/utilFilter.H> -#include <getRepairRing.H> -#include <setRepairRing.H> +#include <getMvpdRing.H> +#include <setMvpdRing.H> + +// pull in CompressedScanData def from proc_slw_build HWP +#include <p8_scan_compression.H> using namespace fapi; using namespace TARGETING; @@ -65,11 +71,12 @@ public: TARGETING::TargetHandleList l_cpuTargetList; getAllChips(l_cpuTargetList, TYPE_PROC); - TS_TRACE( "testGetMvpdPdr l_cpuTargetList.size()= 0x%x ",l_cpuTargetList.size() ); + TS_TRACE( "testGetMvpdPdr l_cpuTargetList.size()= 0x%x ", + l_cpuTargetList.size() ); // loop thru all the cpu's - for ( uint8_t l_cpuNum=0; l_cpuNum < l_cpuTargetList.size(); l_cpuNum++ ) + for (uint8_t l_cpuNum=0; l_cpuNum < l_cpuTargetList.size(); l_cpuNum++ ) { // make a local copy of the CPU target TARGETING::Target* l_cpu_target = l_cpuTargetList[l_cpuNum]; @@ -83,12 +90,12 @@ public: fapi::Target l_fapi_cpu_target( TARGET_TYPE_PROC_CHIP, reinterpret_cast<void *> - (const_cast<TARGETING::Target*>(l_cpu_target)) ); + (const_cast<TARGETING::Target*>(l_cpu_target)) ); TS_TRACE( "call fapiGetMvpdField with NULL pointer" ); - // call fapiGetMvpdField once with a NULL pointer to get the buffer size - // should return no error now. + // call fapiGetMvpdField once with a NULL pointer to get the + // buffer size should return no error now. l_fapirc = fapiGetMvpdField(fapi::MVPD_RECORD_CP00, fapi::MVPD_KEYWORD_PDR, l_fapi_cpu_target, @@ -138,49 +145,36 @@ public: */ void testRepairRings() { -#if 0 // RTC 50971 fapi::ReturnCode l_fapirc = fapi::FAPI_RC_SUCCESS; uint8_t *l_pRingBuf = NULL; uint32_t l_ringBufsize = 0; uint32_t l_ringId = 0; uint32_t l_chipletId = 0; uint32_t l_bufsize = 0x200; -/* TODO comment out until mvpd test data is fixed. RTC 51716 +#if RTC51716 // TODO comment out until mvpd test data is fixed. RTC 51716 + // This data needs to be in sync with the procmvpd.dat file + // the setMvpdFunc tests use the last row, index = 3. The test + // expects it to be a mid x20 byte ring in the #G keyword struct _testRRstr { + fapi::MvpdRecord record; + fapi::MvpdKeyword keyword; uint32_t ringIdval; uint32_t chipletIdval; uint32_t size; } l_ringModifiers[] = { - { 0xe0, 0x8 , 0x20 }, - { 0xe1, 0x11 , 0x20 }, - { 0xe1, 0x12 , 0x20 }, - { 0xe1, 0x13 , 0x20 }, - { 0xe1, 0x14 , 0x20 }, - { 0xe1, 0x15 , 0x20 }, - { 0xe1, 0x18 , 0x20 }, - { 0xe2, 0x11 , 0x20 }, - { 0xe2, 0x12 , 0x20 }, - { 0xe2, 0x13 , 0x20 }, - { 0xe2, 0x14 , 0x20 }, - { 0xe2, 0x15 , 0x20 }, - { 0xe2, 0x18 , 0x20 }, - { 0xe3, 0x2 , 0x20 }, - { 0xe5, 0x2 , 0x20 }, - { 0xe6, 0x2 , 0x20 }, - { 0xe7, 0x9 , 0x20 }, - { 0xe8, 0x1 , 0x20 }, - { 0xe9, 0x1 , 0x20 }, - { 0xea, 0x1 , 0x20 }, - { 0xeb, 0x4 , 0x20 }, + { MVPD_RECORD_CP00, MVPD_KEYWORD_PDG,0xa4, 0xFF , 0x20 }, //last #G + { MVPD_RECORD_CP00, MVPD_KEYWORD_PDR,0xe0, 0x8 , 0x20 },//first #R + { MVPD_RECORD_CP00, MVPD_KEYWORD_PDR,0xe2, 0x16 ,0x138 },//big #R + { MVPD_RECORD_CP00, MVPD_KEYWORD_PDG,0xa2, 0x8 , 0x20 }, //mid #G }; -*/ +#endif // RTC 51716 TS_TRACE( "testRepairRings entry" ); TARGETING::TargetHandleList l_cpuTargetList; getAllChips(l_cpuTargetList, TYPE_PROC); // loop thru all the cpu's - for ( uint8_t l_cpuNum=0; l_cpuNum < l_cpuTargetList.size(); l_cpuNum++ ) + for (uint8_t l_cpuNum=0; l_cpuNum < l_cpuTargetList.size(); l_cpuNum++ ) { // make a local copy of the CPU target TARGETING::Target* l_cpu_target = l_cpuTargetList[l_cpuNum]; @@ -194,9 +188,9 @@ public: // cast OUR type of target to a FAPI type of target. fapi::Target l_fapi_cpu_target( - TARGET_TYPE_PROC_CHIP, - reinterpret_cast<void *> - (const_cast<TARGETING::Target*>(l_cpu_target)) ); + TARGET_TYPE_PROC_CHIP, + reinterpret_cast<void *> + (const_cast<TARGETING::Target*>(l_cpu_target)) ); // allocate some space to put the record(s) l_pRingBuf = new uint8_t[ l_bufsize]; @@ -209,28 +203,29 @@ public: l_ringBufsize = l_bufsize; l_ringId = 0; // ringId l_chipletId = 0; // chipletId - l_fapirc = getRepairRing( l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - TS_TRACE( "testRepairRings: ringId=0x%x, chipletId=0x%x: l_ringBufsize=0x%x", + l_fapirc = getMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x Bufsize=0x%x", l_ringId, l_chipletId, l_ringBufsize ); if ( l_fapirc != fapi::RC_REPAIR_RING_NOT_FOUND ) { // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: rc FAIL: 0x%x, 0x%x", + TS_FAIL("testRepairRings: expect not found rc FAIL: 0x%x, 0x%x", fapi::RC_REPAIR_RING_NOT_FOUND, static_cast<uint32_t>(l_fapirc) ); fapiLogError(l_fapirc); return; } -/* TODO comment out until mvpd test data is fixed. RTC 51716 - // loop takes too long, test ring 5 - uint8_t i = 5; +#if RTC51716 // TODO comment out until mvpd test data is fixed. RTC 51716 + uint8_t i = 2; // ---------------------------------------------------------------- // Pass in a buffer size that is too small with a valid // ringId/chipletId, should return with correct length @@ -240,19 +235,21 @@ public: l_ringBufsize = 0x0; l_ringId = l_ringModifiers[i].ringIdval; l_chipletId = l_ringModifiers[i].chipletIdval; - l_fapirc = getRepairRing( l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - TS_TRACE( "testRepairRings: ringId=0x%x, chipletId=0x%x: l_ringBufsize=0x%x", + l_fapirc = getMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x: Bufsize=0x%x", l_ringId, l_chipletId, l_ringBufsize ); if ( l_fapirc != fapi::RC_REPAIR_RING_INVALID_SIZE ) { // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: rc FAIL: 0x%x, 0x%x", + TS_FAIL("testRepairRings: expect invalid size FAIL: 0x%x, 0x%x", fapi::RC_REPAIR_RING_INVALID_SIZE, static_cast<uint32_t>(l_fapirc)); @@ -261,7 +258,7 @@ public: } if ( l_ringBufsize != l_ringModifiers[i].size ) { - TS_FAIL( "testRepairRings: size FAIL: 0x%x, 0x%x", + TS_FAIL( "testRepairRings: size mismatch FAIL: 0x%x, 0x%x", l_ringModifiers[i].size, l_ringBufsize ); return; @@ -274,19 +271,21 @@ public: l_ringBufsize = 0x0; l_ringId = l_ringModifiers[i].ringIdval; l_chipletId = l_ringModifiers[i].chipletIdval; - l_fapirc = getRepairRing( l_fapi_cpu_target, - l_chipletId, - l_ringId, - NULL, - l_ringBufsize ); - TS_TRACE( "testRepairRings: ringId=0x%x, chipletId=0x%x: l_ringBufsize=0x%x", + l_fapirc = getMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + NULL, + l_ringBufsize ); + TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x: Bufsize=0x%x", l_ringId, l_chipletId, l_ringBufsize ); if ( l_fapirc ) { // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: rc FAIL: 0x%x, 0x%x", + TS_FAIL( "testRepairRings: expect success rc FAIL: 0x%x, 0x%x", fapi::FAPI_RC_SUCCESS, static_cast<uint32_t>(l_fapirc)); @@ -295,109 +294,250 @@ public: } if ( l_ringBufsize != l_ringModifiers[i].size ) { - TS_FAIL( "testRepairRings: size FAIL: 0x%x, 0x%x", + TS_FAIL( "testRepairRings: size mismatch FAIL: 0x%x, 0x%x", l_ringModifiers[i].size, l_ringBufsize ); return; } // ---------------------------------------------------------------- - // Fetch ring 5. + // Fetch rings // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: get ring %d", i ); - l_ringBufsize = l_bufsize; + const uint32_t numRings = + sizeof(l_ringModifiers)/sizeof(l_ringModifiers[0]); + for (i=0;i<numRings;i++) { + TS_TRACE( "testRepairRings: get ring %d", i ); + l_ringBufsize = l_bufsize; + l_ringId = l_ringModifiers[i].ringIdval; + l_chipletId = l_ringModifiers[i].chipletIdval; + l_fapirc = getMvpdRing( l_ringModifiers[i].record, + l_ringModifiers[i].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + TS_TRACE("testRepairRings ringId=0x%x chipletId=0x%x size=0x%x", + l_ringId, l_chipletId, l_ringBufsize ); + + if ( l_fapirc ) + { + // note: uint32_t below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: getMvpdRing rc FAIL: 0x%x, 0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); + return; + } + if ( l_ringBufsize != l_ringModifiers[i].size ) + { + TS_FAIL( "testRepairRings: size mismatch FAIL: 0x%x, 0x%x", + l_ringModifiers[i].size, + l_ringBufsize ); + return; + } + + // Dump ring buffer here. + TRACDBIN(g_trac_test,"testRepairRings:Dump Repair Ring Buffer:", + l_pRingBuf, + l_ringBufsize ); + } +#endif // RTC 51716 + +#if RTC39177 // TODO comment out til mvpd dd supports write. RTC 39177 + // ---------------------------------------------------------------- + // update the data. + // TODO write different data, once the DD is written(story 39177) + // read it back to verify, then put the original data back. + // for now, there is a debug byte dump in mvpdRingFunc to + // manually verify in unit test + // ---------------------------------------------------------------- + uint32_t l_offset =0; + uint8_t l_data = 0; + uint8_t *l_pData = NULL; + + i = 3; // use data from last fetch test case. + TS_TRACE( "testRepairRings: update in place ring %d", i ); l_ringId = l_ringModifiers[i].ringIdval; l_chipletId = l_ringModifiers[i].chipletIdval; - l_fapirc = getRepairRing( l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - TS_TRACE( "testRepairRings: ringId=0x%x, chipletId=0x%x: l_ringBufsize=0x%x", - l_ringId, l_chipletId, l_ringBufsize ); + l_ringBufsize = l_ringModifiers[i].size; - if ( l_fapirc ) + // put in recognizable data for the debug data dump + l_pData = l_pRingBuf+sizeof(CompressedScanData); + for (l_offset = 0,l_data=0x10; l_offset < + l_ringBufsize-sizeof(CompressedScanData); l_offset++) + { + *l_pData++ = l_data++; + } + TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", + l_pRingBuf, + l_ringBufsize ); + l_fapirc = setMvpdRing( l_ringModifiers[i].record, + l_ringModifiers[i].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) { // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: getRepairRing rc FAIL: 0x%x, 0x%x", + TS_FAIL( "testRepairRings: setMvpdRing rc FAIL: 0x%x, 0x%x", fapi::FAPI_RC_SUCCESS, static_cast<uint32_t>(l_fapirc) ); + fapiLogError(l_fapirc); return; } - if ( l_ringBufsize != l_ringModifiers[i].size ) + + // ---------------------------------------------------------------- + // write back a smaller ring to cause a shift left in the record + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: shrink a ring %d", i ); + l_ringBufsize = l_ringModifiers[i].size-4; + reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> + iv_size = l_ringBufsize; + + // put in recognizable data for the debug data dump + l_pData = l_pRingBuf+sizeof(CompressedScanData); + for (l_offset = 0,l_data=0x20; l_offset < + l_ringBufsize-sizeof(CompressedScanData); l_offset++) { - TS_FAIL( "testRepairRings: size FAIL: 0x%x, 0x%x", - l_ringModifiers[i].size, - l_ringBufsize ); + *l_pData++ = l_data++; + } + TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", + l_pRingBuf, + l_ringBufsize ); + l_fapirc = setMvpdRing( l_ringModifiers[i].record, + l_ringModifiers[i].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: setMvpdRing rc FAIL: 0x%x, 0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(l_fapirc) ); + + fapiLogError(l_fapirc); return; } - // @todo dump ring buffer here. - TRACDBIN( g_trac_test, "testRepairRings: Dump Repair Ring Buffer:", + // ---------------------------------------------------------------- + // write back a larger ring to cause a shift right in the record + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: grow a ring %d", i ); + l_ringBufsize = l_ringModifiers[i].size+16; + reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> + iv_size = l_ringBufsize; + + // put in recognizable data for the debug data dump + l_pData = l_pRingBuf+sizeof(CompressedScanData); + for (l_offset = 0,l_data=0x30; l_offset < + l_ringBufsize-sizeof(CompressedScanData); l_offset++) + { + *l_pData++ = l_data++; + } + TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", l_pRingBuf, l_ringBufsize ); -*/ + l_fapirc = setMvpdRing( l_ringModifiers[i].record, + l_ringModifiers[i].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: setMvpdRing rc FAIL: 0x%x, 0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(l_fapirc) ); + + fapiLogError(l_fapirc); + return; + } -/* TODO comment out til mvpd dd supports write. Story 39177 and data is fixed // ---------------------------------------------------------------- - // update the data. - // TODO write different data, once the DD is written(story 39177) - // read it back to verify, then put the original data back. + // append a ring that is not already there to the end // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: set ring %d", i ); - - // l_ringBufsize set from above... - l_fapirc = setRepairRing( l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); + TS_TRACE( "testRepairRings: append a ring" ); + l_ringId = 0x77; + l_chipletId = 0x88; + l_ringBufsize = l_ringModifiers[i].size; + reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> + iv_size = l_ringBufsize; + reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> + iv_ringId = l_ringId; + reinterpret_cast<CompressedScanData *>(l_pRingBuf)-> + iv_chipletId = l_chipletId; + + // put in recognizable data for the debug data dump + l_pData = l_pRingBuf+sizeof(CompressedScanData); + for (l_offset = 0,l_data=0x50; l_offset < + l_ringBufsize-sizeof(CompressedScanData); l_offset++) + { + *l_pData++ = l_data++; + } + TRACDBIN( g_trac_test, "testRepairRings: updated ring data:", + l_pRingBuf, + l_ringBufsize ); + l_fapirc = setMvpdRing( l_ringModifiers[i].record, + l_ringModifiers[i].keyword, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) { // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: setRepairRing rc FAIL: 0x%x, 0x%x", + TS_FAIL( "testRepairRings: setMvpdRing rc FAIL: 0x%x, 0x%x", fapi::FAPI_RC_SUCCESS, static_cast<uint32_t>(l_fapirc) ); fapiLogError(l_fapirc); + return; } + // ---------------------------------------------------------------- // Pass in a buffer size that does not match the exact size // of the ringId/chipletId, should return with correct length // and invalid size return code. // ---------------------------------------------------------------- - TS_TRACE( "testRepairRings: pass wrong size buffer %d ", i ); - l_ringBufsize = l_bufsize; - l_ringId = l_ringModifiers[i].ringIdval; - l_chipletId = l_ringModifiers[i].chipletIdval; - l_fapirc = setRepairRing( l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - TS_TRACE( "testRepairRings: ringId=0x%x, chipletId=0x%x: l_ringBufsize=0x%x", + TS_TRACE("testRepairRing:bad size ring=0x%x chiplet=0x%x size=0x%x", l_ringId, l_chipletId, l_ringBufsize ); - if ( l_fapirc != fapi::RC_REPAIR_RING_INVALID_SIZE ) + l_ringBufsize = l_bufsize; + l_ringId = l_ringModifiers[i].ringIdval; + l_chipletId = l_ringModifiers[i].chipletIdval; + l_fapirc = setMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + if ( l_fapirc != fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER ) { // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: rc FAIL: 0x%x, 0x%x", + TS_FAIL("testRepairRings:invalid ring size rc FAIL: 0x%x, 0x%x", fapi::RC_REPAIR_RING_INVALID_SIZE, static_cast<uint32_t>(l_fapirc)); fapiLogError(l_fapirc); return; } - if ( l_ringBufsize != l_ringModifiers[i].size ) - { - TS_FAIL( "testRepairRings: size FAIL: 0x%x, 0x%x", - l_ringModifiers[i].size, - l_ringBufsize ); - return; - } // ---------------------------------------------------------------- // Pass in 0 for the ring modifier, should return with "not found" // error @@ -406,16 +546,19 @@ public: l_ringBufsize = l_ringModifiers[i].size; l_ringId = 0; // ringId l_chipletId = 0; // chipletId - l_fapirc = setRepairRing( l_fapi_cpu_target, - l_chipletId, - l_ringId, - l_pRingBuf, - l_ringBufsize ); - TS_TRACE( "testRepairRings: ringId=0x%x, chipletId=0x%x: l_ringBufsize=0x%x", + l_fapirc = setMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + l_pRingBuf, + l_ringBufsize ); + + TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x size=0x%x", l_ringId, l_chipletId, l_ringBufsize ); - if ( l_fapirc != fapi::RC_REPAIR_RING_NOT_FOUND ) + if ( l_fapirc != fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER ) { // note: "uint32_t" below is an _operator_ of fapi::ReturnCode TS_FAIL( "testRepairRings: rc FAIL: 0x%x, 0x%x", @@ -432,38 +575,33 @@ public: l_ringBufsize = 0x0; l_ringId = l_ringModifiers[i].ringIdval; l_chipletId = l_ringModifiers[i].chipletIdval; - l_fapirc = setRepairRing( l_fapi_cpu_target, - l_chipletId, - l_ringId, - NULL, - l_ringBufsize ); - TS_TRACE( "testRepairRings: ringId=0x%x, chipletId=0x%x: l_ringBufsize=0x%x", + l_fapirc = setMvpdRing( MVPD_RECORD_CP00, + MVPD_KEYWORD_PDR, + l_fapi_cpu_target, + l_chipletId, + l_ringId, + NULL, + l_ringBufsize ); + + TS_TRACE("testRepairRings:ringId=0x%x chipletId=0x%x size=0x%x", l_ringId, l_chipletId, l_ringBufsize ); - if ( l_fapirc ) + if ( l_fapirc != fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER ) { // note: "uint32_t" below is an _operator_ of fapi::ReturnCode - TS_FAIL( "testRepairRings: rc FAIL: 0x%x, 0x%x", - fapi::FAPI_RC_SUCCESS, + TS_FAIL( "testRepairRings: setMvpdRing rc FAIL: 0x%x, 0x%x", + fapi::RC_MVPD_RING_FUNC_INVALID_PARAMETER, static_cast<uint32_t>(l_fapirc)); fapiLogError(l_fapirc); return; } - if ( l_ringBufsize != l_ringModifiers[i].size ) - { - TS_FAIL( "testRepairRings: size FAIL: 0x%x, 0x%x", - l_ringModifiers[i].size, - l_ringBufsize ); - return; - } -*/ +#endif // RTC 39177 // delete allocated space delete[] l_pRingBuf; } -#endif TS_TRACE( "testRepairRings exit" ); } diff --git a/src/usr/hwpf/test/makefile b/src/usr/hwpf/test/makefile index de77289e4..613addcc0 100644 --- a/src/usr/hwpf/test/makefile +++ b/src/usr/hwpf/test/makefile @@ -27,6 +27,9 @@ EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/fapi EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/plat EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/hwp EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/mvpd_accessors +# CompressedScanData struct needed for getRepairRings() +EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/include +EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build MODULE = testhwpf TESTS = *.H diff --git a/src/usr/mvpd/mvpd.H b/src/usr/mvpd/mvpd.H index 2d2297c23..f1b1f5563 100755 --- a/src/usr/mvpd/mvpd.H +++ b/src/usr/mvpd/mvpd.H @@ -170,6 +170,7 @@ const mvpdKeywordInfo mvpdKeywords[] = { OC, "OC" }, { FO, "FO" }, { pdI, "#I" }, + { pdG, "#G" }, // ------------------------------------------------------------------- // DO NOT USE!! This is for test purposes ONLY! { MVPD_TEST_KEYWORD, "TEST" }, diff --git a/src/usr/mvpd/test/mvpdtest.H b/src/usr/mvpd/test/mvpdtest.H index e9670eb8c..c130cc15f 100755 --- a/src/usr/mvpd/test/mvpdtest.H +++ b/src/usr/mvpd/test/mvpdtest.H @@ -75,6 +75,7 @@ mvpdTestData mvpdData[] = { CP00, PG }, // { CP00, PK }, // TODO - no PK in test data. pull for now RTC 51716 { CP00, pdR }, + { CP00, pdG }, { CP00, pdV }, { CP00, pdH }, // { CP00, pdP }, // TODO - no #P in test data, pull for now RTC 51716 |