iLLD_TC27xD  1.0
IfxCpu_CStart.h
Go to the documentation of this file.
1 /**
2  * \file IfxCpu_Cstart.h
3  * \brief This file contains the Core startup sequence.
4  *
5  *
6  * \version iLLD_1_0_0_11_0
7  * \copyright Copyright (c) 2012 Infineon Technologies AG. All rights reserved.
8  *
9  *
10  * IMPORTANT NOTICE
11  *
12  *
13  * Infineon Technologies AG (Infineon) is supplying this file for use
14  * exclusively with Infineon's microcontroller products. This file can be freely
15  * distributed within development tools that are supporting such microcontroller
16  * products.
17  *
18  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21  * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22  * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23  *
24  * \defgroup IfxLld_Cpu_CStart Core Startup Functions
25  * \ingroup IfxLld_Cpu
26  *
27  * \defgroup IfxLld_Cpu_CStart_StartupSequence Startup Sequence
28  * \ingroup IfxLld_Cpu_CStart
29  *
30  * \defgroup IfxLld_Cpu_CStart_ConfigEnableCache How to enable cache during startup?
31  * \ingroup IfxLld_Cpu_CStart
32  *
33  * \defgroup IfxLld_Cpu_CStart_ConfigEnableCores How to enable CPUs during startup?
34  * \ingroup IfxLld_Cpu_CStart
35  */
36 #ifndef IFXCPU_CSTART_H_
37 #define IFXCPU_CSTART_H_
38 
39 /******************************************************************************/
40 /* Includes */
41 /******************************************************************************/
42 #include "Ifx_Cfg.h"
43 #ifndef IFX_CFG_USE_COMPILER_DEFAULT_LINKER
44 #include "Cpu/Std/Ifx_Types.h"
47 
48 /******************************************************************************/
49 /* Macros */
50 /******************************************************************************/
51 
52 /** \brief Configuration for pre initialization hook function.
53  *
54  */
55 #ifndef IFX_CFG_CPU_CSTART_PRE_C_INIT_HOOK
56 # define IFX_CFG_CPU_CSTART_PRE_C_INIT_HOOK(cpu) /**< Hook function is empty if not configured*/
57 #endif
58 /******************************************************************************/
59 /* Exported prototypes */
60 /******************************************************************************/
61 void _Core1_start(void);
62 void _Core2_start(void);
63 
64 /*Documentation */
65 
66 /** \addtogroup IfxLld_Cpu_CStart_StartupSequence
67  * \{
68  *
69  * The startup driver is responsible for initializing the basic features of microcontroller
70  * to bring it up to the user functions. In framework these functions are called as "CoreX_main".
71  *
72  * In TC27X controllers, CPU0 is master controller which is booted from reset.
73  * IfxCpu_CStart driver provides following functionalities and they are listed in the order of
74  * their execution.
75  *
76  * \section IfxLld_Cpu_CStart_StartupSequence Core Startup Sequence
77  * 1) Execute pre-initialization hook, which is user configurable. \ref Ifx_Cpu_ConfigStartupPreInitHook\n
78  * 2) Setup user stack pointer for the CPU core\n
79  * 3) Set program/data cache bypass to configuration defined settings. Refer \ref Ifx_Cpu_CStart_ConfigEnableCache.\n
80  * 4) Set base address for trap vector and interrupt vector for the CPU core\n
81  * 5) Set interrupt stack pointer\n
82  * 6) Initialize the base pointers for the small data area registers for CPU core\n
83  * 7) Initialize the CSA for CPU core\n
84  * 8) Do the C initialization to initialize the global variables etc.\n
85  * 9) Initialize the clock system to configuration defined settings. \ref Ifx_Scu_Ccu_ConfigClock\n
86  * 10) Start remaining cores if they configuration setting request them to be enabled. \ref Ifx_Cpu_CStart_ConfigEnableCores\n
87  * 11) Call user function "CoreX_main"\n
88  *
89  * \note All the above functionalities are executed by "master core" in this case CPU0. Remaining cores will execute
90  * only subset of the above functions, i.e. steps 8) 9) and 10) are not executed by remaining CPU core startups.
91  *
92  * \section IfxLld_Cpu_CStart_ConfigStartupPreInitHook Using Startup pre-initialization hook
93  *
94  * If the application/ demo example need some activity other than above defined functionalities, user can configure
95  * the function which is called before any other initialization is executed. Example of such activity is testing the CSA and STACK.
96  *
97  * Following are the steps to be done to configure user defined activity which is needed before startup sequence.
98  *
99  * \subsection IfxLld_Cpu_CStart_ConfigStartupPreInitHookStep1 Step1: Define a hook function
100  *
101  * This definition shall be as user defined code (Generally in DemoApps folder).\n
102  * Considerations:\n
103  * 1. Format: IFX_INLINE void <pre init function name>(cpu)
104  * \note Define such a routine with the consideration, that there shall be no function call within this.
105  *
106  * 2. Use the information available as parameter cpu
107  *
108  * Example code in a user defined file eg. Ifx_preInitHook.h, placed under folder/subfolder: 0_AppSw/Tricore/DemoApp:
109  * \code
110  * // file: Ifx_preInitHook.h
111  * //Example function for pre initialization Hook for startup functions.
112  *
113  * IFX_INLINE mySysPreInitHook(uint32 cpu)
114  * {
115  * switch (cpu)
116  * {
117  * case 0:
118  * {
119  * //user code for cpu0: Function calls NOT allowed.
120  * break;
121  * }
122  * case 1:
123  * {
124  * //user code for cpu1: Function calls NOT allowed.
125  * break;
126  * }
127  * case 2:
128  * {
129  * //user code for cpu2: Function calls NOT allowed.
130  * break;
131  * }
132  * case default:
133  * {
134  * break;
135  * }
136  * }
137  * }
138  * \endcode
139  *
140  * \subsection IfxLld_Cpu_CStart_ConfigStartupPreInitHookStep2 Step2: Configure the pre initialization function for startup sequence call
141  * Create a file for configuring the hook. For example, Ifx_Cfg_CStart.h at ../0_Src/0_AppSw/Config/Tricore (or in DemoApp folder)
142  * \note This configuration, overload the macro IFX_CFG_CPU_CSTART_PRE_C_INIT_HOOK(cpu), which is already defined in IfxCpu_CStart.h.
143  * !!IMPORTANT!! Don't modify this at IfxCpu_CStart.h, because this is library file.
144  *
145  * \code
146  * //file: Ifx_Cfg_CStart.h
147  *
148  * #include "Ifx_preInitHook.h" //Assuming this is the file name as in above example
149  *
150  * #define IFX_CFG_CPU_CSTART_PRE_C_INIT_HOOK(cpu) mySysPreInitHook(cpu) //This is INLINE function.
151  *
152  * \endcode
153  */
154 
155 /** \} */
156 
157 /** \addtogroup IfxLld_Cpu_CStart_ConfigEnableCache
158  * \{
159  *
160  * In Tricore Cpu the cache enable/ disable are handled by the feature called cache bypass.
161  * Cache is enabled if the Bypass is disabled.
162  *
163  * Startup sequence of each CPU execute the function to do the cache settings. \ref Ifx_Cpu_StartupSequence
164  * The configuration parameters IFX_CFG_CPU_CSTART_ENABLE_TRICOREx_PCACHE and
165  * IFX_CFG_CPU_CSTART_ENABLE_TRICOREx_DCACHE control this function.
166  *
167  * To modify the default configuration, these macros are to be defined in Ifx_Cfg.h (usually located under ../0_Src/0_AppSw/Config/Common/Ifx_Cfg.h)
168  * \note This kind of definitions overload the macros, which are already defined in IfxCpu_CStart*.c.
169  * !!IMPORTANT!! Don't modify these in IfxCpu_CStart*.c, because theseare library files.
170  *
171  * Details of configuration parameters:\n
172  *
173  * \paragraph IfxLld_Cpu_CStart_ConfigEnableCachePgmParamters program cache configuration parameters
174  *
175  * Enable/Disable program cache of Tricore CPU0 with parameter:\n
176  * IFX_CFG_CPU_CSTART_ENABLE_TRICORE0_PCACHE\n
177  *
178  * Enable/Disable program cache of Tricore CPU1 with parameter:\n
179  * IFX_CFG_CPU_CSTART_ENABLE_TRICORE1_PCACHE\n
180  *
181  * Enable/Disable program cache of Tricore CPU2 with parameter:\n
182  * IFX_CFG_CPU_CSTART_ENABLE_TRICORE2_PCACHE\n
183  *
184  * Enable/Disable data cache of Tricore CPU0 with parameter:\n
185  * IFX_CFG_CPU_CSTART_ENABLE_TRICORE0_DCACHE\n
186  *
187  * Enable/Disable data cache of Tricore CPU1 with parameter:\n
188  * IFX_CFG_CPU_CSTART_ENABLE_TRICORE1_DCACHE\n
189  *
190  * Enable/Disable data cache of Tricore CPU2 with parameter:\n
191  * IFX_CFG_CPU_CSTART_ENABLE_TRICORE2_DCACHE\n
192  *
193  * Following example shows, how to enable program cache of all available cores and disable data cache of all
194  * the available cores.
195  * \code
196  * //file: Ifx_Cfg.h
197  *
198  * #define IFX_CFG_CPU_CSTART_ENABLE_TRICORE0_PCACHE (1) //Program cache for Cpu0 is enabled
199  *
200  * #define IFX_CFG_CPU_CSTART_ENABLE_TRICORE0_DCACHE (1) //Data cache for Cpu0 is enabled
201  *
202  * #define IFX_CFG_CPU_CSTART_ENABLE_TRICORE1_PCACHE (1) //Program cache for Cpu1 is enabled
203  *
204  * #define IFX_CFG_CPU_CSTART_ENABLE_TRICORE1_DCACHE (1) //Data cache for Cpu1 is enabled
205  *
206  * #define IFX_CFG_CPU_CSTART_ENABLE_TRICORE2_PCACHE (1) //Program cache for Cpu2 is enabled
207  *
208  * #define IFX_CFG_CPU_CSTART_ENABLE_TRICORE2_DCACHE (1) //Data cache for Cpu2 is enabled
209  *
210  * \endcode
211  *
212  * To control the the caches during runtime, refer for the details of APIs: \ref Ifx_Cpu_Cache
213  *
214  */
215 
216 /** \} */
217 
218 /** \addtogroup IfxLld_Cpu_CStart_ConfigEnableCores
219  * \{
220  *
221  * Startup sequence of CPU0 execute the function to initialize the remaining available CPUs.
222  * \ref IfxLld_Cpu_StartupSequence.
223  * Startup sequence enables all the available CPUs.
224  *
225  * The configuration parameters IFX_CFG_CPU_CSTART_ENABLE_TRICOREx control this function.
226  * To modify the default configuration, these macros are to be defined. Create a file to define these macros,
227  * for example, Ifx_Cfg_CStart.h at ../0_Src/0_AppSw/Config/Tricore (or in DemoApp folder).
228  * \note This kind of definitions, overload the macros, which are already defined in IfxCpu_CStart.h.
229  * !!IMPORTANT!! Don't modify these at IfxCpu_CStart.h, because this is library file.
230  *
231  * Details of configuration parameters:\n
232  *
233  * \paragraph IfxLld_Cpu_CStart_ConfigEnableCoresParamters CPU enable/disable configuration parameters
234  *
235  * Enable/Disable of Tricore CPU0 with parameter:\n
236  * IFX_CFG_CPU_CSTART_ENABLE_TRICORE0\n
237  *
238  * Enable/Disable of Tricore CPU1 with parameter:\n
239  * IFX_CFG_CPU_CSTART_ENABLE_TRICORE1\n
240  *
241  * Enable/Disable of Tricore CPU2 with parameter:\n
242  * IFX_CFG_CPU_CSTART_ENABLE_TRICORE2\n
243  *
244  * Following example shows, how to enable all available cores.
245  * \code
246  * //file: Ifx_Cfg_CStart.h
247  *
248  * #define IFX_CFG_CPU_CSTART_ENABLE_TRICORE0 (1) //Cpu0 is enabled
249  *
250  * #define IFX_CFG_CPU_CSTART_ENABLE_TRICORE1 (1) //Cpu1 is enabled
251  *
252  * #define IFX_CFG_CPU_CSTART_ENABLE_TRICORE2 (1) //Cpu2 is enabled
253  *
254  * \endcode
255  *
256  */
257 
258 /** \} */
259 
260 #endif /*#ifndef IFX_CFG_USE_COMPILER_DEFAULT_LINKER */
261 #endif /* IFXCPU_CSTART_H_ */