OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [libgloss/] [arm/] [redboot-crt0.S] - Blame information for rev 853

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
 
2
    .file   "crt0.S"
3
 
4
#define XGLUE(a,b) a##b
5
#define GLUE(a,b) XGLUE(a,b)
6
 
7
#ifdef __USER_LABEL_PREFIX__
8
#define SYM_NAME( name ) GLUE (__USER_LABEL_PREFIX__, name)
9
#else
10
#error __USER_LABEL_PREFIX is not defined
11
#endif
12
 
13
    .text
14
     /* Setup the assembly entry point.  */
15
#ifdef __thumb2__
16
.macro FUNC_START name
17
        .global \name
18
        .thumb_func
19
\name:
20
.endm
21
        .syntax unified
22
        .thumb
23
#else
24
.macro FUNC_START name
25
        .global \name
26
\name:
27
.endm
28
        .code 32
29
#endif
30
        FUNC_START SYM_NAME(start)
31
        FUNC_START SYM_NAME(_start)
32
        mov     fp, #0  /* Null frame pointer.  */
33
        mov     r7, #0  /* Null frame pointer for Thumb.  */
34
 
35
        /* Enable interrupts for gdb debugging.  */
36
#ifdef __thumb2__
37
        cpsie if
38
#else
39
        mrs    r0, cpsr
40
        bic    r0, r0, #0xC0
41
        msr    cpsr, r0
42
#endif
43
 
44
        mov     a2, #0                  /* Second arg: fill value.  */
45
        ldr     a1, .LC1                /* First arg: start of memory block.  */
46
        ldr     a3, .LC2
47
        sub     a3, a3, a1              /* Third arg: length of block.  */
48
 
49
#ifdef  GCRT0
50
        /* Zero out the bss without using memset.
51
           Using memset is bad because it may be instrumented for
52
           profiling, but at this point, the profiling data structures
53
           have not been set up.
54
           FIXME: This loop could be a lot more efficient.  */
55
        subs    a3, a3, #0
56
        beq     2f
57
1:      strb    a2, [a1]
58
        subs    a3, a3, #1
59
        add     a1, a1, #1
60
        bne     1b
61
2:
62
        /* Nothing to left to clear.  */
63
#endif
64
 
65
#if defined(__thumb__) && !defined(__thumb2__)  /* Enter Thumb mode. */
66
        add     a4, pc, #1      /* Get the address of the Thumb block.  */
67
        bx      a4              /* Go there and start Thumb decoding.   */
68
 
69
        .code 16
70
        .global __change_mode
71
        .thumb_func
72
__change_mode:
73
#endif
74
 
75
#ifndef GCRT0
76
        bl      SYM_NAME(memset)
77
#endif
78
        bl      SYM_NAME(__get_memtop)
79
        sub     r0, r0, #32
80
        mov     sp, r0
81
 
82
#ifdef __USES_INITFINI__
83
        /* Some arm/elf targets use the .init and .fini sections
84
           to create constructors and destructors, and for these
85
           targets we need to call the _init function and arrange
86
           for _fini to be called at program exit.  */
87
        ldr     r0, .Lfini
88
        bl      SYM_NAME (atexit)
89
        bl      SYM_NAME (_init)
90
#endif
91
 
92
        mov     a1, #0
93
        ldr     a2, .LC3
94
        mov     a3, a2
95
        bl      SYM_NAME(main)
96
    1:  bl      SYM_NAME(exit)
97
        b       1b
98
        .align  2
99
.LC1:
100
        .word   __bss_start__
101
.LC2:
102
        .word   __bss_end__
103
.LC3:
104
        .word   0
105
#ifdef __USES_INITFINI__
106
.Lfini:
107
        .word   SYM_NAME(_fini)
108
#endif
109
#if 0
110
#ifdef __thumb__
111
        .code 16
112
#endif
113
        .global SYM_NAME(__syscall)
114
#ifdef __thumb__
115
        .thumb_func
116
#else
117
        .align  4
118
#endif
119
SYM_NAME(__syscall):
120
        mov     r12, lr
121
#ifdef __thumb__
122
        swi     0x18
123
#else
124
        swi     0x180001
125
#endif
126
        mov     pc, r12
127
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.