diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/mcuxpresso/startup_MIMX8MM6_cm4.cpp')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/mcuxpresso/startup_MIMX8MM6_cm4.cpp | 798 |
1 files changed, 798 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/mcuxpresso/startup_MIMX8MM6_cm4.cpp b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/mcuxpresso/startup_MIMX8MM6_cm4.cpp new file mode 100644 index 000000000..2a2c5e216 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMX8MM6/mcuxpresso/startup_MIMX8MM6_cm4.cpp | |||
@@ -0,0 +1,798 @@ | |||
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 ResetISR(void) { | ||
375 | // Disable interrupts | ||
376 | __asm volatile ("cpsid i"); | ||
377 | |||
378 | #if defined (__USE_CMSIS) | ||
379 | // If __USE_CMSIS defined, then call CMSIS SystemInit code | ||
380 | SystemInit(); | ||
381 | #endif // (__USE_CMSIS) | ||
382 | |||
383 | // | ||
384 | // Copy the data sections from flash to SRAM. | ||
385 | // | ||
386 | unsigned int LoadAddr, ExeAddr, SectionLen; | ||
387 | unsigned int *SectionTableAddr; | ||
388 | |||
389 | // Load base address of Global Section Table | ||
390 | SectionTableAddr = &__data_section_table; | ||
391 | |||
392 | // Copy the data sections from flash to SRAM. | ||
393 | while (SectionTableAddr < &__data_section_table_end) { | ||
394 | LoadAddr = *SectionTableAddr++; | ||
395 | ExeAddr = *SectionTableAddr++; | ||
396 | SectionLen = *SectionTableAddr++; | ||
397 | data_init(LoadAddr, ExeAddr, SectionLen); | ||
398 | } | ||
399 | |||
400 | // At this point, SectionTableAddr = &__bss_section_table; | ||
401 | // Zero fill the bss segment | ||
402 | while (SectionTableAddr < &__bss_section_table_end) { | ||
403 | ExeAddr = *SectionTableAddr++; | ||
404 | SectionLen = *SectionTableAddr++; | ||
405 | bss_init(ExeAddr, SectionLen); | ||
406 | } | ||
407 | |||
408 | #if !defined (__USE_CMSIS) | ||
409 | // Assume that if __USE_CMSIS defined, then CMSIS SystemInit code | ||
410 | // will enable the FPU | ||
411 | #if defined (__VFP_FP__) && !defined (__SOFTFP__) | ||
412 | // | ||
413 | // Code to enable the Cortex-M4 FPU only included | ||
414 | // if appropriate build options have been selected. | ||
415 | // Code taken from Section 7.1, Cortex-M4 TRM (DDI0439C) | ||
416 | // | ||
417 | // Read CPACR (located at address 0xE000ED88) | ||
418 | // Set bits 20-23 to enable CP10 and CP11 coprocessors | ||
419 | // Write back the modified value to the CPACR | ||
420 | asm volatile ("LDR.W R0, =0xE000ED88\n\t" | ||
421 | "LDR R1, [R0]\n\t" | ||
422 | "ORR R1, R1, #(0xF << 20)\n\t" | ||
423 | "STR R1, [R0]"); | ||
424 | #endif // (__VFP_FP__) && !(__SOFTFP__) | ||
425 | #endif // (__USE_CMSIS) | ||
426 | |||
427 | #if !defined (__USE_CMSIS) | ||
428 | // Assume that if __USE_CMSIS defined, then CMSIS SystemInit code | ||
429 | // will setup the VTOR register | ||
430 | |||
431 | // Check to see if we are running the code from a non-zero | ||
432 | // address (eg RAM, external flash), in which case we need | ||
433 | // to modify the VTOR register to tell the CPU that the | ||
434 | // vector table is located at a non-0x0 address. | ||
435 | unsigned int * pSCB_VTOR = (unsigned int *) 0xE000ED08; | ||
436 | if ((unsigned int *)g_pfnVectors!=(unsigned int *) 0x00000000) { | ||
437 | *pSCB_VTOR = (unsigned int)g_pfnVectors; | ||
438 | } | ||
439 | #endif // (__USE_CMSIS) | ||
440 | |||
441 | #if defined (__cplusplus) | ||
442 | // | ||
443 | // Call C++ library initialisation | ||
444 | // | ||
445 | __libc_init_array(); | ||
446 | #endif | ||
447 | |||
448 | |||
449 | // Reenable interrupts | ||
450 | __asm volatile ("cpsie i"); | ||
451 | |||
452 | #if defined (__REDLIB__) | ||
453 | // Call the Redlib library, which in turn calls main() | ||
454 | __main() ; | ||
455 | #else | ||
456 | main(); | ||
457 | #endif | ||
458 | |||
459 | // | ||
460 | // main() shouldn't return, but if it does, we'll just enter an infinite loop | ||
461 | // | ||
462 | while (1) { | ||
463 | ; | ||
464 | } | ||
465 | } | ||
466 | |||
467 | //***************************************************************************** | ||
468 | // Default core exception handlers. Override the ones here by defining your own | ||
469 | // handler routines in your application code. | ||
470 | //***************************************************************************** | ||
471 | WEAK void NMI_Handler(void) //NMI Handler | ||
472 | { while(1) {} | ||
473 | } | ||
474 | |||
475 | WEAK void HardFault_Handler(void) //Hard Fault Handler | ||
476 | { while(1) {} | ||
477 | } | ||
478 | |||
479 | WEAK void MemManage_Handler(void) //MPU Fault Handler | ||
480 | { while(1) {} | ||
481 | } | ||
482 | |||
483 | WEAK void BusFault_Handler(void) //Bus Fault Handler | ||
484 | { while(1) {} | ||
485 | } | ||
486 | |||
487 | WEAK void UsageFault_Handler(void) //Usage Fault Handler | ||
488 | { while(1) {} | ||
489 | } | ||
490 | |||
491 | WEAK void SVC_Handler(void) //SVCall Handler | ||
492 | { while(1) {} | ||
493 | } | ||
494 | |||
495 | WEAK void DebugMon_Handler(void) //Debug Monitor Handler | ||
496 | { while(1) {} | ||
497 | } | ||
498 | |||
499 | WEAK void PendSV_Handler(void) //PendSV Handler | ||
500 | { while(1) {} | ||
501 | } | ||
502 | |||
503 | WEAK void SysTick_Handler(void) //SysTick Handler | ||
504 | { while(1) {} | ||
505 | } | ||
506 | |||
507 | //***************************************************************************** | ||
508 | // Processor ends up here if an unexpected interrupt occurs or a specific | ||
509 | // handler is not present in the application code. | ||
510 | //***************************************************************************** | ||
511 | WEAK_AV void IntDefaultHandler(void) | ||
512 | { while(1) {} | ||
513 | } | ||
514 | |||
515 | //***************************************************************************** | ||
516 | // Default application exception handlers. Override the ones here by defining | ||
517 | // your own handler routines in your application code. These routines call | ||
518 | // driver exception handlers or IntDefaultHandler() if no driver exception | ||
519 | // handler is included. | ||
520 | //***************************************************************************** | ||
521 | WEAK void CTI0_IRQHandler(void) //Cross Trigger Interface for CM4 | ||
522 | { CTI0_DriverIRQHandler(); | ||
523 | } | ||
524 | |||
525 | WEAK void DMA0_0_4_IRQHandler(void) //DMA Channel 0, 4 Transfer Complete | ||
526 | { DMA0_0_4_DriverIRQHandler(); | ||
527 | } | ||
528 | |||
529 | WEAK void DMA0_1_5_IRQHandler(void) //DMA Channel 1, 5 Transfer Complete | ||
530 | { DMA0_1_5_DriverIRQHandler(); | ||
531 | } | ||
532 | |||
533 | WEAK void DMA0_2_6_IRQHandler(void) //DMA Channel 2, 6 Transfer Complete | ||
534 | { DMA0_2_6_DriverIRQHandler(); | ||
535 | } | ||
536 | |||
537 | WEAK void DMA0_3_7_IRQHandler(void) //DMA Channel 3, 7 Transfer Complete | ||
538 | { DMA0_3_7_DriverIRQHandler(); | ||
539 | } | ||
540 | |||
541 | WEAK void DMA0_8_12_IRQHandler(void) //DMA Channel 8, 12 Transfer Complete | ||
542 | { DMA0_8_12_DriverIRQHandler(); | ||
543 | } | ||
544 | |||
545 | WEAK void DMA0_9_13_IRQHandler(void) //DMA Channel 9, 13 Transfer Complete | ||
546 | { DMA0_9_13_DriverIRQHandler(); | ||
547 | } | ||
548 | |||
549 | WEAK void DMA0_10_14_IRQHandler(void) //DMA Channel 10, 14 Transfer Complete | ||
550 | { DMA0_10_14_DriverIRQHandler(); | ||
551 | } | ||
552 | |||
553 | WEAK void DMA0_11_15_IRQHandler(void) //DMA Channel 11, 15 Transfer Complete | ||
554 | { DMA0_11_15_DriverIRQHandler(); | ||
555 | } | ||
556 | |||
557 | WEAK void DMA0_16_20_IRQHandler(void) //DMA Channel 16, 20 Transfer Complete | ||
558 | { DMA0_16_20_DriverIRQHandler(); | ||
559 | } | ||
560 | |||
561 | WEAK void DMA0_17_21_IRQHandler(void) //DMA Channel 17, 21 Transfer Complete | ||
562 | { DMA0_17_21_DriverIRQHandler(); | ||
563 | } | ||
564 | |||
565 | WEAK void DMA0_18_22_IRQHandler(void) //DMA Channel 18, 22 Transfer Complete | ||
566 | { DMA0_18_22_DriverIRQHandler(); | ||
567 | } | ||
568 | |||
569 | WEAK void DMA0_19_23_IRQHandler(void) //DMA Channel 19, 23 Transfer Complete | ||
570 | { DMA0_19_23_DriverIRQHandler(); | ||
571 | } | ||
572 | |||
573 | WEAK void DMA0_24_28_IRQHandler(void) //DMA Channel 24, 28 Transfer Complete | ||
574 | { DMA0_24_28_DriverIRQHandler(); | ||
575 | } | ||
576 | |||
577 | WEAK void DMA0_25_29_IRQHandler(void) //DMA Channel 25, 29 Transfer Complete | ||
578 | { DMA0_25_29_DriverIRQHandler(); | ||
579 | } | ||
580 | |||
581 | WEAK void DMA0_26_30_IRQHandler(void) //DMA Channel 26, 30 Transfer Complete | ||
582 | { DMA0_26_30_DriverIRQHandler(); | ||
583 | } | ||
584 | |||
585 | WEAK void DMA0_27_31_IRQHandler(void) //DMA Channel 27, 31 Transfer Complete | ||
586 | { DMA0_27_31_DriverIRQHandler(); | ||
587 | } | ||
588 | |||
589 | WEAK void DMA0_Error_IRQHandler(void) //DMA Error Interrupt - All Channels | ||
590 | { DMA0_Error_DriverIRQHandler(); | ||
591 | } | ||
592 | |||
593 | WEAK void MCM0_IRQHandler(void) //MCM Interrupt | ||
594 | { MCM0_DriverIRQHandler(); | ||
595 | } | ||
596 | |||
597 | WEAK void EWM_IRQHandler(void) //External Watchdog Monitor Interrupt | ||
598 | { EWM_DriverIRQHandler(); | ||
599 | } | ||
600 | |||
601 | WEAK void LLWU0_IRQHandler(void) //Low Leakage Wake Up | ||
602 | { LLWU0_DriverIRQHandler(); | ||
603 | } | ||
604 | |||
605 | WEAK void SIM_IRQHandler(void) //System Integation Module | ||
606 | { SIM_DriverIRQHandler(); | ||
607 | } | ||
608 | |||
609 | WEAK void MU_A_IRQHandler(void) //Messaging Unit - Side A | ||
610 | { MU_A_DriverIRQHandler(); | ||
611 | } | ||
612 | |||
613 | WEAK void Software1_IRQHandler(void) //Software Interrupt | ||
614 | { Software1_DriverIRQHandler(); | ||
615 | } | ||
616 | |||
617 | WEAK void Software2_IRQHandler(void) //Software Interrupt | ||
618 | { Software2_DriverIRQHandler(); | ||
619 | } | ||
620 | |||
621 | WEAK void WDOG0_IRQHandler(void) //Watchdog Interrupt | ||
622 | { WDOG0_DriverIRQHandler(); | ||
623 | } | ||
624 | |||
625 | WEAK void SCG0_IRQHandler(void) //System Clock Generator for M4 domain | ||
626 | { SCG0_DriverIRQHandler(); | ||
627 | } | ||
628 | |||
629 | WEAK void QSPI_IRQHandler(void) //Quad Serial Peripheral Interface | ||
630 | { QSPI_DriverIRQHandler(); | ||
631 | } | ||
632 | |||
633 | WEAK void LTC_IRQHandler(void) //Low Power Trusted Cryptography | ||
634 | { LTC_DriverIRQHandler(); | ||
635 | } | ||
636 | |||
637 | WEAK void SNVS_IRQHandler(void) //Secure Non-Volatile Storage Consolidated Interrupt | ||
638 | { SNVS_DriverIRQHandler(); | ||
639 | } | ||
640 | |||
641 | WEAK void TRNG0_IRQHandler(void) //Random Number Generator | ||
642 | { TRNG0_DriverIRQHandler(); | ||
643 | } | ||
644 | |||
645 | WEAK void LPIT0_IRQHandler(void) //Low Power Periodic Interrupt Timer | ||
646 | { LPIT0_DriverIRQHandler(); | ||
647 | } | ||
648 | |||
649 | WEAK void PMC0_IRQHandler(void) //Power Management Control interrupts for M4 domain | ||
650 | { PMC0_DriverIRQHandler(); | ||
651 | } | ||
652 | |||
653 | WEAK void CMC0_IRQHandler(void) //Core Mode Controller interrupts for M4 domain | ||
654 | { CMC0_DriverIRQHandler(); | ||
655 | } | ||
656 | |||
657 | WEAK void LPTMR0_IRQHandler(void) //Low Power Timer | ||
658 | { LPTMR0_DriverIRQHandler(); | ||
659 | } | ||
660 | |||
661 | WEAK void LPTMR1_IRQHandler(void) //Low Power Timer | ||
662 | { LPTMR1_DriverIRQHandler(); | ||
663 | } | ||
664 | |||
665 | WEAK void TPM0_IRQHandler(void) //Timer PWM module | ||
666 | { TPM0_DriverIRQHandler(); | ||
667 | } | ||
668 | |||
669 | WEAK void TPM1_IRQHandler(void) //Timer PWM module | ||
670 | { TPM1_DriverIRQHandler(); | ||
671 | } | ||
672 | |||
673 | WEAK void TPM2_IRQHandler(void) //Timer PWM module | ||
674 | { TPM2_DriverIRQHandler(); | ||
675 | } | ||
676 | |||
677 | WEAK void TPM3_IRQHandler(void) //Timer PWM module | ||
678 | { TPM3_DriverIRQHandler(); | ||
679 | } | ||
680 | |||
681 | WEAK void FLEXIO0_IRQHandler(void) //Flexible IO | ||
682 | { FLEXIO0_DriverIRQHandler(); | ||
683 | } | ||
684 | |||
685 | WEAK void LPI2C0_IRQHandler(void) //Inter-integrated circuit 0 | ||
686 | { LPI2C0_DriverIRQHandler(); | ||
687 | } | ||
688 | |||
689 | WEAK void LPI2C1_IRQHandler(void) //Inter-integrated circuit 1 | ||
690 | { LPI2C1_DriverIRQHandler(); | ||
691 | } | ||
692 | |||
693 | WEAK void LPI2C2_IRQHandler(void) //Inter-integrated circuit 2 | ||
694 | { LPI2C2_DriverIRQHandler(); | ||
695 | } | ||
696 | |||
697 | WEAK void LPI2C3_IRQHandler(void) //Inter-integrated circuit 3 | ||
698 | { LPI2C3_DriverIRQHandler(); | ||
699 | } | ||
700 | |||
701 | WEAK void SAI0_IRQHandler(void) //Serial Audio Interface | ||
702 | { SAI0_DriverIRQHandler(); | ||
703 | } | ||
704 | |||
705 | WEAK void SAI1_IRQHandler(void) //Serial Audio Interface 1 | ||
706 | { SAI1_DriverIRQHandler(); | ||
707 | } | ||
708 | |||
709 | WEAK void LPSPI0_IRQHandler(void) //Low Power Serial Peripheral Interface | ||
710 | { LPSPI0_DriverIRQHandler(); | ||
711 | } | ||
712 | |||
713 | WEAK void LPSPI1_IRQHandler(void) //Low Power Serial Peripheral Interface | ||
714 | { LPSPI1_DriverIRQHandler(); | ||
715 | } | ||
716 | |||
717 | WEAK void LPUART0_IRQHandler(void) //Low Power UART | ||
718 | { LPUART0_DriverIRQHandler(); | ||
719 | } | ||
720 | |||
721 | WEAK void LPUART1_IRQHandler(void) //Low Power UART | ||
722 | { LPUART1_DriverIRQHandler(); | ||
723 | } | ||
724 | |||
725 | WEAK void LPUART2_IRQHandler(void) //Low Power UART | ||
726 | { LPUART2_DriverIRQHandler(); | ||
727 | } | ||
728 | |||
729 | WEAK void LPUART3_IRQHandler(void) //Low Power UART | ||
730 | { LPUART3_DriverIRQHandler(); | ||
731 | } | ||
732 | |||
733 | WEAK void DPM_IRQHandler(void) //Dynamic Process Monitor | ||
734 | { DPM_DriverIRQHandler(); | ||
735 | } | ||
736 | |||
737 | WEAK void PCTLA_IRQHandler(void) //Port A pin interrupt | ||
738 | { PCTLA_DriverIRQHandler(); | ||
739 | } | ||
740 | |||
741 | WEAK void PCTLB_IRQHandler(void) //Port B pin interrupt | ||
742 | { PCTLB_DriverIRQHandler(); | ||
743 | } | ||
744 | |||
745 | WEAK void ADC0_IRQHandler(void) //Analog to Digital Convertor | ||
746 | { ADC0_DriverIRQHandler(); | ||
747 | } | ||
748 | |||
749 | WEAK void ADC1_IRQHandler(void) //Analog to Digital Convertor | ||
750 | { ADC1_DriverIRQHandler(); | ||
751 | } | ||
752 | |||
753 | WEAK void CMP0_IRQHandler(void) //Comparator | ||
754 | { CMP0_DriverIRQHandler(); | ||
755 | } | ||
756 | |||
757 | WEAK void CMP1_IRQHandler(void) //Comparator | ||
758 | { CMP1_DriverIRQHandler(); | ||
759 | } | ||
760 | |||
761 | WEAK void DAC0_IRQHandler(void) //Digital to Analog Convertor | ||
762 | { DAC0_DriverIRQHandler(); | ||
763 | } | ||
764 | |||
765 | WEAK void DAC1_IRQHandler(void) //Digital to Analog Convertor | ||
766 | { DAC1_DriverIRQHandler(); | ||
767 | } | ||
768 | |||
769 | WEAK void WDOG1_IRQHandler(void) //Watchdog Interrupt from A7 subsystem | ||
770 | { WDOG1_DriverIRQHandler(); | ||
771 | } | ||
772 | |||
773 | WEAK void USB0_IRQHandler(void) //USB 0 Interrupt from A7 subsystem | ||
774 | { USB0_DriverIRQHandler(); | ||
775 | } | ||
776 | |||
777 | WEAK void USB1_IRQHandler(void) //USB 1 Interrupt from A7 subsystem | ||
778 | { USB1_DriverIRQHandler(); | ||
779 | } | ||
780 | |||
781 | WEAK void WDOG2_IRQHandler(void) //Watchdog Interrupt from A7 subsystem | ||
782 | { WDOG2_DriverIRQHandler(); | ||
783 | } | ||
784 | |||
785 | WEAK void USBPHY_IRQHandler(void) //USB PHY (used in conjunction with USBOTG0) | ||
786 | { USBPHY_DriverIRQHandler(); | ||
787 | } | ||
788 | |||
789 | WEAK void CMC1_IRQHandler(void) //A7 resets | ||
790 | { CMC1_DriverIRQHandler(); | ||
791 | } | ||
792 | |||
793 | //***************************************************************************** | ||
794 | |||
795 | #if defined (DEBUG) | ||
796 | #pragma GCC pop_options | ||
797 | #endif // (DEBUG) | ||
798 | |||