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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [uC-libc/] [sysdeps/] [m68k/] [crt/] [crt0.S] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 199 simons
/*
2
 * Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel
3
 * and Hongjiu Lu.
4
 *
5
 * All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. The name of the above contributors may not be
13
 *    used to endorse or promote products derived from this software
14
 *    without specific prior written permission.
15
 *
16
 * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
17
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
20
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
 * SUCH DAMAGE.
27
 */
28
 
29
/* Notice of general intent:
30
 *
31
 * The linux operating system generally contains large amounts of code
32
 * that fall under the GNU General Public License, or GPL for short.
33
 * This file contains source code that by it's very nature would always
34
 * be linked with an application program, and because of this a GPL type
35
 * of copyright on this file would place restrictions upon the
36
 * distribution of binary-only commercial software.  Since the goal of the
37
 * Linux project as a whole is not to discourage the development and
38
 * distribution of commercial software for Linux, this file has been placed
39
 * under a more relaxed BSD-style of copyright.
40
 *
41
 * It is the general understanding of the above contributors that a
42
 * program executable linked to a library containing code that falls
43
 * under the GPL or GLPL style of license is not subject to the terms of
44
 * the GPL or GLPL license if the program executable(s) that are supplied
45
 * are linked to a shared library form of the GPL or GLPL library, and as long
46
 * as the form of the shared library is such that it is possible for
47
 * the end user to modify and rebuild the library and use it in
48
 * conjunction with the program executable.
49
 */
50
 
51
#ifdef __ELF__
52
#define _main main
53
#define _exit exit
54
#define ___libc_init __libc_init
55
#define _setlocale setlocale
56
#define ___setfpucw __setfpucw
57
#define ___fpu_control __fpu_control
58
#define ___environ __environ
59
#define ____brk_addr ___brk_addr
60
#define d0 %D0
61
#define d1 %D1
62
#define a0 %A0
63
#define sp %SP
64
#endif
65
 
66
        .file "crt0.S"
67
 
68
#if defined (__ELF__) && defined (CALL_DEFAULT_LOCALE)
69
        .section .rodata
70
        .align 4
71
        .type ___null_string,@object
72
        .size ___null_string,4
73
___null_string:
74
        .long .L_shared_dummy__
75
.L_shared_dummy__:
76
        .asciz ""
77
#endif
78
 
79
        .text
80
        .globl  ___crt_dummy__
81
___crt_dummy__:
82
#ifndef __ELF__
83
__entry:
84
/*
85
 * The first thing we do is try to load the shared library. If that
86
 * fails, it won't return.
87
 */
88
        jbsr ___load_shared_libraries
89
#else
90
/* ELF stuff here */
91
.globl _start
92
.type _start,@function
93
_start:
94
        /* First locate the start of the environment variables */
95
        movel sp@+,d0
96
        movel sp,a0
97
        pea sp@(4,d0:l:4)
98
        movel a0,sp@-
99
        movel d0,sp@-
100
/*
101
 * Make sure we are using the linux personality.
102
 */
103
        movel #136,d0
104
        clrl d1
105
        trap #0
106
#endif
107
 
108
#if 0
109
/*
110
 *      This is important, and was missing from the new version...
111
 */
112
        moveq #45,d0
113
        moveq #0,d1
114
        trap  #0
115
        movel d0,____brk_addr
116
#endif
117
/*
118
 *      ok, set up the  ___environ and call _main
119
 */
120
        movel sp@(8),___environ
121
        /* Avoid touching the fpu unless necessary.  */
122
        movel ___fpu_control,d0
123
        movel d0,d1
124
        andw #0xfff0,d1
125
        jeq 1f
126
        movel d0,sp@-
127
        jbsr  ___setfpucw
128
        addql #4,sp
129
1:
130
/* Some functions may be needed. */
131
        jbsr  ___libc_init
132
#ifdef CALL_DEFAULT_LOCALE
133
/* Set up the default locale */
134
        movel ___null_string,sp@-
135
        pea DEFAULT_LOCALE
136
        jbsr _setlocale
137
        addql #8,sp
138
#endif
139
#ifdef ELF_INIT_FINI
140
        pea _fini
141
        jbsr atexit
142
        addql #4,sp
143
        jbsr _init
144
#endif
145
        jbsr  _main
146
        movel d0,sp@-
147
        jbsr  _exit
148
/*
149
 *      Just in case _exit fails... We use trap #0 for __exit().
150
 */
151
        addql #4,sp
152
done:
153
        moveq #1,d0
154
        trap  #0
155
        bras  done
156
 
157
#ifdef __ELF__
158
        .align  4
159
        .size   _start,.-_start
160
#if 1
161
        .data
162
        .globl  __environ
163
        .type   __environ,@object
164
        .align  4
165
__environ:
166
        .long   0
167
        .size   __environ,4
168
        .weak   environ
169
        environ = __environ
170
#endif
171
#else
172
        .align  2
173
#ifdef CALL_DEFAULT_LOCALE
174
___null_string:
175
        .long ___shared_dummy__
176
#endif
177
___shared_dummy__:
178
        .asciz ""
179
        .stabs "___SHARED_LIBRARIES__",25,0,0,___shared_dummy__
180
 
181
        .data
182
        .align  2
183
___shared_dummy1__:
184
        .long 0xfeeb1ed3  /* Magic number used by DLL code to make sure this
185
                             is a real list */
186
 
187
        .stabs "__SHARABLE_CONFLICTS__",25,0,0,___shared_dummy1__
188
#endif

powered by: WebSVN 2.1.0

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