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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [libgloss/] [sparc/] [cygmon-crt0.S] - Blame information for rev 829

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
#ifdef TARGET_CPU_SPARC64
19
#define STACK_BIAS 2047
20
#define SAVE_SIZE -128
21
#else
22
#define SAVE_SIZE -64
23
#endif
24
 
25
.data
26
        .align  8
27
SYM(environ):                   ! this is the first address in the data section
28
        .long   0
29
 
30
SYM(argc):
31
        .long   0
32
 
33
        .text
34
        .align 8
35
 
36
        .globl SYM(start)
37
        .globl start
38
SYM(start):
39
start:
40
        /* see if the stack is already setup. if not, then default
41
         *  to using the value of %sp as set by the ROM monitor
42
         */
43
        sethi   %hi(__stack), %g1
44
        or      %g1,%lo(__stack),%g1
45
        cmp     %g0,%g1
46
        be      1f
47
        nop
48
#ifdef STACK_BIAS
49
        sub     %g1, STACK_BIAS, %g1
50
#endif
51
        mov     %g1, %sp                                ! set the stack pointer
52
        mov     0, %fp
53
1:
54
 
55
        /* zero the bss section */
56
        sethi %hi(__bss_start),%g2
57
        or    %g2,%lo(__bss_start),%g2          ! start of bss
58
        sethi %hi(_end),%g3
59
        or    %g3,%lo(_end),%g3                 ! end of bss
60
        mov   %g0,%g1                           ! so std has two zeros
61
zerobss:
62
        std    %g0,[%g2]
63
        add    %g2,8,%g2
64
        cmp    %g2,%g3
65
        bleu,a zerobss
66
        nop
67
 
68
/*
69
 * initialize target specific stuff. Only execute these
70
 * functions it they exist.
71
 */
72
init:
73
        sethi   %hi(SYM(hardware_init_hook)), %g1
74
        or      %g1,%lo(SYM(hardware_init_hook)),%g1
75
        cmp     %g0,%g1
76
        be      1f
77
        nop
78
        call    SYM(hardware_init_hook)
79
        nop
80
 
81
1:
82
        sethi   %hi(SYM(software_init_hook)), %g1
83
        or      %g1,%lo(SYM(software_init_hook)),%g1
84
        cmp     %g0,%g1
85
        be      2f
86
        nop
87
        call    SYM(software_init_hook)
88
        nop
89
2:
90
        set     SYM(__sigtramp), %o0
91
        call    SYM(__install_signal_handler)
92
        nop
93
 
94
        set     do_dtors,%o0
95
        call    SYM(atexit)
96
        nop
97
 
98
        call    do_ctors
99
        nop
100
 
101
        set     SYM(argc), %o0
102
        call    SYM(__getProgramArgs)
103
        nop
104
 
105
        mov     %o0, %o1
106
        set     SYM(argc), %o0
107
        ld      [%o0], %o0
108
        call SYM(main)
109
        nop
110
 
111
        /* call exit from the C library so atexit gets called, and the
112
         * C++ destructors get run. This calls our exit routine below
113
         * when it's done.
114
         */
115
        call    SYM(exit)
116
        nop
117
 
118
do_ctors:
119
        save    %sp,SAVE_SIZE,%sp
120
        set     __CTOR_LIST__,%l0
121
our_entry:
122
        ld      [%l0],%l1
123
        add     %l0,4,%l0
124
        tst     %l1
125
1:
126
        beq     2f
127
        nop
128
        ld      [%l0],%l2
129
        add     %l0,4,%l0
130
 
131
        call    %l2
132
        nop
133
        deccc   %l1
134
        b       1b
135
        nop
136
2:
137
        ret
138
        restore
139
 
140
do_dtors:
141
        save    %sp,SAVE_SIZE,%sp
142
        set     __DTOR_LIST__,%l0
143
        b       our_entry
144
        nop

powered by: WebSVN 2.1.0

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