]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M0_Infineon_XMC1000_IAR_Keil_GCC/Atollic_Specific/startup_XMC1200.s
Finalise XMC1000 IAR demos.
[freertos] / FreeRTOS / Demo / CORTEX_M0_Infineon_XMC1000_IAR_Keil_GCC / Atollic_Specific / startup_XMC1200.s
1 /**
2 *****************************************************************************
3 **
4 **  File        : startup_XMC1200.s
5 **
6 **  Abstract    : This assembler file contains interrupt vector and
7 **                startup code for ARM.
8 **
9 **  Functions   : Reset_Handler
10 **                Default_Handler
11 **                XMCVeneer code
12 **
13 **  Target      : Infineon $(DEVICE) Device 
14 **
15 **  Environment : Atollic TrueSTUDIO(R)
16 **
17 **  Distribution: The file is distributed \93as is,\94 without any warranty
18 **                of any kind.
19 **
20 **  (c)Copyright Atollic AB.
21 **  You may use this file as-is or modify it according to the needs of your
22 **  project. This file may only be built (assembled or compiled and linked)
23 **  using the Atollic TrueSTUDIO(R) product. The use of this file together
24 **  with other tools than Atollic TrueSTUDIO(R) is not permitted.
25 **
26 *****************************************************************************
27 */
28
29 #ifdef DAVE_CE
30 #include <Device_Data.h>
31 #else
32 #define CLKVAL1_SSW 0x80000000
33 #define CLKVAL2_SSW 0x80000000
34 #endif
35
36   .syntax unified
37   .cpu cortex-m0
38   .fpu softvfp
39   .thumb
40
41 .global Reset_Handler
42 .global InterruptVector
43 .global Default_Handler
44
45 /* Linker script definitions */
46 /* start address for the initialization values of the .data section */
47 .word _sidata
48 /* start address for the .data section */
49 .word _sdata
50 /* end address for the .data section */
51 .word _edata
52 /* start address for the .bss section */
53 .word _sbss
54 /* end address for the .bss section */
55 .word _ebss
56
57 .word VeneerLoadAddr
58 .word VeneerStart
59 .word VeneerSize
60
61
62 /**
63 **===========================================================================
64 **  Program - Reset_Handler
65 **  Abstract: This code gets called after reset.
66 **===========================================================================
67 */
68   .section  .text.Reset_Handler,"ax", %progbits
69   .type Reset_Handler, %function
70 Reset_Handler:
71   /* Set stack pointer */
72   ldr   r0, =_estack
73   mov   sp, r0
74
75   /* Branch to SystemInit function */
76   bl SystemInit
77
78   /* Copy data initialization values */
79   ldr r1,=_sidata
80   ldr r2,=_sdata
81   ldr r3,=_edata
82   b cmpdata
83 CopyLoop:
84   ldr r0, [r1]
85   str r0, [r2]
86   adds r1, r1, #4
87   adds r2, r2, #4
88 cmpdata:
89   cmp r2, r3
90   blt CopyLoop
91
92   /* Clear BSS section */
93   movs r0, #0
94   ldr r2,=_sbss
95   ldr r3,=_ebss
96   b cmpbss
97 ClearLoop:
98   str r0, [r2]
99   adds r2, r2, #4
100 cmpbss:
101   cmp r2, r3
102   blt ClearLoop
103
104   /* VENEER COPY */
105   /* R0 = Start address, R1 = Destination address, R2 = Size */
106   ldr r0, =VeneerLoadAddr
107   ldr r1, =VeneerStart
108   ldr r2, =VeneerSize
109
110 STARTVENEERCOPY:
111   /* R2 contains byte count. Change it to word count. It is ensured in the
112      linker script that the length is always word aligned.
113   */
114   lsrs r2,r2,#2 /* Divide by 4 to obtain word count */
115   beq SKIPVENEERCOPY
116
117   /* The proverbial loop from the schooldays */
118 VENEERCOPYLOOP:
119   ldr r3,[R0]
120   str r3,[R1]
121   subs r2,#1
122   beq SKIPVENEERCOPY
123   adds r0,#4
124   adds r1,#4
125   b VENEERCOPYLOOP
126
127 SKIPVENEERCOPY:
128   /* Update System Clock */
129   ldr r0,=SystemCoreClockUpdate
130   blx r0
131
132   /* Call static constructors */
133   bl __libc_init_array
134
135   /* Branch to main */
136   bl main
137
138   /* If main returns, branch to Default_Handler. */
139   b Default_Handler
140
141   .size  Reset_Handler, .-Reset_Handler
142
143 /**
144 **===========================================================================
145 **  Program - Default_Handler
146 **  Abstract: This code gets called when the processor receives an
147 **    unexpected interrupt.
148 **===========================================================================
149 */
150   .section  .text.Default_Handler,"ax", %progbits
151 Default_Handler:
152   b  Default_Handler
153
154   .size  Default_Handler, .-Default_Handler
155
156 /**
157 **===========================================================================
158 **  Interrupt vector table
159 **===========================================================================
160 */
161   .section .isr_vector,"a", %progbits
162   .globl  InterruptVector
163   .type   InterruptVector, %object
164
165 InterruptVector:
166   .word _estack                   /* 0 - Stack pointer */
167   .word Reset_Handler             /* 1 - Reset */
168   .word NMI_Handler               /* 2 - NMI  */
169   .word HardFault_Handler         /* 3 - Hard fault */
170   .word CLKVAL1_SSW               /* Clock configuration value  */
171   .word CLKVAL2_SSW               /* Clock gating configuration */
172
173   .size  InterruptVector, . - InterruptVector
174
175 /**
176 **===========================================================================
177 **  Weak interrupt handlers redirected to Default_Handler. These can be
178 **  overridden in user code.
179 **===========================================================================
180 */
181   .weak NMI_Handler
182   .thumb_set NMI_Handler, Default_Handler
183
184   .weak HardFault_Handler
185   .thumb_set HardFault_Handler, Default_Handler
186
187   .weak SVC_Handler
188   .thumb_set SVC_Handler, Default_Handler
189
190   .weak PendSV_Handler
191   .thumb_set PendSV_Handler, Default_Handler
192
193   .weak SysTick_Handler
194   .thumb_set SysTick_Handler, Default_Handler
195
196 /* ============= START OF INTERRUPT HANDLER DEFINITION ====================== */
197
198 /* IRQ Handlers */
199     .weak   SCU_0_IRQHandler
200     .type   SCU_0_IRQHandler, %function
201 SCU_0_IRQHandler:
202     B       .
203     .size   SCU_0_IRQHandler, . - SCU_0_IRQHandler
204 /* ======================================================================== */
205     .weak   SCU_1_IRQHandler
206     .type   SCU_1_IRQHandler, %function
207 SCU_1_IRQHandler:
208     B       .
209     .size   SCU_1_IRQHandler, . - SCU_1_IRQHandler
210 /* ======================================================================== */
211     .weak   SCU_2_IRQHandler
212     .type   SCU_2_IRQHandler, %function
213 SCU_2_IRQHandler:
214     B       .
215     .size   SCU_2_IRQHandler, . - SCU_2_IRQHandler
216 /* ======================================================================== */
217     .weak   ERU0_0_IRQHandler
218     .type   ERU0_0_IRQHandler, %function
219 ERU0_0_IRQHandler:
220     B       .
221     .size   ERU0_0_IRQHandler, . - ERU0_0_IRQHandler
222 /* ======================================================================== */
223     .weak   ERU0_1_IRQHandler
224     .type   ERU0_1_IRQHandler, %function
225 ERU0_1_IRQHandler:
226     B       .
227     .size   ERU0_1_IRQHandler, . - ERU0_1_IRQHandler
228 /* ======================================================================== */
229     .weak   ERU0_2_IRQHandler
230     .type   ERU0_2_IRQHandler, %function
231 ERU0_2_IRQHandler:
232     B       .
233     .size   ERU0_2_IRQHandler, . - ERU0_2_IRQHandler
234 /* ======================================================================== */
235     .weak   ERU0_3_IRQHandler
236     .type   ERU0_3_IRQHandler, %function
237 ERU0_3_IRQHandler:
238     B       .
239     .size   ERU0_3_IRQHandler, . - ERU0_3_IRQHandler
240 /* ======================================================================== */
241     .weak   MATH0_0_IRQHandler
242     .type   MATH0_0_IRQHandler, %function
243 MATH0_0_IRQHandler:
244     B       .
245     .size   MATH0_0_IRQHandler, . - MATH0_0_IRQHandler
246 /* ======================================================================== */
247     .weak   VADC0_C0_0_IRQHandler
248     .type   VADC0_C0_0_IRQHandler , %function
249 VADC0_C0_0_IRQHandler:
250     B       .
251     .size   VADC0_C0_0_IRQHandler , . - VADC0_C0_0_IRQHandler
252 /* ======================================================================== */
253     .weak   VADC0_C0_1_IRQHandler
254     .type   VADC0_C0_1_IRQHandler , %function
255 VADC0_C0_1_IRQHandler:
256     B       .
257     .size   VADC0_C0_1_IRQHandler , . - VADC0_C0_1_IRQHandler
258 /* ======================================================================== */
259     .weak   VADC0_G0_0_IRQHandler
260     .type   VADC0_G0_0_IRQHandler, %function
261 VADC0_G0_0_IRQHandler:
262     B       .
263     .size   VADC0_G0_0_IRQHandler, . - VADC0_G0_0_IRQHandler
264 /* ======================================================================== */
265     .weak   VADC0_G0_1_IRQHandler
266     .type   VADC0_G0_1_IRQHandler, %function
267 VADC0_G0_1_IRQHandler:
268     B       .
269     .size   VADC0_G0_1_IRQHandler, . - VADC0_G0_1_IRQHandler
270 /* ======================================================================== */
271     .weak   VADC0_G1_0_IRQHandler
272     .type   VADC0_G1_0_IRQHandler, %function
273 VADC0_G1_0_IRQHandler:
274     B       .
275     .size   VADC0_G1_0_IRQHandler, . - VADC0_G1_0_IRQHandler
276 /* ======================================================================== */
277     .weak   VADC0_G1_1_IRQHandler
278     .type   VADC0_G1_1_IRQHandler, %function
279 VADC0_G1_1_IRQHandler:
280     B       .
281     .size   VADC0_G1_1_IRQHandler, . - VADC0_G1_1_IRQHandler
282 /* ======================================================================== */
283     .weak   CCU40_0_IRQHandler
284     .type   CCU40_0_IRQHandler, %function
285 CCU40_0_IRQHandler:
286     B       .
287     .size   CCU40_0_IRQHandler, . - CCU40_0_IRQHandler
288 /* ======================================================================== */
289     .weak   CCU40_1_IRQHandler
290     .type   CCU40_1_IRQHandler, %function
291
292 CCU40_1_IRQHandler:
293     B       .
294     .size   CCU40_1_IRQHandler, . - CCU40_1_IRQHandler
295 /* ======================================================================== */
296     .weak   CCU40_2_IRQHandler
297     .type   CCU40_2_IRQHandler, %function
298 CCU40_2_IRQHandler:
299     B       .
300     .size   CCU40_2_IRQHandler, . - CCU40_2_IRQHandler
301 /* ======================================================================== */
302     .weak   CCU40_3_IRQHandler
303     .type   CCU40_3_IRQHandler, %function
304 CCU40_3_IRQHandler:
305     B       .
306     .size   CCU40_3_IRQHandler, . - CCU40_3_IRQHandler
307 /* ======================================================================== */
308     .weak   CCU80_0_IRQHandler
309     .type   CCU80_0_IRQHandler, %function
310 CCU80_0_IRQHandler:
311     B       .
312     .size   CCU80_0_IRQHandler, . - CCU80_0_IRQHandler
313 /* ======================================================================== */
314     .weak   CCU80_1_IRQHandler
315     .type   CCU80_1_IRQHandler, %function
316 CCU80_1_IRQHandler:
317     B       .
318     .size   CCU80_1_IRQHandler, . - CCU80_1_IRQHandler
319 /* ======================================================================== */
320     .weak   POSIF0_0_IRQHandler
321     .type   POSIF0_0_IRQHandler, %function
322
323 POSIF0_0_IRQHandler:
324     B       .
325     .size   POSIF0_0_IRQHandler, . - POSIF0_0_IRQHandler
326 /* ======================================================================== */
327     .weak   POSIF0_1_IRQHandler
328     .type   POSIF0_1_IRQHandler, %function
329 POSIF0_1_IRQHandler:
330     B       .
331     .size   POSIF0_1_IRQHandler, . - POSIF0_1_IRQHandler
332 /* ======================================================================== */
333     .weak   USIC0_0_IRQHandler
334     .type   USIC0_0_IRQHandler, %function
335 USIC0_0_IRQHandler:
336     B       .
337     .size   USIC0_0_IRQHandler, . - USIC0_0_IRQHandler
338 /* ======================================================================== */
339     .weak   USIC0_1_IRQHandler
340     .type   USIC0_1_IRQHandler, %function
341 USIC0_1_IRQHandler:
342     B       .
343     .size   USIC0_1_IRQHandler, . - USIC0_1_IRQHandler
344 /* ======================================================================== */
345     .weak   USIC0_2_IRQHandler
346     .type   USIC0_2_IRQHandler, %function
347 USIC0_2_IRQHandler:
348     B       .
349     .size   USIC0_2_IRQHandler, . - USIC0_2_IRQHandler
350 /* ======================================================================== */
351     .weak   USIC0_3_IRQHandler
352     .type   USIC0_3_IRQHandler, %function
353 USIC0_3_IRQHandler:
354     B       .
355     .size   USIC0_3_IRQHandler, . - USIC0_3_IRQHandler
356 /* ======================================================================== */
357     .weak   USIC0_4_IRQHandler
358     .type   USIC0_4_IRQHandler, %function
359 USIC0_4_IRQHandler:
360     B       .
361     .size   USIC0_4_IRQHandler, . - USIC0_4_IRQHandler
362 /* ======================================================================== */
363     .weak   USIC0_5_IRQHandler
364     .type   USIC0_5_IRQHandler, %function
365 USIC0_5_IRQHandler:
366     B       .
367     .size   USIC0_5_IRQHandler, . - USIC0_5_IRQHandler
368 /* ======================================================================== */
369     .weak   LEDTS0_0_IRQHandler
370     .type   LEDTS0_0_IRQHandler, %function
371 LEDTS0_0_IRQHandler:
372     B       .
373     .size   LEDTS0_0_IRQHandler, . - LEDTS0_0_IRQHandler
374 /* ======================================================================== */
375     .weak   LEDTS1_0_IRQHandler
376     .type   LEDTS1_0_IRQHandler, %function
377 LEDTS1_0_IRQHandler:
378     B       .
379     .size   LEDTS1_0_IRQHandler, . - LEDTS1_0_IRQHandler
380 /* ======================================================================== */
381     .weak   BCCU0_0_IRQHandler
382     .type   BCCU0_0_IRQHandler, %function
383 BCCU0_0_IRQHandler:
384     B       .
385     .size   BCCU0_0_IRQHandler, . - BCCU0_0_IRQHandler
386 /* ======================================================================== */
387 /* ======================================================================== */
388
389 /* ==================VENEERS VENEERS VENEERS VENEERS VENEERS=============== */
390     .section ".XmcVeneerCode","ax",%progbits
391 .globl HardFault_Veneer
392 HardFault_Veneer:
393     LDR R0, =HardFault_Handler
394     MOV PC,R0
395     .long 0
396     .long 0
397     .long 0
398     .long 0
399     .long 0
400     .long 0
401     .long 0
402
403 /* ======================================================================== */
404 .globl SVC_Veneer
405 SVC_Veneer:
406     LDR R0, =SVC_Handler
407     MOV PC,R0
408     .long 0
409     .long 0
410 /* ======================================================================== */
411 .globl PendSV_Veneer
412 PendSV_Veneer:
413     LDR R0, =PendSV_Handler
414     MOV PC,R0
415 /* ======================================================================== */
416 .globl SysTick_Veneer
417 SysTick_Veneer:
418     LDR R0, =SysTick_Handler
419     MOV PC,R0
420 /* ======================================================================== */
421 .globl SCU_0_Veneer
422 SCU_0_Veneer:
423     LDR R0, =SCU_0_IRQHandler
424     MOV PC,R0
425 /* ======================================================================== */
426 .globl SCU_1_Veneer
427 SCU_1_Veneer:
428     LDR R0, =SCU_1_IRQHandler
429     MOV PC,R0
430 /* ======================================================================== */
431 .globl SCU_2_Veneer
432 SCU_2_Veneer:
433     LDR R0, =SCU_2_IRQHandler
434     MOV PC,R0
435 /* ======================================================================== */
436 .globl SCU_3_Veneer
437 SCU_3_Veneer:
438     LDR R0, =ERU0_0_IRQHandler
439     MOV PC,R0
440 /* ======================================================================== */
441 .globl SCU_4_Veneer
442 SCU_4_Veneer:
443     LDR R0, =ERU0_1_IRQHandler
444     MOV PC,R0
445 /* ======================================================================== */
446 .globl SCU_5_Veneer
447 SCU_5_Veneer:
448     LDR R0, =ERU0_2_IRQHandler
449     MOV PC,R0
450 /* ======================================================================== */
451 .globl SCU_6_Veneer
452 SCU_6_Veneer:
453     LDR R0, =ERU0_3_IRQHandler
454     MOV PC,R0
455 /* ======================================================================== */
456 .globl SCU_7_Veneer
457 SCU_7_Veneer:
458     LDR R0, =MATH0_0_IRQHandler
459     MOV PC,R0
460     .long 0
461 /* ======================================================================== */
462 .globl VADC0_C0_0_Veneer
463 VADC0_C0_0_Veneer:
464     LDR R0, =VADC0_C0_0_IRQHandler
465     MOV PC,R0
466 /* ======================================================================== */
467 .globl VADC0_C0_1_Veneer
468 VADC0_C0_1_Veneer:
469     LDR R0, =VADC0_C0_1_IRQHandler
470     MOV PC,R0
471 /* ======================================================================== */
472 .globl VADC0_G0_0_Veneer
473 VADC0_G0_0_Veneer:
474     LDR R0, =VADC0_G0_0_IRQHandler
475     MOV PC,R0
476 /* ======================================================================== */
477 .globl VADC0_G0_1_Veneer
478 VADC0_G0_1_Veneer:
479     LDR R0, =VADC0_G0_1_IRQHandler
480     MOV PC,R0
481 /* ======================================================================== */
482 .globl VADC0_G1_0_Veneer
483 VADC0_G1_0_Veneer:
484     LDR R0, =VADC0_G1_0_IRQHandler
485     MOV PC,R0
486 /* ======================================================================== */
487 .globl VADC0_G1_1_Veneer
488 VADC0_G1_1_Veneer:
489     LDR R0, =VADC0_G1_1_IRQHandler
490     MOV PC,R0
491 /* ======================================================================== */
492 .globl CCU40_0_Veneer
493 CCU40_0_Veneer:
494     LDR R0, =CCU40_0_IRQHandler
495     MOV PC,R0
496 /* ======================================================================== */
497 .globl CCU40_1_Veneer
498 CCU40_1_Veneer:
499     LDR R0, =CCU40_1_IRQHandler
500     MOV PC,R0
501 /* ======================================================================== */
502 .globl CCU40_2_Veneer
503 CCU40_2_Veneer:
504     LDR R0, =CCU40_2_IRQHandler
505     MOV PC,R0
506 /* ======================================================================== */
507 .globl CCU40_3_Veneer
508 CCU40_3_Veneer:
509     LDR R0, =CCU40_3_IRQHandler
510     MOV PC,R0
511 /* ======================================================================== */
512 .globl CCU80_0_Veneer
513 CCU80_0_Veneer:
514     LDR R0, =CCU80_0_IRQHandler
515     MOV PC,R0
516 /* ======================================================================== */
517 .globl CCU80_1_Veneer
518 CCU80_1_Veneer:
519     LDR R0, =CCU80_1_IRQHandler
520     MOV PC,R0
521 /* ======================================================================== */
522 .globl POSIF0_0_Veneer
523 POSIF0_0_Veneer:
524     LDR R0, =POSIF0_0_IRQHandler
525     MOV PC,R0
526 /* ======================================================================== */
527 .globl POSIF0_1_Veneer
528 POSIF0_1_Veneer:
529     LDR R0, =POSIF0_1_IRQHandler
530     MOV PC,R0
531 /* ======================================================================== */
532 .globl USIC0_0_Veneer
533 USIC0_0_Veneer:
534     LDR R0, =USIC0_0_IRQHandler
535     MOV PC,R0
536 /* ======================================================================== */
537 .globl USIC0_1_Veneer
538 USIC0_1_Veneer:
539     LDR R0, =USIC0_1_IRQHandler
540     MOV PC,R0
541 /* ======================================================================== */
542 .globl USIC0_2_Veneer
543 USIC0_2_Veneer:
544     LDR R0, =USIC0_2_IRQHandler
545     MOV PC,R0
546 /* ======================================================================== */
547 .globl USIC0_3_Veneer
548 USIC0_3_Veneer:
549     LDR R0, =USIC0_3_IRQHandler
550     MOV PC,R0
551 /* ======================================================================== */
552 .globl USIC0_4_Veneer
553 USIC0_4_Veneer:
554     LDR R0, =USIC0_4_IRQHandler
555     MOV PC,R0
556 /* ======================================================================== */
557 .globl USIC0_5_Veneer
558 USIC0_5_Veneer:
559     LDR R0, =USIC0_5_IRQHandler
560     MOV PC,R0
561 /* ======================================================================== */
562 .globl LEDTS0_0_Veneer
563 LEDTS0_0_Veneer:
564     LDR R0, =LEDTS0_0_IRQHandler
565     MOV PC,R0
566 /* ======================================================================== */
567 .globl LEDTS1_0_Veneer
568 LEDTS1_0_Veneer:
569     LDR R0, =LEDTS1_0_IRQHandler
570     MOV PC,R0
571 /* ======================================================================== */
572     .globl BCCU0_0_Veneer
573 BCCU0_0_Veneer:
574     LDR R0, =BCCU0_0_IRQHandler
575     MOV PC,R0
576
577 /* ======================================================================== */
578
579 /* ===== Decision function queried by CMSIS startup for Clock tree setup === */
580 /* In the absence of DAVE code engine, CMSIS SystemInit() must perform clock
581    tree setup.
582
583    This decision routine defined here will always return TRUE.
584
585    When overridden by a definition defined in DAVE code engine, this routine
586    returns FALSE indicating that the code engine has performed the clock setup
587 */
588      .section ".XmcStartup"
589     .weak   AllowClkInitByStartup
590     .type   AllowClkInitByStartup, %function
591 AllowClkInitByStartup:
592     MOVS R0,#1
593     BX LR
594     .size   AllowClkInitByStartup, . - AllowClkInitByStartup
595
596 /* ======  Definition of the default weak SystemInit_DAVE3 function =========
597 If DAVE3 requires an extended SystemInit it will create its own version of
598 SystemInit_DAVE3 which overrides this weak definition. Example includes
599 setting up of external memory interfaces.
600 */
601      .weak SystemInit_DAVE3
602      .type SystemInit_DAVE3, %function
603 SystemInit_DAVE3:
604      NOP
605      BX LR
606      .size SystemInit_DAVE3, . - SystemInit_DAVE3
607
608   .end