diff options
-rw-r--r-- | src/sbefw/sbecmdiplcontrol.C | 33 | ||||
-rw-r--r-- | src/sbefw/sbecmdprocessor.C | 47 | ||||
-rw-r--r-- | src/sbefw/sbeutil.C | 21 | ||||
-rw-r--r-- | src/sbefw/sbeutil.H | 19 |
4 files changed, 92 insertions, 28 deletions
diff --git a/src/sbefw/sbecmdiplcontrol.C b/src/sbefw/sbecmdiplcontrol.C index 0f2d2686..cc428f48 100644 --- a/src/sbefw/sbecmdiplcontrol.C +++ b/src/sbefw/sbecmdiplcontrol.C @@ -87,8 +87,6 @@ // istep 5 hwp header files #include "p9_sbe_instruct_start.H" #include "p9_sbe_load_bootloader.H" -// Nest frequency array -#include "p9_frequency_buckets.H" // istep mpipl header files #include "p9_block_wakeup_intr.H" @@ -597,15 +595,15 @@ bool validateIstep (const uint8_t i_major, const uint8_t i_minor) //---------------------------------------------------------------------------- -ReturnCode istepAttrSetup( sbeIstepHwp_t i_hwp) +ReturnCode performAttrSetup( ) { - SBE_ENTER("istepAttrSetup"); + #define SBE_FUNC "performAttrSetup " + SBE_ENTER("performAttrSetup "); Target<TARGET_TYPE_PROC_CHIP > proc = plat_getChipTarget(); ReturnCode rc = FAPI2_RC_SUCCESS; do { - assert( NULL != i_hwp.procHwp ); - SBE_EXEC_HWP(rc, i_hwp.procHwp, proc) + SBE_EXEC_HWP(rc, p9_sbe_attr_setup, proc) if( rc != FAPI2_RC_SUCCESS ) { break; @@ -613,8 +611,16 @@ ReturnCode istepAttrSetup( sbeIstepHwp_t i_hwp) // Apply the gard records rc = plat_ApplyGards(); }while(0); - SBE_EXIT("istepAttrSetup"); + SBE_EXIT(SBE_FUNC); return rc; + #undef SBE_FUNC +} + +//---------------------------------------------------------------------------- + +ReturnCode istepAttrSetup( sbeIstepHwp_t i_hwp) +{ + return performAttrSetup(); } //---------------------------------------------------------------------------- @@ -634,14 +640,7 @@ ReturnCode istepNestFreq( sbeIstepHwp_t i_hwp) { #define SBE_FUNC "istepNestFreq " Target<TARGET_TYPE_PROC_CHIP > proc = plat_getChipTarget(); - fapi2::Target<TARGET_TYPE_SYSTEM> sys; ReturnCode rc = FAPI2_RC_SUCCESS; - uint8_t nestPllBkt = 0; - FAPI_ATTR_GET( ATTR_NEST_PLL_BUCKET, sys, nestPllBkt ); - assert( nestPllBkt && (nestPllBkt <= NEST_PLL_FREQ_BUCKETS )); - g_sbefreq = ( NEST_PLL_FREQ_LIST[ nestPllBkt - 1 ] * 1000 * 1000 )/ - SBE::SBE_TO_NEST_FREQ_FACTOR; - assert( NULL != i_hwp.procHwp ); do { @@ -650,10 +649,8 @@ ReturnCode istepNestFreq( sbeIstepHwp_t i_hwp) { break; } - // This function signature though has return value - // But it always return SUCCESS. - SBE_INFO(SBE_FUNC"Setting new frequency:0x%08X", g_sbefreq); - pk_timebase_freq_set(g_sbefreq); + // Update PK frequency + SBE::updatePkFreq(); }while(0); return rc; #undef SBE_FUNC diff --git a/src/sbefw/sbecmdprocessor.C b/src/sbefw/sbecmdprocessor.C index e6e1d012..56c4c153 100644 --- a/src/sbefw/sbecmdprocessor.C +++ b/src/sbefw/sbecmdprocessor.C @@ -45,7 +45,11 @@ #include "sberegaccess.H" #include "sbestates.H" #include "fapi2.H" +#include "sbeutil.H" +using namespace fapi2; +// Forward declaration for performAttrSetup +ReturnCode performAttrSetup( ); ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// @@ -209,6 +213,26 @@ void sbeHandleFifoResponse (const uint32_t i_rc) #undef SBE_FUNC } +ReturnCode sbeDestRuntimeSetup() +{ + #define SBE_FUNC " sbeDestRuntimeSetup " + SBE_ENTER( SBE_FUNC ); + ReturnCode rc = FAPI2_RC_SUCCESS; + do + { + rc = performAttrSetup(); + if( rc != FAPI2_RC_SUCCESS ) + { + SBE_ERROR(SBE_FUNC"performAttrSetup failed"); + break; + } + SBE::updatePkFreq(); + }while(0); + SBE_EXIT("SBE_FUNC"); + return rc; + #undef SBE_FUNC +} + ////////////////////////////////////////////////////// ////////////////////////////////////////////////////// @@ -222,20 +246,25 @@ void sbeSyncCommandProcessor_routine(void *i_pArg) (void)SbeRegAccess::theSbeRegAccess().setSbeReady(); // Check the destination bit at the start - if(SbeRegAccess::theSbeRegAccess().isIstepMode()) + if(true == SbeRegAccess::theSbeRegAccess().isDestBitRuntime()) { - SBE_INFO(SBE_FUNC"Continuous IPL mode not set, will wait for " - "commands..."); + SBE_INFO(SBE_FUNC"Destination bit tells us to go to runtime"); (void)SbeRegAccess::theSbeRegAccess(). - updateSbeState(SBE_STATE_ISTEP); + updateSbeState(SBE_STATE_RUNTIME); + // Do the runtime setup + ReturnCode rc = sbeDestRuntimeSetup(); + if( rc != FAPI2_RC_SUCCESS ) + { + SBE_ERROR(SBE_FUNC"sbeDestRuntimeSetup failed"); + pk_halt(); + } } - // If Istep mode is not set, it makes sense to check if we are directly - // in runtime. - else if(true == SbeRegAccess::theSbeRegAccess().isDestBitRuntime()) + else if(SbeRegAccess::theSbeRegAccess().isIstepMode()) { - SBE_INFO(SBE_FUNC"Destination bit tells us to go to runtime"); + SBE_INFO(SBE_FUNC"Continuous IPL mode not set, will wait for " + "commands..."); (void)SbeRegAccess::theSbeRegAccess(). - updateSbeState(SBE_STATE_RUNTIME); + updateSbeState(SBE_STATE_ISTEP); } else { diff --git a/src/sbefw/sbeutil.C b/src/sbefw/sbeutil.C index ac1eeacd..8ad99bca 100644 --- a/src/sbefw/sbeutil.C +++ b/src/sbefw/sbeutil.C @@ -5,7 +5,8 @@ /* */ /* OpenPOWER sbe Project */ /* */ -/* Contributors Listed Below - COPYRIGHT 2016 */ +/* Contributors Listed Below - COPYRIGHT 2016,2017 */ +/* [+] International Business Machines Corp. */ /* */ /* */ /* Licensed under the Apache License, Version 2.0 (the "License"); */ @@ -22,6 +23,10 @@ /* */ /* IBM_PROLOG_END_TAG */ #include "sbeutil.H" +#include "fapi2.H" +#include "sbetrace.H" +// Nest frequency array +#include "p9_frequency_buckets.H" namespace SBE { bool isSimics() __attribute__((alias("__isSimicsRunning"))); @@ -38,4 +43,18 @@ namespace SBE static bool simics = isSimics(); return simics; } + + void updatePkFreq() + { + using namespace fapi2; + Target<TARGET_TYPE_SYSTEM> sys; + uint8_t nestPllBkt = 0; + FAPI_ATTR_GET( ATTR_NEST_PLL_BUCKET, sys, nestPllBkt ); + assert( nestPllBkt && (nestPllBkt <= NEST_PLL_FREQ_BUCKETS )); + g_sbefreq = ( NEST_PLL_FREQ_LIST[ nestPllBkt - 1 ] * 1000 * 1000 )/ + SBE::SBE_TO_NEST_FREQ_FACTOR; + SBE_INFO(SBE_FUNC"Setting new frequency:0x%08X", g_sbefreq); + pk_timebase_freq_set(g_sbefreq); + } } + diff --git a/src/sbefw/sbeutil.H b/src/sbefw/sbeutil.H index 5dbd2a42..76793927 100644 --- a/src/sbefw/sbeutil.H +++ b/src/sbefw/sbeutil.H @@ -24,9 +24,17 @@ /* IBM_PROLOG_END_TAG */ #ifndef SBE_UTIL_H #define SBE_UTIL_H +#ifdef __cplusplus +extern "C" { +#endif + #include "pk.h" #include "pk_api.h" +#ifdef __cplusplus +} +#endif + #define MASK_ZERO_L32B_UINT64(x) ((x) & 0xFFFFFFFF00000000ull) #define MASK_ZERO_H32B_UINT64(x) ((x) & 0x00000000FFFFFFFFull) #define SHIFT_RIGHT(x, bits) ((x) >> bits) @@ -38,6 +46,11 @@ if ((l_rc) != SBE_SEC_OPERATION_SUCCESSFUL) \ break; \ } +#define mfdec() \ + ({volatile uint32_t l_dec; \ + asm volatile ("mfdec %0" : "=r" (l_dec)); \ + l_dec;}) + // To handle unused variables compilation error static inline void UNUSED(int dummy, ...) {} @@ -167,5 +180,11 @@ namespace SBE */ bool isSimicsRunning(); + /*@brief - Update the pk frequcy as per NEST PLL bucket + * + * @return - void + */ + void updatePkFreq(); + } // namespace SBE #endif //SBE_UTIL_H |