diff options
-rw-r--r-- | src/include/usr/hwpf/fapi/fapi.H | 46 | ||||
-rw-r--r-- | src/include/usr/hwpf/fapi/fapiMvpdAccess.H | 65 | ||||
-rw-r--r-- | src/include/usr/hwpf/hwp/RepairRingFunc.H | 68 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/RepairRingFunc.C | 271 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/makefile | 5 | ||||
-rw-r--r-- | src/usr/hwpf/hwp/mvpd_errors.xml | 63 | ||||
-rw-r--r-- | src/usr/hwpf/makefile | 4 | ||||
-rw-r--r-- | src/usr/hwpf/plat/fapiMvpdAccess.C | 129 | ||||
-rw-r--r-- | src/usr/hwpf/plat/makefile | 9 | ||||
-rw-r--r-- | src/usr/hwpf/test/fapiwinkletest.H | 330 |
10 files changed, 960 insertions, 30 deletions
diff --git a/src/include/usr/hwpf/fapi/fapi.H b/src/include/usr/hwpf/fapi/fapi.H index 5984c05b7..abf00161b 100644 --- a/src/include/usr/hwpf/fapi/fapi.H +++ b/src/include/usr/hwpf/fapi/fapi.H @@ -1,25 +1,26 @@ -// IBM_PROLOG_BEGIN_TAG -// This is an automatically generated prolog. -// -// $Source: src/include/usr/hwpf/fapi/fapi.H $ -// -// IBM CONFIDENTIAL -// -// COPYRIGHT International Business Machines Corp. 2011 -// -// 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 +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/include/usr/hwpf/fapi/fapi.H $ + * + * IBM CONFIDENTIAL + * + * COPYRIGHT International Business Machines Corp. 2011-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 fapi.H * @@ -54,5 +55,6 @@ #include <fapiHwpErrorInfo.H> // Generated file #include <fapiAttributeIds.H> // Generated file #include <ecmdDataBufferBase.H> +#include <fapiMvpdAccess.H> #endif // FAPI_H_ diff --git a/src/include/usr/hwpf/fapi/fapiMvpdAccess.H b/src/include/usr/hwpf/fapi/fapiMvpdAccess.H new file mode 100644 index 000000000..92dc8a3b9 --- /dev/null +++ b/src/include/usr/hwpf/fapi/fapiMvpdAccess.H @@ -0,0 +1,65 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/include/usr/hwpf/fapi/fapiMvpdAccess.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 fapiMvpdAccess.H + * + * @brief Prototype file for fapiMvpdAccess - read / write records from MVPD + * + */ + +#ifndef _FAPI_FAPIMVPDACCESS_H_ +#define _FAPI_FAPIMVPDACCESS_H_ + +#include <stdint.h> +#include <stddef.h> +#include <fapi.H> + +extern "C" +{ + +/** + * @brief fetch Module VPD #R record. + * Suggested way to call this routine is to call it once with a NULL buffer + * pointer to to retrieve the size of the record, then allocate the proper + * size of the buffer and call again. + * + * @param[in] - i_fapiTarget - target that the #R record belongs to + * @param[in] - i_pPdrRecord - pointer to a buffer + * Caller is responsible for allocating the buffer ahead + * of time. + * If NULL is passed in, the proper size of the #R record + * will be returned in the o_rPdrSize parameter below. + * @param[in,out] - io_rPdrSize - size of the #R record in BYTES. + * If the record was not found, an error will be returned + * and this will be set to 0. + * + * @return - FAPI_RC_SUCCESS, or failure value. + */ +fapi::ReturnCode fapiGetMvpdPdr( const fapi::Target &i_fapiTarget, + uint8_t *i_pPdrRecord, + uint32_t &io_rPdrSize ); +} + +#endif diff --git a/src/include/usr/hwpf/hwp/RepairRingFunc.H b/src/include/usr/hwpf/hwp/RepairRingFunc.H new file mode 100644 index 000000000..921b9628e --- /dev/null +++ b/src/include/usr/hwpf/hwp/RepairRingFunc.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 RepairRingFunc.H + * + * @brief Prototype for getRepairRing() - + * get a repair ring from the MVPD #R record + */ + + #ifndef _HWP_REPAIRRINGFUNC_ + #define _HWP_REPAIRRINGFUNC_ + + #include <fapi.H> + + +extern "C" +{ + +/** + * @brief get specified repair ring from MVPD #R record for the specified + * target CPU. + * + * @param i_fapiTarget - cpu target + * @param i_ringModifier - ringModifier/scanSelect id for the repair ring + * @param io_pRingBuf - pointer to a buffer allocated by the caller + * @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 uint32_t i_ringModifier, + uint8_t *io_pRingBuf, + uint32_t &io_rRingBufsize ); + +} + +#endif diff --git a/src/usr/hwpf/hwp/RepairRingFunc.C b/src/usr/hwpf/hwp/RepairRingFunc.C new file mode 100644 index 000000000..2d63f4c60 --- /dev/null +++ b/src/usr/hwpf/hwp/RepairRingFunc.C @@ -0,0 +1,271 @@ +/* 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 RepairRingFunc.C + * + * @brief fetch repair rings from MVPD #R records + * + */ + +#include <stdint.h> + +// fapi support +#include <fapi.H> + +#include <RepairRingFunc.H> + +// +// @todo : +// pull in CompressedScanData def from proc_slw_build HWP and then remove +// the definitions below +// #include <p8_scan_compression.H> +// +/** + * @struct RS4 Compressed Scan Header + */ +typedef struct { + uint32_t magic; // "RSA" + version 01 signature + uint32_t size; // Total size in bytes, including the header + uint32_t algorithReserved; // "reserved to the algorithm" + uint32_t length; // len of original scan chain in BITS + uint32_t scanSelect; // hi 32 bits of the scan select reg + uint8_t reserved[3]; + uint8_t chipletId; // 7-bit pervasive chiplet Id + Multicast bit +} CompressedScanData; + +/** + * @def RSA_MAGIC signature - "RSA"+0x01 + */ +const uint32_t RS4_MAGIC = 0x52533401; + + +extern "C" +{ +using namespace fapi; + + +fapi::ReturnCode getRepairRing( const fapi::Target &i_fapiTarget, + const uint32_t i_ringModifier, + uint8_t *io_pRingBuf, + uint32_t &io_rRingBufsize ) +{ + fapi::ReturnCode l_fapirc( fapi::FAPI_RC_SUCCESS ); + uint8_t *l_pRing = NULL; + uint32_t l_offset = 0; + CompressedScanData *l_pScanData = NULL; + uint8_t *l_pdRRecord = NULL; + uint32_t l_pdRLen = 0; + bool l_foundflag = false; + + + FAPI_DBG(" getRepairRing: entry ringModifier=0x%x, size=0x%x ", + i_ringModifier, + io_rRingBufsize ); + + do { + + // input check + if ( io_pRingBuf == NULL ) + { + FAPI_ERR("getRepairRing: NULL pointer passed in"); + + io_rRingBufsize = 0; + FAPI_SET_HWP_ERROR(l_fapirc, RC_REPAIR_RING_INVALID_RINGBUF_PTR ); + + break; + } + + 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 ); + if ( l_fapirc ) + { + FAPI_ERR("getRepairRing: fapiGetMvpdPdr failed to get buffer size"); + + io_rRingBufsize = 0; + // break out with fapirc + break; + } + + FAPI_DBG( "getRepairRing: fapiGetMvpdPdr returned l_pdRLen=0x%x", + l_pdRLen ); + + // allocate buffer for the record + l_pdRRecord = new uint8_t[l_pdRLen]; + // check to make sure it got allocated + if ( l_pdRRecord == NULL ) + { + FAPI_ERR( "getRepairRing: failed to alloc buffer"); + FAPI_SET_HWP_ERROR(l_fapirc, RC_REPAIR_RING_ALLOC_FAIL ); + + io_rRingBufsize = 0; + // break out with fapirc + break; + } + + // load repair ring from MVPD for this target + l_fapirc = fapiGetMvpdPdr( i_fapiTarget, + l_pdRRecord, + l_pdRLen ); + if ( l_fapirc ) + { + FAPI_ERR("getRepairRing: fapiGetMvpdPdr failed"); + + io_rRingBufsize = 0; + // break out with fapirc + break; + } + + // point to #R record + l_pRing = l_pdRRecord; + // + // 1) 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( "getRepairRing: #R record version = 0x%x", *l_pRing ); + l_pRing++; + l_offset = 0; + + l_foundflag = false; + while ( l_offset < l_pdRLen ) + { + // point to header + l_pScanData = + reinterpret_cast<CompressedScanData *>( l_pRing+l_offset ); + + // dump record info for debug + FAPI_DBG( "getRepairRing: %d scanSelect=0x%x, size=0x%x, chipletId=0x%x", + l_offset, + l_pScanData->scanSelect, + l_pScanData->size, + l_pScanData->chipletId ); + + // Check magic key to make sure this is a valid record. + if ( l_pScanData->magic != RS4_MAGIC ) + { + FAPI_ERR( "getRepairRing: Header 0x%x at offset 0x%x, break", + l_pScanData->magic, + l_offset ); + + // @todo + // test image does not have correct headers, this + // returns early. Revisit this later. + // + // $$const uint32_t &MAGIC = l_pScanData->magic; + // $$FAPI_SET_HWP_ERROR(l_fapirc, RC_REPAIR_RING_INVALID_MAGIC ); + + // return 0 size to indicate bad record + io_rRingBufsize = 0; + // break out of scan loop + break; + } + + // + // @TODO Need to do Leon's translation here?? + // It's not certain that the scanSelect/ringModifier may be + // passed in here; if so we will have to do some translating. + // Leon Freimour has the translation algorithm. + // This will have to wait until Phase II . + + if ( l_pScanData->scanSelect == i_ringModifier ) + { + FAPI_DBG( "getRepairRing: Found it: 0x%x, 0x%x", + i_ringModifier, + l_pScanData->size ); + + l_foundflag = true; + // check if we have enough space + if ( io_rRingBufsize < l_pScanData->size ) + { + FAPI_ERR( "getRepairRing: output buffer too small: 0x%x < 0x%x", + io_rRingBufsize, + l_pScanData->size + ); + + // return actual size of data, so caller can re-try with + // the correct value + io_rRingBufsize = l_pScanData->size; + FAPI_SET_HWP_ERROR(l_fapirc, RC_REPAIR_RING_INVALID_SIZE ); + + // break out of do block with fapi rc set + break; + } + + // Goodness, return ring and actual size of data. + io_rRingBufsize = l_pScanData->size; + // we're good, copy data into the passed-in buffer + memcpy( io_pRingBuf, l_pScanData, io_rRingBufsize ); + + FAPI_DBG( "getRepairRing: return record: 0x%x 0x%p, 0x%x", + i_ringModifier, + l_pScanData, + io_rRingBufsize ); + + // got it, break out of scan loop + break; + } + + // bump to next ring + l_offset += l_pScanData->size ; + + } // end while scan loop + + // foundflag not set, set error and quit + // @todo + // revisit here too, this will overwrite RC_REPAIR_INVALID_MAGIC + // + if ( ! l_foundflag ) + { + const uint32_t & RING_MODIFIER = i_ringModifier; + FAPI_SET_HWP_ERROR(l_fapirc, RC_REPAIR_RING_NOT_FOUND ); + + io_rRingBufsize = 0; + } + + } while ( 0 ); + + // unload the repair ring + if ( l_pdRRecord != NULL ) + { + FAPI_DBG( "Unload repair #R record" ); + + delete[] l_pdRRecord; + l_pdRRecord = NULL; + l_pdRLen = 0; + } + + FAPI_DBG(" getRepairRing: exit" ); + + return l_fapirc; +} + +} // extern "C" diff --git a/src/usr/hwpf/hwp/makefile b/src/usr/hwpf/hwp/makefile index b04637f0f..0090aa7d5 100644 --- a/src/usr/hwpf/hwp/makefile +++ b/src/usr/hwpf/hwp/makefile @@ -1,4 +1,4 @@ -# IBM_PROLOG_BEGIN_TAG +# IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # $Source: src/usr/hwpf/hwp/makefile $ @@ -37,7 +37,8 @@ OBJS = fapiTestHwp.o \ fapiTestHwpDq.o \ fapiHwpExecInitFile.o \ dimmBadDqBitmapFuncs.o \ - dimmBadDqBitmapAccessHwp.o + dimmBadDqBitmapAccessHwp.o \ + RepairRingFunc.o SUBDIRS = dmi_training.d sbe_centaur_init.d mc_init.d \ dram_training.d activate_powerbus.d build_winkle_images.d \ diff --git a/src/usr/hwpf/hwp/mvpd_errors.xml b/src/usr/hwpf/hwp/mvpd_errors.xml new file mode 100644 index 000000000..dacd905e5 --- /dev/null +++ b/src/usr/hwpf/hwp/mvpd_errors.xml @@ -0,0 +1,63 @@ +<!-- 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> + </hwpError> + <!-- *********************************************************************** --> +</hwpErrors> diff --git a/src/usr/hwpf/makefile b/src/usr/hwpf/makefile index b2fae34c2..091293f0d 100644 --- a/src/usr/hwpf/makefile +++ b/src/usr/hwpf/makefile @@ -37,8 +37,8 @@ HWP_ERROR_XML_FILES = hwp/fapiHwpErrorInfo.xml \ hwp/dram_training/memory_errors.xml \ hwp/start_clocks_on_nest_chiplets/proc_start_clocks_chiplets/proc_start_clocks_chiplets_errors.xml \ hwp/edi_ei_initialization/proc_fab_iovalid/proc_fab_smp_errors.xml \ - hwp/build_winkle_images/proc_slw_build/proc_slw_build_errors.xml - + hwp/build_winkle_images/proc_slw_build/proc_slw_build_errors.xml \ + hwp/mvpd_errors.xml HWP_ATTR_XML_FILES = hwp/memory_attributes.xml \ hwp/L2_L3_attributes.xml \ diff --git a/src/usr/hwpf/plat/fapiMvpdAccess.C b/src/usr/hwpf/plat/fapiMvpdAccess.C new file mode 100644 index 000000000..b7d57726b --- /dev/null +++ b/src/usr/hwpf/plat/fapiMvpdAccess.C @@ -0,0 +1,129 @@ +/* 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/makefile b/src/usr/hwpf/plat/makefile index e14cf76a1..5fd92402a 100644 --- a/src/usr/hwpf/plat/makefile +++ b/src/usr/hwpf/plat/makefile @@ -1,11 +1,11 @@ -# IBM_PROLOG_BEGIN_TAG +# IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # $Source: src/usr/hwpf/plat/makefile $ # # IBM CONFIDENTIAL # -# COPYRIGHT International Business Machines Corp. 2011 +# COPYRIGHT International Business Machines Corp. 2011-2012 # # p1 # @@ -19,7 +19,7 @@ # # Origin: 30 # -# IBM_PROLOG_END +# IBM_PROLOG_END_TAG ROOTPATH = ../../../.. MODULE = plat @@ -34,6 +34,7 @@ OBJS = fapiPlatHwAccess.o \ fapiPlatSystemConfig.o \ fapiPlatTarget.o \ fapiPlatUtil.o \ - fapiPlatAttributeService.o + fapiPlatAttributeService.o \ + fapiMvpdAccess.o include ${ROOTPATH}/config.mk diff --git a/src/usr/hwpf/test/fapiwinkletest.H b/src/usr/hwpf/test/fapiwinkletest.H new file mode 100644 index 000000000..365032932 --- /dev/null +++ b/src/usr/hwpf/test/fapiwinkletest.H @@ -0,0 +1,330 @@ +/* IBM_PROLOG_BEGIN_TAG + * This is an automatically generated prolog. + * + * $Source: src/usr/hwpf/test/fapiwinkletest.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 + */ + +#ifndef __FAPIWINKLETEST_H +#define __FAPIWINKLETEST_H + +/** + * @file fapiwinkletest.H + * + * @brief Test cases for winkle HWP utilities. +*/ + +#include <cxxtest/TestSuite.H> + +#include <fapi.H> +#include <fapiPlatHwpInvoker.H> +#include <hwpf/fapi/fapiMvpdAccess.H> + +#include <targeting/common/commontargeting.H> +#include <targeting/common/utilFilter.H> + +#include <RepairRingFunc.H> + +using namespace fapi; +using namespace TARGETING; + +class FapiWinkleTest: public CxxTest::TestSuite +{ +public: + + /** + * @brief call fapiGetMvpdPdr to fetch a #R record. + * + */ + void testGetMvpdPdr() + { + fapi::ReturnCode l_fapirc( fapi::FAPI_RC_SUCCESS ); + uint8_t *l_pdRRecord = NULL; + uint32_t l_pdRLen = 0; + + // test value, coreesponds to procmvpd.dat:e23067dae839f5b434ec12b5c86d2ae4fbb51259 + // @todo change test when we get valid data in procpore.dat + const uint32_t MVPD_PDR_TEST_SIZE = 0x5f74; + + + TS_TRACE( "testGetMvpdPdr 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++ ) + { + // make a local copy of the CPU target + TARGETING::Target* l_cpu_target = l_cpuTargetList[l_cpuNum]; + + // dump physical path to target + EntityPath l_path; + l_path = l_cpu_target->getAttr<ATTR_PHYS_PATH>(); + l_path.dump(); + + // 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)) ); + + TS_TRACE( "call fapiGetMvpdPdr with NULL pointer" ); + + // call fapiGetMvpdPdr once with a NULL pointer to get the buffer size + // should return no error now. + l_fapirc = fapiGetMvpdPdr( l_fapi_cpu_target, + NULL, + l_pdRLen ); + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + TS_FAIL( "testGetMvpdPdr: expected FAPI_RC_SUCCESS" ); + return; + } + + // this will change when MVPD is changed, and will need to be changed + // above. + if ( l_pdRLen != MVPD_PDR_TEST_SIZE ) + { + TS_FAIL( "testGetMvpdPdr: expected size = 0x%x, received 0x%x", + MVPD_PDR_TEST_SIZE, + l_pdRLen ); + return; + } + + // 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, + l_pdRRecord, + l_pdRLen ); + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + TS_FAIL( "testGetMvpdPdr: expected FAPI_RC_SUCCESS" ); + return; + } + + + // clean up memory + free( l_pdRRecord ); + } + + TS_TRACE( "testGetMvpdPdr exit" ); + } + + + // @note: + // ring modifiers are from MVPD #R record, 2012-05-22. + // This will change and the unit test will need to be changed... + + /** + * @brief Fetch Repair Rings + */ + void testRepairRings() + { + fapi::ReturnCode l_fapirc = fapi::FAPI_RC_SUCCESS; + uint8_t *l_pRingBuf = NULL; + uint32_t l_ringBufsize = 0; + uint32_t l_ringModifier = 0; + struct _testRRstr { + uint32_t val; + uint32_t size; + } l_ringModifiers[] = { + { 0x8036006, 0x20, }, + { 0x11033006, 0x20, }, + { 0x12033006, 0x20, }, + { 0x13033006, 0x20, }, + { 0x14033006, 0x20, }, + { 0x15033006, 0x20, }, + { 0x18033006, 0x20, }, + { 0x19033006, 0x20, }, + { 0x1a033006, 0x20, }, + { 0x1b033006, 0x20, }, + { 0x1c033006, 0x20, }, + { 0x1d033006, 0x20, }, + { 0x1e033006, 0x20, }, + { 0x11034f86, 0x20, }, + { 0x12034f86, 0x20, }, + { 0x13034f86, 0x20, }, + { 0x14034f86, 0x20, }, + { 0x15034f86, 0x20, }, + { 0x18034f86, 0x20, }, + { 0x19034f86, 0x20, }, + { 0x1a034f86, 0x20, }, + { 0x1b034f86, 0x20, }, + { 0x1c034f86, 0x20, }, + { 0x1d034f86, 0x20, }, + { 0x1e034f86, 0x20, }, + { 0x2036e06, 0x20, }, + { 0x2031006, 0x20, }, + { 0x9037d06, 0x20, }, + { 0x1034806, 0x20, }, + { 0x3034806, 0x20, }, + }; + + 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++ ) + { + // make a local copy of the CPU target + TARGETING::Target* l_cpu_target = l_cpuTargetList[l_cpuNum]; + + TS_TRACE( "testRepairRings: cpuNum = 0x%x ", l_cpuNum ); + + // dump physical path to target + EntityPath l_path; + l_path = l_cpu_target->getAttr<ATTR_PHYS_PATH>(); + l_path.dump(); + + // 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)) ); + + // allocate some space to put the record(s) + l_pRingBuf = new uint8_t[ 0x200]; + + // ---------------------------------------------------------------- + // Pass in a NULL pointer for the ring buffer, should get an error. + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: pass in NULL ptr" ); + l_ringBufsize = 0x0; + l_ringModifier = 0; + l_fapirc = getRepairRing( l_fapi_cpu_target, + l_ringModifier, + NULL, + l_ringBufsize ); + TS_TRACE( "testRepairRings: ring modifier=0x%x: l_ringBufsize=0x%x", + l_ringModifier, l_ringBufsize ); + if ( l_fapirc != fapi::RC_REPAIR_RING_INVALID_RINGBUF_PTR ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: rc FAIL: 0x%x, 0x%x", + fapi::RC_REPAIR_RING_INVALID_RINGBUF_PTR, + static_cast<uint32_t>(l_fapirc) ); + return; + } + // ---------------------------------------------------------------- + // Pass in 0 for the ring modifier, should return with "not found" + // error + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: pass in invalid ringModifier" ); + l_ringBufsize = 0x100; + l_ringModifier = 0; // ringModifier picked at random + l_fapirc = getRepairRing( l_fapi_cpu_target, + l_ringModifier, + l_pRingBuf, + l_ringBufsize ); + TS_TRACE( "testRepairRings: ring modifier=0x%x: l_ringBufsize=0x%x", + l_ringModifier, + 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", + fapi::RC_REPAIR_RING_NOT_FOUND, + static_cast<uint32_t>(l_fapirc) ); + return; + } + + // loop takes too long, test ring 5 + uint8_t i = 5; + // ---------------------------------------------------------------- + // Pass in 0 length with a valid ringModifier, should return with + // correct length and no buffer. + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: get size of ring %d ", i ); + l_ringBufsize = 0x0; + l_ringModifier = l_ringModifiers[i].val; + l_fapirc = getRepairRing( l_fapi_cpu_target, + l_ringModifier, + l_pRingBuf, + l_ringBufsize ); + TS_TRACE( "testRepairRings: ring modifier=0x%x: l_ringBufsize=0x%x", + l_ringModifier, + 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", + fapi::RC_REPAIR_RING_INVALID_SIZE, + static_cast<uint32_t>(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; + } + + + // ---------------------------------------------------------------- + // RingBufsize should now have the correct size, fetch ring 5. + // ---------------------------------------------------------------- + TS_TRACE( "testRepairRings: get ring %d", i ); + + // l_ringBufsize set from above... + l_ringModifier = l_ringModifiers[i].val; + l_fapirc = getRepairRing( l_fapi_cpu_target, + l_ringModifier, + l_pRingBuf, + l_ringBufsize ); + TS_TRACE( "testRepairRings: ring modifier=0x%x: l_ringBufsize=0x%x", + l_ringModifier, l_ringBufsize ); + + if ( l_fapirc != fapi::FAPI_RC_SUCCESS ) + { + // note: "uint32_t" below is an _operator_ of fapi::ReturnCode + TS_FAIL( "testRepairRings: rc FAIL: 0x%x, 0x%x", + fapi::FAPI_RC_SUCCESS, + static_cast<uint32_t>(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; + } + + // @todo dump ring buffer here. + TRACDBIN( g_trac_test, "testRepairRings: Dump Repair Ring Buffer:", + l_pRingBuf, + l_ringBufsize ); + + // delete allocated space + delete[] l_pRingBuf; + } + + TS_TRACE( "testRepairRings exit" ); + } + +}; + +#endif |