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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [c/] [src/] [lib/] [libbsp/] [arm/] [armulator/] [start/] [start.S] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
#include "../startup/swi.h"
2
 
3
/* ANSI concatenation macros.  */
4
#define CONCAT(a, b) CONCAT2(a, b)
5
#define CONCAT2(a, b) a ## b
6
 
7
#ifdef __USER_LABEL_PREFIX__
8
#define FUNCTION( name ) CONCAT (__USER_LABEL_PREFIX__, name)
9
#else
10
#error __USER_LABEL_PREFIX is not defined
11
#endif
12
 
13
/* .text is used instead of .section .text so it works with arm-aout too.  */
14
        .text
15
        .code 32
16
        .align  0
17
 
18
        .global _mainCRTStartup
19
        .global _start
20
        .global start
21
start:
22
_start:
23
_mainCRTStartup:
24
 
25
/* Start by setting up a stack */
26
#ifdef ARM_RDP_MONITOR
27
        /*  Issue Demon SWI to read stack info */
28
        swi     SWI_GetEnv      /*  Returns command line in r0 */
29
        mov     sp,r1           /*  and the highest memory address in r1 */
30
        ldr     sl, .LC2        /*  stack limit is at end of data */
31
        add     sl, sl, #256    /*  allow slop for stack overflow handling */
32
                                /*  and small frames */
33
#else
34
#ifdef ARM_RDI_MONITOR
35
        /*  Issue Angel SWI to read stack info */
36
        mov     r0, #AngelSWI_Reason_HeapInfo
37
        adr     r1, .LC0        /*  point at ptr to 4 words to receive data */
38
        swi     AngelSWI_ARM    /*  We are always in ARM mode for startup */
39
        ldr     r0, .LC0        /*  point at values read */
