/***************************************************************************** PowerPC specific code for TRACE32 FDX trace $Date: 2014-01-29 15:33:45 +0100 (Wed, 29 Jan 2014) $ $Revision: 6034 $ - Compile together with t32fdx.c and your application code - Use compile switch -DT32_FDX_TRACE_COMPRESSED or -DT32_FDX_TRACE_UNCOMPRESSED for this file and t32fdx.c - Use compiler switch -finstrument-functions for your code to enable instrumentation calls for GCC - Use switch -DFDX_USE_TIMER for this file to use timers as timestamp counter for the recording (c) Lauterbach GmbH http://www.lauterbach.com/ *****************************************************************************/ #if defined(T32_FDX_TRACE_COMPRESSED) || defined(T32_FDX_TRACE_UNCOMPRESSED) /* FDX trace enabled ? */ #include #include "t32fdx.h" #if defined(FDX_USE_TIMEBASE) # define TBL 284 # define TBU 285 # define HID0 1008 # define MFSPR(SPR,VAL) __asm__ __volatile__("mfspr %[gpr],%[spr]" : [gpr]"=b"(VAL) : [spr]"i"(SPR) ); /* move from Special Purpose Registers */ # define MTSPR(SPR,VAL) __asm__ __volatile__("mtspr %[spr],%[gpr]" :: [gpr]"b"(VAL) , [spr]"i"(SPR) ); /* move to Special Purpose Registers */ FDX_NO_INSTRUMENT void T32_Fdx_TimerInit(void) { /* Enable TimeBase and count processor clock */ uint32_t flags; MFSPR(HID0, flags); flags = (flags | 0x4000) & ~0x2000; /* Set TBEN, Clear SEL_TBCLK */ MTSPR(HID0, flags); } FDX_NO_INSTRUMENT unsigned long T32_Fdx_GetTimebase(void) { /* Get timestamp via TimeBase (Works with most MPC5xxx CPUs, but not available on MPC560x "Bolero") */ uint32_t time; MFSPR(TBL, time); /* mftb r3*/ return time; } #elif defined(FDX_USE_SYSTEMTIMER) # define STM_CR STM_BASE[0] # define STM_CNT STM_BASE[1] volatile uint32_t* const STM_BASE = (uint32_t *)0xFFF3C000; /* check this address with your MPC5xxx Microcontroller Reference Manual*/ FDX_NO_INSTRUMENT void T32_Fdx_TimerInit(void) { STM_CR = 3; /* Enable SystemTimerModule */ } FDX_NO_INSTRUMENT unsigned long T32_Fdx_GetTimebase(void) { return STM_CNT; /* Get timestamp via SystemTimerModule */ } #else FDX_NO_INSTRUMENT void T32_Fdx_TimerInit(void) { } FDX_NO_INSTRUMENT unsigned long T32_Fdx_GetTimebase(void) { return 0; } #endif /* FDX_USE_TIMER */ /***************************************************************************** GNU GCC instrumentation calls Just after function entry and just before function exit, the following profiling functions will be called with the address of the current function and its call site, for all files compiled with "-finstrument-functions" *****************************************************************************/ FDX_NO_INSTRUMENT void __cyg_profile_func_enter(void *this_fn, void *call_site) { T32_Fdx_TraceFunction( this_fn ); } FDX_NO_INSTRUMENT void __cyg_profile_func_exit(void *this_fn, void *call_site) { T32_Fdx_TraceFunction( call_site ); } #endif /* T32_FDX_TRACE_COMPRESSED || T32_FDX_TRACE_UNCOMPRESSED */