Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | ;/* File: startup_armv6-m.s |
2 | ; * Purpose: startup file for armv7-m architecture devices. |
||
3 | ; * Should be used with ARMCC |
||
4 | ; * Version: V2.00 |
||
5 | ; * Date: 16 November 2015 |
||
6 | ; * |
||
7 | ; */ |
||
8 | ;/* Copyright (c) 2011 - 2014 ARM LIMITED |
||
9 | ; |
||
10 | ; All rights reserved. |
||
11 | ; Redistribution and use in source and binary forms, with or without |
||
12 | ; modification, are permitted provided that the following conditions are met: |
||
13 | ; - Redistributions of source code must retain the above copyright |
||
14 | ; notice, this list of conditions and the following disclaimer. |
||
15 | ; - Redistributions in binary form must reproduce the above copyright |
||
16 | ; notice, this list of conditions and the following disclaimer in the |
||
17 | ; documentation and/or other materials provided with the distribution. |
||
18 | ; - Neither the name of ARM nor the names of its contributors may be used |
||
19 | ; to endorse or promote products derived from this software without |
||
20 | ; specific prior written permission. |
||
21 | ; * |
||
22 | ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
||
23 | ; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
||
24 | ; IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
||
25 | ; ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE |
||
26 | ; LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
||
27 | ; CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
||
28 | ; SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||
29 | ; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
||
30 | ; CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
||
31 | ; ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
||
32 | ; POSSIBILITY OF SUCH DAMAGE. |
||
33 | ; ---------------------------------------------------------------------------*/ |
||
34 | ;/* |
||
35 | ; //-------- <<< Use Configuration Wizard in Context Menu >>> ------------------ |
||
36 | ;*/ |
||
37 | |||
38 | |||
39 | ; <h> Stack Configuration |
||
40 | ; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8> |
||
41 | ; </h> |
||
42 | |||
43 | Stack_Size EQU 0x00000400 |
||
44 | |||
45 | AREA STACK, NOINIT, READWRITE, ALIGN=3 |
||
46 | Stack_Mem SPACE Stack_Size |
||
47 | __initial_sp |
||
48 | |||
49 | |||
50 | ; <h> Heap Configuration |
||
51 | ; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8> |
||
52 | ; </h> |
||
53 | |||
54 | Heap_Size EQU 0x00000C00 |
||
55 | |||
56 | AREA HEAP, NOINIT, READWRITE, ALIGN=3 |
||
57 | __heap_base |
||
58 | Heap_Mem SPACE Heap_Size |
||
59 | __heap_limit |
||
60 | |||
61 | |||
62 | PRESERVE8 |
||
63 | THUMB |
||
64 | |||
65 | |||
66 | ; Vector Table Mapped to Address 0 at Reset |
||
67 | |||
68 | AREA RESET, DATA, READONLY |
||
69 | EXPORT __Vectors |
||
70 | EXPORT __Vectors_End |
||
71 | EXPORT __Vectors_Size |
||
72 | |||
73 | __Vectors DCD __initial_sp ; Top of Stack |
||
74 | DCD Reset_Handler ; Reset Handler |
||
75 | DCD NMI_Handler ; NMI Handler |
||
76 | DCD HardFault_Handler ; Hard Fault Handler |
||
77 | DCD 0 ; Reserved |
||
78 | DCD 0 ; Reserved |
||
79 | DCD 0 ; Reserved |
||
80 | DCD 0 ; Reserved |
||
81 | DCD 0 ; Reserved |
||
82 | DCD 0 ; Reserved |
||
83 | DCD 0 ; Reserved |
||
84 | DCD SVC_Handler ; SVCall Handler |
||
85 | DCD 0 ; Reserved |
||
86 | DCD 0 ; Reserved |
||
87 | DCD PendSV_Handler ; PendSV Handler |
||
88 | DCD SysTick_Handler ; SysTick Handler |
||
89 | __Vectors_End |
||
90 | |||
91 | __Vectors_Size EQU __Vectors_End - __Vectors |
||
92 | |||
93 | AREA |.text|, CODE, READONLY |
||
94 | |||
95 | |||
96 | ; Reset Handler |
||
97 | |||
98 | Reset_Handler PROC |
||
99 | EXPORT Reset_Handler [WEAK] |
||
100 | IMPORT SystemInit |
||
101 | IMPORT __main |
||
102 | LDR R0, =SystemInit |
||
103 | BLX R0 |
||
104 | LDR R0, =__main |
||
105 | BX R0 |
||
106 | ENDP |
||
107 | |||
108 | |||
109 | ; Dummy Exception Handlers (infinite loops which can be modified) |
||
110 | |||
111 | NMI_Handler PROC |
||
112 | EXPORT NMI_Handler [WEAK] |
||
113 | BKPT #0 |
||
114 | B . |
||
115 | ENDP |
||
116 | HardFault_Handler\ |
||
117 | PROC |
||
118 | EXPORT HardFault_Handler [WEAK] |
||
119 | BKPT #0 |
||
120 | B . |
||
121 | ENDP |
||
122 | SVC_Handler PROC |
||
123 | EXPORT SVC_Handler [WEAK] |
||
124 | B . |
||
125 | ENDP |
||
126 | PendSV_Handler PROC |
||
127 | EXPORT PendSV_Handler [WEAK] |
||
128 | B . |
||
129 | ENDP |
||
130 | SysTick_Handler PROC |
||
131 | EXPORT SysTick_Handler [WEAK] |
||
132 | B . |
||
133 | ENDP |
||
134 | |||
135 | ALIGN |
||
136 | |||
137 | ; User Initial Stack & Heap |
||
138 | IF :DEF:__MICROLIB |
||
139 | |||
140 | EXPORT __initial_sp |
||
141 | EXPORT __heap_base |
||
142 | EXPORT __heap_limit |
||
143 | |||
144 | ELSE |
||
145 | |||
146 | IMPORT __use_two_region_memory |
||
147 | |||
148 | ;/* |
||
149 | ; __user_setup_stackheap() returns the: |
||
150 | ; - heap base in r0 (if the program uses the heap) |
||
151 | ; - stack base in sp |
||
152 | ; - heap limit in r2 (if the program uses the heap and uses two-region memory). |
||
153 | ; */ |
||
154 | EXPORT __user_setup_stackheap |
||
155 | |||
156 | __user_setup_stackheap PROC |
||
157 | LDR R0, = __initial_sp |
||
158 | MOV SP, R0 |
||
159 | IF Heap_Size > 0 |
||
160 | LDR R2, = __heap_limit |
||
161 | LDR R0, = __heap_base |
||
162 | ELSE |
||
163 | MOV R0, #0 |
||
164 | MOV R2, #0 |
||
165 | ENDIF |
||
166 | BX LR |
||
167 | ENDP |
||
168 | |||
169 | |||
170 | ;/* |
||
171 | ;__user_initial_stackheap() returns the: |
||
172 | ; - heap base in r0 |
||
173 | ; - stack base in r1, that is, the highest address in the stack region |
||
174 | ; - heap limit in r2 |
||
175 | ; - stack limit in r3, that is, the lowest address in the stack region. |
||
176 | ; */ |
||
177 | ; |
||
178 | ;/* DEPRICATED |
||
179 | ; EXPORT __user_initial_stackheap |
||
180 | ; |
||
181 | ;__user_initial_stackheap PROC |
||
182 | ; LDR R0, = Heap_Mem |
||
183 | ; LDR R1, =(Stack_Mem + Stack_Size) |
||
184 | ; LDR R2, = (Heap_Mem + Heap_Size) |
||
185 | ; LDR R3, = Stack_Mem |
||
186 | ; BX LR |
||
187 | ; ENDP |
||
188 | ; */ |
||
189 | |||
190 | ALIGN |
||
191 | |||
192 | ENDIF |
||
193 | |||
194 | |||
195 | END |