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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [libgloss/] [sparc/] [crt0.S] - Blame information for rev 39

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

Line No. Rev Author Line
1 39 lampret
/*
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
SYM(environ):                   ! this is the first address in the data section
21
        .long   0
22
 
23
        .text
24
        .align 8
25
 
26
SYM(win_ovf_trap):
27
        sethi %hi(win_ovf), %l3
28
        jmpl %lo(win_ovf)+%l3, %g0
29
        mov %wim, %l0
30
        nop
31
 
32
SYM(win_unf_trap):
33
        sethi %hi(win_unf), %l3
34
        jmpl %lo(win_unf)+%l3, %g0
35
        mov %wim, %l0
36
        nop
37
 
38
SYM(no_fpu_trap):                       ! Come here when no fpu exists.
39
        jmpl %l2, %g0                   ! This just skips the
40
        rett %l2+4                      ! offending instruction.
41
 
42
        .globl SYM(_start)
43
SYM(_start):
44
        .globl SYM(start)
45
SYM(start):
46
        /* see if the stack is already setup. if not, then default
47
         *  to using the value of %sp as set by the ROM monitor
48
         */
49
        sethi   %hi(__stack), %g1
50
        or      %g1,%lo(__stack),%g1
51
        cmp     %g0,%g1
52
        be      1f
53
        mov     %g1, %sp                                ! set the stack pointer
54
        mov     %sp, %fp
55
1:
56
 
57
        /* zero the bss section */
58
        sethi %hi(__bss_start),%g2
59
        or    %g2,%lo(__bss_start),%g2          ! start of bss
60
        sethi %hi(_end),%g3
61
        or    %g3,%lo(_end),%g3                 ! end of bss
62
        mov   %g0,%g1                           ! so std has two zeros
63
zerobss:
64
        std    %g0,[%g2]
65
        add    %g2,8,%g2
66
        cmp    %g2,%g3
67
        bleu,a zerobss
68
        nop
69
 
70
/*
71
 * copy prom & trap vectors to sram.
72
 */
73
        set 0x30000000, %l0
74
        set 0xfff8, %l1
75
        tst %l1                                 ! Set condition codes
76
 
77
copyloop:
78
        ldd [%l1], %l2
79
        std %l2, [%l0 + %l1]
80
        bg copyloop
81
        deccc 8, %l1
82
 
83
        set 0x30000000, %l0                     ! Base of new trap vector
84
        mov %l0, %tbr                           ! Install the new tbr
85
 
86
        set SYM(win_ovf_trap), %l1              ! Setup window overflow trap
87
        ldd [%l1], %l2
88
        std %l2, [%l0 + 5 * 16]
89
        ldd [%l1 + 8], %l2
90
        std %l2, [%l0 + 5 * 16 + 8]
91
 
92
        set SYM(win_unf_trap), %l1              ! Setup window underflow trap
93
        ldd [%l1], %l2
94
        std %l2, [%l0 + 6 * 16]
95
        ldd [%l1 + 8], %l2
96
        std %l2, [%l0 + 6 * 16 + 8]
97
 
98
/*
99
 * Try enabling the FPU by setting EF.  If that causes a trap, then we probably
100
 * don't have an FPU.
101
 */
102
 
103
        ldd [%l0 + 2 * 16], %l4                 ! Save original trap routine
104
        set SYM(no_fpu_trap), %l1               ! Install new one
105
        ldd [%l1], %l2
106
        std %l2, [%l0 + 2 * 16]
107
 
108
        mov %psr, %l0
109
        sethi %hi(0x1000), %l1
110
        bset %l1, %l0
111
!       mov %l0, %psr
112
 
113
        std %l4, [2 * 16]                       ! Restore original trap routine
114
 
115
/*
116
 * Move the data segment from it's ROM address to RAM where it
117
 * belongs.
118
 */
119
relocd:
120
        set (_sdata),%g2                                ! %g2 = start of data in aout file
121
        set SYM(environ),%g4                    ! %g4 = actual data base address
122
        set (_edata),%g3                                ! %g3 = end of where data should go
123
        subcc   %g3, %g4, %g5                   ! %g5 = length of data
124
 
125
        subcc   %g4, %g2, %g0                   ! need to relocate data ?
126
        ble     init
127
        ld      [%g4], %g6
128
        subcc   %g6, 1, %g0
129
        be      init
130
mvdata:
131
        subcc   %g5, 8, %g5
132
        ldd     [%g2 + %g5], %g6
133
        bg      mvdata
134
 
135
/*
136
 * initialize target specific stuff. Only execute these
137
 * functions it they exist.
138
 */
139
init:
140
        sethi   %hi(SYM(hardware_init_hook)), %g1
141
        or      %g1,%lo(SYM(hardware_init_hook)),%g1
142
        cmp     %g0,%g1
143
        be      1f
144
        nop
145
        call    SYM(hardware_init_hook)
146
        nop
147
 
148
1:
149
        sethi   %hi(SYM(software_init_hook)), %g1
150
        or      %g1,%lo(SYM(software_init_hook)),%g1
151
        cmp     %g0,%g1
152
        be      2f
153
        nop
154
        call    SYM(software_init_hook)
155
        nop
156
2:
157
        call SYM(main)
158
        nop
159
 
160
        /* call exit from the C library so atexit gets called, and the
161
         * C++ destructors get run. This calls our exit routine below
162
         * when it's done.
163
         */
164
        call    SYM(exit)
165
        nop
166
 
167
/*
168
 * This should drop control back to the ROM monitor, if there is
169
 * one.
170
 */
171
        .globl  SYM(_exit)
172
SYM(_exit):
173
        call    0
174
        nop

powered by: WebSVN 2.1.0

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