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 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 MemManage_Handler /* MPU Fault Handler */ |
||
| 91 | .long BusFault_Handler /* Bus Fault Handler */ |
||
| 92 | .long UsageFault_Handler /* Usage Fault Handler */ |
||
| 93 | .long 0 /* Reserved */ |
||
| 94 | .long 0 /* Reserved */ |
||
| 95 | .long 0 /* Reserved */ |
||
| 96 | .long 0 /* Reserved */ |
||
| 97 | .long SVC_Handler /* SVCall Handler */ |
||
| 98 | .long DebugMon_Handler /* Debug Monitor Handler */ |
||
| 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 MemManage_Handler |
||
| 136 | .weak MemManage_Handler |
||
| 137 | .type MemManage_Handler, %function |
||
| 138 | .thumb_func |
||
| 139 | MemManage_Handler: |
||
| 140 | bkpt #0 |
||
| 141 | b . |
||
| 142 | |||
| 143 | .globl BusFault_Handler |
||
| 144 | .weak BusFault_Handler |
||
| 145 | .type BusFault_Handler, %function |
||
| 146 | .thumb_func |
||
| 147 | BusFault_Handler: |
||
| 148 | bkpt #0 |
||
| 149 | b . |
||
| 150 | |||
| 151 | .globl UsageFault_Handler |
||
| 152 | .weak UsageFault_Handler |
||
| 153 | .type UsageFault_Handler, %function |
||
| 154 | .thumb_func |
||
| 155 | UsageFault_Handler: |
||
| 156 | bkpt #0 |
||
| 157 | b . |
||
| 158 | |||
| 159 | .globl SVC_Handler |
||
| 160 | .weak SVC_Handler |
||
| 161 | .type SVC_Handler, %function |
||
| 162 | .thumb_func |
||
| 163 | SVC_Handler: |
||
| 164 | bkpt #0 |
||
| 165 | b . |
||
| 166 | |||
| 167 | .globl DebugMon_Handler |
||
| 168 | .weak DebugMon_Handler |
||
| 169 | .type DebugMon_Handler, %function |
||
| 170 | .thumb_func |
||
| 171 | DebugMon_Handler: |
||
| 172 | bkpt #0 |
||
| 173 | b . |
||
| 174 | |||
| 175 | .globl PendSV_Handler |
||
| 176 | .weak PendSV_Handler |
||
| 177 | .type PendSV_Handler, %function |
||
| 178 | .thumb_func |
||
| 179 | PendSV_Handler: |
||
| 180 | bkpt #0 |
||
| 181 | b . |
||
| 182 | |||
| 183 | .globl SysTick_Handler |
||
| 184 | .weak SysTick_Handler |
||
| 185 | .type SysTick_Handler, %function |
||
| 186 | .thumb_func |
||
| 187 | SysTick_Handler: |
||
| 188 | bkpt #0 |
||
| 189 | b . |
||
| 190 | |||
| 191 | |||
| 192 | .global __use_two_region_memory |
||
| 193 | |||
| 194 | /* |
||
| 195 | __user_setup_stackheap() returns the: |
||
| 196 | - heap base in r0 (if the program uses the heap) |
||
| 197 | - stack base in sp |
||
| 198 | - heap limit in r2 (if the program uses the heap and uses two-region memory). |
||
| 199 | */ |
||
| 200 | .globl __user_setup_stackheap |
||
| 201 | .type __user_setup_stackheap, %function |
||
| 202 | .thumb_func |
||
| 203 | __user_setup_stackheap: |
||
| 204 | ldr r0, =__StackTop |
||
| 205 | mov sp, r0 |
||
| 206 | .if Heap_Size |
||
| 207 | ldr r0, =__HeapBase |
||
| 208 | ldr r2, =__HeapLimit |
||
| 209 | .else |
||
| 210 | mov r0, #0 |
||
| 211 | mov r2, #0 |
||
| 212 | .endif |
||
| 213 | bx lr |
||
| 214 | |||
| 215 | |||
| 216 | /* |
||
| 217 | __user_initial_stackheap() returns the: |
||
| 218 | - heap base in r0 |
||
| 219 | - stack base in r1, that is, the highest address in the stack region |
||
| 220 | - heap limit in r2 |
||
| 221 | - stack limit in r3, that is, the lowest address in the stack region. |
||
| 222 | */ |
||
| 223 | /* DEPRICATED |
||
| 224 | .globl __user_initial_stackheap |
||
| 225 | .type __user_initial_stackheap, %function |
||
| 226 | .thumb_func |
||
| 227 | __user_initial_stackheap: |
||
| 228 | ldr r0, = __HeapBase |
||
| 229 | ldr r1, = __StackTop |
||
| 230 | ldr r2, = __HeapLimit |
||
| 231 | ldr r3, = __StackLimit |
||
| 232 | bx lr |
||
| 233 | */ |
||
| 234 | |||
| 235 | .end |