From 720dfdf376155029a429339f7f862232081ccca0 Mon Sep 17 00:00:00 2001 From: William Bryan Date: Wed, 21 Sep 2016 16:26:07 -0500 Subject: SSX Runtime Environment Check RTC: 139829 Change-Id: Ic43ab936fd9d9b0d41270bbea50cd3969d9f8432 Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/30063 Tested-by: FSP CI Jenkins Reviewed-by: Martha Broyles Reviewed-by: Wael El-Essawy Reviewed-by: William A. Bryan --- src/occ_405/main.c | 51 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 41 insertions(+), 10 deletions(-) (limited to 'src/occ_405/main.c') diff --git a/src/occ_405/main.c b/src/occ_405/main.c index 594ba2e..b73c7cc 100755 --- a/src/occ_405/main.c +++ b/src/occ_405/main.c @@ -102,6 +102,9 @@ uint32_t G_mainThreadLoopCounter = 0x0; // Global flag indicating FIR collection is required bool G_fir_collection_required = FALSE; +// Global flag indicating we are running on Simics +bool G_simics_environment = FALSE; + extern uint8_t g_trac_inf_buffer[]; extern uint8_t g_trac_imp_buffer[]; extern uint8_t g_trac_err_buffer[]; @@ -112,6 +115,26 @@ void pmc_hw_error_isr(void *private, SsxIrqId irq, int priority); //mode interrupt handler SSX_IRQ_FAST2FULL(pmc_hw_error_fast, pmc_hw_error_isr); +/* + * Function Specification + * + * Name: check_runtime_environment + * + * Description: Determines whether we are running in Simics or on real HW. + * + * End Function Specification + */ +void check_runtime_environment(void) +{ + uint64_t flags; + flags = in64(OCB_OCCFLG); + + // NOTE: The lower 32 bits of this register have no latches on + // physical hardware and will return 0s, so we can use + // a backdoor hack in Simics to set bit 63, telling the + // firmware what environment it's running in. + G_simics_environment = ( 0 != (flags & 0x0000000000000001) ) ? TRUE : FALSE; +} /* * Function Specification @@ -938,6 +961,9 @@ int main(int argc, char **argv) int l_ssxrc = 0; int l_ssxrc2 = 0; + // First, check what environment we are running on (Simics vs. HW). + check_runtime_environment(); + // ---------------------------------------------------- // Initialize TLB for Linear Window access here so we // can write checkpoints into the fsp response buffer. @@ -975,7 +1001,7 @@ int main(int argc, char **argv) //failure means we can't talk to FSP. SSX_PANIC(0x01000001); } -#endif /* SIMICS_ENVIRONMENT */ +#endif /* TRAC_TO_SIMICS */ l_ssxrc = ppc405_mmu_map( CMDH_OCC_RESPONSE_BASE_ADDRESS, @@ -1125,6 +1151,10 @@ int main(int argc, char **argv) CHECKPOINT(TRACE_INITIALIZED); MAIN_TRAC_INFO("Inside OCC Main"); + + MAIN_TRAC_INFO("Currently %srunning in Simics environment", + ((G_simics_environment == FALSE) ? "not " : "") ); + // Trace what happened before ssx initialization MAIN_TRAC_INFO("HOMER accessed, rc=%d, version=%d, ssx_rc=%d", l_homerrc, l_homer_version, l_ssxrc); @@ -1224,17 +1254,18 @@ int main(int argc, char **argv) } } */ - // enable and register additional interrupt handlers - CHECKPOINT(INITIALIZING_IRQS); -// TODO: Uncomment when this is resolved in Simics. Causes SSX panic -// currently. Not needed until we want to be able to catch -// hardware OCC or PMC (or equivalent) errors. -#if !SIMICS_ENVIRONMENT - occ_irq_setup(); -#endif + //TODO: Causes an SSX panic in Simics. If it's needed in simulation, + // debug of the problem will be necessary to resolve. + if(FALSE == G_simics_environment) + { + // enable and register additional interrupt handlers + CHECKPOINT(INITIALIZING_IRQS); + + occ_irq_setup(); - CHECKPOINT(IRQS_INITIALIZED); + CHECKPOINT(IRQS_INITIALIZED); + } // enable IPC and start GPEs CHECKPOINT(INITIALIZING_IPC); -- cgit v1.2.1