1/*****************************************************************************/
2/* startup_XMC4504.s: Startup file for XMC4504 device series for EWARM                */
3/*****************************************************************************/
4/**
5* @file     startup_XMC4504.s
6*           XMC4004 Device Series
7* @version  V1.4
8* @date     June 2016
9*
10*********************************************************************************************************************
11* Copyright (c) 2013-2016, Infineon Technologies AG
12* All rights reserved.
13*
14* Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
15* following conditions are met:
16*
17* Redistributions of source code must retain the above copyright notice, this list of conditions and the following
18* disclaimer.
19*
20* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
21* disclaimer in the documentation and/or other materials provided with the distribution.
22*
23* Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
24* products derived from this software without specific prior written permission.
25*
26* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
27* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE  FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31* WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33*
34* To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with
35* Infineon Technologies AG dave@infineon.com).
36*********************************************************************************************************************
37*
38******************************************************************************/
39/* ********************* Version History *********************************** */
40/* ***************************************************************************
41V1.0 January, 30 2013:  In ths version a workoraound for the erratum PMU_CM.001
42is implmented (patch for the Exception and interrupt handlers)
43V1.1 Augsut, 17 2013:  Fix the bug of preprocessor due to workoraound for
44the erratum PMU_CM.001, and the bug of stack pointer alignment to a 8 byte boundary
45V1.2 November, 20 2014:  Disable CPU workaround. Removed DAVE3 dependency
46V1.3 November, 26 2015:  Remove peripherals not included in device
47V1.4, June     2016, Rename ENABLE_CPU_CM_001_WORKAROUND to ENABLE_PMU_CM_001_WORKAROUND
48                     Action required: If using AA/AB step, use ENABLE_PMU_CM_001_WORKAROUND instead of ENABLE_CPU_CM_001_WORKAROUND
49**************************************************************************** */
50
51        MODULE  ?vector_table
52
53        AAPCS INTERWORK, VFP_COMPATIBLE, RWPI_COMPATIBLE
54        PRESERVE8
55
56
57        ;; Forward declaration of sections.
58        SECTION CSTACK:DATA:NOROOT(3)
59
60        SECTION .intvec:CODE:NOROOT(2)
61
62        EXTERN  __iar_program_start
63        EXTERN  SystemInit
64        PUBLIC  __vector_table
65        PUBLIC  __Vectors
66        PUBLIC  __Vectors_End
67        PUBLIC  __Vectors_Size
68
69        DATA
70
71__iar_init$$done:               ; The vector table is not needed
72                                ; until after copy initialization is done
73
74;/* ===========START : MACRO DEFINITION MACRO DEFINITION ================== */
75;/*
76; * STEP_AB and below have the prefetch functional deviation (Errata id: PMU_CM.001).
77; * A veneer defined below will first be executed which in turn branches to the final
78; * exception handler.
79; *
80; * In addition to defining the veneers, the vector table must for these buggy
81; * devices contain the veneers.
82; */
83
84;/* A macro to setup a vector table entry based on STEP ID */
85#ifdef WORKAROUND_PMU_CM001
86ExcpVector  macro
87            DCD \1_Veneer
88            endm
89#else
90ExcpVector  macro
91            DCD \1
92            endm
93#endif
94
95;/* A macro to ease definition of the various handlers based on STEP ID */
96#ifdef WORKAROUND_PMU_CM001
97;/* First define the final exception handler */
98ProxyHandler  macro
99              PUBWEAK \1
100              SECTION .text:CODE:REORDER:NOROOT(1)
101\1
102              B \1
103;/* And then define a veneer that will branch to the final excp handler */
104              PUBWEAK \1_Veneer
105              SECTION .text:CODE:REORDER:NOROOT(2)
106\1_Veneer:
107              LDR   R0, =\1
108              PUSH	{LR}  /* Breaks AAPCS */
109              SUB SP,#4    /* Restores AAPCS */
110              BLX   R0
111              ADD SP,#4
112              POP   {PC}
113              endm
114 ;/* No prefetch bug, hence define only the final exception handler */
115#else
116ProxyHandler  macro
117              PUBWEAK \1
118              SECTION .text:CODE:REORDER:NOROOT(1)
119\1
120              B \1
121              endm
122#endif
123
124;/* ============= END OF MACRO DEFINITION MACRO DEFINITION ================== */
125
126__vector_table
127        DCD     sfe(CSTACK)
128        DCD     Reset_Handler
129
130        ExcpVector     NMI_Handler
131        ExcpVector     HardFault_Handler
132        ExcpVector     MemManage_Handler
133        ExcpVector     BusFault_Handler
134        ExcpVector     UsageFault_Handler
135        DCD     0
136        DCD     0
137        DCD     0
138        DCD     0
139        ExcpVector     SVC_Handler
140        ExcpVector     DebugMon_Handler
141        DCD     0
142        ExcpVector     PendSV_Handler
143        ExcpVector     SysTick_Handler
144
145    ; Interrupt Handlers for Service Requests (SR) from XMC4500 Peripherals
146	ExcpVector   SCU_0_IRQHandler            ; Handler name for SR SCU_0
147	ExcpVector   ERU0_0_IRQHandler           ; Handler name for SR ERU0_0
148	ExcpVector   ERU0_1_IRQHandler           ; Handler name for SR ERU0_1
149	ExcpVector   ERU0_2_IRQHandler           ; Handler name for SR ERU0_2
150	ExcpVector   ERU0_3_IRQHandler           ; Handler name for SR ERU0_3
151	ExcpVector   ERU1_0_IRQHandler           ; Handler name for SR ERU1_0
152	ExcpVector   ERU1_1_IRQHandler           ; Handler name for SR ERU1_1
153	ExcpVector   ERU1_2_IRQHandler           ; Handler name for SR ERU1_2
154	ExcpVector   ERU1_3_IRQHandler           ; Handler name for SR ERU1_3
155	DCD   0                           ; Not Available
156	DCD   0                           ; Not Available
157	DCD   0                           ; Not Available
158	ExcpVector   PMU0_0_IRQHandler           ; Handler name for SR PMU0_0
159	DCD   0                           ; Handler name for SR PMU0_1
160	ExcpVector   VADC0_C0_0_IRQHandler       ; Handler name for SR VADC0_C0_0
161	ExcpVector   VADC0_C0_1_IRQHandler       ; Handler name for SR VADC0_C0_1
162	ExcpVector   VADC0_C0_2_IRQHandler       ; Handler name for SR VADC0_C0_1
163	ExcpVector   VADC0_C0_3_IRQHandler       ; Handler name for SR VADC0_C0_3
164	ExcpVector   VADC0_G0_0_IRQHandler       ; Handler name for SR VADC0_G0_0
165	ExcpVector   VADC0_G0_1_IRQHandler       ; Handler name for SR VADC0_G0_1
166	ExcpVector   VADC0_G0_2_IRQHandler       ; Handler name for SR VADC0_G0_2
167	ExcpVector   VADC0_G0_3_IRQHandler       ; Handler name for SR VADC0_G0_3
168	ExcpVector   VADC0_G1_0_IRQHandler       ; Handler name for SR VADC0_G1_0
169	ExcpVector   VADC0_G1_1_IRQHandler       ; Handler name for SR VADC0_G1_1
170	ExcpVector   VADC0_G1_2_IRQHandler       ; Handler name for SR VADC0_G1_2
171	ExcpVector   VADC0_G1_3_IRQHandler       ; Handler name for SR VADC0_G1_3
172	ExcpVector   VADC0_G2_0_IRQHandler       ; Handler name for SR VADC0_G2_0
173	ExcpVector   VADC0_G2_1_IRQHandler       ; Handler name for SR VADC0_G2_1
174	ExcpVector   VADC0_G2_2_IRQHandler       ; Handler name for SR VADC0_G2_2
175	ExcpVector   VADC0_G2_3_IRQHandler       ; Handler name for SR VADC0_G2_3
176	ExcpVector   VADC0_G3_0_IRQHandler       ; Handler name for SR VADC0_G3_0
177	ExcpVector   VADC0_G3_1_IRQHandler       ; Handler name for SR VADC0_G3_1
178	ExcpVector   VADC0_G3_2_IRQHandler       ; Handler name for SR VADC0_G3_2
179	ExcpVector   VADC0_G3_3_IRQHandler       ; Handler name for SR VADC0_G3_3
180	ExcpVector   DSD0_0_IRQHandler           ; Handler name for SR DSD0_0
181	ExcpVector   DSD0_1_IRQHandler           ; Handler name for SR DSD0_1
182	ExcpVector   DSD0_2_IRQHandler           ; Handler name for SR DSD0_2
183	ExcpVector   DSD0_3_IRQHandler           ; Handler name for SR DSD0_3
184	ExcpVector   DSD0_4_IRQHandler           ; Handler name for SR DSD0_4
185	ExcpVector   DSD0_5_IRQHandler           ; Handler name for SR DSD0_5
186	ExcpVector   DSD0_6_IRQHandler           ; Handler name for SR DSD0_6
187	ExcpVector   DSD0_7_IRQHandler           ; Handler name for SR DSD0_7
188	ExcpVector   DAC0_0_IRQHandler           ; Handler name for SR DAC0_0
189	ExcpVector   DAC0_1_IRQHandler           ; Handler name for SR DAC0_0
190	ExcpVector   CCU40_0_IRQHandler          ; Handler name for SR CCU40_0
191	ExcpVector   CCU40_1_IRQHandler          ; Handler name for SR CCU40_1
192	ExcpVector   CCU40_2_IRQHandler          ; Handler name for SR CCU40_2
193	ExcpVector   CCU40_3_IRQHandler          ; Handler name for SR CCU40_3
194	ExcpVector   CCU41_0_IRQHandler          ; Handler name for SR CCU41_0
195	ExcpVector   CCU41_1_IRQHandler          ; Handler name for SR CCU41_1
196	ExcpVector   CCU41_2_IRQHandler          ; Handler name for SR CCU41_2
197	ExcpVector   CCU41_3_IRQHandler          ; Handler name for SR CCU41_3
198	ExcpVector   CCU42_0_IRQHandler          ; Handler name for SR CCU42_0
199	ExcpVector   CCU42_1_IRQHandler          ; Handler name for SR CCU42_1
200	ExcpVector   CCU42_2_IRQHandler          ; Handler name for SR CCU42_2
201	ExcpVector   CCU42_3_IRQHandler          ; Handler name for SR CCU42_3
202	ExcpVector   CCU43_0_IRQHandler          ; Handler name for SR CCU43_0
203	ExcpVector   CCU43_1_IRQHandler          ; Handler name for SR CCU43_1
204	ExcpVector   CCU43_2_IRQHandler          ; Handler name for SR CCU43_2
205	ExcpVector   CCU43_3_IRQHandler          ; Handler name for SR CCU43_3
206	ExcpVector   CCU80_0_IRQHandler          ; Handler name for SR CCU80_0
207	ExcpVector   CCU80_1_IRQHandler          ; Handler name for SR CCU80_1
208	ExcpVector   CCU80_2_IRQHandler          ; Handler name for SR CCU80_2
209	ExcpVector   CCU80_3_IRQHandler          ; Handler name for SR CCU80_3
210	ExcpVector   CCU81_0_IRQHandler          ; Handler name for SR CCU81_0
211	ExcpVector   CCU81_1_IRQHandler          ; Handler name for SR CCU81_1
212	ExcpVector   CCU81_2_IRQHandler          ; Handler name for SR CCU81_2
213	ExcpVector   CCU81_3_IRQHandler          ; Handler name for SR CCU81_3
214	ExcpVector   POSIF0_0_IRQHandler         ; Handler name for SR POSIF0_0
215	ExcpVector   POSIF0_1_IRQHandler         ; Handler name for SR POSIF0_1
216	ExcpVector   POSIF1_0_IRQHandler         ; Handler name for SR POSIF1_0
217	ExcpVector   POSIF1_1_IRQHandler         ; Handler name for SR POSIF1_1
218	DCD   0                           ; Not Available
219	DCD   0                           ; Not Available
220	DCD   0                           ; Not Available
221	DCD   0                           ; Not Available
222	DCD   0                           ; Not Available
223	DCD   0                           ; Not Available
224	DCD   0                           ; Not Available
225	DCD   0                           ; Not Available
226	DCD   0                           ; Not Available
227	DCD   0                           ; Not Available
228	DCD   0                           ; Not Available
229	DCD   0                           ; Not Available
230	ExcpVector   USIC0_0_IRQHandler          ; Handler name for SR USIC0_0
231	ExcpVector   USIC0_1_IRQHandler          ; Handler name for SR USIC0_1
232	ExcpVector   USIC0_2_IRQHandler          ; Handler name for SR USIC0_2
233	ExcpVector   USIC0_3_IRQHandler          ; Handler name for SR USIC0_3
234	ExcpVector   USIC0_4_IRQHandler          ; Handler name for SR USIC0_4
235	ExcpVector   USIC0_5_IRQHandler          ; Handler name for SR USIC0_5
236	ExcpVector   USIC1_0_IRQHandler          ; Handler name for SR USIC1_0
237	ExcpVector   USIC1_1_IRQHandler          ; Handler name for SR USIC1_1
238	ExcpVector   USIC1_2_IRQHandler          ; Handler name for SR USIC1_2
239	ExcpVector   USIC1_3_IRQHandler          ; Handler name for SR USIC1_3
240	ExcpVector   USIC1_4_IRQHandler          ; Handler name for SR USIC1_4
241	ExcpVector   USIC1_5_IRQHandler          ; Handler name for SR USIC1_5
242	ExcpVector   USIC2_0_IRQHandler          ; Handler name for SR USIC2_0
243	ExcpVector   USIC2_1_IRQHandler          ; Handler name for SR USIC2_1
244	ExcpVector   USIC2_2_IRQHandler          ; Handler name for SR USIC2_2
245	ExcpVector   USIC2_3_IRQHandler          ; Handler name for SR USIC2_3
246	ExcpVector   USIC2_4_IRQHandler          ; Handler name for SR USIC2_4
247	ExcpVector   USIC2_5_IRQHandler          ; Handler name for SR USIC2_5
248	ExcpVector   LEDTS0_0_IRQHandler         ; Handler name for SR LEDTS0_0
249	DCD   0                           ; Not Available
250	ExcpVector   FCE0_0_IRQHandler           ; Handler name for SR FCE0_0
251	ExcpVector   GPDMA0_0_IRQHandler         ; Handler name for SR GPDMA0_0
252	ExcpVector   SDMMC0_0_IRQHandler         ; Handler name for SR SDMMC0_0
253	DCD   0                           ; Not Available
254	DCD   0                           ; Not Available
255	DCD   0                           ; Not Available
256	ExcpVector   GPDMA1_0_IRQHandler         ; Handler name for SR GPDMA1_0
257	DCD   0                           ; Not Available
258
259
260__Vectors_End
261
262__Vectors       EQU   __vector_table
263__Vectors_Size  EQU   __Vectors_End - __Vectors
264
265
266;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
267;;
268;; Default interrupt handlers.
269;;
270        THUMB
271        PUBWEAK Reset_Handler
272        SECTION .text:CODE:REORDER:NOROOT(2)
273Reset_Handler
274        LDR     SP, =sfe(CSTACK)
275        LDR     R0, =SystemInit
276        BLX     R0
277        LDR     R0, =__iar_program_start
278        BX      R0
279
280
281        ProxyHandler NMI_Handler
282        ProxyHandler HardFault_Handler
283        ProxyHandler MemManage_Handler
284        ProxyHandler BusFault_Handler
285        ProxyHandler UsageFault_Handler
286        ProxyHandler SVC_Handler
287        ProxyHandler DebugMon_Handler
288        ProxyHandler PendSV_Handler
289        ProxyHandler SysTick_Handler
290
291        ProxyHandler SCU_0_IRQHandler
292        ProxyHandler ERU0_0_IRQHandler
293        ProxyHandler ERU0_1_IRQHandler
294        ProxyHandler ERU0_2_IRQHandler
295        ProxyHandler ERU0_3_IRQHandler
296        ProxyHandler ERU1_0_IRQHandler
297        ProxyHandler ERU1_1_IRQHandler
298        ProxyHandler ERU1_2_IRQHandler
299        ProxyHandler ERU1_3_IRQHandler
300        ProxyHandler PMU0_0_IRQHandler
301        ProxyHandler PMU0_1_IRQHandler
302        ProxyHandler VADC0_C0_0_IRQHandler
303        ProxyHandler VADC0_C0_1_IRQHandler
304        ProxyHandler VADC0_C0_2_IRQHandler
305        ProxyHandler VADC0_C0_3_IRQHandler
306        ProxyHandler VADC0_G0_0_IRQHandler
307        ProxyHandler VADC0_G0_1_IRQHandler
308        ProxyHandler VADC0_G0_2_IRQHandler
309        ProxyHandler VADC0_G0_3_IRQHandler
310        ProxyHandler VADC0_G1_0_IRQHandler
311        ProxyHandler VADC0_G1_1_IRQHandler
312        ProxyHandler VADC0_G1_2_IRQHandler
313        ProxyHandler VADC0_G1_3_IRQHandler
314        ProxyHandler VADC0_G2_0_IRQHandler
315        ProxyHandler VADC0_G2_1_IRQHandler
316        ProxyHandler VADC0_G2_2_IRQHandler
317        ProxyHandler VADC0_G2_3_IRQHandler
318        ProxyHandler VADC0_G3_0_IRQHandler
319        ProxyHandler VADC0_G3_1_IRQHandler
320        ProxyHandler VADC0_G3_2_IRQHandler
321        ProxyHandler VADC0_G3_3_IRQHandler
322        ProxyHandler DSD0_0_IRQHandler
323        ProxyHandler DSD0_1_IRQHandler
324        ProxyHandler DSD0_2_IRQHandler
325        ProxyHandler DSD0_3_IRQHandler
326        ProxyHandler DSD0_4_IRQHandler
327        ProxyHandler DSD0_5_IRQHandler
328        ProxyHandler DSD0_6_IRQHandler
329        ProxyHandler DSD0_7_IRQHandler
330        ProxyHandler DAC0_0_IRQHandler
331        ProxyHandler DAC0_1_IRQHandler
332        ProxyHandler CCU40_0_IRQHandler
333        ProxyHandler CCU40_1_IRQHandler
334        ProxyHandler CCU40_2_IRQHandler
335        ProxyHandler CCU40_3_IRQHandler
336        ProxyHandler CCU41_0_IRQHandler
337        ProxyHandler CCU41_1_IRQHandler
338        ProxyHandler CCU41_2_IRQHandler
339        ProxyHandler CCU41_3_IRQHandler
340        ProxyHandler CCU42_0_IRQHandler
341        ProxyHandler CCU42_1_IRQHandler
342        ProxyHandler CCU42_2_IRQHandler
343        ProxyHandler CCU42_3_IRQHandler
344        ProxyHandler CCU43_0_IRQHandler
345        ProxyHandler CCU43_1_IRQHandler
346        ProxyHandler CCU43_2_IRQHandler
347        ProxyHandler CCU43_3_IRQHandler
348        ProxyHandler CCU80_0_IRQHandler
349        ProxyHandler CCU80_1_IRQHandler
350        ProxyHandler CCU80_2_IRQHandler
351        ProxyHandler CCU80_3_IRQHandler
352        ProxyHandler CCU81_0_IRQHandler
353        ProxyHandler CCU81_1_IRQHandler
354        ProxyHandler CCU81_2_IRQHandler
355        ProxyHandler CCU81_3_IRQHandler
356        ProxyHandler POSIF0_0_IRQHandler
357        ProxyHandler POSIF0_1_IRQHandler
358        ProxyHandler POSIF1_0_IRQHandler
359        ProxyHandler POSIF1_1_IRQHandler
360        ProxyHandler USIC0_0_IRQHandler
361        ProxyHandler USIC0_1_IRQHandler
362        ProxyHandler USIC0_2_IRQHandler
363        ProxyHandler USIC0_3_IRQHandler
364        ProxyHandler USIC0_4_IRQHandler
365        ProxyHandler USIC0_5_IRQHandler
366        ProxyHandler USIC1_0_IRQHandler
367        ProxyHandler USIC1_1_IRQHandler
368        ProxyHandler USIC1_2_IRQHandler
369        ProxyHandler USIC1_3_IRQHandler
370        ProxyHandler USIC1_4_IRQHandler
371        ProxyHandler USIC1_5_IRQHandler
372        ProxyHandler USIC2_0_IRQHandler
373        ProxyHandler USIC2_1_IRQHandler
374        ProxyHandler USIC2_2_IRQHandler
375        ProxyHandler USIC2_3_IRQHandler
376        ProxyHandler USIC2_4_IRQHandler
377        ProxyHandler USIC2_5_IRQHandler
378        ProxyHandler LEDTS0_0_IRQHandler
379        ProxyHandler FCE0_0_IRQHandler
380        ProxyHandler GPDMA0_0_IRQHandler
381        ProxyHandler SDMMC0_0_IRQHandler
382        ProxyHandler GPDMA1_0_IRQHandler
383
384        END
385