diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/mcuxpresso/startup_MIMX8MM6_cm4.c')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/mcuxpresso/startup_MIMX8MM6_cm4.c | 799 |
1 files changed, 799 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/mcuxpresso/startup_MIMX8MM6_cm4.c b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/mcuxpresso/startup_MIMX8MM6_cm4.c new file mode 100644 index 000000000..e85eee580 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/mcuxpresso/startup_MIMX8MM6_cm4.c | |||
@@ -0,0 +1,799 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016, Freescale Semiconductor, Inc. | ||
3 | * Copyright 2018 NXP | ||
4 | * All rights reserved. | ||
5 | * | ||
6 | * SPDX-License-Identifier: BSD-3-Clause | ||
7 | */ | ||
8 | |||
9 | #if defined (DEBUG) | ||
10 | #pragma GCC push_options | ||
11 | #pragma GCC optimize ("Og") | ||
12 | #endif // (DEBUG) | ||
13 | |||
14 | #if defined (__cplusplus) | ||
15 | #ifdef __REDLIB__ | ||
16 | #error Redlib does not support C++ | ||
17 | #else | ||
18 | //***************************************************************************** | ||
19 | // | ||
20 | // The entry point for the C++ library startup | ||
21 | // | ||
22 | //***************************************************************************** | ||
23 | extern "C" { | ||
24 | extern void __libc_init_array(void); | ||
25 | } | ||
26 | #endif | ||
27 | #endif | ||
28 | |||
29 | #define WEAK __attribute__ ((weak)) | ||
30 | #define WEAK_AV __attribute__ ((weak, section(".after_vectors"))) | ||
31 | #define ALIAS(f) __attribute__ ((weak, alias (#f))) | ||
32 | |||
33 | //***************************************************************************** | ||
34 | #if defined (__cplusplus) | ||
35 | extern "C" { | ||
36 | #endif | ||
37 | |||
38 | //***************************************************************************** | ||
39 | // Declaration of external SystemInit function | ||
40 | //***************************************************************************** | ||
41 | #if defined (__USE_CMSIS) | ||
42 | extern void SystemInit(void); | ||
43 | #endif // (__USE_CMSIS) | ||
44 | |||
45 | //***************************************************************************** | ||
46 | // Forward declaration of the core exception handlers. | ||
47 | // When the application defines a handler (with the same name), this will | ||
48 | // automatically take precedence over these weak definitions | ||
49 | //***************************************************************************** | ||
50 | void ResetISR(void); | ||
51 | WEAK void NMI_Handler(void); | ||
52 | WEAK void HardFault_Handler(void); | ||
53 | WEAK void MemManage_Handler(void); | ||
54 | WEAK void BusFault_Handler(void); | ||
55 | WEAK void UsageFault_Handler(void); | ||
56 | WEAK void SVC_Handler(void); | ||
57 | WEAK void DebugMon_Handler(void); | ||
58 | WEAK void PendSV_Handler(void); | ||
59 | WEAK void SysTick_Handler(void); | ||
60 | WEAK void IntDefaultHandler(void); | ||
61 | //***************************************************************************** | ||
62 | // Forward declaration of the application IRQ handlers. When the application | ||
63 | // defines a handler (with the same name), this will automatically take | ||
64 | // precedence over weak definitions below | ||
65 | //***************************************************************************** | ||
66 | WEAK void CTI0_IRQHandler(void); | ||
67 | WEAK void DMA0_0_4_IRQHandler(void); | ||
68 | WEAK void DMA0_1_5_IRQHandler(void); | ||
69 | WEAK void DMA0_2_6_IRQHandler(void); | ||
70 | WEAK void DMA0_3_7_IRQHandler(void); | ||
71 | WEAK void DMA0_8_12_IRQHandler(void); | ||
72 | WEAK void DMA0_9_13_IRQHandler(void); | ||
73 | WEAK void DMA0_10_14_IRQHandler(void); | ||
74 | WEAK void DMA0_11_15_IRQHandler(void); | ||
75 | WEAK void DMA0_16_20_IRQHandler(void); | ||
76 | WEAK void DMA0_17_21_IRQHandler(void); | ||
77 | WEAK void DMA0_18_22_IRQHandler(void); | ||
78 | WEAK void DMA0_19_23_IRQHandler(void); | ||
79 | WEAK void DMA0_24_28_IRQHandler(void); | ||
80 | WEAK void DMA0_25_29_IRQHandler(void); | ||
81 | WEAK void DMA0_26_30_IRQHandler(void); | ||
82 | WEAK void DMA0_27_31_IRQHandler(void); | ||
83 | WEAK void DMA0_Error_IRQHandler(void); | ||
84 | WEAK void MCM0_IRQHandler(void); | ||
85 | WEAK void EWM_IRQHandler(void); | ||
86 | WEAK void LLWU0_IRQHandler(void); | ||
87 | WEAK void SIM_IRQHandler(void); | ||
88 | WEAK void MU_A_IRQHandler(void); | ||
89 | WEAK void Reserved39_IRQHandler(void); | ||
90 | WEAK void Software1_IRQHandler(void); | ||
91 | WEAK void Software2_IRQHandler(void); | ||
92 | WEAK void WDOG0_IRQHandler(void); | ||
93 | WEAK void SCG0_IRQHandler(void); | ||
94 | WEAK void QSPI_IRQHandler(void); | ||
95 | WEAK void LTC_IRQHandler(void); | ||
96 | WEAK void Reserved46_IRQHandler(void); | ||
97 | WEAK void SNVS_IRQHandler(void); | ||
98 | WEAK void TRNG0_IRQHandler(void); | ||
99 | WEAK void LPIT0_IRQHandler(void); | ||
100 | WEAK void PMC0_IRQHandler(void); | ||
101 | WEAK void CMC0_IRQHandler(void); | ||
102 | WEAK void LPTMR0_IRQHandler(void); | ||
103 | WEAK void LPTMR1_IRQHandler(void); | ||
104 | WEAK void TPM0_IRQHandler(void); | ||
105 | WEAK void TPM1_IRQHandler(void); | ||
106 | WEAK void TPM2_IRQHandler(void); | ||
107 | WEAK void TPM3_IRQHandler(void); | ||
108 | WEAK void FLEXIO0_IRQHandler(void); | ||
109 | WEAK void LPI2C0_IRQHandler(void); | ||
110 | WEAK void LPI2C1_IRQHandler(void); | ||
111 | WEAK void LPI2C2_IRQHandler(void); | ||
112 | WEAK void LPI2C3_IRQHandler(void); | ||
113 | WEAK void SAI0_IRQHandler(void); | ||
114 | WEAK void SAI1_IRQHandler(void); | ||
115 | WEAK void LPSPI0_IRQHandler(void); | ||
116 | WEAK void LPSPI1_IRQHandler(void); | ||
117 | WEAK void LPUART0_IRQHandler(void); | ||
118 | WEAK void LPUART1_IRQHandler(void); | ||
119 | WEAK void LPUART2_IRQHandler(void); | ||
120 | WEAK void LPUART3_IRQHandler(void); | ||
121 | WEAK void DPM_IRQHandler(void); | ||
122 | WEAK void PCTLA_IRQHandler(void); | ||
123 | WEAK void PCTLB_IRQHandler(void); | ||
124 | WEAK void ADC0_IRQHandler(void); | ||
125 | WEAK void ADC1_IRQHandler(void); | ||
126 | WEAK void CMP0_IRQHandler(void); | ||
127 | WEAK void CMP1_IRQHandler(void); | ||
128 | WEAK void DAC0_IRQHandler(void); | ||
129 | WEAK void DAC1_IRQHandler(void); | ||
130 | WEAK void WDOG1_IRQHandler(void); | ||
131 | WEAK void USB0_IRQHandler(void); | ||
132 | WEAK void USB1_IRQHandler(void); | ||
133 | WEAK void Reserved83_IRQHandler(void); | ||
134 | WEAK void WDOG2_IRQHandler(void); | ||
135 | WEAK void USBPHY_IRQHandler(void); | ||
136 | WEAK void CMC1_IRQHandler(void); | ||
137 | |||
138 | //***************************************************************************** | ||
139 | // Forward declaration of the driver IRQ handlers. These are aliased | ||
140 | // to the IntDefaultHandler, which is a 'forever' loop. When the driver | ||
141 | // defines a handler (with the same name), this will automatically take | ||
142 | // precedence over these weak definitions | ||
143 | //***************************************************************************** | ||
144 | void CTI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
145 | void DMA0_0_4_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
146 | void DMA0_1_5_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
147 | void DMA0_2_6_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
148 | void DMA0_3_7_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
149 | void DMA0_8_12_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
150 | void DMA0_9_13_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
151 | void DMA0_10_14_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
152 | void DMA0_11_15_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
153 | void DMA0_16_20_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
154 | void DMA0_17_21_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
155 | void DMA0_18_22_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
156 | void DMA0_19_23_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
157 | void DMA0_24_28_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
158 | void DMA0_25_29_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
159 | void DMA0_26_30_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
160 | void DMA0_27_31_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
161 | void DMA0_Error_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
162 | void MCM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
163 | void EWM_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
164 | void LLWU0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
165 | void SIM_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
166 | void MU_A_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
167 | void Reserved39_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
168 | void Software1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
169 | void Software2_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
170 | void WDOG0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
171 | void SCG0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
172 | void QSPI_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
173 | void LTC_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
174 | void Reserved46_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
175 | void SNVS_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
176 | void TRNG0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
177 | void LPIT0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
178 | void PMC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
179 | void CMC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
180 | void LPTMR0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
181 | void LPTMR1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
182 | void TPM0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
183 | void TPM1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
184 | void TPM2_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
185 | void TPM3_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
186 | void FLEXIO0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
187 | void LPI2C0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
188 | void LPI2C1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
189 | void LPI2C2_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
190 | void LPI2C3_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
191 | void SAI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
192 | void SAI1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
193 | void LPSPI0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
194 | void LPSPI1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
195 | void LPUART0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
196 | void LPUART1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
197 | void LPUART2_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
198 | void LPUART3_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
199 | void DPM_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
200 | void PCTLA_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
201 | void PCTLB_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
202 | void ADC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
203 | void ADC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
204 | void CMP0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
205 | void CMP1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
206 | void DAC0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
207 | void DAC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
208 | void WDOG1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
209 | void USB0_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
210 | void USB1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
211 | void Reserved83_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
212 | void WDOG2_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
213 | void USBPHY_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
214 | void CMC1_DriverIRQHandler(void) ALIAS(IntDefaultHandler); | ||
215 | |||
216 | //***************************************************************************** | ||
217 | // The entry point for the application. | ||
218 | // __main() is the entry point for Redlib based applications | ||
219 | // main() is the entry point for Newlib based applications | ||
220 | //***************************************************************************** | ||
221 | #if defined (__REDLIB__) | ||
222 | extern void __main(void); | ||
223 | #endif | ||
224 | extern int main(void); | ||
225 | |||
226 | //***************************************************************************** | ||
227 | // External declaration for the pointer to the stack top from the Linker Script | ||
228 | //***************************************************************************** | ||
229 | extern void _vStackTop(void); | ||
230 | |||
231 | //***************************************************************************** | ||
232 | #if defined (__cplusplus) | ||
233 | } // extern "C" | ||
234 | #endif | ||
235 | |||
236 | //***************************************************************************** | ||
237 | // The vector table. | ||
238 | // This relies on the linker script to place at correct location in memory. | ||
239 | //***************************************************************************** | ||
240 | extern void (* const g_pfnVectors[])(void); | ||
241 | __attribute__ ((section(".isr_vector"))) | ||
242 | void (* const g_pfnVectors[])(void) = { | ||
243 | &_vStackTop, // The initial stack pointer | ||
244 | ResetISR, // The reset handler | ||
245 | NMI_Handler, //NMI Handler | ||
246 | HardFault_Handler, //Hard Fault Handler | ||
247 | MemManage_Handler, //MPU Fault Handler | ||
248 | BusFault_Handler, //Bus Fault Handler | ||
249 | UsageFault_Handler, //Usage Fault Handler | ||
250 | 0, //Reserved | ||
251 | 0, //Reserved | ||
252 | 0, //Reserved | ||
253 | 0, //Reserved | ||
254 | SVC_Handler, //SVCall Handler | ||
255 | DebugMon_Handler, //Debug Monitor Handler | ||
256 | 0, //Reserved | ||
257 | PendSV_Handler, //PendSV Handler | ||
258 | SysTick_Handler, //SysTick Handler | ||
259 | //External Interrupts | ||
260 | CTI0_IRQHandler, //Cross Trigger Interface for CM4 | ||
261 | DMA0_0_4_IRQHandler, //DMA Channel 0, 4 Transfer Complete | ||
262 | DMA0_1_5_IRQHandler, //DMA Channel 1, 5 Transfer Complete | ||
263 | DMA0_2_6_IRQHandler, //DMA Channel 2, 6 Transfer Complete | ||
264 | DMA0_3_7_IRQHandler, //DMA Channel 3, 7 Transfer Complete | ||
265 | DMA0_8_12_IRQHandler, //DMA Channel 8, 12 Transfer Complete | ||
266 | DMA0_9_13_IRQHandler, //DMA Channel 9, 13 Transfer Complete | ||
267 | DMA0_10_14_IRQHandler, //DMA Channel 10, 14 Transfer Complete | ||
268 | DMA0_11_15_IRQHandler, //DMA Channel 11, 15 Transfer Complete | ||
269 | DMA0_16_20_IRQHandler, //DMA Channel 16, 20 Transfer Complete | ||
270 | DMA0_17_21_IRQHandler, //DMA Channel 17, 21 Transfer Complete | ||
271 | DMA0_18_22_IRQHandler, //DMA Channel 18, 22 Transfer Complete | ||
272 | DMA0_19_23_IRQHandler, //DMA Channel 19, 23 Transfer Complete | ||
273 | DMA0_24_28_IRQHandler, //DMA Channel 24, 28 Transfer Complete | ||
274 | DMA0_25_29_IRQHandler, //DMA Channel 25, 29 Transfer Complete | ||
275 | DMA0_26_30_IRQHandler, //DMA Channel 26, 30 Transfer Complete | ||
276 | DMA0_27_31_IRQHandler, //DMA Channel 27, 31 Transfer Complete | ||
277 | DMA0_Error_IRQHandler, //DMA Error Interrupt - All Channels | ||
278 | MCM0_IRQHandler, //MCM Interrupt | ||
279 | EWM_IRQHandler, //External Watchdog Monitor Interrupt | ||
280 | LLWU0_IRQHandler, //Low Leakage Wake Up | ||
281 | SIM_IRQHandler, //System Integation Module | ||
282 | MU_A_IRQHandler, //Messaging Unit - Side A | ||
283 | Reserved39_IRQHandler, //Secured JTAG Controller | ||
284 | Software1_IRQHandler, //Software Interrupt | ||
285 | Software2_IRQHandler, //Software Interrupt | ||
286 | WDOG0_IRQHandler, //Watchdog Interrupt | ||
287 | SCG0_IRQHandler, //System Clock Generator for M4 domain | ||
288 | QSPI_IRQHandler, //Quad Serial Peripheral Interface | ||
289 | LTC_IRQHandler, //Low Power Trusted Cryptography | ||
290 | Reserved46_IRQHandler, //Reserved | ||
291 | SNVS_IRQHandler, //Secure Non-Volatile Storage Consolidated Interrupt | ||
292 | TRNG0_IRQHandler, //Random Number Generator | ||
293 | LPIT0_IRQHandler, //Low Power Periodic Interrupt Timer | ||
294 | PMC0_IRQHandler, //Power Management Control interrupts for M4 domain | ||
295 | CMC0_IRQHandler, //Core Mode Controller interrupts for M4 domain | ||
296 | LPTMR0_IRQHandler, //Low Power Timer | ||
297 | LPTMR1_IRQHandler, //Low Power Timer | ||
298 | TPM0_IRQHandler, //Timer PWM module | ||
299 | TPM1_IRQHandler, //Timer PWM module | ||
300 | TPM2_IRQHandler, //Timer PWM module | ||
301 | TPM3_IRQHandler, //Timer PWM module | ||
302 | FLEXIO0_IRQHandler, //Flexible IO | ||
303 | LPI2C0_IRQHandler, //Inter-integrated circuit 0 | ||
304 | LPI2C1_IRQHandler, //Inter-integrated circuit 1 | ||
305 | LPI2C2_IRQHandler, //Inter-integrated circuit 2 | ||
306 | LPI2C3_IRQHandler, //Inter-integrated circuit 3 | ||
307 | SAI0_IRQHandler, //Serial Audio Interface | ||
308 | SAI1_IRQHandler, //Serial Audio Interface 1 | ||
309 | LPSPI0_IRQHandler, //Low Power Serial Peripheral Interface | ||
310 | LPSPI1_IRQHandler, //Low Power Serial Peripheral Interface | ||
311 | LPUART0_IRQHandler, //Low Power UART | ||
312 | LPUART1_IRQHandler, //Low Power UART | ||
313 | LPUART2_IRQHandler, //Low Power UART | ||
314 | LPUART3_IRQHandler, //Low Power UART | ||
315 | DPM_IRQHandler, //Dynamic Process Monitor | ||
316 | PCTLA_IRQHandler, //Port A pin interrupt | ||
317 | PCTLB_IRQHandler, //Port B pin interrupt | ||
318 | ADC0_IRQHandler, //Analog to Digital Convertor | ||
319 | ADC1_IRQHandler, //Analog to Digital Convertor | ||
320 | CMP0_IRQHandler, //Comparator | ||
321 | CMP1_IRQHandler, //Comparator | ||
322 | DAC0_IRQHandler, //Digital to Analog Convertor | ||
323 | DAC1_IRQHandler, //Digital to Analog Convertor | ||
324 | WDOG1_IRQHandler, //Watchdog Interrupt from A7 subsystem | ||
325 | USB0_IRQHandler, //USB 0 Interrupt from A7 subsystem | ||
326 | USB1_IRQHandler, //USB 1 Interrupt from A7 subsystem | ||
327 | Reserved83_IRQHandler, // | ||
328 | WDOG2_IRQHandler, //Watchdog Interrupt from A7 subsystem | ||
329 | USBPHY_IRQHandler, //USB PHY (used in conjunction with USBOTG0) | ||
330 | CMC1_IRQHandler, //A7 resets | ||
331 | }; /* End of g_pfnVectors */ | ||
332 | |||
333 | //***************************************************************************** | ||
334 | // Functions to carry out the initialization of RW and BSS data sections. These | ||
335 | // are written as separate functions rather than being inlined within the | ||
336 | // ResetISR() function in order to cope with MCUs with multiple banks of | ||
337 | // memory. | ||
338 | //***************************************************************************** | ||
339 | __attribute__ ((section(".after_vectors.init_data"))) | ||
340 | void data_init(unsigned int romstart, unsigned int start, unsigned int len) { | ||
341 | unsigned int *pulDest = (unsigned int*) start; | ||
342 | unsigned int *pulSrc = (unsigned int*) romstart; | ||
343 | unsigned int loop; | ||
344 | for (loop = 0; loop < len; loop = loop + 4) | ||
345 | *pulDest++ = *pulSrc++; | ||
346 | } | ||
347 | |||
348 | __attribute__ ((section(".after_vectors.init_bss"))) | ||
349 | void bss_init(unsigned int start, unsigned int len) { | ||
350 | unsigned int *pulDest = (unsigned int*) start; | ||
351 | unsigned int loop; | ||
352 | for (loop = 0; loop < len; loop = loop + 4) | ||
353 | *pulDest++ = 0; | ||
354 | } | ||
355 | |||
356 | //***************************************************************************** | ||
357 | // The following symbols are constructs generated by the linker, indicating | ||
358 | // the location of various points in the "Global Section Table". This table is | ||
359 | // created by the linker via the Code Red managed linker script mechanism. It | ||
360 | // contains the load address, execution address and length of each RW data | ||
361 | // section and the execution and length of each BSS (zero initialized) section. | ||
362 | //***************************************************************************** | ||
363 | extern unsigned int __data_section_table; | ||
364 | extern unsigned int __data_section_table_end; | ||
365 | extern unsigned int __bss_section_table; | ||
366 | extern unsigned int __bss_section_table_end; | ||
367 | |||
368 | //***************************************************************************** | ||
369 | // Reset entry point for your code. | ||
370 | // Sets up a simple runtime environment and initializes the C/C++ | ||
371 | // library. | ||
372 | //***************************************************************************** | ||
373 | __attribute__ ((section(".after_vectors.reset"))) | ||
374 | void | ||
375 | ResetISR(void) { | ||
376 | // Disable interrupts | ||
377 | __asm volatile ("cpsid i"); | ||
378 | |||
379 | #if defined (__USE_CMSIS) | ||
380 | // If __USE_CMSIS defined, then call CMSIS SystemInit code | ||
381 | SystemInit(); | ||
382 | #endif // (__USE_CMSIS) | ||
383 | |||
384 | // | ||
385 | // Copy the data sections from flash to SRAM. | ||
386 | // | ||
387 | unsigned int LoadAddr, ExeAddr, SectionLen; | ||
388 | unsigned int *SectionTableAddr; | ||
389 | |||
390 | // Load base address of Global Section Table | ||
391 | SectionTableAddr = &__data_section_table; | ||
392 | |||
393 | // Copy the data sections from flash to SRAM. | ||
394 | while (SectionTableAddr < &__data_section_table_end) { | ||
395 | LoadAddr = *SectionTableAddr++; | ||
396 | ExeAddr = *SectionTableAddr++; | ||
397 | SectionLen = *SectionTableAddr++; | ||
398 | data_init(LoadAddr, ExeAddr, SectionLen); | ||
399 | } | ||
400 | |||
401 | // At this point, SectionTableAddr = &__bss_section_table; | ||
402 | // Zero fill the bss segment | ||
403 | while (SectionTableAddr < &__bss_section_table_end) { | ||
404 | ExeAddr = *SectionTableAddr++; | ||
405 | SectionLen = *SectionTableAddr++; | ||
406 | bss_init(ExeAddr, SectionLen); | ||
407 | } | ||
408 | |||
409 | #if !defined (__USE_CMSIS) | ||
410 | // Assume that if __USE_CMSIS defined, then CMSIS SystemInit code | ||
411 | // will enable the FPU | ||
412 | #if defined (__VFP_FP__) && !defined (__SOFTFP__) | ||
413 | // | ||
414 | // Code to enable the Cortex-M4 FPU only included | ||
415 | // if appropriate build options have been selected. | ||
416 | // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C) | ||
417 | // | ||
418 | // Read CPACR (located at address 0xE000ED88) | ||
419 | // Set bits 20-23 to enable CP10 and CP11 coprocessors | ||
420 | // Write back the modified value to the CPACR | ||
421 | asm volatile ("LDR.W R0, =0xE000ED88\n\t" | ||
422 | "LDR R1, [R0]\n\t" | ||
423 | "ORR R1, R1, #(0xF << 20)\n\t" | ||
424 | "STR R1, [R0]"); | ||
425 | #endif // (__VFP_FP__) && !(__SOFTFP__) | ||
426 | #endif // (__USE_CMSIS) | ||
427 | |||
428 | #if !defined (__USE_CMSIS) | ||
429 | // Assume that if __USE_CMSIS defined, then CMSIS SystemInit code | ||
430 | // will setup the VTOR register | ||
431 | |||
432 | // Check to see if we are running the code from a non-zero | ||
433 | // address (eg RAM, external flash), in which case we need | ||
434 | // to modify the VTOR register to tell the CPU that the | ||
435 | // vector table is located at a non-0x0 address. | ||
436 | unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08; | ||
437 | if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) { | ||
438 | *pSCB_VTOR = (unsigned int)g_pfnVectors; | ||
439 | } | ||
440 | #endif // (__USE_CMSIS) | ||
441 | |||
442 | #if defined (__cplusplus) | ||
443 | // | ||
444 | // Call C++ library initialisation | ||
445 | // | ||
446 | __libc_init_array(); | ||
447 | #endif | ||
448 | |||
449 | |||
450 | // Reenable interrupts | ||
451 | __asm volatile ("cpsie i"); | ||
452 | |||
453 | #if defined (__REDLIB__) | ||
454 | // Call the Redlib library, which in turn calls main() | ||
455 | __main() ; | ||
456 | #else | ||
457 | main(); | ||
458 | #endif | ||
459 | |||
460 | // | ||
461 | // main() shouldn't return, but if it does, we'll just enter an infinite loop | ||
462 | // | ||
463 | while (1) { | ||
464 | ; | ||
465 | } | ||
466 | } | ||
467 | |||
468 | //***************************************************************************** | ||
469 | // Default core exception handlers. Override the ones here by defining your own | ||
470 | // handler routines in your application code. | ||
471 | //***************************************************************************** | ||
472 | WEAK void NMI_Handler(void) //NMI Handler | ||
473 | { while(1) {} | ||
474 | } | ||
475 | |||
476 | WEAK void HardFault_Handler(void) //Hard Fault Handler | ||
477 | { while(1) {} | ||
478 | } | ||
479 | |||
480 | WEAK void MemManage_Handler(void) //MPU Fault Handler | ||
481 | { while(1) {} | ||
482 | } | ||
483 | |||
484 | WEAK void BusFault_Handler(void) //Bus Fault Handler | ||
485 | { while(1) {} | ||
486 | } | ||
487 | |||
488 | WEAK void UsageFault_Handler(void) //Usage Fault Handler | ||
489 | { while(1) {} | ||
490 | } | ||
491 | |||
492 | WEAK void SVC_Handler(void) //SVCall Handler | ||
493 | { while(1) {} | ||
494 | } | ||
495 | |||
496 | WEAK void DebugMon_Handler(void) //Debug Monitor Handler | ||
497 | { while(1) {} | ||
498 | } | ||
499 | |||
500 | WEAK void PendSV_Handler(void) //PendSV Handler | ||
501 | { while(1) {} | ||
502 | } | ||
503 | |||
504 | WEAK void SysTick_Handler(void) //SysTick Handler | ||
505 | { while(1) {} | ||
506 | } | ||
507 | |||
508 | //***************************************************************************** | ||
509 | // Processor ends up here if an unexpected interrupt occurs or a specific | ||
510 | // handler is not present in the application code. | ||
511 | //***************************************************************************** | ||
512 | WEAK_AV void IntDefaultHandler(void) | ||
513 | { while(1) {} | ||
514 | } | ||
515 | |||
516 | //***************************************************************************** | ||
517 | // Default application exception handlers. Override the ones here by defining | ||
518 | // your own handler routines in your application code. These routines call | ||
519 | // driver exception handlers or IntDefaultHandler() if no driver exception | ||
520 | // handler is included. | ||
521 | //***************************************************************************** | ||
522 | WEAK void CTI0_IRQHandler(void) //Cross Trigger Interface for CM4 | ||
523 | { CTI0_DriverIRQHandler(); | ||
524 | } | ||
525 | |||
526 | WEAK void DMA0_0_4_IRQHandler(void) //DMA Channel 0, 4 Transfer Complete | ||
527 | { DMA0_0_4_DriverIRQHandler(); | ||
528 | } | ||
529 | |||
530 | WEAK void DMA0_1_5_IRQHandler(void) //DMA Channel 1, 5 Transfer Complete | ||
531 | { DMA0_1_5_DriverIRQHandler(); | ||
532 | } | ||
533 | |||
534 | WEAK void DMA0_2_6_IRQHandler(void) //DMA Channel 2, 6 Transfer Complete | ||
535 | { DMA0_2_6_DriverIRQHandler(); | ||
536 | } | ||
537 | |||
538 | WEAK void DMA0_3_7_IRQHandler(void) //DMA Channel 3, 7 Transfer Complete | ||
539 | { DMA0_3_7_DriverIRQHandler(); | ||
540 | } | ||
541 | |||
542 | WEAK void DMA0_8_12_IRQHandler(void) //DMA Channel 8, 12 Transfer Complete | ||
543 | { DMA0_8_12_DriverIRQHandler(); | ||
544 | } | ||
545 | |||
546 | WEAK void DMA0_9_13_IRQHandler(void) //DMA Channel 9, 13 Transfer Complete | ||
547 | { DMA0_9_13_DriverIRQHandler(); | ||
548 | } | ||
549 | |||
550 | WEAK void DMA0_10_14_IRQHandler(void) //DMA Channel 10, 14 Transfer Complete | ||
551 | { DMA0_10_14_DriverIRQHandler(); | ||
552 | } | ||
553 | |||
554 | WEAK void DMA0_11_15_IRQHandler(void) //DMA Channel 11, 15 Transfer Complete | ||
555 | { DMA0_11_15_DriverIRQHandler(); | ||
556 | } | ||
557 | |||
558 | WEAK void DMA0_16_20_IRQHandler(void) //DMA Channel 16, 20 Transfer Complete | ||
559 | { DMA0_16_20_DriverIRQHandler(); | ||
560 | } | ||
561 | |||
562 | WEAK void DMA0_17_21_IRQHandler(void) //DMA Channel 17, 21 Transfer Complete | ||
563 | { DMA0_17_21_DriverIRQHandler(); | ||
564 | } | ||
565 | |||
566 | WEAK void DMA0_18_22_IRQHandler(void) //DMA Channel 18, 22 Transfer Complete | ||
567 | { DMA0_18_22_DriverIRQHandler(); | ||
568 | } | ||
569 | |||
570 | WEAK void DMA0_19_23_IRQHandler(void) //DMA Channel 19, 23 Transfer Complete | ||
571 | { DMA0_19_23_DriverIRQHandler(); | ||
572 | } | ||
573 | |||
574 | WEAK void DMA0_24_28_IRQHandler(void) //DMA Channel 24, 28 Transfer Complete | ||
575 | { DMA0_24_28_DriverIRQHandler(); | ||
576 | } | ||
577 | |||
578 | WEAK void DMA0_25_29_IRQHandler(void) //DMA Channel 25, 29 Transfer Complete | ||
579 | { DMA0_25_29_DriverIRQHandler(); | ||
580 | } | ||
581 | |||
582 | WEAK void DMA0_26_30_IRQHandler(void) //DMA Channel 26, 30 Transfer Complete | ||
583 | { DMA0_26_30_DriverIRQHandler(); | ||
584 | } | ||
585 | |||
586 | WEAK void DMA0_27_31_IRQHandler(void) //DMA Channel 27, 31 Transfer Complete | ||
587 | { DMA0_27_31_DriverIRQHandler(); | ||
588 | } | ||
589 | |||
590 | WEAK void DMA0_Error_IRQHandler(void) //DMA Error Interrupt - All Channels | ||
591 | { DMA0_Error_DriverIRQHandler(); | ||
592 | } | ||
593 | |||
594 | WEAK void MCM0_IRQHandler(void) //MCM Interrupt | ||
595 | { MCM0_DriverIRQHandler(); | ||
596 | } | ||
597 | |||
598 | WEAK void EWM_IRQHandler(void) //External Watchdog Monitor Interrupt | ||
599 | { EWM_DriverIRQHandler(); | ||
600 | } | ||
601 | |||
602 | WEAK void LLWU0_IRQHandler(void) //Low Leakage Wake Up | ||
603 | { LLWU0_DriverIRQHandler(); | ||
604 | } | ||
605 | |||
606 | WEAK void SIM_IRQHandler(void) //System Integation Module | ||
607 | { SIM_DriverIRQHandler(); | ||
608 | } | ||
609 | |||
610 | WEAK void MU_A_IRQHandler(void) //Messaging Unit - Side A | ||
611 | { MU_A_DriverIRQHandler(); | ||
612 | } | ||
613 | |||
614 | WEAK void Software1_IRQHandler(void) //Software Interrupt | ||
615 | { Software1_DriverIRQHandler(); | ||
616 | } | ||
617 | |||
618 | WEAK void Software2_IRQHandler(void) //Software Interrupt | ||
619 | { Software2_DriverIRQHandler(); | ||
620 | } | ||
621 | |||
622 | WEAK void WDOG0_IRQHandler(void) //Watchdog Interrupt | ||
623 | { WDOG0_DriverIRQHandler(); | ||
624 | } | ||
625 | |||
626 | WEAK void SCG0_IRQHandler(void) //System Clock Generator for M4 domain | ||
627 | { SCG0_DriverIRQHandler(); | ||
628 | } | ||
629 | |||
630 | WEAK void QSPI_IRQHandler(void) //Quad Serial Peripheral Interface | ||
631 | { QSPI_DriverIRQHandler(); | ||
632 | } | ||
633 | |||
634 | WEAK void LTC_IRQHandler(void) //Low Power Trusted Cryptography | ||
635 | { LTC_DriverIRQHandler(); | ||
636 | } | ||
637 | |||
638 | WEAK void SNVS_IRQHandler(void) //Secure Non-Volatile Storage Consolidated Interrupt | ||
639 | { SNVS_DriverIRQHandler(); | ||
640 | } | ||
641 | |||
642 | WEAK void TRNG0_IRQHandler(void) //Random Number Generator | ||
643 | { TRNG0_DriverIRQHandler(); | ||
644 | } | ||
645 | |||
646 | WEAK void LPIT0_IRQHandler(void) //Low Power Periodic Interrupt Timer | ||
647 | { LPIT0_DriverIRQHandler(); | ||
648 | } | ||
649 | |||
650 | WEAK void PMC0_IRQHandler(void) //Power Management Control interrupts for M4 domain | ||
651 | { PMC0_DriverIRQHandler(); | ||
652 | } | ||
653 | |||
654 | WEAK void CMC0_IRQHandler(void) //Core Mode Controller interrupts for M4 domain | ||
655 | { CMC0_DriverIRQHandler(); | ||
656 | } | ||
657 | |||
658 | WEAK void LPTMR0_IRQHandler(void) //Low Power Timer | ||
659 | { LPTMR0_DriverIRQHandler(); | ||
660 | } | ||
661 | |||
662 | WEAK void LPTMR1_IRQHandler(void) //Low Power Timer | ||
663 | { LPTMR1_DriverIRQHandler(); | ||
664 | } | ||
665 | |||
666 | WEAK void TPM0_IRQHandler(void) //Timer PWM module | ||
667 | { TPM0_DriverIRQHandler(); | ||
668 | } | ||
669 | |||
670 | WEAK void TPM1_IRQHandler(void) //Timer PWM module | ||
671 | { TPM1_DriverIRQHandler(); | ||
672 | } | ||
673 | |||
674 | WEAK void TPM2_IRQHandler(void) //Timer PWM module | ||
675 | { TPM2_DriverIRQHandler(); | ||
676 | } | ||
677 | |||
678 | WEAK void TPM3_IRQHandler(void) //Timer PWM module | ||
679 | { TPM3_DriverIRQHandler(); | ||
680 | } | ||
681 | |||
682 | WEAK void FLEXIO0_IRQHandler(void) //Flexible IO | ||
683 | { FLEXIO0_DriverIRQHandler(); | ||
684 | } | ||
685 | |||
686 | WEAK void LPI2C0_IRQHandler(void) //Inter-integrated circuit 0 | ||
687 | { LPI2C0_DriverIRQHandler(); | ||
688 | } | ||
689 | |||
690 | WEAK void LPI2C1_IRQHandler(void) //Inter-integrated circuit 1 | ||
691 | { LPI2C1_DriverIRQHandler(); | ||
692 | } | ||
693 | |||
694 | WEAK void LPI2C2_IRQHandler(void) //Inter-integrated circuit 2 | ||
695 | { LPI2C2_DriverIRQHandler(); | ||
696 | } | ||
697 | |||
698 | WEAK void LPI2C3_IRQHandler(void) //Inter-integrated circuit 3 | ||
699 | { LPI2C3_DriverIRQHandler(); | ||
700 | } | ||
701 | |||
702 | WEAK void SAI0_IRQHandler(void) //Serial Audio Interface | ||
703 | { SAI0_DriverIRQHandler(); | ||
704 | } | ||
705 | |||
706 | WEAK void SAI1_IRQHandler(void) //Serial Audio Interface 1 | ||
707 | { SAI1_DriverIRQHandler(); | ||
708 | } | ||
709 | |||
710 | WEAK void LPSPI0_IRQHandler(void) //Low Power Serial Peripheral Interface | ||
711 | { LPSPI0_DriverIRQHandler(); | ||
712 | } | ||
713 | |||
714 | WEAK void LPSPI1_IRQHandler(void) //Low Power Serial Peripheral Interface | ||
715 | { LPSPI1_DriverIRQHandler(); | ||
716 | } | ||
717 | |||
718 | WEAK void LPUART0_IRQHandler(void) //Low Power UART | ||
719 | { LPUART0_DriverIRQHandler(); | ||
720 | } | ||
721 | |||
722 | WEAK void LPUART1_IRQHandler(void) //Low Power UART | ||
723 | { LPUART1_DriverIRQHandler(); | ||
724 | } | ||
725 | |||
726 | WEAK void LPUART2_IRQHandler(void) //Low Power UART | ||
727 | { LPUART2_DriverIRQHandler(); | ||
728 | } | ||
729 | |||
730 | WEAK void LPUART3_IRQHandler(void) //Low Power UART | ||
731 | { LPUART3_DriverIRQHandler(); | ||
732 | } | ||
733 | |||
734 | WEAK void DPM_IRQHandler(void) //Dynamic Process Monitor | ||
735 | { DPM_DriverIRQHandler(); | ||
736 | } | ||
737 | |||
738 | WEAK void PCTLA_IRQHandler(void) //Port A pin interrupt | ||
739 | { PCTLA_DriverIRQHandler(); | ||
740 | } | ||
741 | |||
742 | WEAK void PCTLB_IRQHandler(void) //Port B pin interrupt | ||
743 | { PCTLB_DriverIRQHandler(); | ||
744 | } | ||
745 | |||
746 | WEAK void ADC0_IRQHandler(void) //Analog to Digital Convertor | ||
747 | { ADC0_DriverIRQHandler(); | ||
748 | } | ||
749 | |||
750 | WEAK void ADC1_IRQHandler(void) //Analog to Digital Convertor | ||
751 | { ADC1_DriverIRQHandler(); | ||
752 | } | ||
753 | |||
754 | WEAK void CMP0_IRQHandler(void) //Comparator | ||
755 | { CMP0_DriverIRQHandler(); | ||
756 | } | ||
757 | |||
758 | WEAK void CMP1_IRQHandler(void) //Comparator | ||
759 | { CMP1_DriverIRQHandler(); | ||
760 | } | ||
761 | |||
762 | WEAK void DAC0_IRQHandler(void) //Digital to Analog Convertor | ||
763 | { DAC0_DriverIRQHandler(); | ||
764 | } | ||
765 | |||
766 | WEAK void DAC1_IRQHandler(void) //Digital to Analog Convertor | ||
767 | { DAC1_DriverIRQHandler(); | ||
768 | } | ||
769 | |||
770 | WEAK void WDOG1_IRQHandler(void) //Watchdog Interrupt from A7 subsystem | ||
771 | { WDOG1_DriverIRQHandler(); | ||
772 | } | ||
773 | |||
774 | WEAK void USB0_IRQHandler(void) //USB 0 Interrupt from A7 subsystem | ||
775 | { USB0_DriverIRQHandler(); | ||
776 | } | ||
777 | |||
778 | WEAK void USB1_IRQHandler(void) //USB 1 Interrupt from A7 subsystem | ||
779 | { USB1_DriverIRQHandler(); | ||
780 | } | ||
781 | |||
782 | WEAK void WDOG2_IRQHandler(void) //Watchdog Interrupt from A7 subsystem | ||
783 | { WDOG2_DriverIRQHandler(); | ||
784 | } | ||
785 | |||
786 | WEAK void USBPHY_IRQHandler(void) //USB PHY (used in conjunction with USBOTG0) | ||
787 | { USBPHY_DriverIRQHandler(); | ||
788 | } | ||
789 | |||
790 | WEAK void CMC1_IRQHandler(void) //A7 resets | ||
791 | { CMC1_DriverIRQHandler(); | ||
792 | } | ||
793 | |||
794 | //***************************************************************************** | ||
795 | |||
796 | #if defined (DEBUG) | ||
797 | #pragma GCC pop_options | ||
798 | #endif // (DEBUG) | ||
799 | \ No newline at end of file | ||