]> git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_Freescale/TARGET_KLXX/TARGET_KL43Z/TOOLCHAIN_GCC_ARM/startup_MKL43Z4.S
Merge commit '20b787fc1284176834cbe7ca2134e4b36bec5828'
[tmk_keyboard.git] / tmk_core / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_Freescale / TARGET_KLXX / TARGET_KL43Z / TOOLCHAIN_GCC_ARM / startup_MKL43Z4.S
1 /* KL43Z startup ARM GCC
2 * Purpose: startup file for Cortex-M0 devices. Should use with
3 * GCC for ARM Embedded Processors
4 * Version: V1.3
5 * Date: 10 Nov 2014
6 *
7 * Copyright (c) 2011, ARM Limited
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright
13 notice, this list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright
15 notice, this list of conditions and the following disclaimer in the
16 documentation and/or other materials provided with the distribution.
17 * Neither the name of the ARM Limited nor the
18 names of its contributors may be used to endorse or promote products
19 derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL ARM LIMITED BE LIABLE FOR ANY
25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
28 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32 .syntax unified
33 .arch armv6-m
34
35 /* Memory Model
36 The HEAP starts at the end of the DATA section and grows upward.
37
38 The STACK starts at the end of the RAM and grows downward.
39
40 The HEAP and stack STACK are only checked at compile time:
41 (DATA_SIZE + HEAP_SIZE + STACK_SIZE) < RAM_SIZE
42
43 This is just a check for the bare minimum for the Heap+Stack area before
44 aborting compilation, it is not the run time limit:
45 Heap_Size + Stack_Size = 0x200 + 0x400 = 0x600
46 */
47 .section .stack
48 .align 3
49 #ifdef __STACK_SIZE
50 .equ Stack_Size, __STACK_SIZE
51 #else
52 .equ Stack_Size, 0x400
53 #endif
54 .globl __StackTop
55 .globl __StackLimit
56 __StackLimit:
57 .space Stack_Size
58 .size __StackLimit, . - __StackLimit
59 __StackTop:
60 .size __StackTop, . - __StackTop
61
62 .section .heap
63 .align 3
64 #ifdef __HEAP_SIZE
65 .equ Heap_Size, __HEAP_SIZE
66 #else
67 .equ Heap_Size, 0x200
68 #endif
69 .globl __HeapBase
70 .globl __HeapLimit
71 __HeapBase:
72 .space Heap_Size
73 .size __HeapBase, . - __HeapBase
74 __HeapLimit:
75 .size __HeapLimit, . - __HeapLimit
76
77 .section .vector_table,"a",%progbits
78 .align 2
79 .globl __isr_vector
80 __isr_vector:
81 .long __StackTop /* Top of Stack */
82 .long Reset_Handler /* Reset Handler */
83 .long NMI_Handler /* NMI Handler */
84 .long HardFault_Handler /* Hard Fault Handler */
85 .long 0 /* Reserved */
86 .long 0 /* Reserved */
87 .long 0 /* Reserved */
88 .long 0 /* Reserved */
89 .long 0 /* Reserved */
90 .long 0 /* Reserved */
91 .long 0 /* Reserved */
92 .long SVC_Handler /* SVCall Handler */
93 .long 0 /* Reserved */
94 .long 0 /* Reserved */
95 .long PendSV_Handler /* PendSV Handler */
96 .long SysTick_Handler /* SysTick Handler */
97
98 /* External interrupts */
99 .long DMA0_IRQHandler /* DMA channel 0 transfer complete interrupt */
100 .long DMA1_IRQHandler /* DMA channel 1 transfer complete interrupt */
101 .long DMA2_IRQHandler /* DMA channel 2 transfer complete interrupt */
102 .long DMA3_IRQHandler /* DMA channel 3 transfer complete interrupt */
103 .long Default_Handler /* Reserved interrupt 20 */
104 .long FTFA_IRQHandler /* FTFA interrupt */
105 .long PMC_IRQHandler /* Low-voltage detect, low-voltage warning*/
106 .long LLWU_IRQHandler /* Low leakage wakeup*/
107 .long I2C0_IRQHandler /* I2C0 interrupt*/
108 .long I2C1_IRQHandler /* I2C1 interrupt*/
109 .long SPI0_IRQHandler /* SPI0 single interrupt vector for all sources*/
110 .long SPI1_IRQHandler /* SPI1 single interrupt vector for all sources*/
111 .long LPUART0_IRQHandler /* LPUART0 status and error*/
112 .long LPUART1_IRQHandler /* LPUART1 status and error*/
113 .long UART2_FLEXIO_IRQHandler /* UART2 or FLEXIO*/
114 .long ADC0_IRQHandler /* ADC0 interrupt*/
115 .long CMP0_IRQHandler /* CMP0 interrupt*/
116 .long TPM0_IRQHandler /* TPM0 single interrupt vector for all sources*/
117 .long TPM1_IRQHandler /* TPM1 single interrupt vector for all sources*/
118 .long TPM2_IRQHandler /* TPM2 single interrupt vector for all sources*/
119 .long RTC_IRQHandler /* RTC alarm*/
120 .long RTC_Seconds_IRQHandler /* RTC seconds*/
121 .long PIT_IRQHandler /* PIT interrupt*/
122 .long I2S0_IRQHandler /* I2S0 interrupt*/
123 .long USB0_IRQHandler /* USB0 interrupt*/
124 .long DAC0_IRQHandler /* DAC0 interrupt*/
125 .long Reserved42_IRQHandler /* Reserved interrupt*/
126 .long Reserved43_IRQHandler /* Reserved interrupt*/
127 .long LPTMR0_IRQHandler /* LPTMR0 interrupt*/
128 .long LCD_IRQHandler /* LCD interrupt*/
129 .long PORTA_IRQHandler /* PORTA Pin detect*/
130 .long PORTCD_IRQHandler /* Single interrupt vector for PORTC; PORTD Pin detect*/
131
132 .size __isr_vector, . - __isr_vector
133
134 /* Reset Handler */
135 .section .text.Reset_Handler
136 .thumb
137 .thumb_func
138 .align 2
139 .globl Reset_Handler
140 .type Reset_Handler, %function
141 Reset_Handler:
142 /* Loop to copy data from read only memory to RAM. The ranges
143 * of copy from/to are specified by following symbols evaluated in
144 * linker script.
145 * __etext: End of code section, i.e., begin of data sections to copy from.
146 * __data_start__/__data_end__: RAM address range that data should be
147 * copied to. Both must be aligned to 4 bytes boundary. */
148 ldr r1, =__etext
149 ldr r2, =__data_start__
150 ldr r3, =__data_end__
151
152 subs r3, r2
153 ble .Lflash_to_ram_loop_end
154
155 movs r4, 0
156 .Lflash_to_ram_loop:
157 ldr r0, [r1,r4]
158 str r0, [r2,r4]
159 adds r4, 4
160 cmp r4, r3
161 blt .Lflash_to_ram_loop
162 .Lflash_to_ram_loop_end:
163
164 ldr r0, =SystemInit
165 blx r0
166 ldr r0, =_start
167 bx r0
168 .pool
169 .size Reset_Handler, . - Reset_Handler
170
171
172 .text
173 /* Macro to define default handlers. Default handler
174 * will be weak symbol and just dead loops. They can be
175 * overwritten by other handlers */
176 .macro def_default_handler handler_name
177 .align 1
178 .thumb_func
179 .weak \handler_name
180 .type \handler_name, %function
181 \handler_name :
182 b .
183 .size \handler_name, . - \handler_name
184 .endm
185
186 def_default_handler NMI_Handler
187 def_default_handler HardFault_Handler
188 def_default_handler SVC_Handler
189 def_default_handler PendSV_Handler
190 def_default_handler SysTick_Handler
191 def_default_handler Default_Handler
192
193 .macro def_irq_default_handler handler_name
194 .weak \handler_name
195 .set \handler_name, Default_Handler
196 .endm
197
198 def_irq_default_handler DMA0_IRQHandler
199 def_irq_default_handler DMA1_IRQHandler
200 def_irq_default_handler DMA2_IRQHandler
201 def_irq_default_handler DMA3_IRQHandler
202 def_irq_default_handler Reserved20_IRQHandler
203 def_irq_default_handler FTFA_IRQHandler
204 def_irq_default_handler PMC_IRQHandler
205 def_irq_default_handler LLWU_IRQHandler
206 def_irq_default_handler I2C0_IRQHandler
207 def_irq_default_handler I2C1_IRQHandler
208 def_irq_default_handler SPI0_IRQHandler
209 def_irq_default_handler SPI1_IRQHandler
210 def_irq_default_handler LPUART0_IRQHandler
211 def_irq_default_handler LPUART1_IRQHandler
212 def_irq_default_handler UART2_FLEXIO_IRQHandler
213 def_irq_default_handler ADC0_IRQHandler
214 def_irq_default_handler CMP0_IRQHandler
215 def_irq_default_handler TPM0_IRQHandler
216 def_irq_default_handler TPM1_IRQHandler
217 def_irq_default_handler TPM2_IRQHandler
218 def_irq_default_handler RTC_IRQHandler
219 def_irq_default_handler RTC_Seconds_IRQHandler
220 def_irq_default_handler PIT_IRQHandler
221 def_irq_default_handler I2S0_IRQHandler
222 def_irq_default_handler USB0_IRQHandler
223 def_irq_default_handler DAC0_IRQHandler
224 def_irq_default_handler Reserved42_IRQHandler
225 def_irq_default_handler Reserved43_IRQHandler
226 def_irq_default_handler LPTMR0_IRQHandler
227 def_irq_default_handler LCD_IRQHandler
228 def_irq_default_handler PORTA_IRQHandler
229 def_irq_default_handler PORTCD_IRQHandler
230 def_irq_default_handler DefaultISR
231
232 /* Flash protection region, placed at 0x400 */
233 .text
234 .thumb
235 .align 2
236 .section .kinetis_flash_config_field,"a",%progbits
237 kinetis_flash_config:
238 .long 0xFFFFFFFF
239 .long 0xFFFFFFFF
240 .long 0xFFFFFFFF
241 .long 0xFFFF3FFE
242
243 .end
Imprint / Impressum