From 4d144fd0ec9620cd96dd0e7a5565980e7cefe056 Mon Sep 17 00:00:00 2001 From: Claus Michael Olsen Date: Sun, 11 Sep 2016 12:12:09 -0500 Subject: xip_customize: MVPD compatible file set. Change-Id: Ib3b7aeb8045a28ca05d33370c1ef1dcb9ba1fb64 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/29448 Tested-by: PPE CI Tested-by: Hostboot CI Reviewed-by: Martin Gloff Reviewed-by: Michael C. Sgro Reviewed-by: Martin Peschke Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/29450 Tested-by: Jenkins Server Reviewed-by: Daniel M. Crowell --- .../p9/procedures/hwp/customize/p9_xip_customize.C | 95 ++++++++++++++++++---- .../p9/procedures/hwp/customize/p9_xip_customize.H | 21 ++++- .../p9/utils/imageProcs/p9_infrastruct_help.H | 20 +++-- src/import/chips/p9/utils/imageProcs/p9_ringId.H | 11 ++- .../p9/utils/imageProcs/p9_ring_identification.C | 21 ++++- .../p9/utils/imageProcs/p9_ring_identification.H | 16 +++- src/import/chips/p9/utils/imageProcs/p9_tor.C | 7 +- src/import/chips/p9/xip/p9_xip_image.c | 17 ++-- src/import/chips/p9/xip/p9_xip_image.h | 6 +- 9 files changed, 173 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/import/chips/p9/procedures/hwp/customize/p9_xip_customize.C b/src/import/chips/p9/procedures/hwp/customize/p9_xip_customize.C index 496a94dda..9e9293f50 100644 --- a/src/import/chips/p9/procedures/hwp/customize/p9_xip_customize.C +++ b/src/import/chips/p9/procedures/hwp/customize/p9_xip_customize.C @@ -22,6 +22,19 @@ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ +#ifdef WIN32 +#include "win32_stdint.h" +#include "endian.h" +#include "win_sim_fapi.h" +#include "p9_xip_customize.H" +#include "p9_xip_image.h" +#include "p9_ring_identification.H" +#include "p9_tor.H" +#include "p9_scan_compression.H" +#include "p9_infrastruct_help.H" + +using namespace fapi2; +#else #include #include #include @@ -149,6 +162,7 @@ fapi_try_exit: return fapi2::current_err; } +#endif // Function: _fetch_and_insert_vpd_rings() // @@ -165,9 +179,13 @@ fapi_try_exit: // const RingIdList i_ring: The ring ID list (#G or #R list) // uint32_t& io_bootCoreMask: Desired (in) and actual (out) boot cores. // - +#ifdef WIN32 +ReturnCode _fetch_and_insert_vpd_rings( + int& i_proc_target, +#else fapi2::ReturnCode _fetch_and_insert_vpd_rings( const fapi2::Target& i_proc_target, +#endif void* i_ringSection, uint32_t& io_ringSectionSize, uint32_t i_maxRingSectionSize, @@ -228,12 +246,16 @@ fapi2::ReturnCode _fetch_and_insert_vpd_rings( for (l_evenOdd = 0; l_evenOdd < l_ringsPerChipletId; l_evenOdd++) { - FAPI_INF("_fetch_and_insert_vpd_rings: (ringId,chipletId) = (0x%02X,0x%02x)", - i_ring.ringId, l_chipletId); - - auto l_vpdRingSize = i_vpdRingSize; +#ifdef WIN32 + uint16_t l_vpdRingSize = i_vpdRingSize; +#else + uint32_t l_vpdRingSize = i_vpdRingSize; +#endif MvpdKeyword l_mvpdKeyword; + FAPI_INF("_fetch_and_insert_vpd_rings: (ringId,chipletId) = (0x%02x,0x%02x)", + i_ring.ringId, l_chipletId); + switch (i_ring.vpdKeyword) { case VPD_KEYWORD_PDG: // #G Time rings @@ -575,7 +597,7 @@ fapi2::ReturnCode _fetch_and_insert_vpd_rings( } // End if(redundant) } - else if (l_fapiRc.isRC(RC_MVPD_RING_NOT_FOUND)) + else if ((uint32_t)l_fapiRc == RC_MVPD_RING_NOT_FOUND) { // No match, do nothing. Next chipletId. @@ -595,11 +617,10 @@ fapi2::ReturnCode _fetch_and_insert_vpd_rings( //-------------------------- // Handle other error cases //-------------------------- - // getMvpdRing failed due to insufficient ring buffer space. // Assumption here is that getMvpdRing returns required buffer size // in l_vpdRingSize (and which it does!). - FAPI_ASSERT( !l_fapiRc.isRC(RC_MVPD_RING_BUFFER_TOO_SMALL), + FAPI_ASSERT( (uint32_t)l_fapiRc != RC_MVPD_RING_BUFFER_TOO_SMALL, fapi2::XIPC_MVPD_RING_SIZE_TOO_BIG(). set_CHIP_TARGET(i_proc_target). set_RING_ID(i_ring.ringId). @@ -611,7 +632,7 @@ fapi2::ReturnCode _fetch_and_insert_vpd_rings( l_vpdRingSize, i_vpdRingSize ); // getMvpdRing failed due to invalid record data magic word. - FAPI_ASSERT( !l_fapiRc.isRC(RC_MVPD_INVALID_RS4_HEADER), + FAPI_ASSERT( (uint32_t)l_fapiRc != RC_MVPD_INVALID_RS4_HEADER, fapi2::XIPC_MVPD_INVALID_RECORD_DATA(). set_CHIP_TARGET(i_proc_target). set_RING_ID(i_ring.ringId). @@ -621,8 +642,19 @@ fapi2::ReturnCode _fetch_and_insert_vpd_rings( // getMvpdRing failed for some other reason aside from above handled cases. if (l_fapiRc != fapi2::FAPI2_RC_SUCCESS) { +#ifdef WIN32 + + if (l_fapiRc == SKIP_RING_ID ) + { + l_fapiRc = fapi2::FAPI2_RC_SUCCESS; + FAPI_DBG("N/A MVPD ring for chiptype: ringId=0x%02X, chipletId=0x%02X ", + i_ring.ringId, l_chipletId); + } + +#else FAPI_ERR("_fetch_and_insert_vpd_rings(): getMvpdRing failed " " w/rc=0x%08X", (uint64_t)l_fapiRc); +#endif fapi2::current_err = l_fapiRc; goto fapi_try_exit; } @@ -638,7 +670,7 @@ fapi_try_exit: FAPI_DBG("Exiting _fetch_and_insert_vpd_rings"); return fapi2::current_err; -} +} // End of _fetch_and_insert_vpd_rings() @@ -656,8 +688,13 @@ fapi_try_exit: // uint32_t i_ringBufSize2: Size of ring work buffer. // uint32_t& io_bootCoreMask: Desired (in) and actual (out) boot cores. // +#ifdef WIN32 +int fetch_and_insert_vpd_rings( + int i_proc_target, +#else fapi2::ReturnCode fetch_and_insert_vpd_rings( const fapi2::Target& i_proc_target, +#endif void* i_ringSection, uint32_t& io_ringSectionSize, // Running size uint32_t i_maxRingSectionSize, // Max size @@ -737,7 +774,6 @@ fapi2::ReturnCode fetch_and_insert_vpd_rings( l_ring_id_list[iRing].vpdRingClass == VPD_RING_CLASS_EX_INS || l_ring_id_list[iRing].vpdRingClass == VPD_RING_CLASS_EC_INS) { - FAPI_TRY( _fetch_and_insert_vpd_rings( i_proc_target, i_ringSection, io_ringSectionSize, @@ -765,12 +801,17 @@ fapi_try_exit: FAPI_DBG("Exiting fetch_and_insert_vpd_rings"); return fapi2::current_err; -} +} // End of fetch_and_insert_vpd_rings() +#ifndef WIN32 fapi2::ReturnCode p9_xip_customize ( const fapi2::Target& i_proc_target, +#else +ReturnCode p9_xip_customize ( + int& i_proc_target, +#endif void* io_image, uint32_t& io_imageSize, // In: Max, Out: Actual void* io_ringSectionBuf, @@ -783,11 +824,15 @@ fapi2::ReturnCode p9_xip_customize ( uint32_t i_ringBufSize2, uint32_t& io_bootCoreMask ) // Bits(8:31) = EC00:EC23 { +#ifndef WIN32 fapi2::ReturnCode l_fapiRc = fapi2::FAPI2_RC_SUCCESS; fapi2::ReturnCode l_fapiRc2 = fapi2::FAPI2_RC_SUCCESS; - int l_rc = 0; // Non-fapi RC - const fapi2::Target FAPI_SYSTEM; +#else + ReturnCode l_fapiRc = fapi2::FAPI2_RC_SUCCESS; + ReturnCode l_fapiRc2 = fapi2::FAPI2_RC_SUCCESS; +#endif + int l_rc = 0; // Non-fapi RC P9XipSection l_xipRingsSection; uint32_t l_inputImageSize; @@ -873,16 +918,16 @@ fapi2::ReturnCode p9_xip_customize ( (uintptr_t)i_ringBufSize1, (uintptr_t)i_ringBufSize2 ); - FAPI_DBG("Input image size: %d", l_inputImageSize); - /////////////////////////////////////////////////////////////////////////// // CUSTOMIZE item: Write mailbox attributes // System phase: HB_SBE /////////////////////////////////////////////////////////////////////////// +#ifndef WIN32 + if (i_sysPhase == SYSPHASE_HB_SBE) { FAPI_TRY(writeMboxRegs(i_proc_target, io_image), @@ -968,6 +1013,8 @@ fapi2::ReturnCode p9_xip_customize ( } +#endif + /////////////////////////////////////////////////////////////////////////// @@ -1062,6 +1109,7 @@ fapi2::ReturnCode p9_xip_customize ( FAPI_DBG("Image size before any VPD updates: %d", l_currentImageSize); +#ifndef WIN32 // Adjust the local size of MAX_SEEPROM_IMAGE_SIZE to accommodate enlarged image for Cronus l_fapiRc2 = FAPI_ATTR_GET(fapi2::ATTR_MAX_SBE_SEEPROM_SIZE, FAPI_SYSTEM, attrMaxSbeSeepromSize); @@ -1095,6 +1143,9 @@ fapi2::ReturnCode p9_xip_customize ( } FAPI_DBG("Platform adjusted MAX_SEEPROM_IMAGE_SIZE: %d", l_maxImageSize); +#else + l_maxImageSize = MAX_SEEPROM_IMAGE_SIZE; +#endif // Make sure current image size isn't already too big for Seeprom FAPI_ASSERT( l_currentImageSize <= l_maxImageSize, @@ -1202,6 +1253,8 @@ fapi2::ReturnCode p9_xip_customize ( if (l_fapiRc) { +#ifndef WIN32 + if (l_fapiRc.isRC(RC_XIPC_IMAGE_WOULD_OVERFLOW)) { FAPI_INF("p9_xip_customize(): Image is full. Ran out of space appending VPD rings" @@ -1258,6 +1311,9 @@ fapi2::ReturnCode p9_xip_customize ( } +#else + FAPI_INF("fetch_and_insert_vpd_rings returned error rc=0x%08x", l_fapiRc); +#endif fapi2::current_err = l_fapiRc; goto fapi_try_exit; @@ -1369,6 +1425,7 @@ fapi2::ReturnCode p9_xip_customize ( l_hwRingsSection = (void*)((uintptr_t)io_image + l_xipRingsSection.iv_offset); +#ifndef WIN32 // Extract the DD level to enable retrieval of correct CME/SGPE ring blocks l_fapiRc = FAPI_ATTR_GET_PRIVILEGED(fapi2::ATTR_EC, i_proc_target, attrDdLevel); @@ -1377,6 +1434,9 @@ fapi2::ReturnCode p9_xip_customize ( set_CHIP_TARGET(i_proc_target). set_OCCURRENCE(1), "FAPI_ATTR_GET(ATTR_EC) failed." ); +#else + attrDdLevel = g_ddLevel; +#endif FAPI_DBG("attrDdLevel = 0x%x", attrDdLevel); @@ -1443,7 +1503,7 @@ fapi2::ReturnCode p9_xip_customize ( if (l_fapiRc) { - FAPI_ASSERT( !l_fapiRc.isRC(RC_XIPC_IMAGE_WOULD_OVERFLOW), + FAPI_ASSERT( (uint32_t)l_fapiRc != RC_XIPC_IMAGE_WOULD_OVERFLOW, fapi2::XIPC_IMAGE_WOULD_OVERFLOW_BEFORE_REACHING_MIN_ECS(). set_CHIP_TARGET(i_proc_target). set_REQUESTED_BOOT_CORE_MASK(l_requestedBootCoreMask). @@ -1473,6 +1533,7 @@ fapi2::ReturnCode p9_xip_customize ( set_OCCURRENCE(1), "Caller bug: Caller supplied unsupported value of sysPhase (=%d)", i_sysPhase ); + break; } diff --git a/src/import/chips/p9/procedures/hwp/customize/p9_xip_customize.H b/src/import/chips/p9/procedures/hwp/customize/p9_xip_customize.H index 1d9082f56..0b6de8a23 100644 --- a/src/import/chips/p9/procedures/hwp/customize/p9_xip_customize.H +++ b/src/import/chips/p9/procedures/hwp/customize/p9_xip_customize.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -25,6 +25,7 @@ #ifndef _P9_XIP_CUSTOMIZE_ #define _P9_XIP_CUSTOMIZE_ +#ifndef WIN32 #include typedef fapi2::ReturnCode (*p9_xip_customize_FP_t) ( @@ -109,4 +110,22 @@ extern "C" uint32_t& io_bootCoreMask); } +#else +extern "C" { + int p9_xip_customize ( + int& i_proc_target, + void* i_image, + uint32_t& io_imageSize, + void* i_ringSectionBuf, + uint32_t& io_ringSectionBufSize, + uint8_t i_sysPhase, + uint8_t i_modeBuild, + void* i_ringBuf1, + uint32_t i_ringBufSize1, + void* i_ringBuf2, + uint32_t i_ringBufSize2, + uint32_t& io_bootCoreMask); +} +#endif + #endif diff --git a/src/import/chips/p9/utils/imageProcs/p9_infrastruct_help.H b/src/import/chips/p9/utils/imageProcs/p9_infrastruct_help.H index bc3784869..501047505 100644 --- a/src/import/chips/p9/utils/imageProcs/p9_infrastruct_help.H +++ b/src/import/chips/p9/utils/imageProcs/p9_infrastruct_help.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -25,7 +25,11 @@ #ifndef _P9_INFRASTRUCT_HELP_H_ #define _P9_INFRASTRUCT_HELP_H_ -#include +#ifdef WIN32 + #include "win32_stdint.h" +#else + #include +#endif #include #include #include @@ -71,9 +75,15 @@ enum MODEBUILD #define MY_ERR(_fmt_, _args_...) FAPI_INF(_fmt_, ##_args_) #define MY_DBG(_fmt_, _args_...) FAPI_DBG(_fmt_, ##_args_) #else - #define MY_INF(_fmt_, _args_...) printf(_fmt_, ##_args_) - #define MY_ERR(_fmt_, _args_...) printf(_fmt_, ##_args_) - #define MY_DBG(_fmt_, _args_...) printf(_fmt_, ##_args_) + #ifdef WIN32 + #define MY_INF(...) { printf(__VA_ARGS__); } + #define MY_ERR(...) { printf(__VA_ARGS__); } + #define MY_DBG(...) { printf(__VA_ARGS__); } + #else + #define MY_INF(_fmt_, _args_...) printf(_fmt_, ##_args_) + #define MY_ERR(_fmt_, _args_...) printf(_fmt_, ##_args_) + #define MY_DBG(_fmt_, _args_...) printf(_fmt_, ##_args_) + #endif #endif diff --git a/src/import/chips/p9/utils/imageProcs/p9_ringId.H b/src/import/chips/p9/utils/imageProcs/p9_ringId.H index 325c3c0b5..f41dbb0ca 100644 --- a/src/import/chips/p9/utils/imageProcs/p9_ringId.H +++ b/src/import/chips/p9/utils/imageProcs/p9_ringId.H @@ -26,10 +26,15 @@ #ifndef _P9_RINGID_H_ #define _P9_RINGID_H_ -#include -#include -#include +#ifdef WIN32 + #include "win32_stdint.h" + #include "p9_ring_id.h" +#else + #include + #include + #include +#endif // General Ring ID list structure typedef struct diff --git a/src/import/chips/p9/utils/imageProcs/p9_ring_identification.C b/src/import/chips/p9/utils/imageProcs/p9_ring_identification.C index 511b314c7..c14f84b05 100644 --- a/src/import/chips/p9/utils/imageProcs/p9_ring_identification.C +++ b/src/import/chips/p9/utils/imageProcs/p9_ring_identification.C @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -22,7 +22,17 @@ /* permissions and limitations under the License. */ /* */ /* IBM_PROLOG_END_TAG */ -#include +#ifdef WIN32 + #include "win32_stdint.h" + #include "p9_ring_identification.H" +#else + #ifdef __sun + #include + #include "p9_ring_identification.H" + #else + #include + #endif +#endif const RingIdList RING_ID_LIST_PDG[] = { @@ -151,10 +161,17 @@ const VPDRingList ALL_VPD_RINGS[NUM_OF_VPD_TYPES] = {RING_ID_LIST_PDR, (sizeof(RING_ID_LIST_PDR) / sizeof(RING_ID_LIST_PDR[0]))}, }; +#if defined(WIN32) || defined(__sun) +const uint32_t RING_ID_LIST_PG_SIZE = sizeof(RING_ID_LIST_PDG) / sizeof( + RING_ID_LIST_PDG[0]); +const uint32_t RING_ID_LIST_PR_SIZE = sizeof(RING_ID_LIST_PDR) / sizeof( + RING_ID_LIST_PDR[0]); +#endif const uint32_t RING_ID_LIST_CORE_SIZE = 4; +//@TODO: This function will be used in RTC158106 (VPD insertion ordering). // get_vpd_ring_list_entry() retrieves the MVPD list entry based on either a ringName // or a ringId. If both are supplied, only the ringName is used. If ringName==NULL, // then the ringId is used. A pointer to the RingIdList is returned. diff --git a/src/import/chips/p9/utils/imageProcs/p9_ring_identification.H b/src/import/chips/p9/utils/imageProcs/p9_ring_identification.H index 188bcaf7e..42b8141e2 100644 --- a/src/import/chips/p9/utils/imageProcs/p9_ring_identification.H +++ b/src/import/chips/p9/utils/imageProcs/p9_ring_identification.H @@ -5,7 +5,7 @@ /* */ /* OpenPOWER HostBoot Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ /* [+] International Business Machines Corp. */ /* */ /* */ @@ -26,7 +26,15 @@ #ifndef _P9_RING_IDENT_H_ #define _P9_RING_IDENT_H_ #include -#include +#ifdef WIN32 + #include "win32_stdint.h" +#else + #ifdef __sun + #include + #else + #include + #endif +#endif #include #include #include @@ -54,6 +62,10 @@ extern const VPDRingList ALL_VPD_RINGS[]; extern const uint32_t RING_ID_LIST_CHIP_SIZE, RING_ID_LIST_CORE_SIZE, RING_ID_LIST_CME_SIZE, RING_ID_LIST_CC_SIZE; +#if defined(WIN32) || defined(__sun) + extern const RingIdList RING_ID_LIST_PDG[], RING_ID_LIST_PDR[]; + extern const uint32_t RING_ID_LIST_PG_SIZE, RING_ID_LIST_PR_SIZE; +#endif // Enumerated VPD keyword values. // Note! This is DIFFERENT from the MvpdKeyword list in fapiMvpdAccess.H which diff --git a/src/import/chips/p9/utils/imageProcs/p9_tor.C b/src/import/chips/p9/utils/imageProcs/p9_tor.C index 92738a319..19f348d13 100644 --- a/src/import/chips/p9/utils/imageProcs/p9_tor.C +++ b/src/import/chips/p9/utils/imageProcs/p9_tor.C @@ -23,6 +23,12 @@ /* */ /* IBM_PROLOG_END_TAG */ +#ifdef WIN32 + #include "endian.h" +#else + #include +#endif + // IMPORTANT notice on usage of io_RingType and io_instanceId arguments // // io_RingTyp @@ -35,7 +41,6 @@ // While using tor_tor_get_block_of_rings and tor_get_single_ring API, // it is used pass by value // -#include #include "p9_ringId.H" #include "p9_tor.H" #include "p9_xip_image.h" diff --git a/src/import/chips/p9/xip/p9_xip_image.c b/src/import/chips/p9/xip/p9_xip_image.c index 32518c7d6..4e11f40f7 100644 --- a/src/import/chips/p9/xip/p9_xip_image.c +++ b/src/import/chips/p9/xip/p9_xip_image.c @@ -37,20 +37,19 @@ /// ensure that no memory outside of the putative bounds of the image is ever /// referenced during validation. -#ifndef PLIC_MODULE - #include - #include - #include - #include -#endif // PLIC_MODULE - #include -#include +#ifdef _WIN32 + #include "win32_stdint.h" + #include "endian.h" +#else + #include + #include +#endif #include #include -#include #include "p9_xip_image.h" + //////////////////////////////////////////////////////////////////////////// // Local Functions //////////////////////////////////////////////////////////////////////////// diff --git a/src/import/chips/p9/xip/p9_xip_image.h b/src/import/chips/p9/xip/p9_xip_image.h index 70357c8f5..b314cd54b 100644 --- a/src/import/chips/p9/xip/p9_xip_image.h +++ b/src/import/chips/p9/xip/p9_xip_image.h @@ -244,8 +244,12 @@ typedef enum { //////////////////////////////////////////////////////////////////////////// #ifndef __ASSEMBLER__ -#include +#ifdef _WIN32 +#include "win32_stdint.h" +#else #include +#endif +#include #ifdef __cplusplus extern "C" { -- cgit v1.2.1