Subversion Repositories AFRtranscoder

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
;/* File: startup_armv7-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     MemManage_Handler         ; MPU Fault Handler
78
                DCD     BusFault_Handler          ; Bus Fault Handler
79
                DCD     UsageFault_Handler        ; Usage Fault Handler
80
                DCD     0                         ; Reserved
81
                DCD     0                         ; Reserved
82
                DCD     0                         ; Reserved
83
                DCD     0                         ; Reserved
84
                DCD     SVC_Handler               ; SVCall Handler
85
                DCD     DebugMon_Handler          ; Debug Monitor Handler
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
MemManage_Handler\
123
                PROC
124
                EXPORT  MemManage_Handler         [WEAK]
125
                BKPT #0
126
                B       .
127
                ENDP
128
BusFault_Handler\
129
                PROC
130
                EXPORT  BusFault_Handler          [WEAK]
131
                BKPT #0
132
                B       .
133
                ENDP
134
UsageFault_Handler\
135
                PROC
136
                EXPORT  UsageFault_Handler        [WEAK]
137
                BKPT #0
138
                B       .
139
                ENDP
140
SVC_Handler     PROC
141
                EXPORT  SVC_Handler               [WEAK]
142
                B       .
143
                ENDP
144
DebugMon_Handler\
145
                PROC
146
                EXPORT  DebugMon_Handler          [WEAK]
147
                B       .
148
                ENDP
149
PendSV_Handler  PROC
150
                EXPORT  PendSV_Handler            [WEAK]
151
                B       .
152
                ENDP
153
SysTick_Handler PROC
154
                EXPORT  SysTick_Handler           [WEAK]
155
                B       .
156
                ENDP
157
 
158
                ALIGN
159
 
160
; User Initial Stack & Heap
161
                IF      :DEF:__MICROLIB
162
 
163
                EXPORT  __initial_sp
164
                EXPORT  __heap_base
165
                EXPORT  __heap_limit
166
 
167
                ELSE
168
 
169
                IMPORT  __use_two_region_memory
170
 
171
;/*
172
;  __user_setup_stackheap() returns the:
173
;     - heap base in r0 (if the program uses the heap)
174
;     - stack base in sp
175
;     - heap limit in r2 (if the program uses the heap and uses two-region memory).
176
; */
177
                EXPORT  __user_setup_stackheap
178
 
179
__user_setup_stackheap PROC
180
                LDR     R0, = __initial_sp
181
                MOV     SP, R0
182
				IF Heap_Size > 0
183
                LDR     R2, = __heap_limit
184
                LDR     R0, = __heap_base
185
				ELSE
186
                MOV     R0, #0
187
                MOV     R2, #0
188
                ENDIF
189
                BX      LR
190
                ENDP
191
 
192
 
193
;/*
194
;__user_initial_stackheap() returns the:
195
;   - heap base in r0
196
;   - stack base in r1, that is, the highest address in the stack region
197
;   - heap limit in r2
198
;   - stack limit in r3, that is, the lowest address in the stack region.
199
; */
200
;
201
;/* DEPRICATED
202
;                EXPORT  __user_initial_stackheap
203
;
204
;__user_initial_stackheap PROC
205
;                LDR     R0, =  Heap_Mem
206
;                LDR     R1, =(Stack_Mem + Stack_Size)
207
;                LDR     R2, = (Heap_Mem +  Heap_Size)
208
;                LDR     R3, = Stack_Mem
209
;                BX      LR
210
;                ENDP
211
; */
212
 
213
                ALIGN
214
 
215
                ENDIF
216
 
217
 
218
                END