40
        ldr     sp, [r0, #8]
41
        ldr     sl, [r0, #12]
42
        add     sl, sl, #256    /*  allow slop for stack overflow handling */
43
                                /*  and small frames */
44
#else
45
        /*  Set up the stack pointer to a fixed value */
46
        ldr     r3, .LC0
47
        mov     sp, r3
48
        /* Setup a default stack-limit in-case the code has been
49
           compiled with "-mapcs-stack-check".  Hard-wiring this value
50
           is not ideal, since there is currently no support for
51
           checking that the heap and stack have not collided, or that
52
           this default 64k is enough for the program being executed.
53
           However, it ensures that this simple crt0 world will not
54
           immediately cause an overflow event:  */
55
        sub     sl, sp, #64 << 10       /* Still assumes 256bytes below sl */
56
#endif
57
#endif
58
        mov     a2, #0                  /* Second arg: fill value */
59
        mov     fp, a2                  /* Null frame pointer */
60
        mov     r7, a2                  /* Null frame pointer for Thumb */
61
 
62
        ldr     a1, .LC1                /* First arg: start of memory block */
63
        ldr     a3, .LC2
64
        sub     a3, a3, a1              /* Third arg: length of block */
65
 
66
 
67
#ifdef __thumb__                /* Enter Thumb mode.... */
68
 
69
        add     a4, pc, #1      /* Get the address of the Thumb block */
70
        bx      a4              /* Go there and start Thumb decoding  */
71
 
72
        .code 16
73
        .global __change_mode
74
        .thumb_func
75
__change_mode:
76
#endif
77
 
78
        bl      FUNCTION (memset)
79
#if !defined (ARM_RDP_MONITOR) && !defined (ARM_RDI_MONITOR)
80
        mov     r0, #0          /*  no arguments  */
81
        mov     r1, #0          /*  no argv either */
82
#else
83
        /* Need to set up standard file handles */
84
        bl      FUNCTION (initialize_monitor_handles)
85
 
86
/* XXX for now let's just get the code up :) */
87
#if 0
88
#ifdef ARM_RDP_MONITOR
89
        swi     SWI_GetEnv      /*  sets r0 to point to the command line */
90
        mov     r1, r0
91
#else
92
        mov     r0, #AngelSWI_Reason_GetCmdLine
93
        adr     r1, .LC30       /*  Space for command line */
94
        swi     AngelSWI
95
        ldr     r1, .LC30
96
#endif
97
        /*  Parse string at r1 */
98
        mov     r0, #0          /*  count of arguments so far */
99
.LC10:
100
/*  Skip leading blanks */
101
#ifdef __thumb__
102
        ldrb    r3, [r1]
103
        add     r1, #1
104
#else
105
        ldrb    r3, [r1], #1
106
#endif
107
        cmp     r3, #0
108
        beq     .LC12
109
        cmp     r3, #' '
110
        beq     .LC10
111
 
112
/*  See whether we are scanning a string */
113
        cmp     r3, #'"'
114
#ifdef __thumb__
115
        beq     .LC20
116
        cmp     r3, #'\''
117
        bne     .LC21
118
.LC20:
119
        mov     r2, r3
120
        b       .LC22
121
 
122
.LC21:
123
        mov     r2, #' '        /*  terminator type */
124
        sub     r1, r1, #1      /*  adjust back to point at start char */
125
.LC22:
126
#else
127
        cmpne   r3, #'\''
128
        moveq   r2, r3
129
        movne   r2, #' '        /*  terminator type */
130
        subne   r1, r1, #1      /*  adjust back to point at start char */
131
#endif
132
 
133
/*  Stack a pointer to the current argument */
134
#ifdef __thumb__
135
        push    {r1}
136
#else
137
        stmfd   sp!, {r1}
138
#endif
139
        add     r0, r0, #1
140
.LC11:
141
#ifdef __thumb__
142
        ldrb    r3, [r1]
143
        add     r1, #1
144
#else
145
        ldrb    r3, [r1], #1
146
#endif
147
        cmp     r3, #0
148
        beq     .LC12
149
        cmp     r2, r3          /*  reached terminator? */
150
        bne     .LC11
151
        mov     r2, #0
152
        sub     r3, r1, #1
153
        strb    r2, [r3]        /*  terminate the arg string */
154
        b       .LC10
155
 
156
.LC12:
157
        mov     r1, sp          /*  point at stacked arg pointers */
158
        /* We've now got the stacked args in order reverse the */
159
#ifdef __thumb__
160
        mov     r2, r0
161
        lsl     r2, #2
162
        add     r2, sp
163
        mov     r3, sp
164
.LC15:  cmp     r2, r3
165
        bls     .LC14
166
        sub     r2, #4
167
        ldr     r4, [r2]
168
        ldr     r5, [r3]
169
        str     r5, [r2]
170
        str     r4, [r3]
171
        add     r3, #4
172
        b       .LC15
173
.LC14:
174
#else
175
        add     r2, sp, r0, LSL #2      /* End of args */
176
        mov     r3, sp                  /* Start of args */
177
.LC13:  cmp     r2, r3
178
        ldrhi   r4,[r2, #-4]            /* Reverse ends of list */
179
        ldrhi   r5, [r3]
180
        strhi   r5, [r2, #-4]!
181
        strhi   r4, [r3], #4
182
        bhi     .LC13
183
#endif
184
 
185
#endif
186
#endif
187
        bl      FUNCTION (boot_card)
188
 
189
        bl      FUNCTION (exit)         /* Should not return */
190
 
191
#ifdef __thumb__
192
        /* Come out of Thumb mode... This code should be redundant...   */
193
 
194
        mov     a4, pc
195
        bx      a4
196
 
197
        .code 32
198
        .global change_back
199
change_back:
200
        /* Halt the execution.  This code should never be executed.  */
201
        /*
202
        ** With no debug monitor, this probably aborts (eventually).
203
        ** With a Demon debug monitor, this halts cleanly.
204
        ** With an Angel debug monitor, this will report 'Unknown SWI'.
205
        */
206
        swi     SWI_Exit
207
#endif
208
 
209
        /* For Thumb, constants must be after the code since only
210
        positive offsets are supported for PC relative addresses. */
211
 
212
        .align 0
213
.LC0:
214
#ifdef ARM_RDI_MONITOR
215
        .word   HeapBase
216
#else
217
#ifndef ARM_RDP_MONITOR
218
#ifdef __pe__
219
        .word   0x800000
220
#else
221
/*      .word   0x80000 */              /* Top of RAM on the PIE board */
222
#endif
223
#endif
224
#endif
225
.LC1:
226
        .word   _clear_start
227
.LC2:
228
        .word   _clear_end
229
 
230
#ifdef ARM_RDI_MONITOR
231
.LC30:  .word   CommandLine
232
 
233
/*  Workspace for Angel calls. */
234
        .data
235
/*  Data returned by monitor SWI */
236
HeapBase:       .word   0
237
HeapLimit:      .word   0
238
StackBase:      .word   0
239
StackLimit:     .word   0
240
CommandLine:    .space  256,0   /*  Maximum length of 255 chars handled */
241
#endif
242
        .globl SWI_Handler
243
SWI_Handler:
244
        B       SWI_Handler
245
 
246
#ifdef __pe__
247
        .section .idata$3
248
        .long   0,0,0,0,0,0,0,0
249
#endif
250
 

powered by: WebSVN 2.1.0

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