Subversion Repositories AFRtranscoder

Rev

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 armv6-m architecture devices.
3
 *          Should be used with ARMCLANG
4
 * Version: V2.00
5
 * Date: 16 November 2015
6
 *
7
 */
8
/* Copyright (c) 2011 - 2015 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
    .syntax unified
40
    .arch   armv6-m
41
 
42
/* .eabi_attribute Tag_ABI_align8_preserved,1    www.support.code-red-tech.com/CodeRedWiki/Preserve8 */
43
.eabi_attribute 25, 1   /* Tag_ABI_align_preserved */
44
 
45
 
46
/*
47
  ;<h> Stack Configuration
48
  ;  <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
49
  ;</h>
50
*/
51
    .equ    Stack_Size, 0x00000400
52
 
53
    .section STACK, "w"
54
    .align  3
55
    .globl  __StackTop
56
    .globl  __StackLimit
57
__StackLimit:
58
    .space  Stack_Size
59
__StackTop:   /* formerly known as __initial_sp */
60
 
61
 
62
/*
63
  ;<h> Heap Configuration
64
  ;  <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
65
  ;</h>
66
*/
67
    .equ    Heap_Size, 0x00000C00
68
 
69
    .section HEAP, "w"
70
    .align  3
71
    .globl  __HeapBase
72
    .globl  __HeapLimit
73
__HeapBase:
74
    .if Heap_Size
75
    .space  Heap_Size
76
    .endif
77
__HeapLimit:
78
 
79
 
80
    .section RESET, "x"
81
    .align  2
82
    .globl  __Vectors
83
    .globl  __Vectors_End
84
    .globl  __Vectors_Size
85
__Vectors:
86
    .long   __StackTop            /* Top of Stack */
87
    .long   Reset_Handler         /* Reset Handler */
88
    .long   NMI_Handler           /* NMI Handler */
89
    .long   HardFault_Handler     /* Hard Fault Handler */
90
    .long   0                     /* Reserved */
91
    .long   0                     /* Reserved */
92
    .long   0                     /* Reserved */
93
    .long   0                     /* Reserved */
94
    .long   0                     /* Reserved */
95
    .long   0                     /* Reserved */
96
    .long   0                     /* Reserved */
97
    .long   SVC_Handler           /* SVCall Handler */
98
    .long   0                     /* Reserved */
99
    .long   0                     /* Reserved */
100
    .long   PendSV_Handler        /* PendSV Handler */
101
    .long   SysTick_Handler       /* SysTick Handler */
102
__Vectors_End:
103
 
104
    .equ    __Vectors_Size, __Vectors_End - __Vectors
105
 
106
 
107
    .text
108
    .thumb
109
    .align  2
110
 
111
    .globl  Reset_Handler
112
    .weak   Reset_Handler
113
    .type   Reset_Handler, %function
114
    .thumb_func
115
Reset_Handler:
116
    bl      SystemInit
117
    bl      __main
118
 
119
    .globl  NMI_Handler
120
    .weak   NMI_Handler
121
    .type   NMI_Handler, %function
122
    .thumb_func
123
NMI_Handler:
124
    bkpt    #0
125
    b       .
126
 
127
    .globl  HardFault_Handler
128
    .weak   HardFault_Handler
129
    .type   HardFault_Handler, %function
130
    .thumb_func
131
HardFault_Handler:
132
    bkpt    #0
133
    b       .
134
 
135
    .globl  SVC_Handler
136
    .weak   SVC_Handler
137
    .type   SVC_Handler, %function
138
    .thumb_func
139
SVC_Handler:
140
    bkpt    #0
141
    b       .
142
 
143
    .globl  PendSV_Handler
144
    .weak   PendSV_Handler
145
    .type   PendSV_Handler, %function
146
    .thumb_func
147
PendSV_Handler:
148
    bkpt    #0
149
    b       .
150
 
151
    .globl  SysTick_Handler
152
    .weak   SysTick_Handler
153
    .type   SysTick_Handler, %function
154
    .thumb_func
155
SysTick_Handler:
156
    bkpt    #0
157
    b       .
158
 
159
 
160
    .global __use_two_region_memory
161
 
162
/*
163
  __user_setup_stackheap() returns the:
164
     - heap base in r0 (if the program uses the heap)
165
     - stack base in sp
166
     - heap limit in r2 (if the program uses the heap and uses two-region memory).
167
 */
168
    .globl  __user_setup_stackheap
169
    .type   __user_setup_stackheap, %function
170
    .thumb_func
171
__user_setup_stackheap:
172
    ldr     r0, =__StackTop
173
    mov     sp, r0
174
    .if Heap_Size
175
    ldr     r0, =__HeapBase
176
    ldr     r2, =__HeapLimit
177
    .else
178
    mov     r0, #0
179
    mov     r2, #0
180
    .endif
181
    bx      lr
182
 
183
 
184
/*
185
__user_initial_stackheap() returns the:
186
   - heap base in r0
187
   - stack base in r1, that is, the highest address in the stack region
188
   - heap limit in r2
189
   - stack limit in r3, that is, the lowest address in the stack region.
190
 */
191
/* DEPRICATED
192
    .globl  __user_initial_stackheap
193
    .type   __user_initial_stackheap, %function
194
    .thumb_func
195
__user_initial_stackheap:
196
    ldr     r0, = __HeapBase
197
    ldr     r1, = __StackTop
198
    ldr     r2, = __HeapLimit
199
    ldr     r3, = __StackLimit
200
    bx      lr
201
*/
202
 
203
    .end