iLLD_TC27xD  1.0
IfxCpu_CStart2.c
Go to the documentation of this file.
1 /**
2  * \file IfxCpu_Cstart2.c
3  * \brief This file contains the Core startup sequence for Cpu2.
4  * \version iLLD_1_0_0_11_0
5  * \copyright Copyright (c) 2012 Infineon Technologies AG. All rights reserved.
6  *
7  *
8  *
9  * IMPORTANT NOTICE
10  *
11  *
12  * Infineon Technologies AG (Infineon) is supplying this file for use
13  * exclusively with Infineon's microcontroller products. This file can be freely
14  * distributed within development tools that are supporting such microcontroller
15  * products.
16  *
17  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
18  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
19  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
20  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
21  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
22  *
23  *
24  */
25 /*******************************************************************************
26 ** Includes **
27 *******************************************************************************/
28 #include "Ifx_Cfg.h"
29 #ifndef IFX_CFG_USE_COMPILER_DEFAULT_LINKER
30 #include "Scu/Std/IfxScuWdt.h"
31 #include "Cpu/Std/IfxCpu.h"
33 #include "IfxScu_reg.h"
34 #include "IfxCpu_reg.h"
35 
36 /******************************************************************************/
37 /* Macros */
38 /******************************************************************************/
39 /** \brief Configuration for cache enable.
40  *
41  */
42 #ifndef IFX_CFG_CPU_CSTART_ENABLE_TRICORE2_PCACHE
43 # define IFX_CFG_CPU_CSTART_ENABLE_TRICORE2_PCACHE (1) /**< Program Cache enabled by default*/
44 #endif
45 #ifndef IFX_CFG_CPU_CSTART_ENABLE_TRICORE2_DCACHE
46 # define IFX_CFG_CPU_CSTART_ENABLE_TRICORE2_DCACHE (1) /**< Data Cache enabled by default*/
47 #endif
48 /*******************************************************************************
49 ** Imported Function Declarations **
50 *******************************************************************************/
53 
54 IFX_EXTERN void core2_main(void);
55 #if defined(__TASKING__)
56 __asm("\t .extern core2_main");
57 #endif
58 /*******************************************************************************
59 ** Private Constant Definitions **
60 *******************************************************************************/
61 #define IFXCSTART2_PSW_DEFAULT (0x00000980u)
62 #define IFXCSTART2_PCX_O_S_DEFAULT (0xfff00000u)
63 
64 /********************************************************************************
65 * _start() - startup code
66 ********************************************************************************/
67 void _Core2_start(void)
68 {
69  uint32 pcxi;
70  uint16 wdtPassword = IfxScuWdt_getCpuWatchdogPasswordInline(&MODULE_SCU.WDTCPU[2]);
71 
72  IFX_CFG_CPU_CSTART_PRE_C_INIT_HOOK(2); /*Test Stack, CSA and Cache */
73 
74  /* Load user stack pointer */
75  __setareg(sp, __USTACK(2));
76  __dsync();
77 
78  /* Set the PSW to its reset value in case of a warm start,clear PSW.IS */
79  __mtcr(CPU_PSW, IFXCSTART2_PSW_DEFAULT); /* 0x00000980 */
80 
81  /* Set the PCXS and PCXO to its reset value in case of a warm start */
82  pcxi = __mfcr(CPU_PCXI);
83  pcxi &= IFXCSTART2_PCX_O_S_DEFAULT; /*0xfff00000; */
84  __mtcr(CPU_PCXI, pcxi);
85 
86  /* Clear the ENDINIT bit in the Password register, inline funtion */
87  IfxScuWdt_clearCpuEndinitInline(&MODULE_SCU.WDTCPU[2], wdtPassword);
88 
89  /*enable program cache */
91 
92  /*enable data cache */
94 
95  /* Clear the ENDINIT bit in the WDT_CON0 register, inline funtion */
96  IfxScuWdt_clearCpuEndinitInline(&MODULE_SCU.WDTCPU[2], wdtPassword);
97 
98  /* Load Base Address of Trap Vector Table. */
99  __mtcr(CPU_BTV, (uint32)__TRAPTAB(2));
100 
101  /* Load Base Address of Interrupt Vector Table. we will do this later in the program */
102  __mtcr(CPU_BIV, (uint32)__INTTAB(2));
103 
104  /* Load interupt stack pointer. */
105  __mtcr(CPU_ISP, (uint32)__ISTACK(2));
106 
107  IfxScuWdt_setCpuEndinitInline(&MODULE_SCU.WDTCPU[2], wdtPassword);
108 
109  /* initialize SDA base pointers */
110  __setareg(a0, __SDATA1(2));
111  __setareg(a1, __SDATA2(2));
112 
113  /* These to be un commented if A8 and A9 are required to be initialized */
114  __setareg(a8, __SDATA3(2));
115  __setareg(a9, __SDATA4(2));
116  /* Setup the context save area linked list. */
117 
119 
120  /*Call main function of Cpu0 */
122 }
123 
124 
125 #endif /*#ifndef IFX_CFG_USE_COMPILER_DEFAULT_LINKER */