OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [libgloss/] [sparc/] [crt0.S] - Blame information for rev 252

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

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * C startup code for the Fujitsu SPARClite demo board
3
 *
4
 * Copyright (c) 1995, 1996 Cygnus Support
5
 *
6
 * The authors hereby grant permission to use, copy, modify, distribute,
7
 * and license this software and its documentation for any purpose, provided
8
 * that existing copyright notices are retained in all copies and that this
9
 * notice is included verbatim in any distributions. No written agreement,
10
 * license, or royalty fee is required for any of the authorized uses.
11
 * Modifications to this software may be copyrighted by their authors
12
 * and need not follow the licensing terms described here, provided that
13
 * the new terms are clearly indicated on the first page of each file where
14
 * they apply.
15
 */
16
#include "asm.h"
17
 
18
.data
19
        .align  8
20
        .ascii  "DaTa"          ! this is the first address in the data section
21
        .long   SYM(sdata)
22
SYM(environ):
23
        .long   0
24
 
25
        .text
26
        .align 8
27
 
28
        .globl SYM(_start)
29
SYM(_start):
30
        .globl SYM(start)
31
SYM(start):
32
        /* see if the stack is already setup. if not, then default
33
         *  to using the value of %sp as set by the ROM monitor
34
         */
35
        sethi   %hi(__stack), %g1
36
        or      %g1,%lo(__stack),%g1
37
        cmp     %g0,%g1
38
        be      1f
39
        mov     %g1, %sp                                ! set the stack pointer
40
        mov     %sp, %fp
41
1:
42
 
43
        /* zero the bss section */
44
        sethi %hi(__bss_start),%g2
45
        or    %g2,%lo(__bss_start),%g2          ! start of bss
46
        sethi %hi(_end),%g3
47
        or    %g3,%lo(_end),%g3                 ! end of bss
48
        mov   %g0,%g1                           ! so std has two zeros
49
zerobss:
50
        std    %g0,[%g2]
51
        add    %g2,8,%g2
52
        cmp    %g2,%g3
53
        bleu,a zerobss
54
        nop
55
 
56
/*
57
 * copy prom & trap vectors to sram.
58
 */
59
        set 0x30000000, %l0
60
        set 0xfff8, %l1
61
        tst %l1                                 ! Set condition codes
62
 
63
copyloop:
64
        ldd [%l1], %l2
65
        std %l2, [%l0 + %l1]
66
        bg copyloop
67
        deccc 8, %l1
68
 
69
        set 0x30000000, %l0                     ! Base of new trap vector
70
        mov %l0, %tbr                           ! Install the new tbr
71
 
72
        set SYM(win_ovf_trap), %l1              ! Setup window overflow trap
73
        ldd [%l1], %l2
74
        std %l2, [%l0 + 5 * 16]
75
        ldd [%l1 + 8], %l2
76
        std %l2, [%l0 + 5 * 16 + 8]
77
 
78
        set SYM(win_unf_trap), %l1              ! Setup window underflow trap
79
        ldd [%l1], %l2
80
        std %l2, [%l0 + 6 * 16]
81
        ldd [%l1 + 8], %l2
82
        std %l2, [%l0 + 6 * 16 + 8]
83
 
84
/*
85
 * Try enabling the FPU by setting EF.  If that causes a trap, then we probably
86
 * don't have an FPU.
87
 */
88
 
89
        ldd [%l0 + 2 * 16], %l4                 ! Save original trap routine
90
        set SYM(no_fpu_trap), %l1               ! Install new one
91
        ldd [%l1], %l2
92
        std %l2, [%l0 + 2 * 16]
93
 
94
        mov %psr, %l0
95
        sethi %hi(0x1000), %l1
96
        bset %l1, %l0
97
!       mov %l0, %psr
98
 
99
        std %l4, [2 * 16]                       ! Restore original trap routine
100
 
101
 
102
/*
103
 * Move the data segment from it's ROM address to RAM where it
104
 * belongs.
105
 */
106
 
107
relocd:
108
#if 0   /* This code is broken.  FIXME */
109
        set (_sdata),%g2                        ! %g2 = start of data in aout file
110
        set SYM(environ),%g4                    ! %g4 = actual data base address
111
        set (_edata),%g3                        ! %g3 = end of where data should go
112
        subcc   %g3, %g4, %g5                   ! %g5 = length of data
113
 
114
        subcc   %g4, %g2, %g0                   ! need to relocate data ?
115
        ble     init
116
        ld      [%g4], %g6
117
        subcc   %g6, 1, %g0
118
        be      init
119
mvdata:
120
        subcc   %g5, 8, %g5
121
        ldd     [%g2 + %g5], %g6
122
        bg      mvdata
123
#endif
124
 
125
/*
126
 * initialize target specific stuff. Only execute these
127
 * functions it they exist.
128
 */
129
init:
130
        sethi   %hi(SYM(hardware_init_hook)), %g1
131
        or      %g1,%lo(SYM(hardware_init_hook)),%g1
132
        cmp     %g0,%g1
133
        be      1f
134
        nop
135
        call    SYM(hardware_init_hook)
136
        nop
137
 
138
1:
139
        sethi   %hi(SYM(software_init_hook)), %g1
140
        or      %g1,%lo(SYM(software_init_hook)),%g1
141
        cmp     %g0,%g1
142
        be      2f
143
        nop
144
        call    SYM(software_init_hook)
145
        nop
146
2:
147
        call SYM(main)
148
        nop
149
 
150
        /* call exit from the C library so atexit gets called, and the
151
         * C++ destructors get run. This calls our exit routine below
152
         * when it's done.
153
         */
154
        call    SYM(exit)
155
        nop
156
 
157
/*
158
 * This should drop control back to the ROM monitor, if there is
159
 * one.
160
 */
161
        .globl  SYM(_exit)
162
SYM(_exit):
163
        call    0
164
        nop
165
 
166
/*
167
 * Trap handlers.
168
 */
169
 
170
        .align 8
171
 
172
SYM(win_ovf_trap):
173
        sethi %hi(SYM(win_ovf)), %l3
174
        jmpl %lo(SYM(win_ovf))+%l3, %g0
175
        mov %wim, %l0
176
        nop
177
 
178
SYM(win_unf_trap):
179
        sethi %hi(SYM(win_unf)), %l3
180
        jmpl %lo(SYM(win_unf))+%l3, %g0
181
        mov %wim, %l0
182
        nop
183
 
184
SYM(no_fpu_trap):                       ! Come here when no fpu exists.
185
        jmpl %l2, %g0                   ! This just skips the
186
        rett %l2+4                      ! offending instruction.

powered by: WebSVN 2.1.0

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