boolean IfxCpu_startCore(Ifx_CPU *cpu, uint32 programCounter) { boolean retVal = TRUE; /* Set the PC for Core 1 */ retVal &= IfxCpu_setProgramCounter(cpu, programCounter); /* Get the mode for Core 1 and set it to RUNNING */ /* Core not running already */ if (IfxCpu_getCoreMode(cpu) == IfxCpu_CoreMode_halt) { retVal &= IfxCpu_setCoreMode(cpu, IfxCpu_CoreMode_run); } return retVal; }
/********************************************************************************* * _start() - startup code *********************************************************************************/ void _Core0_start(void) { uint32 pcxi; uint16 cpuWdtPassword = IfxScuWdt_getCpuWatchdogPasswordInline(&MODULE_SCU.WDTCPU[0]); IFX_CFG_CPU_CSTART_PRE_C_INIT_HOOK(0); /*Test Stack, CSA and Cache */ /* Load user stack pointer */ __setareg(sp, __USTACK(0)); __dsync(); /* Set the PSW to its reset value in case of a warm start,clear PSW.IS */ __mtcr(CPU_PSW, IFXCSTART0_PSW_DEFAULT); /* Set the PCXS and PCXO to its reset value in case of a warm start */ pcxi = __mfcr(CPU_PCXI); pcxi &= IFXCSTART0_PCX_O_S_DEFAULT; /*0xfff00000; */ __mtcr(CPU_PCXI, pcxi); /*enable/disable program cache depending on the configuration */ IfxCpu_setProgramCache(IFX_CFG_CPU_CSTART_ENABLE_TRICORE0_PCACHE); /*enable/disable data cache depending on the configuration */ IfxCpu_setDataCache(IFX_CFG_CPU_CSTART_ENABLE_TRICORE0_DCACHE); /* Clear the ENDINIT bit in the WDT_CON0 register, inline funtion */ IfxScuWdt_clearCpuEndinitInline(&MODULE_SCU.WDTCPU[0], cpuWdtPassword); /* Load Base Address of Trap Vector Table. */ __mtcr(CPU_BTV, (uint32)__TRAPTAB(0)); /* Load Base Address of Interrupt Vector Table. we will do this later in the program */ __mtcr(CPU_BIV, (uint32)__INTTAB(0)); /* Load interupt stack pointer. */ __mtcr(CPU_ISP, (uint32)__ISTACK(0)); IfxScuWdt_setCpuEndinitInline(&MODULE_SCU.WDTCPU[0], cpuWdtPassword); /* initialize SDA base pointers */ __setareg(a0, __SDATA1(0)); __setareg(a1, __SDATA2(0)); /* These to be un commented if A8 and A9 are required to be initialized */ __setareg(a8, __SDATA3(0)); __setareg(a9, __SDATA4(0)); /* Setup the context save area linked list. */ IfxCpu_initCSA((uint32 *)__CSA(0), (uint32 *)__CSA_END(0)); /*Initialize the context save area for CPU0 */ { /*CPU and safety watchdogs are enabled by default, C initialization functions are not servicing the watchdogs */ uint16 safetyWdtPassword = IfxScuWdt_getSafetyWatchdogPassword(); IfxScuWdt_disableCpuWatchdog(cpuWdtPassword); IfxScuWdt_disableSafetyWatchdog(safetyWdtPassword); Ifx_C_Init(); /*Initialization of C runtime variables */ IfxScuWdt_enableCpuWatchdog(cpuWdtPassword); IfxScuWdt_enableSafetyWatchdog(safetyWdtPassword); } /*Initialize the clock system */ IFXCPU_CSTART_CCU_INIT_HOOK(); /*Start remaining cores */ #if (IFX_CFG_CPU_CSTART_ENABLE_TRICORE1 != 0) (void)IfxCpu_startCore(&MODULE_CPU1, (uint32)&_Core1_start); /*The status returned by function call is ignored */ #endif #if (IFX_CFG_CPU_CSTART_ENABLE_TRICORE2 != 0) (void)IfxCpu_startCore(&MODULE_CPU2, (uint32)&_Core2_start); /*The status returned by function call is ignored */ #endif #if (IFX_CFG_CPU_CSTART_ENABLE_TRICORE0 == 0) /*halt the CPU 0 if it is not needed to be enabled */ IfxCpu_setCoreMode(&MODULE_CPU0, IfxCpu_CoreMode_idle); #endif /*Call main function of Cpu0 */ __non_return_call(core0_main); }