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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [libgloss/] [m68k/] [crt0.S] - Blame information for rev 868

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

Line No. Rev Author Line
1 148 jeremybenn
/*
2
 * crt0.S -- startup file for m68k-coff
3
 *
4
 * Copyright (c) 1995, 1996, 1998 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
 
17
#include "asm.h"
18
 
19
        .title "crt0.S for m68k-coff"
20
#define STACKSIZE       0x4000
21
 
22
/*
23
 * Define an empty environment.
24
 */
25
        .data
26
        .align 2
27
SYM (environ):
28
        .long 0
29
 
30
        .align  2
31
        .text
32
 
33
/*
34
 * These symbols are defined in C code, so they need to always be
35
 * named with SYM because of the difference between object file formats.
36
 */
37
 
38
/* These are defined in C code. */
39
        .extern SYM (main)
40
        .extern SYM (exit)
41
        .extern SYM (hardware_init_hook)
42
        .extern SYM (software_init_hook)
43
        .extern SYM (atexit)
44
        .extern SYM(__do_global_dtors)
45
 
46
/*
47
 * These values are set in the linker script, so they must be
48
 * explicitly named here without SYM.
49
 */
50
        .extern __stack
51
        .extern __bss_start
52
        .extern _end
53
 
54
/*
55
 * Set things up so the application will run. For historical reasons
56
 * this is called 'start'.  We set things up to provide '_start'
57
 * as with other systems, but also provide a weak alias called
58
 * 'start' for compatibility with existing linker scripts.
59
 */
60
        .global SYM (start)
61
        .weak SYM (start)
62
        .set SYM (start),SYM(_start)
63
 
64
        .global SYM (_start)
65
SYM (_start):
66
        /*
67
         * put any hardware init code here
68
         */
69
 
70
        /* See if user supplied their own stack (__stack != 0).  If not, then
71
         * default to using the value of %sp as set by the ROM monitor.
72
         */
73
        movel   IMM(__stack), a0
74
        cmpl    IMM(0), a0
75
        jbeq    1f
76
        movel   a0, sp
77
1:
78
        /* set up initial stack frame */
79
        link    a6, IMM(-8)
80
 
81
/*
82
 * zero out the bss section.
83
 */
84
        movel   IMM(__bss_start), d1
85
        movel   IMM(_end), d0
86
        cmpl    d0, d1
87
        jbeq    3f
88
        movl    d1, a0
89
        subl    d1, d0
90
        subql   IMM(1), d0
91
2:
92
        clrb    (a0)+
93
#if !defined(__mcoldfire__)
94
        dbra    d0, 2b
95
        clrw    d0
96
        subql   IMM(1), d0
97
        jbcc    2b
98
#else
99
        subql   IMM(1), d0
100
        jbpl    2b
101
#endif
102
 
103
3:
104
 
105
/*
106
 * initialize target specific stuff. Only execute these
107
 * functions it they exist.
108
 */
109
        PICLEA  SYM (hardware_init_hook), a0
110
        cmpl    IMM(0),a0
111
        jbeq    4f
112
        jsr     (a0)
113
4:
114
 
115
        PICLEA  SYM (software_init_hook), a0
116
        cmpl    IMM(0),a0
117
        jbeq    5f
118
        jsr     (a0)
119
5:
120
 
121
/*
122
 * call the main routine from the application to get it going.
123
 * main (argc, argv, environ)
124
 * we pass argv as a pointer to NULL.
125
 */
126
 
127
#ifdef ADD_DTORS
128
        /* put __do_global_dtors in the atexit list so the destructors get run */
129
        movel   IMM (SYM(__do_global_dtors)),(sp)
130
        PICCALL SYM (atexit)
131
#endif
132
        movel   IMM (__FINI_SECTION__),(sp)
133
        PICCALL SYM (atexit)
134
 
135
        PICCALL __INIT_SECTION__
136
 
137
        pea     0
138
        PICPEA  SYM (environ),a0
139
        pea     sp@(4)
140
        pea     0
141
        PICCALL SYM (main)
142
        movel   d0, sp@-
143
 
144
/*
145
 * drop down into exit incase the user doesn't. This should drop
146
 * control back to the ROM monitor, if there is one. This calls the
147
 * exit() from the C library so the C++ tables get cleaned up right.
148
 */
149
        PICCALL SYM (exit)

powered by: WebSVN 2.1.0

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