diff options
author | Sachin Gupta <sgupta2m@in.ibm.com> | 2016-10-21 18:11:41 -0500 |
---|---|---|
committer | AMIT J. TENDOLKAR <amit.tendolkar@in.ibm.com> | 2016-12-01 04:44:03 -0500 |
commit | 7e9ef2247c142869c58d7fe3ffac8a0bb1cdb12f (patch) | |
tree | ea4809198e0ba06ff0aae73b943c754c1e863f9e | |
parent | ba6c6e611b394a60fa68c10dcc6925bb50afc590 (diff) | |
download | talos-sbe-7e9ef2247c142869c58d7fe3ffac8a0bb1cdb12f.tar.gz talos-sbe-7e9ef2247c142869c58d7fe3ffac8a0bb1cdb12f.zip |
Update fapi::delay implementation
Change-Id: I1194b6819de9c9c4935e2761b984de1f40ba9aec
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/31680
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: RAJA DAS <rajadas2@in.ibm.com>
Reviewed-by: Shakeeb A. Pasha B K <shakeebbk@in.ibm.com>
Reviewed-by: AMIT J. TENDOLKAR <amit.tendolkar@in.ibm.com>
-rw-r--r-- | src/hwpf/src/plat/plat_utils.C | 32 | ||||
-rw-r--r-- | src/sbefw/sbecmdiplcontrol.C | 8 | ||||
-rw-r--r-- | src/sbefw/sbemain.C | 8 | ||||
-rw-r--r-- | src/sbefw/sbeutil.H | 1 |
4 files changed, 16 insertions, 33 deletions
diff --git a/src/hwpf/src/plat/plat_utils.C b/src/hwpf/src/plat/plat_utils.C index 4b5a60ea..41b9a53b 100644 --- a/src/hwpf/src/plat/plat_utils.C +++ b/src/hwpf/src/plat/plat_utils.C @@ -39,6 +39,13 @@ namespace fapi2 { + // Define own function rather than using PK function + // This is required as PK function does not scale well for low + // frequency till istep 2.7 + inline uint64_t delayCycles(uint64_t i_nanoSeconds ) + { + return ( i_nanoSeconds/1000) * ( g_sbefreq /(1000*1000)); + } /// @brief Delay this thread. /// ReturnCode delay(uint64_t i_nanoSeconds, uint64_t i_simCycles, bool i_fixed /* = false*/) @@ -51,8 +58,6 @@ namespace fapi2 #ifndef __FAPI_DELAY_SIM__ -#define PK_NANOSECONDS_SBE(n) ((PkTimebase)((PK_BASE_FREQ_HZ * (PkTimebase)(n)) / (1024*1024*1024))) - PkTimebase target_time; PkTimebase current_time; PkMachineContext ctx; @@ -61,33 +66,12 @@ namespace fapi2 // Only execute if nanoSeconds is non-zero (eg a real wait) if (i_nanoSeconds) { - // @todo For SBE applications, the time accuracy can be traded off - // for space with the PK_NANOSECONDS_SBE implemenation as the compiler - // use shift operations for the unit normalizing division. - // The critical section enter/exit set is done to ensure the timebase // operations are non-interrupible. pk_critical_section_enter(&ctx); - // - // The "accurate" version is the next line. - // target_time = pk_timebase_get() + PK_INTERVAL_SCALE(PK_NANOSECONDS(i_nanoSeconds)); - uint64_t cycles = 0; - if( SBE::isSimicsRunning() ) - { - cycles = PK_INTERVAL_SCALE( - PK_NANOSECONDS_SBE(i_nanoSeconds)); - } - else - { - // TODO via RTC 163216 - // Fix for the timer ( using in cycle mode ) - // Check what should be the right approach for time calculatin. - cycles = PK_INTERVAL_SCALE( - PK_NANOSECONDS_SBE(i_nanoSeconds)) * 64; - } - target_time = pk_timebase_get() + cycles; + target_time = pk_timebase_get() + delayCycles( i_nanoSeconds); do { diff --git a/src/sbefw/sbecmdiplcontrol.C b/src/sbefw/sbecmdiplcontrol.C index 1558ac47..1767f513 100644 --- a/src/sbefw/sbecmdiplcontrol.C +++ b/src/sbefw/sbecmdiplcontrol.C @@ -614,8 +614,8 @@ ReturnCode istepNestFreq( sbeIstepHwp_t i_hwp) uint8_t nestPllBkt = 0; FAPI_ATTR_GET( ATTR_NEST_PLL_BUCKET, sys, nestPllBkt ); assert( nestPllBkt && (nestPllBkt <= NEST_PLL_FREQ_BUCKETS )); - uint32_t sbeFreqHz = ( NEST_PLL_FREQ_LIST[ nestPllBkt - 1 ] * 1000 * 1000 )/ - SBE::SBE_TO_NEST_FREQ_FACTOR; + g_sbefreq = ( NEST_PLL_FREQ_LIST[ nestPllBkt - 1 ] * 1000 * 1000 )/ + SBE::SBE_TO_NEST_FREQ_FACTOR; assert( NULL != i_hwp.procHwp ); do @@ -627,8 +627,8 @@ ReturnCode istepNestFreq( sbeIstepHwp_t i_hwp) } // This function signature though has return value // But it always return SUCCESS. - SBE_INFO(SBE_FUNC"Setting new frequency:0x%08X", sbeFreqHz); - pk_timebase_freq_set(sbeFreqHz); + SBE_INFO(SBE_FUNC"Setting new frequency:0x%08X", g_sbefreq); + pk_timebase_freq_set(g_sbefreq); }while(0); return rc; #undef SBE_FUNC diff --git a/src/sbefw/sbemain.C b/src/sbefw/sbemain.C index 83a02185..101da9c4 100644 --- a/src/sbefw/sbemain.C +++ b/src/sbefw/sbemain.C @@ -77,7 +77,8 @@ PkThread g_sbeSyncCommandProcessor_thread; //// processing thread //////////////////////////////////////////////////////////////// PkThread g_sbeAsyncCommandProcessor_thread; - +// SBE Frequency. Initially nest frequency is 133 MHZ +uint32_t g_sbefreq = ( 133 * 1000 * 1000)/SBE::SBE_TO_NEST_FREQ_FACTOR; extern "C" { // These variables are declared in linker script to keep track of @@ -281,15 +282,12 @@ uint32_t main(int argc, char **argv) do { - // Keep default nest frequncy as 133 MHZ - static const uint32_t initialSbefreq = ( 133 * 1000 * 1000)/ - SBE::SBE_TO_NEST_FREQ_FACTOR; // initializes kernel data - // stack, threads, timebase, timers, etc. l_rc = pk_initialize((PkAddress)g_sbe_Kernel_NCInt_stack, SBE_NONCRITICAL_STACK_SIZE, 0, - initialSbefreq ); + g_sbefreq ); if (l_rc) { break; diff --git a/src/sbefw/sbeutil.H b/src/sbefw/sbeutil.H index e8e3e281..e572f6af 100644 --- a/src/sbefw/sbeutil.H +++ b/src/sbefw/sbeutil.H @@ -115,6 +115,7 @@ inline void SBE_MAGIC_INSTRUCTION(int _n) void sbeHandleFifoResponse (const uint32_t i_rc); void sbeHandlePsuResponse (const uint32_t i_rc); +extern uint32_t g_sbefreq; namespace SBE { |