source: trunk/firmware/Cortex_M_Startup.s

Last change on this file was 6, checked in by f.jahn, 8 months ago
File size: 5.3 KB
Line 
1// **********************************************************************
2// * SEGGER Microcontroller GmbH *
3// * The Embedded Experts *
4// **********************************************************************
5// * *
6// * (c) 2014 - 2020 SEGGER Microcontroller GmbH *
7// * (c) 2001 - 2020 Rowley Associates Limited *
8// * *
9// * www.segger.com Support: support@segger.com *
10// * *
11// **********************************************************************
12// * *
13// * All rights reserved. *
14// * *
15// * Redistribution and use in source and binary forms, with or *
16// * without modification, are permitted provided that the following *
17// * conditions are met: *
18// * *
19// * - Redistributions of source code must retain the above copyright *
20// * notice, this list of conditions and the following disclaimer. *
21// * *
22// * - Neither the name of SEGGER Microcontroller GmbH *
23// * nor the names of its contributors may be used to endorse or *
24// * promote products derived from this software without specific *
25// * prior written permission. *
26// * *
27// * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND *
28// * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, *
29// * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF *
30// * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
31// * DISCLAIMED. *
32// * IN NO EVENT SHALL SEGGER Microcontroller GmbH BE LIABLE FOR *
33// * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR *
34// * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT *
35// * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; *
36// * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
37// * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
38// * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
39// * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH *
40// * DAMAGE. *
41// * *
42// **********************************************************************
43
44.macro ISR_HANDLER name=
45 .section .vectors, "ax"
46 .word \name
47 .section .init, "ax"
48 .thumb_func
49 .weak \name
50\name:
511: b 1b /* endless loop */
52.endm
53
54.macro ISR_RESERVED
55 .section .vectors, "ax"
56 .word 0
57.endm
58
59 .syntax unified
60 .global reset_handler
61 .global Reset_Handler
62 .equ Reset_Handler, reset_handler
63
64 .section .vectors, "ax"
65 .code 16
66 .balign 2
67 .global _vectors
68
69.macro DEFAULT_ISR_HANDLER name=
70 .thumb_func
71 .weak \name
72\name:
731: b 1b /* endless loop */
74.endm
75
76_vectors:
77 .word __stack_end__
78 .word reset_handler
79ISR_HANDLER NMI_Handler
80ISR_HANDLER HardFault_Handler
81ISR_HANDLER MemManage_Handler
82ISR_HANDLER BusFault_Handler
83ISR_HANDLER UsageFault_Handler
84ISR_RESERVED
85ISR_RESERVED
86ISR_RESERVED
87ISR_RESERVED
88ISR_HANDLER SVC_Handler
89ISR_HANDLER DebugMon_Handler
90ISR_RESERVED
91ISR_HANDLER PendSV_Handler
92ISR_HANDLER SysTick_Handler
93#ifdef __VECTORS
94#include __VECTORS
95#else
96ISR_HANDLER ExternalISR0
97ISR_HANDLER ExternalISR1
98ISR_HANDLER ExternalISR2
99ISR_HANDLER ExternalISR3
100ISR_HANDLER ExternalISR4
101ISR_HANDLER ExternalISR5
102ISR_HANDLER ExternalISR6
103ISR_HANDLER ExternalISR7
104ISR_HANDLER ExternalISR8
105ISR_HANDLER ExternalISR9
106ISR_HANDLER ExternalISR10
107ISR_HANDLER ExternalISR11
108ISR_HANDLER ExternalISR12
109ISR_HANDLER ExternalISR13
110ISR_HANDLER ExternalISR14
111ISR_HANDLER ExternalISR15
112ISR_HANDLER ExternalISR16
113ISR_HANDLER ExternalISR17
114ISR_HANDLER ExternalISR18
115ISR_HANDLER ExternalISR19
116ISR_HANDLER ExternalISR20
117ISR_HANDLER ExternalISR21
118ISR_HANDLER ExternalISR22
119ISR_HANDLER ExternalISR23
120ISR_HANDLER ExternalISR24
121ISR_HANDLER ExternalISR25
122ISR_HANDLER ExternalISR26
123ISR_HANDLER ExternalISR27
124ISR_HANDLER ExternalISR28
125ISR_HANDLER ExternalISR29
126ISR_HANDLER ExternalISR30
127ISR_HANDLER ExternalISR31
128#endif
129 .section .vectors, "ax"
130_vectors_end:
131
132 .section .init, "ax"
133 .balign 2
134
135 .thumb_func
136 reset_handler:
137
138#ifndef __NO_SYSTEM_INIT
139 ldr r0, =__stack_end__
140 mov sp, r0
141 bl SystemInit
142#endif
143
144#if !defined(__SOFTFP__)
145 // Enable CP11 and CP10 with CPACR |= (0xf<<20)
146 movw r0, 0xED88
147 movt r0, 0xE000
148 ldr r1, [r0]
149 orrs r1, r1, #(0xf << 20)
150 str r1, [r0]
151#endif
152
153 b _start
154
155#ifndef __NO_SYSTEM_INIT
156 .thumb_func
157 .weak SystemInit
158SystemInit:
159 bx lr
160#endif
Note: See TracBrowser for help on using the repository browser.