From a3b4a0ff044b60b2af8082fd5256b1926e8b35b5 Mon Sep 17 00:00:00 2001 From: Thi Tran Date: Thu, 1 Mar 2012 08:36:31 -0600 Subject: VSBE code change to run SBE cen_sbe_tp_chiplet_init1 Updated with Review comments Change-Id: I745f0cd19b5e3159bba590f4efa9eab6fec71779 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/710 Tested-by: Jenkins Server Reviewed-by: MIKE J. JONES Reviewed-by: A. Patrick Williams III --- src/usr/hwpf/hwp/sbe_centaur_init/makefile | 5 + .../hwpf/hwp/sbe_centaur_init/sbe_centaur_init.C | 228 ++++++++++++++++++--- 2 files changed, 199 insertions(+), 34 deletions(-) (limited to 'src/usr/hwpf/hwp/sbe_centaur_init') diff --git a/src/usr/hwpf/hwp/sbe_centaur_init/makefile b/src/usr/hwpf/hwp/sbe_centaur_init/makefile index 457783336..b1d97c2c9 100644 --- a/src/usr/hwpf/hwp/sbe_centaur_init/makefile +++ b/src/usr/hwpf/hwp/sbe_centaur_init/makefile @@ -34,6 +34,11 @@ EXTRAINCDIR += ${ROOTPATH}/src/include/usr/hwpf/hwp ## pointer to common HWP files EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/include +## pointer to fapiporeve files +EXTRAINCDIR += ${ROOTPATH}/src/usr/pore/fapiporeve +EXTRAINCDIR += ${ROOTPATH}/src/usr/pore/poreve/model +EXTRAINCDIR += ${ROOTPATH}/src/usr/pore/poreve/porevesrc + ## Include sub dirs ## NOTE: add a new EXTRAINCDIR when you add a new HWP ## EXTRAINCDIR += ${ROOTPATH}/src/usr/hwpf/hwp/sbe_centaur_init/???? diff --git a/src/usr/hwpf/hwp/sbe_centaur_init/sbe_centaur_init.C b/src/usr/hwpf/hwp/sbe_centaur_init/sbe_centaur_init.C index 1dc9ad501..10e6dbdbe 100644 --- a/src/usr/hwpf/hwp/sbe_centaur_init/sbe_centaur_init.C +++ b/src/usr/hwpf/hwp/sbe_centaur_init/sbe_centaur_init.C @@ -40,19 +40,36 @@ #include #include #include - #include - #include #include #include #include #include #include - -// -- prototype includes -- -#include "sbe_centaur_init.H" -// #include "/.H" +#include +#include +#include +#include +#include +#include +#include "sbe_centaur_init.H" + +//@todo - These two include files are to workaround +//1. Avoid running test case in VBU +//2. To call isSlavePresent(). Need to be removed when PD works. +#include +#include + +// Extern function declaration +extern fapi::ReturnCode fapiPoreVe(const fapi::Target i_target, + std::list & io_sharedObjectArgs); +// Constants +#define CENTAUR_SBE_PNOR_MRR 0 // Memory Relocation Register for Centaur SBE image + +// Name spaces +using namespace TARGETING; +using namespace vsbe; namespace SBE_CENTAUR_INIT { @@ -68,12 +85,11 @@ void call_cen_sbe_tp_chiplet_init1( void *io_pArgs ) INITSERVICE::TaskArgs *pTaskArgs = static_cast( io_pArgs ); fapi::ReturnCode l_fapirc; + fapi::ReturnCode l_fapirc2; TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_cen_sbe_tp_chiplet_init1 entry" ); - - // figure out what targets we need - // ADD TARGET GENERATION STUFF HERE + // Get target list to pass in procedure // Use PredicateIsFunctional to filter only functional chips TARGETING::PredicateIsFunctional l_isFunctional; @@ -89,39 +105,183 @@ void call_cen_sbe_tp_chiplet_init1( void *io_pArgs ) TARGETING::targetService().end(), &l_functionalAndMembufChipFilter ); - for ( ; l_pMemBufs; ++l_pMemBufs ) - { - // make a local copy of the target for ease of use - const TARGETING::Target* l_membuf_target = *l_pMemBufs; + bool l_unloadSbePnorImg = false; + size_t l_sbePnorSize = 0; + const char * l_sbePnorAddr = NULL; + errlHndl_t l_errl = NULL; - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "===== cen_sbe_tp_chiplet_init1 HWP(? ? ? )" ); - EntityPath l_path; - l_path = l_membuf_target->getAttr(); - l_path.dump(); - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "===== " ); -#if 0 - // $$$$ Thi add your code here, pass it l_membuf_target - // call the HWP with each target ( if parallel, spin off a task ) - l_fapirc = cen_sbe_tp_chiplet_init1( ? , ?, ? ); -#endif + do + { + // ----------------------- Setup sbe_pnor stuff -------------------- - // process return code. - if ( l_fapirc == fapi::FAPI_RC_SUCCESS ) + // Loading sbe_pnor img + l_errl = VFS::module_load("sbe_pnor.bin"); + if (l_errl) { - TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "SUCCESS : cen_sbe_tp_chiplet_init1 HWP(? ? ? )" ); + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "call_cen_sbe_tp_chiplet_init1 - VFS::module_load(sbe_pnor.bin) returns error"); + //@todo - Commit error and generate error FapiReturn code here + delete l_errl; + break; } else { - /** - * @todo fapi error - just print out for now... - */ + // Set flag to unload + l_unloadSbePnorImg = true; + l_errl = VFS::module_address("sbe_pnor.bin", l_sbePnorAddr, l_sbePnorSize); + if(l_errl) + { + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "call_cen_sbe_tp_chiplet_init1 - VFS::module_address(sbe_pnor.bin) return error"); + //@todo- Commit error and generate error FapiReturn code + delete l_errl; + break; + } + else + { + char l_header[10]; + memcpy (l_header, l_sbePnorAddr, 9); + l_header[9] = '\0'; + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "call_cen_sbe_tp_chiplet_init1 -Loading sbe_pnor.bin, Addr 0x%llX, Size %d, Header %s", + l_sbePnorAddr, l_sbePnorSize, l_header); + } + } + + // Setup args + std::list myArgs; + + // Set FapiPoreVeOtherArg: run unlimited instructions + FapiPoreVeOtherArg *l_otherArg = + new FapiPoreVeOtherArg(vsbe::RUN_UNLIMITED, + vsbe::PORE_SBE); + // Entry point + l_otherArg->iv_entryPoint = const_cast("pnor::_sbe_pnor_start"); + l_otherArg->iv_mrr = CENTAUR_SBE_PNOR_MRR; + uint64_t fapiArg = reinterpret_cast (l_otherArg); + myArgs.push_back(fapiArg); + + // Set FapiPoreVeMemArg for pnor option, base address = 0 + uint32_t base_addr = 0; + char* l_dataPnor = const_cast(l_sbePnorAddr); + FapiPoreVeMemArg* l_memArg = new FapiPoreVeMemArg(ARG_PNOR, + base_addr, l_sbePnorSize, + static_cast(l_dataPnor)); + fapiArg = reinterpret_cast (l_memArg); + myArgs.push_back(fapiArg); + + // Create state argument to dump out state for debugging purpose + FapiPoreVeStateArg *l_stateArg = new FapiPoreVeStateArg(NULL); + l_stateArg->iv_installState = false; + l_stateArg->iv_extractState = true; + fapiArg = reinterpret_cast (l_stateArg); + myArgs.push_back(fapiArg); + + // Loop thru all Centaurs in list + for ( ; l_pMemBufs; ++l_pMemBufs ) + { + // Create a FAPI Target + const TARGETING::Target* l_membuf_target = *l_pMemBufs; + const fapi::Target l_fapiTarget( + fapi::TARGET_TYPE_MEMBUF_CHIP, + reinterpret_cast + (const_cast(l_membuf_target))); + + // Put out info on target TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, - "ERROR %d: cen_sbe_tp_chiplet_init1 HWP(?,?,? ) ", - static_cast(l_fapirc) ); + "Running cen_sbe_tp_chiplet_init1 on Centaur entity path..."); + + EntityPath l_path; + l_path = l_membuf_target->getAttr(); + l_path.dump(); + + //@todo - This is a temporary hack to skip if Target is not present. + // This should be removed when PD works. + if ( !FSI::isSlavePresent(l_membuf_target) ) + { + TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "call_cen_sbe_tp_chiplet_init1 - Skip this Centaur because it's not present"); + continue; + } + + // Run the engine + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "call_cen_sbe_tp_chiplet_init1 - Start VSBE engine..."); + + //@todo + //@VBU workaround - Do not run in VPO since it takes too long + //Temporarily disable this test case in VBU because it takes too long to run. + //Also, the image used for Centaur is only a temporary image provided by Todd to try out. + if ( !TARGETING::is_vpo() ) + { + //@todo - Do not run poreve with temp image for now + l_fapirc = fapiPoreVe(l_fapiTarget, myArgs); + } + + if (l_fapirc != fapi::FAPI_RC_SUCCESS) + { + uint32_t val = l_fapirc; + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "call_cen_sbe_tp_chiplet_init1 - Error returned from VSBE engine on this Centaur, l_rc 0x%llX", + val); + //@todo - We want to commit the error here and should probably trigger a can continue loop (per Dean). + // For now, just move onto the next Centaur + continue; + } + else + { + TRACFCOMP(ISTEPS_TRACE::g_trac_isteps_trace, "call_cen_sbe_tp_chiplet_init1 - VSBE engine runs successfully on this Centaur"); + } + + } // end for l_pMemBufs + + // Freeing memory + if (l_otherArg) + { + delete l_otherArg; + l_otherArg = NULL; + } + + if (l_memArg) + { + delete l_memArg; + l_memArg = NULL; + } + + if (l_stateArg) + { + delete l_stateArg; + l_stateArg = NULL; } - } // end for l_pMemBufs + + + } while(0); + + // Unload sbe_pnor + if (l_unloadSbePnorImg == true) + { + l_fapirc2 = fapiUnloadInitFile("sbe_pnor.bin", + l_sbePnorAddr, + l_sbePnorSize); + if (l_fapirc2 != fapi::FAPI_RC_SUCCESS) + { + FAPI_ERR("call_cen_sbe_tp_chiplet_init1 - Error unloading sbe_pnor.bin"); + if (l_fapirc == fapi::FAPI_RC_SUCCESS) + { + l_fapirc = l_fapirc2; + } + } + } + + // process return code. + if ( l_fapirc == fapi::FAPI_RC_SUCCESS ) + { + TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, + "SUCCESS : cen_sbe_tp_chiplet_init1 HWP(? ? ? )" ); + } + else + { + /** + * @todo fapi error - just print out for now... + */ + TRACFCOMP( ISTEPS_TRACE::g_trac_isteps_trace, + "ERROR %d: cen_sbe_tp_chiplet_init1 HWP(?,?,? ) ", + static_cast(l_fapirc) ); + } TRACDCOMP( ISTEPS_TRACE::g_trac_isteps_trace, "cen_sbe_tp_chiplet_init1 exit" ); -- cgit v1.2.1