diff options
12 files changed, 911 insertions, 1608 deletions
diff --git a/src/usr/hwpf/hwp/build_winkle_images/build_winkle_images.C b/src/usr/hwpf/hwp/build_winkle_images/build_winkle_images.C index 6a67bcd7c..48bbc2fea 100644 --- a/src/usr/hwpf/hwp/build_winkle_images/build_winkle_images.C +++ b/src/usr/hwpf/hwp/build_winkle_images/build_winkle_images.C @@ -76,6 +76,7 @@ #include "p8_set_pore_bar/p8_poreslw_init.H" #include "p8_slw_build/sbe_xip_image.h" #include <runtime/runtime.H> +#include "p8_slw_build/p8_image_help_base.H" namespace BUILD_WINKLE_IMAGES @@ -100,7 +101,7 @@ using namespace DeviceFW; * @return NULL if success, errorlog if failure * */ -errlHndl_t loadPoreImage( const char *& o_rporeAddr, +errlHndl_t loadPoreImage( char *& o_rporeAddr, uint32_t & o_rporeSize ) { errlHndl_t l_errl = NULL; @@ -144,7 +145,7 @@ errlHndl_t loadPoreImage( const char *& o_rporeAddr, break; } - o_rporeAddr = reinterpret_cast<const char*>(l_info.vaddr); + o_rporeAddr = reinterpret_cast<char*>(l_info.vaddr); TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "WINK addr = 0x%p, size=0x%x", @@ -223,12 +224,12 @@ errlHndl_t applyPoreGenCpuRegs( TARGETING::Target *i_cpuTarget, // msr and hrmor are common across all threads, only set for thread 0 // on each core l_threadId = 0; - l_rc = p8_pore_gen_cpureg( io_image, - i_sizeImage, - P8_MSR_MSR, - l_msrVal, - l_coreId, - l_threadId); + l_rc = p8_pore_gen_cpureg_fixed( io_image, + P8_SLW_MODEBUILD_IPL, + P8_MSR_MSR, + l_msrVal, + l_coreId, + l_threadId); if ( l_rc ) { TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, @@ -237,12 +238,12 @@ errlHndl_t applyPoreGenCpuRegs( TARGETING::Target *i_cpuTarget, break; } - l_rc = p8_pore_gen_cpureg( io_image, - i_sizeImage, - P8_SPR_HRMOR, - l_hrmorVal, - l_coreId, - l_threadId); + l_rc = p8_pore_gen_cpureg_fixed( io_image, + P8_SLW_MODEBUILD_IPL, + P8_SPR_HRMOR, + l_hrmorVal, + l_coreId, + l_threadId); if ( l_rc ){ TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "ERROR: HRMOR: core=0x%x,thread=0x%x,l_rc=0x%x", @@ -266,12 +267,12 @@ errlHndl_t applyPoreGenCpuRegs( TARGETING::Target *i_cpuTarget, "applyPoreGenCpuRegs: msrc=0x%x,lpcr=0x%x,hrmor=0x%x", l_msrVal, l_lpcrVal, l_hrmorVal ); - l_rc = p8_pore_gen_cpureg( io_image, - i_sizeImage, - P8_SPR_LPCR, - l_lpcrVal, - l_coreId, - l_threadId); + l_rc = p8_pore_gen_cpureg_fixed( io_image, + P8_SLW_MODEBUILD_IPL, + P8_SPR_LPCR, + l_lpcrVal, + l_coreId, + l_threadId); if ( l_rc ) { TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, @@ -356,7 +357,7 @@ void* call_host_build_winkle( void *io_pArgs ) { errlHndl_t l_errl = NULL; - const char *l_pPoreImage = NULL; + char *l_pPoreImage = NULL; uint32_t l_poreSize = 0; void *l_pRealMemBase = NULL; void* l_pVirtMemBase = NULL; @@ -369,6 +370,11 @@ void* call_host_build_winkle( void *io_pArgs ) // @@@@@ CUSTOM BLOCK: @@@@@ + // allocate some working buffers + void* l_rs4_tmp = malloc(FIXED_RING_BUF_SIZE); + void* l_wf_tmp = malloc(FIXED_RING_BUF_SIZE); + + do { // Get a chunk of real memory big enough to store all the possible // SLW images. @@ -475,13 +481,16 @@ void* call_host_build_winkle( void *io_pArgs ) // call the HWP with each fapi::Target FAPI_INVOKE_HWP( l_errl, - p8_slw_build, - l_fapi_cpu_target, - reinterpret_cast<const void*>(l_pPoreImage), - l_poreSize, + p8_slw_build_fixed, + l_fapi_cpu_target, //Proc chip target. + reinterpret_cast<void*>(l_pPoreImage), l_pImageOut, - &l_sizeImageOut - ); + l_sizeImageOut, + P8_SLW_MODEBUILD_IPL, //i_modeBuild + l_rs4_tmp,//RS4 + FIXED_RING_BUF_SIZE, + l_wf_tmp,//WF + FIXED_RING_BUF_SIZE ); if ( l_errl ) { TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, @@ -555,6 +564,10 @@ void* call_host_build_winkle( void *io_pArgs ) } while (0); // @@@@@ END CUSTOM BLOCK: @@@@@ + // delete working buffers + if( l_rs4_tmp ) { free(l_rs4_tmp); } + if( l_wf_tmp ) { free(l_wf_tmp); } + if(l_pVirtMemBase) { int rc = 0; diff --git a/src/usr/hwpf/hwp/build_winkle_images/makefile b/src/usr/hwpf/hwp/build_winkle_images/makefile index 3e79e2c22..f5901964b 100644 --- a/src/usr/hwpf/hwp/build_winkle_images/makefile +++ b/src/usr/hwpf/hwp/build_winkle_images/makefile @@ -56,14 +56,13 @@ OBJS = build_winkle_images.o \ p8_pba_bar_config.o \ sbe_xip_image.o \ p8_pore_table_static_data.o \ - p8_pore_table_gen_api.o \ p8_pore_table_gen_api_fixed.o \ p8_pmc_deconfig_setup.o \ p8_poreslw_init.o \ p8_set_pore_bar.o \ p8_xip_customize.o \ p8_ring_identification.o \ - p8_slw_build.o \ + p8_slw_build_fixed.o \ p8_image_help_base.o \ p8_pfet_init.o \ p8_pfet_control.o diff --git a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/HvPlicModule.H b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/HvPlicModule.H deleted file mode 100644 index a74bc37d4..000000000 --- a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/HvPlicModule.H +++ /dev/null @@ -1,23 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/HvPlicModule.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 otherwise */ -/* divested of its trade secrets, irrespective of what has been */ -/* deposited with the U.S. Copyright Office. */ -/* */ -/* Origin: 30 */ -/* */ -/* IBM_PROLOG_END_TAG */ - diff --git a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_gen_api.C b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_gen_api.C deleted file mode 100644 index b38c02ee0..000000000 --- a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_gen_api.C +++ /dev/null @@ -1,740 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_gen_api.C $ */ -/* */ -/* IBM CONFIDENTIAL */ -/* */ -/* COPYRIGHT International Business Machines Corp. 2012,2013 */ -/* */ -/* p1 */ -/* */ -/* Object Code Only (OCO) source materials */ -/* Licensed Internal Code Source Materials */ -/* IBM HostBoot Licensed Internal Code */ -/* */ -/* The source code for this program is not published or otherwise */ -/* divested of its trade secrets, irrespective of what has been */ -/* deposited with the U.S. Copyright Office. */ -/* */ -/* Origin: 30 */ -/* */ -/* IBM_PROLOG_END_TAG */ -// $Id: p8_pore_table_gen_api.C,v 1.13 2013/05/08 20:16:58 cmolsen Exp $ -// -/*------------------------------------------------------------------------------*/ -/* *! (C) Copyright International Business Machines Corp. 2012 */ -/* *! All Rights Reserved -- Property of IBM */ -/* *! *** IBM Confidential *** */ -/*------------------------------------------------------------------------------*/ -/* *! TITLE : p8_pore_table_gen_api.C */ -/* *! DESCRIPTION : PORE SLW table generaion APIs */ -/* *! OWNER NAME : Michael Olsen Email: cmolsen@us.ibm.com */ -/* *! USAGE : To build for PHYP command-line - */ -// buildecmdprcd_cmo -d "sbe_xip_image.c,pore_inline_assembler.c" p8_pore_table_gen_api.C -// Other usages: -// - Passing the DYNAMIC_RAM_TABLE PPD, gen_cpureg() will build -// up the ramming table in a space saving way, occupying only -// as much space as needed in the [pre-defined sized] .slw -// section. This implementation, even though presently not -// safe due to race condition to the ramming vector, may come -// in handy at a later stage. -// -/* *! COMMENTS : Start file: p7p_pore_api.c */ -// -/*------------------------------------------------------------------------------*/ - -#define __P8_PORE_TABLE_GEN_API_C -#include <HvPlicModule.H> -#include <p8_pore_api_custom.h> -#include <p8_pore_table_gen_api.H> -#include <p8_delta_scan_rw.h> - -/* -// io_image - pointer to SLW image -// i_sizeImage - size of SLW image -// i_regName - unswizzled enum SPR value (NOT a name) -// i_regData - data to write -// i_coreIndex - core ID -// i_threadIndex - thread to operate on, API changes thread num to 0 for shared SPRs, except for HRMOR which -// is always done on thread 3 to be the last SPR -*/ -uint32_t p8_pore_gen_cpureg( void *io_image, - uint32_t i_sizeImage, - uint32_t i_regName, - uint64_t i_regData, - uint32_t i_coreId, // [0:15] - uint32_t i_threadId) -{ - uint32_t rc=0, rcLoc=0, iCount=0; - int i=0, iReg=-1; - uint32_t sizeImageIn=0; - uint64_t xipSlwRamSection; - void *hostSlwRamSection; - uint64_t xipRamTableThis; - void *hostRamVector; - void *hostRamTableThis; - void *hostRamEntryThis, *hostRamEntryNext; - uint8_t bNewTable=0, bFound=0; - uint8_t bEntryEnd=1, headerType=0; - SbeXipSection xipSection; - SbeXipItem xipTocItem; - RamTableEntry ramEntryThis, *ramEntryNext; - uint32_t sprSwiz=0; -#ifdef DYNAMIC_RAM_TABLE - uint32_t iCore=0, sizeTableThis=0, sizeTableAll=0; - void *hostRamEntryFirstAll; // First entry of all Ram tables. - void *hostRamEntryLastAll; // Last entry of all Ram tables. - uint64_t xipRamTableNext; - void *hostRamTableNext; -#endif - - // ------------------------------------------------------------------------- - // Validate Ramming parameters. - // - // ...check register value - bFound = 0; - for (i=0;i<SLW_SPR_REGS_SIZE;i++) { - if (i_regName==SLW_SPR_REGS[i].value) { - bFound = 1; - iReg = i; - break; - } - } - if (!bFound) { - MY_ERR("Register value = %i is not supported.\n",i_regName); - MY_ERR("The following registers are supported:\n"); - for (i=0;i<SLW_SPR_REGS_SIZE;i++) - MY_ERR("\t(%s,%i)\n",SLW_SPR_REGS[i].name,SLW_SPR_REGS[i].value); - rcLoc = 1; - } - // ...check core ID - if (i_coreId>=SLW_MAX_CORES) { - MY_ERR("Core ID = %i is not within valid range of [0;%i]\n",i_coreId,SLW_MAX_CORES-1); - rcLoc = 1; - } - // ...check thread ID - if (i_threadId>=SLW_CORE_THREADS) { - MY_ERR("Thread ID = %i is not within valid range of [0;%i]\n",i_threadId,SLW_CORE_THREADS-1); - rcLoc = 1; - } - if (rcLoc) - return IMGBUILD_ERR_RAM_INVALID_PARM; - rcLoc = 0; - - // ------------------------------------------------------------------------- - // Validate image and get pointer to SLW section. - // - // ...validate - rc = sbe_xip_validate( io_image, i_sizeImage); - if (rc) { - MY_ERR("Invalid image.\n"); - return IMGBUILD_INVALID_IMAGE; - } - // ...size check - sbe_xip_image_size( io_image, &sizeImageIn); - if (sizeImageIn!=i_sizeImage) { - MY_ERR("Supplied image size (=%i) differs from size in image header (=%i).\n", - i_sizeImage, sizeImageIn); - return IMGBUILD_IMAGE_SIZE_MISMATCH; - } - // ...get pointer to SLW section where Ram table resides - rc = sbe_xip_get_section( io_image, SBE_XIP_SECTION_SLW, &xipSection); - if (rc) { - MY_ERR("Probably invalid section name for SBE_XIP_SECTION_SLW.\n"); - return IMGBUILD_ERR_GET_SECTION; - } - hostSlwRamSection = (void*)((uint8_t*)io_image + xipSection.iv_offset); - sbe_xip_host2pore( io_image, hostSlwRamSection, &xipSlwRamSection); - - // ------------------------------------------------------------------------- - // Cross check SPR register and table defines - // - if (SLW_SPR_REGS_SIZE!=(SLW_MAX_CPUREGS_CORE+SLW_MAX_CPUREGS_THREADS)) { - MY_ERR("Defines in *.H header file not in sync.\n"); - return IMGBUILD_ERR_RAM_HDRS_NOT_SYNCED; - } - if (xipSection.iv_size!=SLW_RAM_TABLE_SIZE+SLW_SCOM_TABLE_SIZE_ALL) { - MY_ERR("SLW table size in *.H header file differs from SLW section size in image.\n"); - MY_ERR("Check code or image version.\n"); - return IMGBUILD_ERR_RAM_HDRS_NOT_SYNCED; - } - // ------------------------------------------------------------------------- - // Summarize parameters and checking results. - // - MY_INF("Input parameter checks - OK\n"); - MY_INF("\tRegister = (%s,%i)\n",SLW_SPR_REGS[iReg].name,SLW_SPR_REGS[iReg].value); - MY_INF("\tCore ID = %i\n",i_coreId); - MY_INF("\tThread ID = %i\n",i_threadId); - MY_INF("Image validation and size checks - OK\n"); - MY_INF("\tImage size = %i\n",i_sizeImage); - MY_INF("\tSLW section size= %i\n",xipSection.iv_size); - - // ------------------------------------------------------------------------- - // Locate RAM vector and locate RAM table associated with "This" core ID. - // - rc = sbe_xip_find( io_image, SLW_HOST_REG_VECTOR_TOC_NAME, &xipTocItem); - if (rc) { - MY_ERR("Probably invalid key word for SLW_HOST_REG_VECTOR_TOC_NAME.\n"); - return IMGBUILD_ERR_KEYWORD_NOT_FOUND; - } - sbe_xip_pore2host( io_image, xipTocItem.iv_address, &hostRamVector); - xipRamTableThis = myRev64(*((uint64_t*)hostRamVector + i_coreId)); - if (xipRamTableThis) { - sbe_xip_pore2host( io_image, xipRamTableThis, &hostRamTableThis); - bNewTable = 0; - } - else { - hostRamTableThis = NULL; - bNewTable = 1; - } - -#ifdef DYNAMIC_RAM_TABLE - hostRamEntryFirstAll = hostSlwRamSection; - hostRamEntryLastAll = hostRamEntryFirstAll; - - // ------------------------------------------------------------------------- - // Walk the RAM vector and RAM tables to - // - determine size of present tables, sizeTableAll - we'll need it when/if shifting entries forward - // - check for RAM table overflow. - // - sizeTableAll = 0; - for (iCore=0; iCore<SLW_MAX_CORES; iCore++) { - xipRamTableNext = myRev64(*((uint64_t*)hostRamVector + iCore)); - if (xipRamTableNext) - sbe_xip_pore2host( io_image, xipRamTableNext, &hostRamTableNext); - else - hostRamTableNext = NULL; - sizeTableThis = 0; - if (hostRamTableNext) { - hostRamEntryNext = hostRamTableNext; - ramEntryNext = (RamTableEntry*)hostRamEntryNext; - sizeTableThis = sizeTableThis + XIPSIZE_RAM_ENTRY; - while ((myRev32(ramEntryNext->header) & RAM_HEADER_END_MASK_C)==0) { - hostRamEntryNext = (void*)((uint8_t*)hostRamEntryNext + XIPSIZE_RAM_ENTRY); - ramEntryNext = (RamTableEntry*)hostRamEntryNext; - sizeTableThis = sizeTableThis + XIPSIZE_RAM_ENTRY; - } - // Keep searching for last entry. - if ((uint64_t)hostRamEntryLastAll<(uint64_t)hostRamEntryNext) - hostRamEntryLastAll = hostRamEntryNext; - // Check hostRamTableThis for sizeTableThis>SLW_MAX_CPUREGS_OPS - if ((uint64_t)hostRamTableNext==(uint64_t)hostRamTableThis) { - if ((sizeTableThis/XIPSIZE_RAM_ENTRY+1)>SLW_MAX_CPUREGS_OPS) { - MY_ERR("RAM table is full. Max %i entries allowed.\n",SLW_MAX_CPUREGS_OPS); - return IMGBUILD_ERR_RAM_TABLE_FULL; - } - } - // Update total table size. - sizeTableAll = sizeTableAll + sizeTableThis; - // Increment RAM vector entries, if needed, but not if a new table which goes at the end. - // (This must be done at this stage while walking everything.) - if (!bNewTable && ((uint64_t)hostRamTableNext>(uint64_t)hostRamTableThis)) { - sbe_xip_host2pore( io_image, (void*)((uint8_t*)hostRamTableNext + XIPSIZE_RAM_ENTRY), &xipRamTableNext); - *((uint64_t*)hostRamVector + iCore) = myRev64(xipRamTableNext); - } - } - } -#else - // ------------------------------------------------------------------------- - // We don't need to walk the "this" RAM table to check for RAM table - // as this is done further down during insertion of the entry. - // -#endif - - - // ------------------------------------------------------------------------- - // Walk the "This" core ID's RAM table to - // - determine insertion point, hostRamEntryThis, of new RAM entry - // - if (bNewTable) { -#ifdef DYNAMIC_RAM_TABLE - // Append to end of table. - hostRamTableThis = (void*)((uint8_t*)hostRamEntryFirstAll + sizeTableAll); - hostRamEntryThis = hostRamTableThis; - // ...update RAM vector (since it is currently NULL) - sbe_xip_host2pore( io_image, hostRamTableThis, &xipRamTableThis); - *((uint64_t*)hostRamVector + i_coreId) = myRev64(xipRamTableThis); - bEntryEnd = 1; -#else - // Append to beginning of agreed upon static position for this coreId. - hostRamTableThis = (void*)((uint8_t*)hostSlwRamSection + - (uint32_t)(SLW_RAM_TABLE_SIZE/SLW_MAX_CORES)*i_coreId ); - hostRamEntryThis = hostRamTableThis; - // ...update RAM vector (since it is currently NULL) - *((uint64_t*)hostRamVector + i_coreId) = myRev64( xipSlwRamSection + - (uint32_t)(SLW_RAM_TABLE_SIZE/SLW_MAX_CORES)*i_coreId ); - bEntryEnd = 1; -#endif - } - else { - // Insert at end of existing table. - hostRamEntryNext = hostRamTableThis; - ramEntryNext = (RamTableEntry*)hostRamEntryNext; - iCount = 1; - while ((myRev32(ramEntryNext->header) & RAM_HEADER_END_MASK_C)==0) { - if (iCount>=SLW_MAX_CPUREGS_OPS) { - MY_ERR("Bad table! Header end bit not found and RAM table full (=%i entries).\n",SLW_MAX_CPUREGS_OPS); - return IMGBUILD_ERR_RAM_TABLE_END_NOT_FOUND; - } - hostRamEntryNext = (void*)((uint8_t*)hostRamEntryNext + XIPSIZE_RAM_ENTRY); - ramEntryNext = (RamTableEntry*)hostRamEntryNext; - iCount++; - } - if (iCount<SLW_MAX_CPUREGS_OPS) { - // ...zero out previous END bit in header - if ((myRev32(ramEntryNext->header) & RAM_HEADER_END_MASK_C)) { - ramEntryNext->header = ramEntryNext->header & myRev32(~RAM_HEADER_END_MASK_C); - } - else { - MY_ERR("We should never get here. Check code. Dumping data:\n"); - MY_ERR("myRev32(ramEntryNext->header) = 0x%08x\n",myRev32(ramEntryNext->header)); - MY_ERR("RAM_HEADER_END_MASK_C = 0x%08x\n",RAM_HEADER_END_MASK_C); - return IMGBUILD_ERR_RAM_CODE; - } - } - else { - MY_ERR("RAM table is full. Max %i entries allowed.\n",SLW_MAX_CPUREGS_OPS); - return IMGBUILD_ERR_RAM_TABLE_FULL; - } - // ...this is the spot for the new entry - hostRamEntryThis = (void*)((uint8_t*)hostRamEntryNext + XIPSIZE_RAM_ENTRY); - bEntryEnd = 1; - } - -#ifdef DYNAMIC_RAM_TABLE - // ------------------------------------------------------------------------- - // Shift RAM entries forward by XIPSIZE_RAM_ENTRY - // (Need to do this before inserting new RAM entry at hostRamEntryThis.) - // - if (!bNewTable) - for ( ramEntryNext=(RamTableEntry*)hostRamEntryLastAll; - ramEntryNext>=(RamTableEntry*)hostRamEntryThis; - ramEntryNext-- ) { - *(ramEntryNext+1) = *ramEntryNext; - if ((ramEntryNext+1)->instr!=ramEntryNext->instr) { - MY_ERR("Incorrect shifting of table entries. Check code.\n"); - return IMGBUILD_ERR_RAM_CODE; - } - } -#endif - - // ------------------------------------------------------------------------- - // Create, or modify, the RAM entry. - // - if (i_regName==P8_MSR_MSR) { - // ...do the MSR header - headerType = 0x1; // MTMSRD header. - ramEntryThis.header = ( ((uint32_t)bEntryEnd) << RAM_HEADER_END_START_C & RAM_HEADER_END_MASK_C ) | - ( ((uint32_t)headerType) << RAM_HEADER_TYPE_START_C & RAM_HEADER_TYPE_MASK_C ) | - ( i_threadId << RAM_HEADER_THREAD_START_C & RAM_HEADER_THREAD_MASK_C ); - // ...do the MSR instr - ramEntryThis.instr = RAM_MTMSRD_INSTR_TEMPL_C; - } - else { - // ...do the SPR header - headerType = 0x0; // MTSPR header. - ramEntryThis.header = ( ((uint32_t)bEntryEnd) << RAM_HEADER_END_START_C & RAM_HEADER_END_MASK_C ) | - ( ((uint32_t)headerType) << RAM_HEADER_TYPE_START_C & RAM_HEADER_TYPE_MASK_C ) | - ( i_regName << RAM_HEADER_SPRN_START_C & RAM_HEADER_SPRN_MASK_C ) | - ( i_threadId << RAM_HEADER_THREAD_START_C & RAM_HEADER_THREAD_MASK_C ); - // ...do the SPR instr - sprSwiz = i_regName>>5 | (i_regName & 0x0000001f)<<5; - if (sprSwiz!=SLW_SPR_REGS[iReg].swizzled) { - MY_ERR("Inconsistent swizzle rules implemented. Check code. Dumping data.\n"); - MY_ERR("\tsprSwiz (on-the-fly-calc)=%i\n",sprSwiz); - MY_ERR("\tSLW_SPR_REGS[%i].swizzled=%i\n",iReg,SLW_SPR_REGS[iReg].swizzled); - return IMGBUILD_ERR_RAM_CODE; - } - ramEntryThis.instr = RAM_MTSPR_INSTR_TEMPL_C | ( ( sprSwiz<<RAM_MTSPR_SPR_START_C ) & RAM_MTSPR_SPR_MASK_C ); - } - // ...do the data - ramEntryThis.data = i_regData; - // ...summarize new table entry data - MY_INF("New table entry data (host format):\n"); - MY_INF("\theader = 0x%08x\n",ramEntryThis.header); - MY_INF("\tinstr = 0x%08x\n",ramEntryThis.instr); - MY_INF("\tdata = 0x%016llx\n",ramEntryThis.data); - - // ------------------------------------------------------------------------- - // Insert the new RAM entry into the table in BE format. - // - ramEntryNext = (RamTableEntry*)hostRamEntryThis; - // ...some redundant checking - if (bNewTable) { - // For any new table, the insertion location should be clean. We check for this here. - if (myRev32(ramEntryNext->header)!=0) { - MY_ERR("WARNING : Table entry location should be empty for a new table. Check code and image. Dumping data:\n"); - MY_ERR("\theader = 0x%08x\n",myRev32(ramEntryNext->header)); - MY_ERR("\tinstr = 0x%08x\n",myRev32(ramEntryNext->instr)); - MY_ERR("\tdata = 0x%016llx\n",myRev64(ramEntryNext->data)); - rc = IMGBUILD_WARN_RAM_TABLE_CONTAMINATION; - } - } - ramEntryNext->header = myRev32(ramEntryThis.header); - ramEntryNext->instr = myRev32(ramEntryThis.instr); - ramEntryNext->data = myRev64(ramEntryThis.data); - - return rc; -} - - -/* -// io_image - pointer to SLW image -// i_sizeImage - size of SLW image -// i_scomAddr - Scom address -// i_scomData - Data to write to scom register -// i_operation - What to do with the scom addr and data -// i_coreId - The core ID [0:15]. -*/ -uint32_t p8_pore_gen_scom( void *io_image, - uint32_t i_sizeImage, - uint32_t i_scomAddr, - uint32_t i_coreId, // [0:15] - uint64_t i_scomData, - uint32_t i_operation, // [0:5] - uint32_t i_section) // [0,2,3] -{ - uint32_t rc=0, rcLoc=0, iEntry=0; - uint32_t chipletId=0; - uint32_t operation=0; - uint32_t entriesCount=0, entriesMatch=0, entriesNOP=0; - uint32_t sizeImageIn=0; - uint64_t xipScomTableThis; - void *hostScomVector, *hostScomTableThis; - void *hostScomEntryNext; // running entry pointer - void *hostScomEntryMatch=NULL; // pointer to entry that matches scomAddr - void *hostScomEntryRET=NULL; // pointer to first return instr after table - void *hostScomEntryNOP=NULL; // pointer to first nop IIS - uint8_t bufIIS[XIPSIZE_SCOM_ENTRY], bufNOP[4], bufRET[4]; - SbeXipSection xipSection; - SbeXipItem xipTocItem; - PoreInlineContext ctx; - - // ------------------------------------------------------------------------- - // Validate Scom parameters. - // - // ...check if valid Scom register (is there anything we can do here to check?) - // Skipping check. We blindly trust caller. - // - // ...check Scom operation - if (i_operation<P8_PORE_SCOM_FIRST_OP || i_operation>P8_PORE_SCOM_LAST_OP) { - MY_ERR("Scom operation = %i is not within valid range of [%d;%d]\n", - i_operation, P8_PORE_SCOM_FIRST_OP, P8_PORE_SCOM_LAST_OP); - rcLoc = 1; - } - // ...check that core ID corresponds to valid chiplet ID - chipletId = i_coreId + P8_CID_EX_LOW; - if (chipletId<P8_CID_EX_LOW || chipletId>P8_CID_EX_HIGH) { - MY_ERR("Chiplet ID = 0x%02x is not within valid range of [0x%02x;0x%02x]\n", - chipletId, P8_CID_EX_LOW, P8_CID_EX_HIGH); - rcLoc = 1; - } - if (rcLoc) - return IMGBUILD_ERR_SCOM_INVALID_PARM; - rcLoc = 0; - - // ------------------------------------------------------------------------- - // Validate image and get pointer to SLW section. - // - // ...validate - rc = sbe_xip_validate( io_image, i_sizeImage); - if (rc) { - MY_ERR("Invalid image.\n"); - return IMGBUILD_INVALID_IMAGE; - } - // ...size check - sbe_xip_image_size( io_image, &sizeImageIn); - if (sizeImageIn!=i_sizeImage) { - MY_ERR("Supplied image size (=%i) differs from size in image header (=%i).\n", - i_sizeImage, sizeImageIn); - return IMGBUILD_IMAGE_SIZE_MISMATCH; - } - // ...get pointer to SLW section where Scom table resides - rc = sbe_xip_get_section( io_image, SBE_XIP_SECTION_SLW, &xipSection); - if (rc) { - MY_ERR("Probably invalid section name for SBE_XIP_SECTION_SLW.\n"); - return IMGBUILD_ERR_GET_SECTION; - } - // ...check .slw section size - if (xipSection.iv_size!=SLW_RAM_TABLE_SIZE+SLW_SCOM_TABLE_SIZE_ALL) { - MY_ERR("SLW table size in *.H header file differs from SLW section size in image.\n"); - MY_ERR("Check code or image version.\n"); - return IMGBUILD_ERR_SCOM_HDRS_NOT_SYNCD; - } - - // ------------------------------------------------------------------------- - // Summarize parameters and checking results. - // - MY_INF("Input parameter checks - OK\n"); - MY_INF("\tRegister = 0x%08x\n",i_scomAddr); - MY_INF("\tOperation = %i\n",i_operation); - MY_INF("\tSection = %i\n",i_section); - MY_INF("\tCore ID = %i\n",i_coreId); - MY_INF("Image validation and size checks - OK\n"); - MY_INF("\tImage size = %i\n",i_sizeImage); - MY_INF("\tSLW section size= %i\n",xipSection.iv_size); - - // ------------------------------------------------------------------------- - // Locate Scom vector according to i_section and then locate Scom table - // associated with "This" core ID. - // - switch (i_section) { - case 0: - rc = sbe_xip_find( io_image, SLW_HOST_SCOM_NC_VECTOR_TOC_NAME, &xipTocItem); - if (rc) { - MY_ERR("Probably invalid key word for SLW_HOST_SCOM_NC_VECTOR_TOC_NAME.\n"); - return IMGBUILD_ERR_KEYWORD_NOT_FOUND; - } - break; - case 2: - rc = sbe_xip_find( io_image, SLW_HOST_SCOM_L2_VECTOR_TOC_NAME, &xipTocItem); - if (rc) { - MY_ERR("Probably invalid key word for SLW_HOST_SCOM_L2_VECTOR_TOC_NAME.\n"); - return IMGBUILD_ERR_KEYWORD_NOT_FOUND; - } - break; - case 3: - rc = sbe_xip_find( io_image, SLW_HOST_SCOM_L3_VECTOR_TOC_NAME, &xipTocItem); - if (rc) { - MY_ERR("Probably invalid key word for SLW_HOST_SCOM_L3_VECTOR_TOC_NAME.\n"); - return IMGBUILD_ERR_KEYWORD_NOT_FOUND; - } - break; - default: - MY_ERR("Invalid value for i_section (=%i).\n",i_section); - MY_ERR("Valid values for i_section = [0,2,3].\n"); - return IMGBUILD_ERR_SCOM_INVALID_SUBSECTION; - } - MY_INF("xipTocItem.iv_address = 0x%016llx\n",xipTocItem.iv_address); - sbe_xip_pore2host( io_image, xipTocItem.iv_address, &hostScomVector); - MY_INF("hostScomVector = 0x%016llx\n",(uint64_t)hostScomVector); - xipScomTableThis = myRev64(*((uint64_t*)hostScomVector + i_coreId)); - MY_INF("xipScomTableThis = 0x%016llx\n",xipScomTableThis); - if (xipScomTableThis) { - sbe_xip_pore2host( io_image, xipScomTableThis, &hostScomTableThis); - } - else { // Should never be here. - MY_ERR("Code or image bug. Scom vector table entries should never be null.\n"); - return IMGBUILD_ERR_CHECK_CODE; - } - - // - // Determine where to place/do Scom action and if entry already exists. - // Insertion rules: - // - If entry doesn't exist, insert at first NOP. (Note that if you don't do - // this, then the table might potentially overflow since the max table size - // doesn't include NOP entries.) - // - If no NOP found, insert at first RET. - // - - // First, create search strings for addr, nop and ret. - // Note, the following IIS will also be used in case of - // - i_operation==append - // - i_operation==replace - pore_inline_context_create( &ctx, (void*)bufIIS, XIPSIZE_SCOM_ENTRY, 0, 0); - pore_LS( &ctx, P1, chipletId); - pore_STI( &ctx, i_scomAddr, P1, i_scomData); - if (ctx.error > 0) { - MY_ERR("pore_LS or _STI generated rc = %d", ctx.error); - return IMGBUILD_ERR_PORE_INLINE_ASM; - } - pore_inline_context_create( &ctx, (void*)bufRET, 4, 0, 0); - pore_RET( &ctx); - if (ctx.error > 0) { - MY_ERR("pore_RET generated rc = %d", ctx.error); - return IMGBUILD_ERR_PORE_INLINE_ASM; - } - pore_inline_context_create( &ctx, (void*)bufNOP, 4, 0, 0); - pore_NOP( &ctx); - if (ctx.error > 0) { - MY_ERR("pore_NOP generated rc = %d", ctx.error); - return IMGBUILD_ERR_PORE_INLINE_ASM; - } - - // Second, search for addr and nop in relevant coreId table until first RET. - // Note: - // - We go through ALL entries until first RET instr. We MUST find a RET instr, - // though we don't check for overrun until later. (Should be improved.) - // - Count number of entries and check for overrun, though we'll continue - // searching until we find an RET. (Should be improved.) - // - The STI(+SCOM_addr) opcode is in the 2nd word of the Scom entry. - // - For an append operation, if a NOP is found (before a RET obviously), the - // SCOM is replacing that NNNN sequence. - hostScomEntryNext = hostScomTableThis; - while (memcmp(hostScomEntryNext, bufRET, sizeof(uint32_t))) { - entriesCount++; - if (*((uint32_t*)bufIIS+1)==*((uint32_t*)hostScomEntryNext+1) && entriesMatch==0) {// +1 skips 1st word in Scom entry (which loads the PC in an LS operation.) - hostScomEntryMatch = hostScomEntryNext; - entriesMatch++; - } - if ((0 == memcmp(hostScomEntryNext, bufNOP, sizeof(uint32_t))) && entriesNOP==0) { - hostScomEntryNOP = hostScomEntryNext; - entriesNOP++; - } - hostScomEntryNext = (void*)((uintptr_t)hostScomEntryNext + XIPSIZE_SCOM_ENTRY); - } - hostScomEntryRET = hostScomEntryNext; // The last EntryNext will always be the first RET. - - switch (i_section) { - case 0: - if (entriesCount>=SLW_MAX_SCOMS_NC) { - MY_ERR("SCOM table NC is full. Max %i entries allowed.\n",SLW_MAX_SCOMS_NC); - return IMGBUILD_ERR_CHECK_CODE; - } - break; - case 2: - if (entriesCount>=SLW_MAX_SCOMS_L2) { - MY_ERR("SCOM table L2 is full. Max %i entries allowed.\n",SLW_MAX_SCOMS_L2); - return IMGBUILD_ERR_CHECK_CODE; - } - break; - case 3: - if (entriesCount>=SLW_MAX_SCOMS_L3) { - MY_ERR("SCOM table L3 is full. Max %i entries allowed.\n",SLW_MAX_SCOMS_L3); - return IMGBUILD_ERR_CHECK_CODE; - } - break; - default: - MY_ERR("Invalid value for i_section (=%i).\n",i_section); - MY_ERR("Valid values for i_section = [0,2,3].\n"); - return IMGBUILD_ERR_SCOM_INVALID_SUBSECTION; - } - - // - // Further qualify (translate) operation and IIS. - // - if (i_operation==P8_PORE_SCOM_APPEND) { - operation = i_operation; - } - else if (i_operation==P8_PORE_SCOM_REPLACE) { - if (hostScomEntryMatch) - // ... do a replace - operation = i_operation; - else - // ... do an append - operation = P8_PORE_SCOM_APPEND; - } - else if (i_operation==P8_PORE_SCOM_NOOP) { - // ...overwrite earlier bufIIS from the search step - pore_inline_context_create( &ctx, (void*)bufIIS, XIPSIZE_SCOM_ENTRY, 0, 0); - pore_NOP( &ctx); - pore_NOP( &ctx); - pore_NOP( &ctx); - pore_NOP( &ctx); - if (ctx.error > 0) { - MY_ERR("*** _NOP generated rc = %d", ctx.error); - return IMGBUILD_ERR_PORE_INLINE_ASM; - } - operation = i_operation; - } - else if (i_operation==P8_PORE_SCOM_AND || - i_operation==P8_PORE_SCOM_OR) { - operation = i_operation; - } - else if (i_operation==P8_PORE_SCOM_RESET) { - // ... create RNNN instruction sequence. - pore_inline_context_create( &ctx, (void*)bufIIS, XIPSIZE_SCOM_ENTRY, 0, 0); - pore_RET( &ctx); - pore_NOP( &ctx); - pore_NOP( &ctx); - pore_NOP( &ctx); - if (ctx.error > 0) { - MY_ERR("***_RET or _NOP generated rc = %d", ctx.error); - return IMGBUILD_ERR_PORE_INLINE_ASM; - } - operation = i_operation; - } - else { - MY_ERR("Scom operation = %i is not within valid range of [%d;%d]\n", - i_operation, P8_PORE_SCOM_FIRST_OP, P8_PORE_SCOM_LAST_OP); - return IMGBUILD_ERR_SCOM_INVALID_PARM; - } - - // ------------------------------------------------------------------------- - // Assuming pre-allocated Scom table (after pre-allocated Ram table): - // - Table is pre-filled with RNNN ISS. - // - Each core Id has dedicated space, uniformly distributed by SLW_MAX_SCOMS_NC* - // XIPSIZE_SCOM_ENTRY. - // - Remember to check for more than SLW_MAX_SCOMS_NC entries! - switch (operation) { - - case P8_PORE_SCOM_APPEND: // Append a Scom at first occurring NNNN or RNNN, - if (hostScomEntryNOP) { - // ... replace the NNNN - MY_INF("Append at NOP\n"); - memcpy(hostScomEntryNOP,(void*)bufIIS,XIPSIZE_SCOM_ENTRY); - } - else if (hostScomEntryRET) { - // ... replace the RNNN - MY_INF("Append at RET\n"); - memcpy(hostScomEntryRET,(void*)bufIIS,XIPSIZE_SCOM_ENTRY); - } - else { - // We should never be here. - MY_ERR("In case=_SCOM_APPEND: EntryRET=NULL is impossible. Check code.\n"); - return IMGBUILD_ERR_CHECK_CODE; - } - break; - case P8_PORE_SCOM_REPLACE: // Replace existing Scom with new data - if (hostScomEntryMatch) { - // ... do a vanilla replace - MY_INF("Replace existing Scom\n"); - memcpy(hostScomEntryMatch,(void*)bufIIS,XIPSIZE_SCOM_ENTRY); - } - else { - // We should never be here. - MY_ERR("In case=_SCOM_REPLACE: EntryMatch=NULL is impossible. Check code.\n"); - return IMGBUILD_ERR_CHECK_CODE; - } - break; - case P8_PORE_SCOM_NOOP: - if (hostScomEntryMatch) { - // ... do a vanilla replace - MY_INF("Replace existing Scom w/NOPs\n"); - memcpy(hostScomEntryMatch,(void*)bufIIS,XIPSIZE_SCOM_ENTRY); - } - else { - // do nothing, and assume everything is fine, since we did no damage. - } - break; - case P8_PORE_SCOM_OR: // Overlay Scom data onto existing data by bitwise OR - if (hostScomEntryMatch) { - // ... do an OR on the data (which is the 2nd DWord in the entry) - MY_INF("Overlay existing Scom - OR case\n"); - *((uint64_t*)hostScomEntryMatch+1) = - *((uint64_t*)hostScomEntryMatch+1) | myRev64(i_scomData); - } - else { - MY_ERR("No Scom entry found to do OR operation with.\n"); - return IMGBUILD_ERR_SCOM_ENTRY_NOT_FOUND; - } - break; - case P8_PORE_SCOM_AND: // Overlay Scom data onto existing data by bitwise AND - if (hostScomEntryMatch) { - // ... do an AND on the data (which is the 2nd DWord in the entry) - MY_INF("Overlay existing Scom - AND case\n"); - *((uint64_t*)hostScomEntryMatch+1) = - *((uint64_t*)hostScomEntryMatch+1) & myRev64(i_scomData); - } - else { - MY_ERR("No Scom entry found to do AND operation with.\n"); - return IMGBUILD_ERR_SCOM_ENTRY_NOT_FOUND; - } - break; - case P8_PORE_SCOM_RESET: // Reset (delete) table. Refill w/RNNN ISS. - MY_INF("Reset table\n"); - hostScomEntryNext = hostScomTableThis; - for ( iEntry=0; iEntry<entriesCount; iEntry++) { - memcpy( hostScomEntryNext, (void*)bufIIS, XIPSIZE_SCOM_ENTRY); - hostScomEntryNext = (void*)((uintptr_t)hostScomEntryNext + XIPSIZE_SCOM_ENTRY); - } - break; - default: - MY_ERR("Impossible value of operation (=%i). Check code.\n",operation); - return IMGBUILD_ERR_CHECK_CODE; - - } // End of switch(operation) - - return rc; -} diff --git a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_gen_api.H b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_gen_api.H index 4ba6dedf6..896e8feb5 100644 --- a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_gen_api.H +++ b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_gen_api.H @@ -20,7 +20,7 @@ /* Origin: 30 */ /* */ /* IBM_PROLOG_END_TAG */ -// $Id: p8_pore_table_gen_api.H,v 1.20 2013/05/08 20:18:50 cmolsen Exp $ +// $Id: p8_pore_table_gen_api.H,v 1.21 2013/05/23 21:10:40 dcrowell Exp $ /*------------------------------------------------------------------------------*/ /* *! (C) Copyright International Business Machines Corp. 2012 */ /* *! All Rights Reserved -- Property of IBM */ @@ -156,7 +156,9 @@ CONST_UINT64_T( SCRATCH0_RESET_VALUE, (0xABBA99EBBA33DADA) ); //#include <stdio.h> +#ifndef PPC_HYP #include <stdlib.h> +#endif // PPC_HYP #ifndef __P8_PORE_TABLE_GEN_API_C #include <p8_pore_api_custom.h> #endif @@ -313,9 +315,11 @@ enum { #define SLW_RAM_WARNING_TABLE_CONTAMINATION 6 +#ifndef PPC_HYP #ifdef __cplusplus extern "C" { #endif +#endif // PPC_HYP /********************************************************************/ /* C-code RAM section - begin */ @@ -410,9 +414,11 @@ uint32_t p8_pore_gen_scom_fixed(void *io_image, uint32_t i_operation, uint32_t i_section); +#ifndef PPC_HYP #ifdef __cplusplus } #endif +#endif // PPC_HYP #endif // FOR_PORE_RAMMING diff --git a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_static_data.c b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_static_data.c index 48d3b8460..0181203f6 100644 --- a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_static_data.c +++ b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_pore_table_static_data.c @@ -20,7 +20,8 @@ /* Origin: 30 */ /* */ /* IBM_PROLOG_END_TAG */ -// $Id: p8_pore_table_static_data.c,v 1.6 2013/05/08 20:19:41 cmolsen Exp $ + +// $Id: p8_pore_table_static_data.c,v 1.7 2013-05-23 21:10:38 dcrowell Exp $ /*------------------------------------------------------------------------------*/ /* *! (C) Copyright International Business Machines Corp. 2012 */ /* *! All Rights Reserved -- Property of IBM */ @@ -33,7 +34,6 @@ /* *! COMMENTS : This file is exclusively for PHYP environment. */ // /*------------------------------------------------------------------------------*/ -#include <HvPlicModule.H> #include <p8_pore_table_gen_api.H> const SlwSprRegs SLW_SPR_REGS[] = { diff --git a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build.C b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build.C deleted file mode 100644 index 822cca027..000000000 --- a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build.C +++ /dev/null @@ -1,731 +0,0 @@ -/* IBM_PROLOG_BEGIN_TAG */ -/* This is an automatically generated prolog. */ -/* */ -/* $Source: src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build.C $ */ -/* */ -/* IBM CONFIDENTIAL */ -/* */ -/* COPYRIGHT International Business Machines Corp. 2012,2013 */ -/* */ -/* p1 */ -/* */ -/* Object Code Only (OCO) source materials */ -/* Licensed Internal Code Source Materials */ -/* IBM HostBoot Licensed Internal Code */ -/* */ -/* The source code for this program is not published or otherwise */ -/* divested of its trade secrets, irrespective of what has been */ -/* deposited with the U.S. Copyright Office. */ -/* */ -/* Origin: 30 */ -/* */ -/* IBM_PROLOG_END_TAG */ -// $Id: p8_slw_build.C,v 1.23 2013/06/13 15:15:14 cmolsen Exp $ -/*------------------------------------------------------------------------------*/ -/* *! TITLE : p8_slw_build */ -/* *! DESCRIPTION : Extracts and decompresses delta ring states from EPROM */ -// image. Utilizes the linked list approach (LLA) to extract -// and position wiggle-flip programs in .rings according to -// back pointer, DD level, phase and override settings. -/* *! OWNER NAME : Michael Olsen cmolsen@us.ibm.com */ -// -/* *! EXTENDED DESCRIPTION : */ -// -/* *! USAGE : To build (for Hostboot) - */ -// buildfapiprcd -C "p8_image_help.C,p8_image_help_base.C,p8_scan_compression.C" -c "sbe_xip_image.c,pore_inline_assembler.c" -e "../../xml/error_info/p8_slw_build_errors.xml" p8_slw_build.C -// To build (for command-line) - -// buildfapiprcd -r ver-13-0 -C "p8_image_help.C,p8_image_help_base.C,p8_scan_compression.C" -c "sbe_xip_image.c,pore_inline_assembler.c" -e "../../xml/error_info/p8_slw_build_errors.xml" -u "SLW_COMMAND_LINE,IMGBUILD_PPD_IGNORE_XIPC,IMGBUILD_PPD_WF_POLLING_PROT" p8_slw_build.C -// Other Pre-Processor Directive (PPD) options - -// To debug WF programs: -// -u "IMGBUILD_PPD_DEBUG_WF" -// To add worst-case PIB access to wf programs: -// -u "IMGBUILD_PPD_WF_WORST_CASE_PIB" -// To add polling protocol to wf programs: -// -u "IMGBUILD_PPD_WF_POLLING_PROT" -// (NB! This will eventually be changed to IMGBUILD_PPD_WF_NO POLLING_PROT -// because we want the polling protocol to be default.) -// To NOT run xip_customize: -// -u "IMGBUILD_PPD_IGNORE_XIPC" -// (NB! Thus, by defaul for HB and PHYP, since they don't used PPDs, -// xip_customize() will always be called.) -// -/* *! ASSUMPTIONS : */ -// - For Hostboot environment: -// - No precompiler directives needed -// - dynamic P0/P1 calculation -// - polling scan protocol -// - check header word after WF -// - sysPhase=1 -// - non-command-line mode, FAPI call -// -/* *! COMMENTS : */ -// - All image content, incl .initf content and ring layout, is handled -// in BE format. No matter which platform. -// - A ring may only be requested with the sysPhase=0 or 1. Any other -// sysPhase value, incl sysPhase=2, will cause no rings to be found. -// -/*------------------------------------------------------------------------------*/ - -#include <p8_pore_api_custom.h> -#include <HvPlicModule.H> -#include <p8_slw_build.H> -#include <p8_xip_customize.H> -#include <p8_delta_scan_rw.h> -#include <p8_pore_table_gen_api.H> - -extern "C" { - -using namespace fapi; - -// Parameter list: -// fapi::Target &i_target: Hardware target -// void *i_imageIn: Pointer to memory mapped input Reference PNOR image -// uint32_t i_sizeImageIn: Size of input image. -// void *i_imageOut: Pointer to where to put SLW mainstore image -// uint32_t *io_sizeImageOut: Size of output image. Initial upper limit supplied by HB. Final size returned. -// -ReturnCode p8_slw_build( const fapi::Target &i_target, - const void *i_imageIn, - uint32_t i_sizeImageIn, - void *i_imageOut, - uint32_t *io_sizeImageOut) -{ - ReturnCode rc; - uint8_t l_uint8 = 0; - uint32_t ddLevel=0; - uint8_t sysPhase=1; - uint32_t rcLoc=0, rcSearch=0, i, countWF=0; - uint32_t sizeImage=0, sizeImageOutMax, sizeImageTmp, sizeImageOld; - CompressedScanData *deltaRingRS4=NULL; - DeltaRingLayout rs4RingLayout; - void *nextRing=NULL; - uint32_t ringBitLen=0; - uint32_t *wfInline=NULL; - uint32_t wfInlineLenInWords; - uint64_t scanMaxRotate=SCAN_ROTATE_DEFAULT; - sizeImageOutMax = *io_sizeImageOut; - uint32_t bootCoreMask=0x000FFFF; - - - // 2012-11-13: CMO- Temporary defines of ring buffers. This will be changed by - // Dec 03 where we'll switch over to a fixed size image for ffdc - // support and will schedule the enhancement to slw_build's - // interface to accept these buffers as well as to ditch - // io_sizeImageOut. We also should drop i_sizeImageIn. It really - // serves no purpose to require caller to pass this when we can - // immediately retrieve through xip_image_size(). - // CMO- Very important. Stop freeing buffers, incl wfInline, once - // these buffers are being passed as parms by slw_build(). - void *buf1=NULL, *buf2=NULL; - uint32_t sizeBuf1=0, sizeBuf2=0; - uint32_t rcTmp=1; - sizeBuf1 = FIXED_RING_BUF_SIZE; - buf1 = malloc(sizeBuf1); - if (!buf1) { - FAPI_ERR("malloc() for ring buffer 1 failed."); - uint32_t & RC_LOCAL = rcTmp; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MEMORY_ERROR); - return rc; - } - sizeBuf2 = FIXED_RING_BUF_SIZE; - buf2 = malloc(sizeBuf2); - if (!buf2) { - FAPI_ERR("malloc() for ring buffer 1 failed."); - uint32_t & RC_LOCAL = rcTmp; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MEMORY_ERROR); - free(buf1); - return rc; - } - - - // Sanity check. - if (sizeImageOutMax<i_sizeImageIn) { - FAPI_ERR("Inp image size (from caller): %i",i_sizeImageIn); - FAPI_ERR("Max image size (from caller): %i",*io_sizeImageOut); - uint32_t & DATA_IMG_SIZE_INP = i_sizeImageIn; - uint32_t & DATA_IMG_SIZE_MAX = *io_sizeImageOut; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_INPUT_IMAGE_SIZE_MESS); - return rc; - } - - // ========================================================================== - // Check and copy image to mainstore and clean it up. - // ========================================================================== - // ToDo: - // - Eventually, automate emptying sections in proper order (last section goes first). - // - For 5/15, assume following order of removal: rings, pibmem0, and halt. - // - // First, check supplied size and validation of input EPROM image. - // - sbe_xip_image_size((void*)i_imageIn, &sizeImage); - rcLoc = sbe_xip_validate((void*)i_imageIn, sizeImage); - if (rcLoc) { - FAPI_ERR("xip_validate() failed w/rcLoc=%i",rcLoc); - uint32_t & RC_LOCAL = rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_INTERNAL_IMAGE_ERR); - return rc; - } - if (sizeImage!=i_sizeImageIn) { - FAPI_ERR("Size obtained from image's header (=%i) differs from supplied size (=%i).", - sizeImage,i_sizeImageIn); - uint32_t & DATA_IMG_SIZE_INP = i_sizeImageIn; - uint32_t & DATA_IMG_SIZE = sizeImage; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_IMAGE_SIZE_MISMATCH); - return rc; - } - FAPI_DBG("Image size (in EPROM): %i",i_sizeImageIn); - - // Second, copy input image to supplied mainstore location. - // - memcpy( i_imageOut, i_imageIn, i_sizeImageIn); - sbe_xip_image_size(i_imageOut, &sizeImage); - rcLoc = sbe_xip_validate(i_imageOut, sizeImage); - if (rcLoc) { - FAPI_ERR("xip_validate() failed w/rcLoc=%i",rcLoc); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MS_INTERNAL_IMAGE_ERR); - return rc; - } - if (sizeImage!=i_sizeImageIn) { - FAPI_ERR("Size obtained from image's header (=%i) differs from supplied size (=%i).", - sizeImage,i_sizeImageIn); - uint32_t & DATA_IMG_SIZE_INP = i_sizeImageIn; - uint32_t & DATA_IMG_SIZE = sizeImage; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MS_IMAGE_SIZE_MISMATCH); - return rc; - } - - // Third, delete .dcrings, .rings and .pibmem0 sections (but keep .halt) - // - rcLoc = sbe_xip_delete_section( i_imageOut, SBE_XIP_SECTION_DCRINGS); - if (rcLoc) { - FAPI_ERR("xip_delete_section(.dcrings) failed w/rcLoc=%i",rcLoc); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_DELETE_IMAGE_SECTION_ERROR); - return rc; - } - sbe_xip_image_size(i_imageOut, &sizeImage); - rcLoc = sbe_xip_validate(i_imageOut, sizeImage); - if (rcLoc) { - FAPI_ERR("xip_validate() failed w/rcLoc=%i",rcLoc); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MS_INTERNAL_IMAGE_ERR); - return rc; - } - FAPI_DBG("Image size (after .dcrings delete): %i",sizeImage); - - rcLoc = sbe_xip_delete_section( i_imageOut, SBE_XIP_SECTION_RINGS); - if (rcLoc) { - FAPI_ERR("xip_delete_section(.rings) failed w/rcLoc=%i",rcLoc); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_DELETE_IMAGE_SECTION_ERROR); - return rc; - } - sbe_xip_image_size(i_imageOut, &sizeImage); - rcLoc = sbe_xip_validate(i_imageOut, sizeImage); - if (rcLoc) { - FAPI_ERR("xip_validate() failed w/rcLoc=%i",rcLoc); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MS_INTERNAL_IMAGE_ERR); - return rc; - } - FAPI_DBG("Image size (after .rings delete): %i",sizeImage); - - rcLoc = sbe_xip_delete_section( i_imageOut, SBE_XIP_SECTION_PIBMEM0); - if (rcLoc) { - FAPI_ERR("xip_delete_section(.pibmem0) failed w/rcLoc=%i",rcLoc); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_DELETE_IMAGE_SECTION_ERROR); - return rc; - } - sbe_xip_image_size(i_imageOut, &sizeImage); - rcLoc = sbe_xip_validate(i_imageOut, sizeImage); - if (rcLoc) { - FAPI_ERR("xip_validate() failed w/rcLoc=%i",rcLoc); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MS_INTERNAL_IMAGE_ERR); - return rc; - } - FAPI_DBG("Image size (after .pibmem0 delete): %i",sizeImage); - - // - // DD level. - // - rc = FAPI_ATTR_GET_PRIVILEGED(ATTR_EC, &i_target, l_uint8); - ddLevel = (uint32_t)l_uint8; - if (rc) { - FAPI_ERR("FAPI_ATTR_GET_PRIVILEGED() failed w/rc=%i and ddLevel=0x%02x",(uint32_t)rc,l_uint8); - return rc; - } - - -#ifndef IMGBUILD_PPD_IGNORE_XIPC - // ========================================================================== - // Get various FAPI attributes and variables needed for ring unraveling. - // ========================================================================== - uint8_t attrAsyncSafeMode=0, bAsyncSafeMode; - uint32_t attrFuncL3RingList[MAX_FUNC_L3_RING_LIST_ENTRIES]={0}; - uint8_t attrFuncL3RingData[MAX_FUNC_L3_RING_SIZE]={0}; - uint32_t attrFuncL3RingLength=0; - SbeXipItem xipTocItem; - uint64_t xipFuncL3RingVector=0; - uint32_t iEntry; - - // Safe mode status. - // - rc = FAPI_ATTR_GET(ATTR_PROC_FABRIC_ASYNC_SAFE_MODE, NULL, attrAsyncSafeMode); - FAPI_DBG("--> attrAsyncSafeMode = 0x%x ",attrAsyncSafeMode); - if (rc) { - FAPI_ERR("FAPI_ATTR_GET(ATTR_PROC_FABRIC_ASYNC_SAFE_MODE) returned error."); - return rc; - } - bAsyncSafeMode = attrAsyncSafeMode; - FAPI_DBG("--> bAsyncSafeMode = 0x%x ",bAsyncSafeMode); - - // Obtain ex_func_l3_ring overlay data and length from attributes. - // Obtain ring name and ring's vector location from image. - // - FAPI_DBG("--> (1) Check if we should modify the ex_func_l3_ring with attribute data."); - if (!bAsyncSafeMode) { - FAPI_DBG("--> (1) Yes, we should modify the ex_func_l3_ring with attribute data."); - // Get overlay ring from attributes. - rc = FAPI_ATTR_GET(ATTR_PROC_EX_FUNC_L3_DELTA_DATA, &i_target, attrFuncL3RingList); - if (rc) { - FAPI_ERR("FAPI_ATTR_GET(ATTR_PROC_EX_FUNC_L3_DELTA_DATA) returned error."); - return rc; - } - rc = FAPI_ATTR_GET(ATTR_PROC_EX_FUNC_L3_LENGTH, &i_target, attrFuncL3RingLength); - if (rc) { - FAPI_ERR("FAPI_ATTR_GET(ATTR_PROC_EX_FUNC_L3_LENGTH) returned error."); - return rc; - } - //attrFuncL3RingLength = 0xBEBA; - for (iEntry=0; iEntry<MAX_FUNC_L3_RING_LIST_ENTRIES; iEntry++) { - if (attrFuncL3RingList[iEntry]!=0xffff0000) { - attrFuncL3RingData[attrFuncL3RingList[iEntry]>>16] = (uint8_t)((attrFuncL3RingList[iEntry]<<24)>>24); - } - else - break; - } - FAPI_DBG("Overlay [raw] ring created for func L3 ring."); - // Get ring name from xip image. - rcLoc = sbe_xip_find((void*)i_imageIn, FUNC_L3_RING_TOC_NAME, &xipTocItem); - if (rcLoc) { - FAPI_ERR("sbe_xip_find() failed w/rc=%i", rcLoc); - FAPI_ERR("Probable cause:"); - FAPI_ERR("\tThe keyword (=%s) was not found.", FUNC_L3_RING_TOC_NAME); - uint32_t & RC_LOCAL = rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_KEYWORD_NOT_FOUND_ERROR); - return rc; - } - xipFuncL3RingVector = xipTocItem.iv_address; - } -#endif - - - /*************************************************************************** - * SEARCH LOOP - Begin * - ***************************************************************************/ - do { - - FAPI_DBG("nextRing (at top)=0x%016llx",(uint64_t)nextRing); - - - // ========================================================================== - // Get ring layout from image - // ========================================================================== - FAPI_DBG("--> Reading RS4 delta ring info from SBE-XIP Image."); - rcLoc = get_ring_layout_from_image( i_imageIn, - ddLevel, - sysPhase, - &rs4RingLayout, - &nextRing); - rcSearch = rcLoc; - if (rcSearch!=DSLWB_RING_SEARCH_MATCH && - rcSearch!=DSLWB_RING_SEARCH_EXHAUST_MATCH && - rcSearch!=DSLWB_RING_SEARCH_NO_MATCH) { - FAPI_ERR("\tGetting delta ring from image was unsuccessful (rcSearch=%i).",rcSearch); - FAPI_ERR("\tNo wiggle-flip programs will be stored in .rings section."); - FAPI_ERR("\tThe following ELF sections have been emptied: .rings, .pibmem0, .ipl_text."); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_RING_RETRIEVAL_ERROR); - return rc; - } - if (rcSearch==DSLWB_RING_SEARCH_MATCH || - rcSearch==DSLWB_RING_SEARCH_EXHAUST_MATCH) - FAPI_DBG("\tRetrieving RS4 delta ring was successful."); - - // Check if we're done at this point. - // - if (rcSearch==DSLWB_RING_SEARCH_NO_MATCH) { - FAPI_INF("Wiggle-flip programming done."); - FAPI_INF("Number of wf programs appended: %i", countWF); - if (countWF==0) - FAPI_INF("ZERO WF programs appended to .rings section."); -#ifndef IMGBUILD_PPD_IGNORE_XIPC - // Do various customizations to image. - if (!buf1 || !buf2) { - FAPI_ERR("The [assumed] pre-allocated ring buffers, buf1/2, do not exist.\n"); - uint32_t & RC_LOCAL = rcTmp; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MEMORY_ERROR); - return rc; - } - sizeImageTmp = sizeImageOutMax; - FAPI_INF("Calling xip_customize().\n"); - FAPI_EXEC_HWP(rc, p8_xip_customize, - i_target, - (void*)i_imageIn, - i_imageOut, - sizeImageTmp, - sysPhase, - 2, // We're only interested in SRAM mode for non-fixed img. - buf1, - sizeBuf1, - buf2, - sizeBuf2, - bootCoreMask); - free(buf1); - free(buf2); - buf1 = buf2 = NULL; - if (rc!=FAPI_RC_SUCCESS) { - FAPI_ERR("Xip customization failed."); - return rc; - } - FAPI_INF("Xip customization done."); -#else - // Initialize .slw section with PORE table. - sizeImageTmp = sizeImageOutMax; - rcLoc = initialize_slw_section( i_imageOut, - &sizeImageTmp); - if (rcLoc) { - if (rcLoc==IMGBUILD_ERR_IMAGE_TOO_LARGE) { - uint32_t & DATA_IMG_SIZE_OLD=sizeImageOld; - uint32_t & DATA_IMG_SIZE_EST=sizeImageTmp; - uint32_t & DATA_IMG_SIZE_MAX=sizeImageOutMax; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MAX_IMAGE_SIZE_EXCEEDED); - } - else { - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_APPEND_SLW_SECTION_ERROR); - } - return rc; - } - FAPI_INF("SLW section allocated for Ramming and Scomming tables."); -#endif - - // Update host_runtime_scom pointer to point to sub_slw_runtime_scom - rcLoc = update_runtime_scom_pointer( i_imageOut); - if (rcLoc==IMGBUILD_ERR_KEYWORD_NOT_FOUND) { - uint32_t &RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_KEYWORD_NOT_FOUND_ERROR); - return rc; - } - // Report final size. - sbe_xip_image_size( i_imageOut, io_sizeImageOut); - FAPI_INF("Final SLW image size: %i", *io_sizeImageOut); - return FAPI_RC_SUCCESS; - } - - deltaRingRS4 = (CompressedScanData*)rs4RingLayout.rs4Delta; - - FAPI_DBG("Dumping ring layout:"); - FAPI_DBG("\tentryOffset = %i",(uint32_t)myRev64(rs4RingLayout.entryOffset)); - FAPI_DBG("\tbackItemPtr = 0x%016llx",myRev64(rs4RingLayout.backItemPtr)); - FAPI_DBG("\tsizeOfThis = %i",myRev32(rs4RingLayout.sizeOfThis)); - FAPI_DBG("\tsizeOfMeta = %i",myRev32(rs4RingLayout.sizeOfMeta)); - FAPI_DBG("\tddLevel = %i",myRev32(rs4RingLayout.ddLevel)); - FAPI_DBG("\tsysPhase = %i",rs4RingLayout.sysPhase); - FAPI_DBG("\toverride = %i",rs4RingLayout.override); - FAPI_DBG("\treserved1+2 = %i",rs4RingLayout.reserved1|rs4RingLayout.reserved2); - FAPI_DBG("\tRS4 magic # = 0x%08x",myRev32(deltaRingRS4->iv_magic)); - FAPI_DBG("\tRS4 total size = %i",myRev32(deltaRingRS4->iv_size)); - FAPI_DBG("\tUnXed data size = %i",myRev32(deltaRingRS4->iv_length)); - FAPI_DBG("\tScan select = 0x%08x",myRev32(deltaRingRS4->iv_scanSelect)); - FAPI_DBG("\tHeader version = 0x%02x",deltaRingRS4->iv_headerVersion); - FAPI_DBG("\tFlush optimize = 0x%02x (reverse of override)",deltaRingRS4->iv_flushOptimization); - FAPI_DBG("\tRing ID = 0x%02x",deltaRingRS4->iv_ringId); - FAPI_DBG("\tChiplet ID = 0x%02x",deltaRingRS4->iv_chipletId); - FAPI_DBG("Dumping meta data:"); - FAPI_DBG("\tsizeOfData = %i",myRev32(rs4RingLayout.sizeOfMeta)); - FAPI_DBG("\tMeta data = "); - for (i=0; i<myRev32(rs4RingLayout.sizeOfMeta); i++) { // String may not be null terminated. - FAPI_DBG("%c",rs4RingLayout.metaData[i]); - } - - - // ========================================================================== - // Decompress RS4 delta state. - // ========================================================================== - FAPI_DBG("--> Decompressing RS4 delta ring."); - rcLoc = _rs4_decompress((uint8_t*)buf2, - sizeBuf2, - &ringBitLen, - deltaRingRS4); - if (rcLoc) { - FAPI_ERR("\t_rs4_decompress() failed: rc=%i",rcLoc); - if (buf2) free(buf2); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_RS4_DECOMPRESSION_ERROR); - return rc; - } - FAPI_DBG("\tDecompression successful.\n"); - - -#ifndef IMGBUILD_PPD_IGNORE_XIPC - // ========================================================================== - // CUSTOMIZE item: Overlay ex_func_l3_ring. - // Retrieval method: Attribute. - // Note: Check if ex_func_l3_ring's vector address matches current backPtr. - // If so, perform OR operation with new attribute data for this ring. - // Assumptions: - // - Base ring only. - // - Correct DD level rings only. - // ========================================================================== - uint8_t byteExisting=0, byteOverlay=0, bGoodByte=1; - uint32_t iByte, sizeRingInBytes; - FAPI_DBG("--> (2) Check if we should modify the ex_func_l3_ring with attribute data."); - if (!bAsyncSafeMode) { - FAPI_DBG("--> (2) Yes, we should modify the ex_func_l3_ring with attribute data."); - // Find ring match by comparing backItemPtr and ring lengths. Note that - // we can't use fwdPtr for finding a match since we don't know which DD - // level ring it ended up pointing at. - if (xipFuncL3RingVector==myRev64(rs4RingLayout.backItemPtr) && - attrFuncL3RingLength==myRev32(deltaRingRS4->iv_length)) { - // Perform OR between the existing ring and attribute ring. - sizeRingInBytes = (attrFuncL3RingLength-1)/8 + 1; - bGoodByte = 1; -//// FAPI_DBG("Byte[ # ]: ER OR FR "); - FAPI_DBG("Byte[ # ]: ER OR =ER? "); - FAPI_DBG("-----------------------"); - for (iByte=0; (iByte<sizeRingInBytes && bGoodByte); iByte++) { -//// FAPI_DBG("Byte[%4i]: %02x ", -//// iByte, -//// *((uint8_t*)buf2+iByte)); - if (*(attrFuncL3RingData+iByte)) { - // Check there are 0-bits in the existing byte where there are - // 1-bits in the overlay byte. - byteExisting = *((uint8_t*)buf2+iByte); - byteOverlay = *(&attrFuncL3RingData[0]+iByte); - if (byteExisting!=(byteExisting & ~byteOverlay)) { - FAPI_ERR("Byte[%4i]: %02x %02x %02x <-violation",iByte,byteExisting,byteOverlay,byteExisting&~byteOverlay); - bGoodByte = 0; - break; - } - else { - FAPI_DBG("Byte[%4i]: %02x %02x %02x ",iByte,byteExisting,byteOverlay,byteExisting&~byteOverlay); - } - // Only update existing ring when there's content in overlay data. -//// FAPI_DBG("Byte[%4i]: %02x %02x %02x ", -//// iByte, -//// *((uint8_t*)buf2+iByte), -//// *(&attrFuncL3RingData[0]+iByte), -//// *((uint8_t*)buf2+iByte) | *(&attrFuncL3RingData[0]+iByte)); - *((uint8_t*)buf2+iByte) = byteExisting | byteOverlay; -//// FAPI_DBG("Byte[%4i]: %02x ", -//// iByte, -//// *((uint8_t*)buf2+iByte)); - } -//// FAPI_DBG("Byte[%4i]: %02x ", -//// iByte, -//// *((uint8_t*)buf2+iByte)); - } - FAPI_DBG("-----------------------"); - if (!bGoodByte) { - FAPI_ERR("The existing ex_l3_func_ring has 1-bits in overlay locations. "); - if (buf2) free(buf2); - uint32_t & DATA_FAIL_BYTE_NO = iByte; - uint8_t & DATA_EXISTING_RING_BYTE = byteExisting; - uint8_t & DATA_OVERLAY_RING_BYTE = byteOverlay; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_L3_FUNC_OVERLAY_ERROR); - return rc; - } - } - } -#endif - - - // ========================================================================== - // Create Wiggle-Flip Programs (but first resolve max rotate status.) - // ========================================================================== - FAPI_DBG("--> Creating Wiggle-Flip Program."); - rcLoc = sbe_xip_get_scalar( (void*)i_imageIn, SCAN_MAX_ROTATE_38XXX_NAME, &scanMaxRotate); - if (rcLoc) { - FAPI_INF("WARNING: sbe_xip_get_scalar() failed...but we might wing it."); - if (rcLoc==SBE_XIP_ITEM_NOT_FOUND) { - FAPI_INF("Probable cause:"); - FAPI_INF("\tThe key word in SCAN_MAX_ROTATE_38XXX_NAME does not exist the TOC."); - scanMaxRotate = SCAN_ROTATE_DEFAULT; - FAPI_INF("\tscanMaxRotate set to 0x%llx", scanMaxRotate); - FAPI_INF("Continuing..."); - } - else { - FAPI_ERR("ERROR: Nope, couldn't wing it."); - if (buf2) free(buf2); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_UNKNOWN_XIP_ERROR); - return rc; - } - } - if (scanMaxRotate<0x20 || scanMaxRotate>SCAN_MAX_ROTATE) { - FAPI_INF("WARNING: Value of key word SCAN_MAX_ROTATE_38XXX_NAME=0x%llx is not permitted.\n",scanMaxRotate); - scanMaxRotate = SCAN_ROTATE_DEFAULT; - FAPI_INF("\tscanMaxRotate set to 0x%llx\n", scanMaxRotate); - FAPI_INF("Continuing...\n"); - } - - // Support for enforcing delay after WF scan write scoms. - uint64_t waitsScanDelay=10; - rcLoc = sbe_xip_get_scalar( (void*)i_imageIn, "waits_delay_for_scan", &waitsScanDelay); - if (rcLoc) { - FAPI_ERR("Error obtaining waits_delay_for_scan keyword.\n"); - if (buf2) free(buf2); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_UNKNOWN_XIP_ERROR); - return rc; - } - - wfInline = (uint32_t*)buf1; - wfInlineLenInWords = sizeBuf1/4; - rcLoc = create_wiggle_flip_prg( (uint32_t*)buf2, - ringBitLen, - myRev32(deltaRingRS4->iv_scanSelect), - (uint32_t)deltaRingRS4->iv_chipletId, - &wfInline, - &wfInlineLenInWords, - deltaRingRS4->iv_flushOptimization, - (uint32_t)scanMaxRotate, - (uint32_t)waitsScanDelay); - if (rcLoc) { - FAPI_ERR("create_wiggle_flip_prg() failed w/rcLoc=%i",rcLoc); - //if (deltaRingDxed) free(deltaRingDxed); - if (buf1) free(buf1); - if (buf2) free(buf2); - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_WF_CREATION_ERROR); - return rc; - } - FAPI_DBG("\tWiggle-flip programming successful."); - - - // ========================================================================== - // Append Wiggle-Flip programs to .rings section. - // ========================================================================== - FAPI_DBG("--> Appending wiggle-flip and layout header to .rings section."); - sizeImageTmp = sizeImageOutMax; - rcLoc = write_wiggle_flip_to_image( i_imageOut, - &sizeImageTmp, - &rs4RingLayout, - wfInline, - wfInlineLenInWords); - if (rcLoc) { - FAPI_ERR("write_wiggle_flip_to_image() failed w/rcLoc=%i",rcLoc); - //if (deltaRingDxed) free(deltaRingDxed); - if (buf1) free(buf1); - if (buf2) free(buf2); - if (rcLoc==IMGBUILD_ERR_IMAGE_TOO_LARGE) { - uint32_t & DATA_IMG_SIZE_OLD=sizeImageOld; - uint32_t & DATA_IMG_SIZE_EST=sizeImageTmp; - uint32_t & DATA_IMG_SIZE_MAX=sizeImageOutMax; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MAX_IMAGE_SIZE_EXCEEDED); - } - else { - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_IMAGE_UPDATE_ERROR); - } - return rc; - } - FAPI_DBG("\tUpdating image w/wiggle-flip program + header was successful."); - - // Update some variables for debugging and error reporting. - sizeImageOld = sizeImageTmp; - countWF++; - - // ========================================================================== - // Are we done? - // ========================================================================== - if (rcSearch==DSLWB_RING_SEARCH_EXHAUST_MATCH) { - FAPI_INF("Wiggle-flip programming done."); - FAPI_INF("Number of wf programs appended: %i", countWF); - if (countWF==0) - FAPI_INF("ZERO WF programs appended to .rings section."); -#ifndef IMGBUILD_PPD_IGNORE_XIPC - // Do various customizations to image. - if (!buf1 || !buf2) { - FAPI_ERR("The [assumed] pre-allocated ring buffers, buf1/2, do not exist.\n"); - uint32_t & RC_LOCAL = rcTmp; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MEMORY_ERROR); - return rc; - } - sizeImageTmp = sizeImageOutMax; - FAPI_INF("Calling xip_customize().\n"); - FAPI_EXEC_HWP(rc, p8_xip_customize, - i_target, - (void*)i_imageIn, - i_imageOut, - sizeImageTmp, - sysPhase, - 2, // We're only interested in SRAM mode for non-fixed img. - buf1, - sizeBuf1, - buf2, - sizeBuf2, - bootCoreMask); - free(buf1); - free(buf2); - buf1 = buf2 = NULL; - if (rc!=FAPI_RC_SUCCESS) { - FAPI_ERR("Xip customization failed."); - return rc; - } - FAPI_INF("Xip customization done."); -#else - // Initialize .slw section with PORE table. - sizeImageTmp = sizeImageOutMax; - rcLoc = initialize_slw_section( i_imageOut, - &sizeImageTmp); - if (rcLoc) { - if (rcLoc==IMGBUILD_ERR_IMAGE_TOO_LARGE) { - uint32_t & DATA_IMG_SIZE_OLD=sizeImageOld; - uint32_t & DATA_IMG_SIZE_EST=sizeImageTmp; - uint32_t & DATA_IMG_SIZE_MAX=sizeImageOutMax; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MAX_IMAGE_SIZE_EXCEEDED); - } - else { - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_APPEND_SLW_SECTION_ERROR); - } - return rc; - } - FAPI_INF("SLW section initialized for Ramming and Scomming tables."); -#endif - - // Update host_runtime_scom pointer to point to sub_slw_runtime_scom - rcLoc = update_runtime_scom_pointer(i_imageOut); - if (rcLoc==IMGBUILD_ERR_KEYWORD_NOT_FOUND) { - uint32_t &RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_KEYWORD_NOT_FOUND_ERROR); - return rc; - } - - // Report final size. - sbe_xip_image_size( i_imageOut, io_sizeImageOut); - FAPI_INF("Final SLW image size: %i", *io_sizeImageOut); - return FAPI_RC_SUCCESS; - } - - FAPI_DBG("nextRing (at bottom)=0x%016llx",(uint64_t)nextRing); - - } while (nextRing!=NULL); - /*************************************************************************** - * SEARCH LOOP - End * - ***************************************************************************/ - - FAPI_ERR("Shouldn't be in this code section. Check code."); - rcLoc = IMGBUILD_ERR_CHECK_CODE; - uint32_t & RC_LOCAL=rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_UNKNOWN_ERROR); - return rc; - -} - -} // End of extern C diff --git a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build.H b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build.H index 831c51d46..3e202686e 100644 --- a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build.H +++ b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build.H @@ -20,35 +20,36 @@ /* Origin: 30 */ /* */ /* IBM_PROLOG_END_TAG */ -// $Id: p8_slw_build.H,v 1.4 2013/02/12 23:25:58 cmolsen Exp $ + +// $Id: p8_slw_build.H,v 1.4 2013-02-12 23:25:58 cmolsen Exp $ #include <fapi.H> #include <p8_scan_compression.H> typedef fapi::ReturnCode (*p8_slw_build_FP_t) ( const fapi::Target&, - const void*, - uint32_t, - void*, - uint32_t*); + const void*, + uint32_t, + void*, + uint32_t*); typedef fapi::ReturnCode (*p8_slw_build_fixed_FP_t) ( const fapi::Target&, - void*, - void*, - uint32_t&, - const uint8_t, - void*, - const uint32_t, - void*, - const uint32_t ); + void*, + void*, + uint32_t&, + const uint8_t, + void*, + const uint32_t, + void*, + const uint32_t ); typedef fapi::ReturnCode (*p8_slw_repair_FP_t) (const fapi::Target&, - void*, - CompressedScanData*, - void*, - const uint32_t, - void*, - const uint32_t); + void*, + CompressedScanData*, + void*, + const uint32_t, + void*, + const uint32_t); extern "C" @@ -63,11 +64,11 @@ extern "C" // mainstore. // *io_sizeImageOut: On input, upper limit of size of output // image. On output, final size of output image. - fapi::ReturnCode p8_slw_build( const fapi::Target &i_target, - const void *i_imageIn, - uint32_t i_sizeImageIn, - void *i_imageOut, - uint32_t *io_sizeImageOut); + fapi::ReturnCode p8_slw_build( const fapi::Target &i_target, + const void *i_imageIn, + uint32_t i_sizeImageIn, + void *i_imageOut, + uint32_t *io_sizeImageOut); // Description: FAPI HWP entry point. p8_slw_build_fixed() constructs the @@ -86,15 +87,15 @@ extern "C" // *i_buf2: Temp buffer 2 for WF ring. (Caller // allocs/frees.) // i_sizeBuf2: Size of buf2. - fapi::ReturnCode p8_slw_build_fixed( const fapi::Target &i_target, - void *i_imageIn, - void *i_imageOut, - uint32_t &io_sizeImageOut, - const uint8_t i_modeBuild, - void *i_buf1, - const uint32_t i_sizeBuf1, - void *i_buf2, - const uint32_t i_sizeBuf2 ); + fapi::ReturnCode p8_slw_build_fixed( const fapi::Target &i_target, + void *i_imageIn, + void *i_imageOut, + uint32_t &io_sizeImageOut, + const uint8_t i_modeBuild, + void *i_buf1, + const uint32_t i_sizeBuf1, + void *i_buf2, + const uint32_t i_sizeBuf2 ); // Description: FAPI HWP entry point. p8_slw_repair() updates the L2 (core) @@ -108,12 +109,12 @@ extern "C" // *i_buf2: Temp buffer 2 for WF ring. (Caller // allocs/frees.) // i_sizeBuf2: Size of buf2. - fapi::ReturnCode p8_slw_repair( const fapi::Target &i_target, - void *io_image, - CompressedScanData *i_bufRs4, - void *i_buf1, - const uint32_t i_sizeBuf1, - void *i_buf2, - const uint32_t i_sizeBuf2); + fapi::ReturnCode p8_slw_repair( const fapi::Target &i_target, + void *io_image, + CompressedScanData *i_bufRs4, + void *i_buf1, + const uint32_t i_sizeBuf1, + void *i_buf2, + const uint32_t i_sizeBuf2); } diff --git a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build_errors.xml b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build_errors.xml index 5acb92c56..5748ef689 100644 --- a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build_errors.xml +++ b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build_errors.xml @@ -20,6 +20,7 @@ <!-- Origin: 30 --> <!-- --> <!-- IBM_PROLOG_END_TAG --> +<!-- $Id: p8_slw_build_errors.xml,v 1.8 2013-04-23 22:47:26 wenning Exp $ --> <!-- Error definitions for proc_slw_build procedure --> <hwpErrors> <!-- *********************************************************************** --> @@ -31,8 +32,15 @@ </hwpError> <!-- *********************************************************************** --> <hwpError> + <rc>RC_PROC_SLWB_IMG_PTR_ERROR</rc> + <description>Supplied image ptrs are the same. This is not allowed.</description> + <ffdc>DATA_BUF1_PTR</ffdc> + <ffdc>DATA_BUF2_PTR</ffdc> + </hwpError> + <!-- *********************************************************************** --> + <hwpError> <rc>RC_PROC_SLWB_BUF_PTR_ERROR</rc> - <description>Supplied buffer(s) is invalid.</description> + <description>Supplied buffer(s) is invalid. Either it (they) does not exist or they are the same. This is not allowed.</description> <ffdc>DATA_BUF1_PTR</ffdc> <ffdc>DATA_BUF2_PTR</ffdc> </hwpError> diff --git a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build_fixed.C b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build_fixed.C new file mode 100644 index 000000000..721756a91 --- /dev/null +++ b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build_fixed.C @@ -0,0 +1,768 @@ +/* IBM_PROLOG_BEGIN_TAG */ +/* This is an automatically generated prolog. */ +/* */ +/* $Source: src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_slw_build_fixed.C $ */ +/* */ +/* IBM CONFIDENTIAL */ +/* */ +/* COPYRIGHT International Business Machines Corp. 2013 */ +/* */ +/* p1 */ +/* */ +/* Object Code Only (OCO) source materials */ +/* Licensed Internal Code Source Materials */ +/* IBM HostBoot Licensed Internal Code */ +/* */ +/* The source code for this program is not published or otherwise */ +/* divested of its trade secrets, irrespective of what has been */ +/* deposited with the U.S. Copyright Office. */ +/* */ +/* Origin: 30 */ +/* */ +/* IBM_PROLOG_END_TAG */ +// $Id: p8_slw_build_fixed.C,v 1.16 2013/07/25 15:50:47 dcrowell Exp $ +/*------------------------------------------------------------------------------*/ +/* *! TITLE : p8_slw_build_fixed */ +/* *! DESCRIPTION : Extracts and decompresses delta ring states from EPROM */ +// image. Utilizes the linked list approach (LLA) to extract +// and position wiggle-flip programs in .rings according to +// back pointer, DD level, phase and override settings. +/* *! OWNER NAME : Michael Olsen cmolsen@us.ibm.com */ +// +/* *! EXTENDED DESCRIPTION : */ +// +/* *! USAGE : To build (for Hostboot) - */ +// buildfapiprcd -C "p8_image_help.C,p8_image_help_base.C,p8_scan_compression.C" -c "sbe_xip_image.c,pore_inline_assembler.c" -e "../../xml/error_info/p8_slw_build_errors.xml" p8_slw_build_fixed.C +// To build (for command-line) - +// buildfapiprcd -r ver-13-0 -C "p8_image_help.C,p8_image_help_base.C,p8_scan_compression.C" -c "sbe_xip_image.c,pore_inline_assembler.c" -e "../../xml/error_info/p8_slw_build_errors.xml" -u "SLW_COMMAND_LINE,IMGBUILD_PPD_IGNORE_XIPC" p8_slw_build_fixed.C +// Other Pre-Processor Directive (PPD) options - +// To add worst-case PIB access to wf programs: +// -u "IMGBUILD_PPD_WF_WORST_CASE_PIB" +// To add polling protocol to wf programs: +// -u "IMGBUILD_PPD_WF_POLLING_PROT" +// To NOT run xip_customize: +// -u "IMGBUILD_PPD_IGNORE_XIPC" +// +/* *! ASSUMPTIONS : */ +// +/* *! COMMENTS : */ +// - All image content, incl .rings content and ring layout, is handled +// in BE format. No matter which platform. +// - A ring may only be requested with the sysPhase=0 or 1. Any other +// sysPhase value, incl sysPhase=2, will cause no rings to be found. +// - io_sizeImageOut may only change value for SRAM mode 2. For modes 0 and 1, +// it should be the agreed upon fixed SLW image size of 1MB. +// +/*------------------------------------------------------------------------------*/ + +#include <p8_pore_api_custom.h> +#include <p8_slw_build.H> +#include <p8_xip_customize.H> +#include <p8_delta_scan_rw.h> +#include <p8_pore_table_gen_api.H> + +extern "C" { + +using namespace fapi; + +// Parameter list: +// fapi::Target &i_target: Hardware target +// void *i_imageIn: Pointer to memory mapped input Reference PNOR image +// void *i_imageOut: Pointer to where to put SLW mainstore image +// uint32_t &io_sizeImageOut: In: Max size of outp img. Out: Final size of outp img. +// On input, this MUST be equal to FIXED_SLW_IMAGE_SIZE for +// i_modeBuild={0,1}. +// uint8_t i_modeBuild: 0: HB/IPL mode, 1: PHYP/Rebuild mode, 2: SRAM mode. +// void *i_buf1: Temp buffer 1 for dexed RS4 ring. (Caller allocs/frees.) +// uint32_t i_sizeBuf1: Size of buf1. +// This MUST be equal to FIXED_RING_BUF_SIZE. +// void *i_buf2: Temp buffer 2 for WF ring. (Caller allocs/frees.) +// uint32_t i_sizeBuf22 Size of buf2. +// This MUST be equal to FIXED_RING_BUF_SIZE. +// +ReturnCode p8_slw_build_fixed( const fapi::Target &i_target, + void *i_imageIn, + void *i_imageOut, + uint32_t &io_sizeImageOut, + const uint8_t i_modeBuild, + void *i_buf1, + const uint32_t i_sizeBuf1, + void *i_buf2, + const uint32_t i_sizeBuf2 ) +{ + ReturnCode rc; + uint8_t l_uint8=0; + uint8_t bSearchDone=0; + uint32_t ddLevel=0; + uint8_t sysPhase=1; // SLW image build phase. + uint32_t rcLoc=0, rcSearch=0, i, countWF=0; + uint32_t sizeImage=0, sizeImageIn=0, sizeImageOutMax, sizeImageTmp, sizeImageOld; + CompressedScanData *deltaRingRS4=NULL; + DeltaRingLayout rs4RingLayout; + void *nextRing=NULL; + uint32_t ringBitLen=0; + uint32_t *wfInline=NULL; + uint32_t wfInlineLenInWords; + uint64_t scanMaxRotate=SCAN_ROTATE_DEFAULT; + uint32_t dataTmp1, dataTmp2, dataTmp3; + uint64_t ptrTmp1, ptrTmp2; + uint32_t bufLC; + uint32_t bootCoreMask=0x000FFFF; + + // Sanity checks on buffers and image. + // - validate image. + // - do pre-allocated buffers exist? + // - are pre-allocated buffers the correct size? + // - is supplied output image size the correct size? + // - is input image smaller than the output image size? + // - is modeBuild valid? + // + sbe_xip_image_size((void*)i_imageIn, &sizeImageIn); + rcLoc = sbe_xip_validate((void*)i_imageIn, sizeImageIn); + if (rcLoc) { + FAPI_ERR("xip_validate() failed w/rcLoc=%i",rcLoc); + uint32_t & RC_LOCAL = rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_INTERNAL_IMAGE_ERR); + return rc; + } + if (i_imageOut==i_imageIn) { + FAPI_ERR("The images, imageIn and imageOut, point to the same buffer space."); + ptrTmp1 = (uint64_t)i_imageIn; + ptrTmp2 = (uint64_t)i_imageOut; + uint64_t & DATA_BUF1_PTR = ptrTmp1; + uint64_t & DATA_BUF2_PTR = ptrTmp2; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_IMG_PTR_ERROR); + return rc; + } + sizeImageOutMax = io_sizeImageOut; // This should be 1MB for mode 0 and 1. + FAPI_DBG("Mode build = %i\n",i_modeBuild); + if ((i_modeBuild==P8_SLW_MODEBUILD_IPL || + i_modeBuild==P8_SLW_MODEBUILD_REBUILD) && + sizeImageOutMax!=FIXED_SLW_IMAGE_SIZE) { + FAPI_ERR("Supplied output image size differs from agreed upon fixed SLW image size."); + FAPI_ERR("Supplied output image size: %i",sizeImageOutMax); + FAPI_ERR("Agreed upon fixed SLW image size: %i",FIXED_SLW_IMAGE_SIZE); + dataTmp1 = FIXED_SLW_IMAGE_SIZE; + uint32_t & DATA_IMG_SIZE_MAX = sizeImageOutMax; + uint32_t & DATA_IMG_SIZE_FIXED = dataTmp1; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_IMAGE_SIZE_NOT_FIXED); + return rc; + } + if ((i_modeBuild==P8_SLW_MODEBUILD_IPL || + i_modeBuild==P8_SLW_MODEBUILD_REBUILD) && + sizeImageIn>sizeImageOutMax) { + FAPI_ERR("Input image size exceeds fixed output image size."); + FAPI_ERR("Size of supplied input image: %i",sizeImageIn); + FAPI_ERR("Supplied output image size: %i",sizeImageOutMax); + uint32_t & DATA_IMG_SIZE_INP = sizeImageIn; + uint32_t & DATA_IMG_SIZE_MAX = sizeImageOutMax; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_INPUT_IMAGE_SIZE_MESS); + return rc; + } + if (!i_buf1 || !i_buf2) { + FAPI_ERR("The [assumed] pre-allocated ring buffers, i_buf1/2, do not exist."); + ptrTmp1 = (uint64_t)i_buf1; + ptrTmp2 = (uint64_t)i_buf2; + uint64_t & DATA_BUF1_PTR = ptrTmp1; + uint64_t & DATA_BUF2_PTR = ptrTmp2; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_BUF_PTR_ERROR); + return rc; + } + if (i_buf1==i_buf2) { + FAPI_ERR("The buffers, buf1 and buf2, point to the same buffer space."); + ptrTmp1 = (uint64_t)i_buf1; + ptrTmp2 = (uint64_t)i_buf2; + uint64_t & DATA_BUF1_PTR = ptrTmp1; + uint64_t & DATA_BUF2_PTR = ptrTmp2; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_BUF_PTR_ERROR); + return rc; + } + if (i_sizeBuf1!=FIXED_RING_BUF_SIZE || i_sizeBuf2!=FIXED_RING_BUF_SIZE) { + FAPI_ERR("Supplied ring buffer size(s) differs from agreed upon fixed size."); + FAPI_ERR("Supplied ring buf1 size: %i",i_sizeBuf1); + FAPI_ERR("Supplied ring buf2 size: %i",i_sizeBuf2); + FAPI_ERR("Agreed upon fixed ring buf size: %i",FIXED_RING_BUF_SIZE); + dataTmp1 = i_sizeBuf1; + dataTmp2 = i_sizeBuf2; + dataTmp3 = FIXED_RING_BUF_SIZE; + uint32_t & DATA_BUF1_SIZE = dataTmp1; + uint32_t & DATA_BUF2_SIZE = dataTmp2; + uint32_t & DATA_BUF_SIZE_FIXED = dataTmp3; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_BUF_SIZE_NOT_FIXED); + return rc; + } + if (i_modeBuild>P8_SLW_MODEBUILD_MAX_VALUE) { + FAPI_ERR("modeBuild=%i invalid. Valid range is [0;%i].", + i_modeBuild,P8_SLW_MODEBUILD_MAX_VALUE); + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_BAD_CODE_OR_PARM); + return rc; + } + FAPI_DBG("Reference/input image size: %i",sizeImageIn); + + + // ========================================================================== + // Check and copy image to mainstore and clean it up. + // ========================================================================== + // ToDo: + // - Eventually, automate emptying sections in proper order (last section goes first). + // - For 5/15, assume following order of removal: rings, pibmem0, and halt. + // + // First, copy input image to supplied mainstore location. + // + memcpy( i_imageOut, i_imageIn, sizeImageIn); + sbe_xip_image_size(i_imageOut, &sizeImage); + rcLoc = sbe_xip_validate(i_imageOut, sizeImage); + if (rcLoc) { + FAPI_ERR("xip_validate() failed w/rcLoc=%i",rcLoc); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MS_INTERNAL_IMAGE_ERR); + return rc; + } + if (sizeImage!=sizeImageIn) { + FAPI_ERR("Size obtained from copied image's header (=%i) differs from input image's size (=%i).", + sizeImage,sizeImageIn); + uint32_t & DATA_IMG_SIZE = sizeImage; + uint32_t & DATA_IMG_SIZE_INP = sizeImageIn; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MS_IMAGE_SIZE_MISMATCH); + return rc; + } + + // Second, delete .dcrings, .rings and .pibmem0 sections (but keep .halt) + // + rcLoc = sbe_xip_delete_section( i_imageOut, SBE_XIP_SECTION_DCRINGS); + if (rcLoc) { + FAPI_ERR("xip_delete_section(.dcrings) failed w/rcLoc=%i",rcLoc); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_DELETE_IMAGE_SECTION_ERROR); + return rc; + } + sbe_xip_image_size(i_imageOut, &sizeImage); + rcLoc = sbe_xip_validate(i_imageOut, sizeImage); + if (rcLoc) { + FAPI_ERR("xip_validate() failed w/rcLoc=%i",rcLoc); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MS_INTERNAL_IMAGE_ERR); + return rc; + } + FAPI_DBG("Image size (after .dcrings delete): %i",sizeImage); + + rcLoc = sbe_xip_delete_section( i_imageOut, SBE_XIP_SECTION_RINGS); + if (rcLoc) { + FAPI_ERR("xip_delete_section(.rings) failed w/rcLoc=%i",rcLoc); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_DELETE_IMAGE_SECTION_ERROR); + return rc; + } + sbe_xip_image_size(i_imageOut, &sizeImage); + rcLoc = sbe_xip_validate(i_imageOut, sizeImage); + if (rcLoc) { + FAPI_ERR("xip_validate() failed w/rcLoc=%i",rcLoc); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MS_INTERNAL_IMAGE_ERR); + return rc; + } + FAPI_DBG("Image size (after .rings delete): %i",sizeImage); + + rcLoc = sbe_xip_delete_section( i_imageOut, SBE_XIP_SECTION_PIBMEM0); + if (rcLoc) { + FAPI_ERR("xip_delete_section(.pibmem0) failed w/rcLoc=%i",rcLoc); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_DELETE_IMAGE_SECTION_ERROR); + return rc; + } + sbe_xip_image_size(i_imageOut, &sizeImage); + rcLoc = sbe_xip_validate(i_imageOut, sizeImage); + if (rcLoc) { + FAPI_ERR("xip_validate() failed w/rcLoc=%i",rcLoc); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MS_INTERNAL_IMAGE_ERR); + return rc; + } + FAPI_DBG("Image size (after .pibmem0 delete): %i",sizeImage); + + // + // DD level. + // + rc = FAPI_ATTR_GET_PRIVILEGED(ATTR_EC, &i_target, l_uint8); + ddLevel = (uint32_t)l_uint8; + if (rc) { + FAPI_ERR("FAPI_ATTR_GET_PRIVILEGED() failed w/rc=%i and ddLevel=0x%02x",(uint32_t)rc,l_uint8); + return rc; + } + + +#ifndef IMGBUILD_PPD_IGNORE_XIPC + // ========================================================================== + // Get various FAPI attributes and variables needed for ring unraveling. + // ========================================================================== + uint8_t attrAsyncSafeMode=0, bAsyncSafeMode; + uint32_t attrFuncL3RingList[MAX_FUNC_L3_RING_LIST_ENTRIES]={0}; + uint8_t attrFuncL3RingData[MAX_FUNC_L3_RING_SIZE]={0}; + uint32_t attrFuncL3RingLength=0; + SbeXipItem xipTocItem; + uint64_t xipFuncL3RingVector=0; + uint32_t iEntry; + + // Safe mode status. + // + rc = FAPI_ATTR_GET(ATTR_PROC_FABRIC_ASYNC_SAFE_MODE, NULL, attrAsyncSafeMode); + if (rc) { + FAPI_ERR("FAPI_ATTR_GET(ATTR_PROC_FABRIC_ASYNC_SAFE_MODE) returned error."); + return rc; + } + bAsyncSafeMode = attrAsyncSafeMode; + + // Obtain ex_func_l3_ring overlay data and length from attributes. + // Obtain ring name and ring's vector location from image. + // + if (!bAsyncSafeMode) { + // Get overlay ring from attributes. + rc = FAPI_ATTR_GET(ATTR_PROC_EX_FUNC_L3_DELTA_DATA, &i_target, attrFuncL3RingList); + if (rc) { + FAPI_ERR("FAPI_ATTR_GET(ATTR_PROC_EX_FUNC_L3_DELTA_DATA) returned error."); + return rc; + } + rc = FAPI_ATTR_GET(ATTR_PROC_EX_FUNC_L3_LENGTH, &i_target, attrFuncL3RingLength); + if (rc) { + FAPI_ERR("FAPI_ATTR_GET(ATTR_PROC_EX_FUNC_L3_LENGTH) returned error."); + return rc; + } + //attrFuncL3RingLength = 0xBEBA; + for (iEntry=0; iEntry<MAX_FUNC_L3_RING_LIST_ENTRIES; iEntry++) { + if (attrFuncL3RingList[iEntry]!=0xffff0000) { + attrFuncL3RingData[attrFuncL3RingList[iEntry]>>16] = + (uint8_t)((attrFuncL3RingList[iEntry]<<24)>>24); + } + else + break; + } + FAPI_DBG("Overlay [raw] ring created for func L3."); + // Get ring name from xip image. + rcLoc = sbe_xip_find((void*)i_imageIn, FUNC_L3_RING_TOC_NAME, &xipTocItem); + if (rcLoc) { + FAPI_ERR("sbe_xip_find() failed w/rc=%i", rcLoc); + FAPI_ERR("Probable cause:"); + FAPI_ERR("\tThe keyword (=%s) was not found.", FUNC_L3_RING_TOC_NAME); + uint32_t & RC_LOCAL = rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_KEYWORD_NOT_FOUND_ERROR); + return rc; + } + xipFuncL3RingVector = xipTocItem.iv_address; + } +#endif + + + /*************************************************************************** + * SEARCH LOOP - Begin * + ***************************************************************************/ + do { + + FAPI_DBG("nextRing (at top)=0x%016llx",(uint64_t)nextRing); + + + // ========================================================================== + // Get ring layout from image + // ========================================================================== + FAPI_DBG("--> Reading RS4 delta ring info from SBE-XIP Image."); + rcLoc = get_ring_layout_from_image( i_imageIn, + ddLevel, + sysPhase, + &rs4RingLayout, + &nextRing); + rcSearch = rcLoc; + if (rcSearch!=DSLWB_RING_SEARCH_MATCH && + rcSearch!=DSLWB_RING_SEARCH_EXHAUST_MATCH && + rcSearch!=DSLWB_RING_SEARCH_NO_MATCH) { + FAPI_ERR("\tGetting delta ring from image was unsuccessful (rcSearch=%i).",rcSearch); + FAPI_ERR("\tNo wiggle-flip programs will be stored in .rings section."); + FAPI_ERR("\tThe following ELF sections have been emptied: .rings, .pibmem0, .ipl_text."); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_RING_RETRIEVAL_ERROR); + return rc; + } + if (rcSearch==DSLWB_RING_SEARCH_MATCH || + rcSearch==DSLWB_RING_SEARCH_EXHAUST_MATCH) + FAPI_DBG("\tRetrieving RS4 delta ring was successful."); + + // + // Check if we're done at this point, and save status in bSearchDone. + // + if (rcSearch==DSLWB_RING_SEARCH_NO_MATCH) { + + bSearchDone = 1; + + } + else { // More rings to search... + + deltaRingRS4 = (CompressedScanData*)rs4RingLayout.rs4Delta; + + FAPI_DBG("Dumping ring layout:"); + FAPI_DBG("\tentryOffset = %i",(uint32_t)myRev64(rs4RingLayout.entryOffset)); + FAPI_DBG("\tbackItemPtr = 0x%016llx",myRev64(rs4RingLayout.backItemPtr)); + FAPI_DBG("\tsizeOfThis = %i",myRev32(rs4RingLayout.sizeOfThis)); + FAPI_DBG("\tsizeOfMeta = %i",myRev32(rs4RingLayout.sizeOfMeta)); + FAPI_DBG("\tddLevel = %i",myRev32(rs4RingLayout.ddLevel)); + FAPI_DBG("\tsysPhase = %i",rs4RingLayout.sysPhase); + FAPI_DBG("\toverride = %i",rs4RingLayout.override); + FAPI_DBG("\treserved1+2 = %i",rs4RingLayout.reserved1|rs4RingLayout.reserved2); + FAPI_DBG("\tRS4 magic # = 0x%08x",myRev32(deltaRingRS4->iv_magic)); + FAPI_DBG("\tRS4 total size = %i",myRev32(deltaRingRS4->iv_size)); + FAPI_DBG("\tUnXed data size = %i",myRev32(deltaRingRS4->iv_length)); + FAPI_DBG("\tScan select = 0x%08x",myRev32(deltaRingRS4->iv_scanSelect)); + FAPI_DBG("\tHeader version = 0x%02x",deltaRingRS4->iv_headerVersion); + FAPI_DBG("\tFlush optimize = 0x%02x (reverse of override)",deltaRingRS4->iv_flushOptimization); + FAPI_DBG("\tRing ID = 0x%02x",deltaRingRS4->iv_ringId); + FAPI_DBG("\tChiplet ID = 0x%02x",deltaRingRS4->iv_chipletId); + FAPI_DBG("Dumping meta data:"); + FAPI_DBG("\tsizeOfData = %i",myRev32(rs4RingLayout.sizeOfMeta)); + FAPI_DBG("\tMeta data = "); + for (i=0; i<myRev32(rs4RingLayout.sizeOfMeta); i++) { // String may not be null terminated. + FAPI_DBG("%c",rs4RingLayout.metaData[i]); + } + + + // ========================================================================== + // Decompress RS4 delta state. + // ========================================================================== + FAPI_DBG("--> Decompressing RS4 delta ring."); + rcLoc = _rs4_decompress((uint8_t*)i_buf2, + i_sizeBuf2, + &ringBitLen, + deltaRingRS4); + if (rcLoc) { + FAPI_ERR("\t_rs4_decompress() failed: rc=%i",rcLoc); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_RS4_DECOMPRESSION_ERROR); + return rc; + } + FAPI_DBG("\tDecompression successful.\n"); + + +#ifndef IMGBUILD_PPD_IGNORE_XIPC + // ========================================================================== + // CUSTOMIZE item: Overlay ex_func_l3_ring. + // Retrieval method: Attribute. + // Note: Check if ex_func_l3_ring's vector address matches current backPtr. + // If so, perform OR operation with new attribute data for this ring. + // Assumptions: + // - Base ring only. + // - Correct DD level rings only. + // ========================================================================== + uint8_t byteExisting=0, byteOverlay=0, bGoodByte=1; + uint32_t iByte, sizeRingInBytes; + FAPI_DBG("--> Check if we should modify the ex_func_l3_ring with attribute data."); + if (!bAsyncSafeMode) { + // Find ring match by comparing backItemPtr and ring lengths. Note that + // we can't use fwdPtr for finding a match since we don't know which DD + // level ring it ended up pointing at. + if (xipFuncL3RingVector==myRev64(rs4RingLayout.backItemPtr) && + attrFuncL3RingLength==myRev32(deltaRingRS4->iv_length)) { + // Perform OR between the existing ring and attribute ring. + sizeRingInBytes = (attrFuncL3RingLength-1)/8 + 1; + bGoodByte = 1; + FAPI_DBG("Byte[ # ]: ER OR =ER? "); + FAPI_DBG("-----------------------"); + for (iByte=0; (iByte<sizeRingInBytes && bGoodByte); iByte++) { + if (*(attrFuncL3RingData+iByte)) { + // Check there are 0-bits in the existing byte where there are + // 1-bits in the overlay byte. + byteExisting = *((uint8_t*)i_buf2+iByte); + byteOverlay = *(&attrFuncL3RingData[0]+iByte); + if (byteExisting!=(byteExisting & ~byteOverlay)) { + FAPI_ERR("Byte[%4i]: %02x %02x %02x <-violation",iByte,byteExisting,byteOverlay,byteExisting&~byteOverlay); + bGoodByte = 0; + break; + } + else { + FAPI_DBG("Byte[%4i]: %02x %02x %02x ",iByte,byteExisting,byteOverlay,byteExisting&~byteOverlay); + } + // Only update existing ring when there's content in overlay data. + *((uint8_t*)i_buf2+iByte) = byteExisting | byteOverlay; + } + } + FAPI_DBG("-----------------------"); + if (!bGoodByte) { + FAPI_ERR("The existing ex_l3_func_ring has 1-bits in overlay locations. "); + uint32_t & DATA_FAIL_BYTE_NO = iByte; + uint8_t & DATA_EXISTING_RING_BYTE = byteExisting; + uint8_t & DATA_OVERLAY_RING_BYTE = byteOverlay; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_L3_FUNC_OVERLAY_ERROR); + return rc; + } + } + } +#endif + + // ========================================================================== + // Create Wiggle-Flip Programs (but first resolve max rotate status.) + // ========================================================================== + FAPI_DBG("--> Creating Wiggle-Flip Program."); + + rcLoc = sbe_xip_get_scalar( (void*)i_imageIn, SCAN_MAX_ROTATE_38XXX_NAME, &scanMaxRotate); + if (rcLoc) { + FAPI_INF("WARNING: sbe_xip_get_scalar() failed...but we might wing it."); + if (rcLoc==SBE_XIP_ITEM_NOT_FOUND) { + FAPI_INF("Probable cause:"); + FAPI_INF("\tThe key word in SCAN_MAX_ROTATE_38XXX_NAME does not exist the TOC."); + scanMaxRotate = SCAN_ROTATE_DEFAULT; + FAPI_INF("\tscanMaxRotate set to 0x%llx", scanMaxRotate); + FAPI_INF("Continuing..."); + } + else { + FAPI_ERR("ERROR: Nope, couldn't wing it."); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_UNKNOWN_XIP_ERROR); + return rc; + } + } + if (scanMaxRotate<0x20 || scanMaxRotate>SCAN_MAX_ROTATE) { + FAPI_INF("WARNING: Value of key word SCAN_MAX_ROTATE_38XXX_NAME=0x%llx is not permitted.\n",scanMaxRotate); + scanMaxRotate = SCAN_ROTATE_DEFAULT; + FAPI_INF("\tscanMaxRotate set to 0x%llx\n", scanMaxRotate); + FAPI_INF("Continuing...\n"); + } + + // Support for enforcing delay after WF scan write scoms. + uint64_t waitsScanDelay=10; + rcLoc = sbe_xip_get_scalar( (void*)i_imageIn, "waits_delay_for_scan", &waitsScanDelay); + if (rcLoc) { + FAPI_ERR("Error obtaining waits_delay_for_scan keyword.\n"); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_UNKNOWN_XIP_ERROR); + return rc; + } + + wfInline = (uint32_t*)i_buf1; + wfInlineLenInWords = i_sizeBuf1/4; + rcLoc = create_wiggle_flip_prg( (uint32_t*)i_buf2, // Input buffer, buf2 + ringBitLen, + myRev32(deltaRingRS4->iv_scanSelect), + (uint32_t)deltaRingRS4->iv_chipletId, + &wfInline, // Output buffer, buf1 + &wfInlineLenInWords, + deltaRingRS4->iv_flushOptimization, + (uint32_t)scanMaxRotate, + (uint32_t)waitsScanDelay); + if (rcLoc) { + FAPI_ERR("create_wiggle_flip_prg() failed w/rcLoc=%i",rcLoc); + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_WF_CREATION_ERROR); + return rc; + } + FAPI_DBG("\tWiggle-flip programming successful."); + + + // ========================================================================== + // Append Wiggle-Flip programs to .rings section. (But 1st put ring block together.) + // ========================================================================== + FAPI_DBG("--> Building WF ring header."); + // + // Populate ring header and put ring header and Wf ring into + // proper spots in pre-allocated bufWfRingBlock buffer (HB buf1). + // + DeltaRingLayout *bufWfRingBlock; + uint64_t entryOffsetWfRingBlock; + uint32_t sizeWfRingBlock, sizeWfRingBlockMax; + + bufWfRingBlock = (DeltaRingLayout*)i_buf2; // Previously contained delta ring state. + sizeWfRingBlockMax = i_sizeBuf2; + + entryOffsetWfRingBlock = calc_ring_layout_entry_offset( + 1, + myRev32(rs4RingLayout.sizeOfMeta) ); + bufWfRingBlock->entryOffset = myRev64(entryOffsetWfRingBlock); + bufWfRingBlock->sizeOfMeta = rs4RingLayout.sizeOfMeta; + bufWfRingBlock->backItemPtr = rs4RingLayout.backItemPtr; + sizeWfRingBlock = entryOffsetWfRingBlock + // Must be 8-byte aligned. + wfInlineLenInWords*4; // Must be 8-byte aligned. + // Quick check to see if final ring block size will fit in HB buffer. + if (sizeWfRingBlock>sizeWfRingBlockMax) { + FAPI_ERR("WF ring block size (=%i) exceeds pre-allocated buf1 size (=%i).", + sizeWfRingBlock, sizeWfRingBlockMax); + uint32_t &DATA_RING_BLOCK_SIZEOFTHIS=sizeWfRingBlock; + uint32_t &DATA_SIZE_OF_BUF1=sizeWfRingBlock; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_RING_BLOCK_TOO_LARGE); + return rc; + } + bufWfRingBlock->sizeOfThis = myRev32(sizeWfRingBlock); + // Find where meta data goes. + bufLC = (uint32_t)( entryOffsetWfRingBlock - + myByteAlign(8, myRev32(bufWfRingBlock->sizeOfMeta)) ); + // Copy over meta data. Do not worry about alignment here. + memcpy( (uint8_t*)bufWfRingBlock+bufLC, + rs4RingLayout.metaData, + (size_t)myRev32(rs4RingLayout.sizeOfMeta)); + // Find where WF prg goes. + bufLC = (uint32_t)entryOffsetWfRingBlock; + // Copy over WF ring prg which is already 8-byte aligned. + memcpy( (uint8_t*)bufWfRingBlock+bufLC, + wfInline, + (size_t)wfInlineLenInWords*4); + + // Now, some post-sanity checks on alignments. + if ( entryOffsetWfRingBlock%8 || + sizeWfRingBlock%8) { + FAPI_ERR("Member(s) of WF ring block are not 8-byte aligned:"); + FAPI_ERR(" Entry offset = %i", (uint32_t)entryOffsetWfRingBlock); + FAPI_ERR(" Size of ring block = %i", sizeWfRingBlock); + dataTmp1=(uint32_t)entryOffsetWfRingBlock; + uint32_t &DATA_RING_BLOCK_ENTRYOFFSET=dataTmp1; + uint32_t &DATA_RING_BLOCK_SIZEOFTHIS=sizeWfRingBlock; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_RING_BLOCK_ALIGN_ERROR); + return rc; + } + + FAPI_DBG("--> Appending WF ring to .rings section."); + rcLoc = write_ring_block_to_image(i_imageOut, + NULL, + bufWfRingBlock, + 0, + rs4RingLayout.override, + 1, + sizeImageOutMax, + SBE_XIP_SECTION_RINGS, + i_buf1, // Use buf1 as temp buf. + i_sizeBuf1); + if (rcLoc) { + FAPI_ERR("write_ring_block_to_image() failed w/rc=%i",rcLoc); + FAPI_ERR("Check p8_delta_scan_rw.h for meaning of IMGBUILD_xyz rc code."); + uint32_t &RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_IMGBUILD_ERROR); + return rc; + } + + + // Update some variables for debugging and error reporting. + sizeImageOld = sizeImageTmp; + countWF++; + FAPI_DBG("\tUpdating image w/WF prg + ring header was successful.sizeImageOld=%d",sizeImageOld); + + } // End of if (rcSearch!=DSLWB_RING_SEARCH_NO_MATCH) + + // ============================================================================ + // Are we done now? + // ============================================================================ + if (bSearchDone || rcSearch==DSLWB_RING_SEARCH_EXHAUST_MATCH) { + FAPI_INF("Wiggle-flip programming done."); + FAPI_INF("Number of wf programs appended: %i", countWF); + if (countWF==0) + FAPI_INF("ZERO WF programs appended to .rings section."); +#ifndef IMGBUILD_PPD_IGNORE_XIPC + // + // Do various customizations to image. + // + sizeImageTmp = sizeImageOutMax; + FAPI_INF("Calling xip_customize().\n"); + FAPI_EXEC_HWP(rc, p8_xip_customize, + i_target, + i_imageIn, + i_imageOut, + sizeImageTmp, + sysPhase, + i_modeBuild, + i_buf1, + i_sizeBuf1, + i_buf2, + i_sizeBuf2, + bootCoreMask); + if (rc!=FAPI_RC_SUCCESS) { + FAPI_ERR("Xip customization failed."); + return rc; + } + FAPI_INF("Xip customization done."); +#else + // + // Initialize .slw section, just in case we ignore xip_customize in a build. + // + switch (i_modeBuild) { + // -------------------------------------------------------------------- + // case 0: IPL mode. + // - This is first time SLW image is built. Go all out. + // -------------------------------------------------------------------- + case P8_SLW_MODEBUILD_IPL: // IPL mode. + rcLoc = create_and_initialize_fixed_image( i_imageOut); + if (rcLoc) { + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_CREATE_FIXED_IMAGE_ERROR); + return rc; + } + FAPI_INF("IPL mode build: Fixed SLW and FFDC sections allocated and SLW section initialized for Ramming and Scomming tables."); + break; + // -------------------------------------------------------------------- + // case 1: Rebuild mode - Nothing to do. + // - Image size already fixed at 1MB during IPL mode. + // - Fixed positioning of .slw and .ffdc already done during IPL mode. + // -------------------------------------------------------------------- + case P8_SLW_MODEBUILD_REBUILD: // Rebuild mode. (Need to update Ram/Scom vectors.) + rcLoc = create_and_initialize_fixed_image( i_imageOut); + if (rcLoc) { + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_CREATE_FIXED_IMAGE_ERROR); + return rc; + } + FAPI_INF("Rebuild mode build: Fixed SLW and FFDC sections allocated and SLW section initialized for Ramming and Scomming tables."); + break; + // -------------------------------------------------------------------- + // case 2: SRAM mode. + // - Assumption: slw_build() called by OCC. + // - Need to make image as slim as possible. + // - Do not append .fit. + // - Position .slw right after .rings. + // - Do not append .ffdc. + // -------------------------------------------------------------------- + case P8_SLW_MODEBUILD_SRAM: // SRAM mode. + sizeImageTmp = sizeImageOutMax; + rcLoc = initialize_slw_section( i_imageOut, + &sizeImageTmp); + if (rcLoc) { + if (rcLoc==IMGBUILD_ERR_IMAGE_TOO_LARGE) { + uint32_t & DATA_IMG_SIZE_OLD=sizeImageOld; + uint32_t & DATA_IMG_SIZE_EST=sizeImageTmp; + uint32_t & DATA_IMG_SIZE_MAX=sizeImageOutMax; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_MAX_IMAGE_SIZE_EXCEEDED); + } + else { + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_APPEND_SLW_SECTION_ERROR); + } + return rc; + } + FAPI_INF("SRAM mode build: SLW section allocated for Ramming and Scomming tables."); + break; + // Default case - Should never get here. + default: + FAPI_ERR("Bad code, or bad modeBuild (=%i) parm.",i_modeBuild); + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_BAD_CODE_OR_PARM); + return rc; + } +#endif + + // Update host_runtime_scom pointer to point to sub_slw_runtime_scom + rcLoc = update_runtime_scom_pointer(i_imageOut); + if (rcLoc==IMGBUILD_ERR_KEYWORD_NOT_FOUND) { + uint32_t &RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_KEYWORD_NOT_FOUND_ERROR); + return rc; + } + // Report final size. + sbe_xip_image_size( i_imageOut, &io_sizeImageOut); + FAPI_INF("Final SLW image size (should be 1MB for modeBuild={0,1}): %i", io_sizeImageOut); + return FAPI_RC_SUCCESS; + } + + FAPI_DBG("nextRing (at bottom)=0x%016llx",(uint64_t)nextRing); + + } while (nextRing!=NULL); + /*************************************************************************** + * RING SEARCH LOOP - End * + ***************************************************************************/ + + FAPI_ERR("Shouldn't be in this code section. Check code."); + rcLoc = IMGBUILD_ERR_CHECK_CODE; + uint32_t & RC_LOCAL=rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_SLWB_UNKNOWN_ERROR); + return rc; + +} + +} // End of extern C diff --git a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_xip_customize.C b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_xip_customize.C index e85815a1c..2567780b6 100644 --- a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_xip_customize.C +++ b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_xip_customize.C @@ -20,7 +20,8 @@ /* Origin: 30 */ /* */ /* IBM_PROLOG_END_TAG */ -// $Id: p8_xip_customize.C,v 1.51 2013/06/13 22:38:28 cmolsen Exp $ + +// $Id: p8_xip_customize.C,v 1.52 2013-08-06 18:47:46 jeshua Exp $ /*------------------------------------------------------------------------------*/ /* *! TITLE : p8_xip_customize */ /* *! DESCRIPTION : Obtains repair rings from VPD and adds them to either */ @@ -238,21 +239,21 @@ ReturnCode p8_xip_customize_insert_chiplet_rings( const fapi::Target &i_target, return rc; } } - // Check if the VPD ring is redundant - int redundant = 0; - rcLoc = rs4_redundant((CompressedScanData*)bufVpdRing, &redundant); - if(rcLoc) { - FAPI_ERR("rs4_redundant() failed w/rc=%i ",rcLoc); - uint32_t & RC_LOCAL = rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_XIPC_CHECK_REDUNDANT_ERROR); - return rc; - } - rcLoc = 0; - // Add VPD ring to image if not redundant - if( redundant ) { - FAPI_INF("Skipping VPD ring because it doesn't change the ring (iRing,ringId,chipletId)=(%i,0x%02X,0x%02X).",iRing,ringId,chipletId); - } else { - if (i_sysPhase==0) { + if (i_sysPhase==0) { + // Check if the VPD ring is redundant + int redundant = 0; + rcLoc = rs4_redundant((CompressedScanData*)bufVpdRing, &redundant); + if(rcLoc) { + FAPI_ERR("rs4_redundant() failed w/rc=%i ",rcLoc); + uint32_t & RC_LOCAL = rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_XIPC_CHECK_REDUNDANT_ERROR); + return rc; + } + rcLoc = 0; + // Add VPD ring to image if not redundant + if( redundant ) { + FAPI_INF("Skipping VPD ring because it doesn't change the ring (iRing,ringId,chipletId)=(%i,0x%02X,0x%02X).",iRing,ringId,chipletId); + } else { // Add VPD ring to --->>> IPL <<<--- image rcLoc = write_vpd_ring_to_ipl_image( o_imageOut, @@ -282,27 +283,27 @@ ReturnCode p8_xip_customize_insert_chiplet_rings( const fapi::Target &i_target, return rc; } } + } //if not redundant + } + else { + // Add VPD ring to --->>> SLW <<<--- image + rcLoc = write_vpd_ring_to_slw_image( + o_imageOut, + sizeImageOut, + (CompressedScanData*)bufVpdRing, //HB buf1 + ddLevel, + i_sysPhase, + (char*)(ring_id_list+iRing)->ringNameImg, + (void*)i_buf2, //HB buf2 + i_sizeBuf2, + (ring_id_list+iRing)->bWcSpace); + if (rcLoc) { + FAPI_ERR("write_vpd_ring_to_slw_image() failed w/rc=%i",rcLoc); + uint32_t & RC_LOCAL = rcLoc; + FAPI_SET_HWP_ERROR(rc, RC_PROC_XIPC_WRITE_VPD_RING_TO_SLW_IMAGE_ERROR); + return rc; } - else { - // Add VPD ring to --->>> SLW <<<--- image - rcLoc = write_vpd_ring_to_slw_image( - o_imageOut, - sizeImageOut, - (CompressedScanData*)bufVpdRing, //HB buf1 - ddLevel, - i_sysPhase, - (char*)(ring_id_list+iRing)->ringNameImg, - (void*)i_buf2, //HB buf2 - i_sizeBuf2, - (ring_id_list+iRing)->bWcSpace); - if (rcLoc) { - FAPI_ERR("write_vpd_ring_to_slw_image() failed w/rc=%i",rcLoc); - uint32_t & RC_LOCAL = rcLoc; - FAPI_SET_HWP_ERROR(rc, RC_PROC_XIPC_WRITE_VPD_RING_TO_SLW_IMAGE_ERROR); - return rc; - } - } - } //if not redundant + } } //no buffer overflow } //ring found in VPD } //chiplet ID is valid for this ring name diff --git a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_xip_customize.H b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_xip_customize.H index 42387de78..ec018eed9 100644 --- a/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_xip_customize.H +++ b/src/usr/hwpf/hwp/build_winkle_images/p8_slw_build/p8_xip_customize.H @@ -20,6 +20,7 @@ /* Origin: 30 */ /* */ /* IBM_PROLOG_END_TAG */ + // $Id: p8_xip_customize.H,v 1.8 2013/06/13 16:52:41 jeshua Exp $ #include <fapi.H> @@ -30,7 +31,7 @@ typedef fapi::ReturnCode (*fapiGetMvpdField_FP_t) ( const fapi::MvpdRecord i_rec uint8_t * const i_pBuffer, uint32_t &io_fieldSize); -typedef fapi::ReturnCode (*p8_xip_customize_FP_t) ( const fapi::Target&, +typedef fapi::ReturnCode (*p8_xip_customize_FP_t) ( const fapi::Target&, void*, void*, uint32_t&, @@ -49,18 +50,18 @@ extern "C" // Function declares. // - // Description: + // Description: // FAPI HWP entry point for p8_xip_customize(). // p8_xip_customize() adds VPD rings to the IPL and SLW images and updates // various vectors in the images. // - // Parameters: + // Parameters: // fapi::Target &i_target: Processor chip target. // void *i_imageIn: Ptr to input IPL or SLW image. // void *i_imageOut: Ptr to output IPL img. (Ignored for SLW/RAM imgs.) // uint32_t &io_sizeImageOut: In: Max size of IPL/SRAM img. Out: Final size. // uint8_t i_sysPhase: 0: IPL 1: SLW - // uint8_t i_modeBuild: 0: HB/IPL 1: PHYP/Rebuild 2: SRAM + // uint8_t i_modeBuild: 0: HB/IPL 1: PHYP/Rebuild 2: SRAM // void *i_buf1: Temp buffer1 for dexed RS4 ring. Caller allocs/frees. // uint32_t i_sizeBuf1: Size of buf1. // void *i_buf2: Temp buffer2 for WF ring. Caller allocs/frees. @@ -73,7 +74,7 @@ extern "C" void *i_imageOut, uint32_t &io_sizeImageOut, const uint8_t i_sysPhase, - const uint8_t i_modeBuild, + const uint8_t i_modeBuild, void *i_buf1, const uint32_t i_sizeBuf1, void *i_buf2, |