]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio/Source/SilLabs_Code/Device/SiliconLabs/EFM32WG/Source/GCC/startup_efm32wg.S
Add files necessary to create a Pearl Gecko build configuration in the new EFM32...
[freertos] / FreeRTOS / Demo / CORTEX_EFM32_Gecko_Starter_Kit_Simplicity_Studio / Source / SilLabs_Code / Device / SiliconLabs / EFM32WG / Source / GCC / startup_efm32wg.S
1 /* @file startup_efm32wg.S\r
2  * @brief startup file for Silicon Labs EFM32WG devices.\r
3  *        For use with GCC for ARM Embedded Processors\r
4  * @version 4.2.1\r
5  * Date:    12 June 2014\r
6  *\r
7  */\r
8 /* Copyright (c) 2011 - 2014 ARM LIMITED\r
9 \r
10    All rights reserved.\r
11    Redistribution and use in source and binary forms, with or without\r
12    modification, are permitted provided that the following conditions are met:\r
13    - Redistributions of source code must retain the above copyright\r
14      notice, this list of conditions and the following disclaimer.\r
15    - Redistributions in binary form must reproduce the above copyright\r
16      notice, this list of conditions and the following disclaimer in the\r
17      documentation and/or other materials provided with the distribution.\r
18    - Neither the name of ARM nor the names of its contributors may be used\r
19      to endorse or promote products derived from this software without\r
20      specific prior written permission.\r
21    *\r
22    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
23    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
24    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
25    ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE\r
26    LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
27    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
28    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
29    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
30    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
31    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\r
32    POSSIBILITY OF SUCH DAMAGE.\r
33    ---------------------------------------------------------------------------*/\r
34 \r
35     .syntax     unified\r
36     .arch       armv7-m\r
37     .section    .stack\r
38     .align      3\r
39 #ifdef __STACK_SIZE\r
40     .equ        Stack_Size, __STACK_SIZE\r
41 #else\r
42     .equ        Stack_Size, 0x00000400\r
43 #endif\r
44     .globl      __StackTop\r
45     .globl      __StackLimit\r
46 __StackLimit:\r
47     .space      Stack_Size\r
48     .size       __StackLimit, . - __StackLimit\r
49 __StackTop:\r
50     .size       __StackTop, . - __StackTop\r
51 \r
52     .section    .heap\r
53     .align      3\r
54 #ifdef __HEAP_SIZE\r
55     .equ        Heap_Size, __HEAP_SIZE\r
56 #else\r
57     .equ        Heap_Size, 0x00000C00\r
58 #endif\r
59     .globl      __HeapBase\r
60     .globl      __HeapLimit\r
61 __HeapBase:\r
62     .if Heap_Size\r
63     .space      Heap_Size\r
64     .endif\r
65     .size       __HeapBase, . - __HeapBase\r
66 __HeapLimit:\r
67     .size       __HeapLimit, . - __HeapLimit\r
68 \r
69     .section    .vectors\r
70     .align      2\r
71     .globl      __Vectors\r
72 __Vectors:\r
73     .long       __StackTop            /* Top of Stack */\r
74     .long       Reset_Handler         /* Reset Handler */\r
75     .long       NMI_Handler           /* NMI Handler */\r
76     .long       HardFault_Handler     /* Hard Fault Handler */\r
77     .long       MemManage_Handler     /* MPU Fault Handler */\r
78     .long       BusFault_Handler      /* Bus Fault Handler */\r
79     .long       UsageFault_Handler    /* Usage Fault Handler */\r
80     .long       Default_Handler       /* Reserved */\r
81     .long       Default_Handler       /* Reserved */\r
82     .long       Default_Handler       /* Reserved */\r
83     .long       Default_Handler       /* Reserved */\r
84     .long       SVC_Handler           /* SVCall Handler */\r
85     .long       DebugMon_Handler      /* Debug Monitor Handler */\r
86     .long       Default_Handler       /* Reserved */\r
87     .long       PendSV_Handler        /* PendSV Handler */\r
88     .long       SysTick_Handler       /* SysTick Handler */\r
89 \r
90     /* External interrupts */\r
91 \r
92     .long       DMA_IRQHandler    /* 0 - DMA */\r
93     .long       GPIO_EVEN_IRQHandler    /* 1 - GPIO_EVEN */\r
94     .long       TIMER0_IRQHandler    /* 2 - TIMER0 */\r
95     .long       USART0_RX_IRQHandler    /* 3 - USART0_RX */\r
96     .long       USART0_TX_IRQHandler    /* 4 - USART0_TX */\r
97     .long       USB_IRQHandler    /* 5 - USB */\r
98     .long       ACMP0_IRQHandler    /* 6 - ACMP0 */\r
99     .long       ADC0_IRQHandler    /* 7 - ADC0 */\r
100     .long       DAC0_IRQHandler    /* 8 - DAC0 */\r
101     .long       I2C0_IRQHandler    /* 9 - I2C0 */\r
102     .long       I2C1_IRQHandler    /* 10 - I2C1 */\r
103     .long       GPIO_ODD_IRQHandler    /* 11 - GPIO_ODD */\r
104     .long       TIMER1_IRQHandler    /* 12 - TIMER1 */\r
105     .long       TIMER2_IRQHandler    /* 13 - TIMER2 */\r
106     .long       TIMER3_IRQHandler    /* 14 - TIMER3 */\r
107     .long       USART1_RX_IRQHandler    /* 15 - USART1_RX */\r
108     .long       USART1_TX_IRQHandler    /* 16 - USART1_TX */\r
109     .long       LESENSE_IRQHandler    /* 17 - LESENSE */\r
110     .long       USART2_RX_IRQHandler    /* 18 - USART2_RX */\r
111     .long       USART2_TX_IRQHandler    /* 19 - USART2_TX */\r
112     .long       UART0_RX_IRQHandler    /* 20 - UART0_RX */\r
113     .long       UART0_TX_IRQHandler    /* 21 - UART0_TX */\r
114     .long       UART1_RX_IRQHandler    /* 22 - UART1_RX */\r
115     .long       UART1_TX_IRQHandler    /* 23 - UART1_TX */\r
116     .long       LEUART0_IRQHandler    /* 24 - LEUART0 */\r
117     .long       LEUART1_IRQHandler    /* 25 - LEUART1 */\r
118     .long       LETIMER0_IRQHandler    /* 26 - LETIMER0 */\r
119     .long       PCNT0_IRQHandler    /* 27 - PCNT0 */\r
120     .long       PCNT1_IRQHandler    /* 28 - PCNT1 */\r
121     .long       PCNT2_IRQHandler    /* 29 - PCNT2 */\r
122     .long       RTC_IRQHandler    /* 30 - RTC */\r
123     .long       BURTC_IRQHandler    /* 31 - BURTC */\r
124     .long       CMU_IRQHandler    /* 32 - CMU */\r
125     .long       VCMP_IRQHandler    /* 33 - VCMP */\r
126     .long       LCD_IRQHandler    /* 34 - LCD */\r
127     .long       MSC_IRQHandler    /* 35 - MSC */\r
128     .long       AES_IRQHandler    /* 36 - AES */\r
129     .long       EBI_IRQHandler    /* 37 - EBI */\r
130     .long       EMU_IRQHandler    /* 38 - EMU */\r
131     .long       FPUEH_IRQHandler    /* 39 - FPUEH */\r
132 \r
133 \r
134     .size       __Vectors, . - __Vectors\r
135 \r
136     .text\r
137     .thumb\r
138     .thumb_func\r
139     .align      2\r
140     .globl      Reset_Handler\r
141     .type       Reset_Handler, %function\r
142 Reset_Handler:\r
143 #ifndef __NO_SYSTEM_INIT\r
144     ldr     r0, =SystemInit\r
145     blx     r0\r
146 #endif\r
147 \r
148 /*  Firstly it copies data from read only memory to RAM. There are two schemes\r
149  *  to copy. One can copy more than one sections. Another can only copy\r
150  *  one section.  The former scheme needs more instructions and read-only\r
151  *  data to implement than the latter.\r
152  *  Macro __STARTUP_COPY_MULTIPLE is used to choose between two schemes.  */\r
153 \r
154 #ifdef __STARTUP_COPY_MULTIPLE\r
155 /*  Multiple sections scheme.\r
156  *\r
157  *  Between symbol address __copy_table_start__ and __copy_table_end__,\r
158  *  there are array of triplets, each of which specify:\r
159  *    offset 0: LMA of start of a section to copy from\r
160  *    offset 4: VMA of start of a section to copy to\r
161  *    offset 8: size of the section to copy. Must be multiply of 4\r
162  *\r
163  *  All addresses must be aligned to 4 bytes boundary.\r
164  */\r
165     ldr     r4, =__copy_table_start__\r
166     ldr     r5, =__copy_table_end__\r
167 \r
168 .L_loop0:\r
169     cmp     r4, r5\r
170     bge     .L_loop0_done\r
171     ldr     r1, [r4]\r
172     ldr     r2, [r4, #4]\r
173     ldr     r3, [r4, #8]\r
174 \r
175 .L_loop0_0:\r
176     subs    r3, #4\r
177     ittt    ge\r
178     ldrge   r0, [r1, r3]\r
179     strge   r0, [r2, r3]\r
180     bge     .L_loop0_0\r
181 \r
182     adds    r4, #12\r
183     b       .L_loop0\r
184 \r
185 .L_loop0_done:\r
186 #else\r
187 /*  Single section scheme.\r
188  *\r
189  *  The ranges of copy from/to are specified by following symbols\r
190  *    __etext: LMA of start of the section to copy from. Usually end of text\r
191  *    __data_start__: VMA of start of the section to copy to\r
192  *    __data_end__: VMA of end of the section to copy to\r
193  *\r
194  *  All addresses must be aligned to 4 bytes boundary.\r
195  */\r
196     ldr     r1, =__etext\r
197     ldr     r2, =__data_start__\r
198     ldr     r3, =__data_end__\r
199 \r
200 .L_loop1:\r
201     cmp     r2, r3\r
202     ittt    lt\r
203     ldrlt   r0, [r1], #4\r
204     strlt   r0, [r2], #4\r
205     blt     .L_loop1\r
206 #endif /*__STARTUP_COPY_MULTIPLE */\r
207 \r
208 /*  This part of work usually is done in C library startup code. Otherwise,\r
209  *  define this macro to enable it in this startup.\r
210  *\r
211  *  There are two schemes too. One can clear multiple BSS sections. Another\r
212  *  can only clear one section. The former is more size expensive than the\r
213  *  latter.\r
214  *\r
215  *  Define macro __STARTUP_CLEAR_BSS_MULTIPLE to choose the former.\r
216  *  Otherwise efine macro __STARTUP_CLEAR_BSS to choose the later.\r
217  */\r
218 #ifdef __STARTUP_CLEAR_BSS_MULTIPLE\r
219 /*  Multiple sections scheme.\r
220  *\r
221  *  Between symbol address __copy_table_start__ and __copy_table_end__,\r
222  *  there are array of tuples specifying:\r
223  *    offset 0: Start of a BSS section\r
224  *    offset 4: Size of this BSS section. Must be multiply of 4\r
225  */\r
226     ldr     r3, =__zero_table_start__\r
227     ldr     r4, =__zero_table_end__\r
228 \r
229 .L_loop2:\r
230     cmp     r3, r4\r
231     bge     .L_loop2_done\r
232     ldr     r1, [r3]\r
233     ldr     r2, [r3, #4]\r
234     movs    r0, 0\r
235 \r
236 .L_loop2_0:\r
237     subs    r2, #4\r
238     itt     ge\r
239     strge   r0, [r1, r2]\r
240     bge     .L_loop2_0\r
241     adds    r3, #8\r
242     b       .L_loop2\r
243 .L_loop2_done:\r
244 #elif defined (__STARTUP_CLEAR_BSS)\r
245 /*  Single BSS section scheme.\r
246  *\r
247  *  The BSS section is specified by following symbols\r
248  *    __bss_start__: start of the BSS section.\r
249  *    __bss_end__: end of the BSS section.\r
250  *\r
251  *  Both addresses must be aligned to 4 bytes boundary.\r
252  */\r
253     ldr     r1, =__bss_start__\r
254     ldr     r2, =__bss_end__\r
255 \r
256     movs    r0, 0\r
257 .L_loop3:\r
258     cmp     r1, r2\r
259     itt     lt\r
260     strlt   r0, [r1], #4\r
261     blt     .L_loop3\r
262 #endif /* __STARTUP_CLEAR_BSS_MULTIPLE || __STARTUP_CLEAR_BSS */\r
263 \r
264 #ifndef __START\r
265 #define __START _start\r
266 #endif\r
267     bl      __START\r
268 \r
269     .pool\r
270     .size   Reset_Handler, . - Reset_Handler\r
271 \r
272     .align  1\r
273     .thumb_func\r
274     .weak   Default_Handler\r
275     .type   Default_Handler, %function\r
276 Default_Handler:\r
277     b       .\r
278     .size   Default_Handler, . - Default_Handler\r
279 \r
280 /*    Macro to define default handlers. Default handler\r
281  *    will be weak symbol and just dead loops. They can be\r
282  *    overwritten by other handlers */\r
283     .macro  def_irq_handler     handler_name\r
284     .weak   \handler_name\r
285     .set    \handler_name, Default_Handler\r
286     .endm\r
287 \r
288     def_irq_handler     NMI_Handler\r
289     def_irq_handler     HardFault_Handler\r
290     def_irq_handler     MemManage_Handler\r
291     def_irq_handler     BusFault_Handler\r
292     def_irq_handler     UsageFault_Handler\r
293     def_irq_handler     SVC_Handler\r
294     def_irq_handler     DebugMon_Handler\r
295     def_irq_handler     PendSV_Handler\r
296     def_irq_handler     SysTick_Handler\r
297 \r
298     def_irq_handler     DMA_IRQHandler\r
299     def_irq_handler     GPIO_EVEN_IRQHandler\r
300     def_irq_handler     TIMER0_IRQHandler\r
301     def_irq_handler     USART0_RX_IRQHandler\r
302     def_irq_handler     USART0_TX_IRQHandler\r
303     def_irq_handler     USB_IRQHandler\r
304     def_irq_handler     ACMP0_IRQHandler\r
305     def_irq_handler     ADC0_IRQHandler\r
306     def_irq_handler     DAC0_IRQHandler\r
307     def_irq_handler     I2C0_IRQHandler\r
308     def_irq_handler     I2C1_IRQHandler\r
309     def_irq_handler     GPIO_ODD_IRQHandler\r
310     def_irq_handler     TIMER1_IRQHandler\r
311     def_irq_handler     TIMER2_IRQHandler\r
312     def_irq_handler     TIMER3_IRQHandler\r
313     def_irq_handler     USART1_RX_IRQHandler\r
314     def_irq_handler     USART1_TX_IRQHandler\r
315     def_irq_handler     LESENSE_IRQHandler\r
316     def_irq_handler     USART2_RX_IRQHandler\r
317     def_irq_handler     USART2_TX_IRQHandler\r
318     def_irq_handler     UART0_RX_IRQHandler\r
319     def_irq_handler     UART0_TX_IRQHandler\r
320     def_irq_handler     UART1_RX_IRQHandler\r
321     def_irq_handler     UART1_TX_IRQHandler\r
322     def_irq_handler     LEUART0_IRQHandler\r
323     def_irq_handler     LEUART1_IRQHandler\r
324     def_irq_handler     LETIMER0_IRQHandler\r
325     def_irq_handler     PCNT0_IRQHandler\r
326     def_irq_handler     PCNT1_IRQHandler\r
327     def_irq_handler     PCNT2_IRQHandler\r
328     def_irq_handler     RTC_IRQHandler\r
329     def_irq_handler     BURTC_IRQHandler\r
330     def_irq_handler     CMU_IRQHandler\r
331     def_irq_handler     VCMP_IRQHandler\r
332     def_irq_handler     LCD_IRQHandler\r
333     def_irq_handler     MSC_IRQHandler\r
334     def_irq_handler     AES_IRQHandler\r
335     def_irq_handler     EBI_IRQHandler\r
336     def_irq_handler     EMU_IRQHandler\r
337     def_irq_handler     FPUEH_IRQHandler\r
338 \r
339 \r
340     .end\r