summaryrefslogtreecommitdiff
path: root/bsp/efm32/start_gcc.S
blob: 4c806a6ebd6ad0712115afb2e3913daf58e23ed8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
 * Copyright (c) 2006-2022, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date         Author      Notes
 * 2010-12-21   onelife     Initial creation for EFM32
 * 2011-07-06   onelife     Modify to make use the start code in libraries
 * 2012-05-15   onelife     Modified to compatible with CMSIS v3
 */

/***************************************************************************//**
* @addtogroup cortex-m3
* @{
*******************************************************************************/
    .syntax unified
    .cpu    cortex-m3
    .fpu    softvfp
    .thumb

/* start address for the initialization values of the .data section.
defined in linker script */
    .word __etext
/* start address for the .data section. defined in linker script */
    .word __data_start__
/* end address for the .data section. defined in linker script */
    .word __data_end__
/* start address for the .bss section. defined in linker script */
    .word __bss_start__
/* end address for the .bss section. defined in linker script */
    .word __bss_end__

/***************************************************************************//**
 * @brief  This is the code that gets called when the processor first
 *          starts execution following a reset event. Only the absolutely
 *          necessary set is performed, after which the application
 *          supplied main() routine is called.
 * @param  None
 * @retval None
*******************************************************************************/
    .thumb
    .thumb_func
    .section    .cs3.init,"ax", %progbits
    .globl      _start
    .type       _start, %function
_start:
    /* Copy the data segment initializers from flash to SRAM */
    movs  r1, #0
    b  LoopCopyDataInit

CopyDataInit:
    ldr  r3, =__etext
    ldr  r3, [r3, r1]
    str  r3, [r0, r1]
    adds  r1, r1, #4

LoopCopyDataInit:
    ldr  r0, =__data_start__
    ldr  r3, =__data_end__
    adds  r2, r0, r1
    cmp  r2, r3
    bcc  CopyDataInit
    ldr  r2, =__bss_start__
    b  LoopFillZerobss

/* Zero fill the bss segment. */
FillZerobss:
    movs  r3, #0
    str  r3, [r2], #4

LoopFillZerobss:
    ldr  r3, = __bss_end__
    cmp  r2, r3
    bcc  FillZerobss
    /* Call the application's entry point.*/
    bl  main
    bx  lr
    .size _start, .-_start

/***************************************************************************//**
 * @}
*******************************************************************************/