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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [libgloss/] [mn10300/] [crt0_cygmon.S] - Blame information for rev 258

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

Line No. Rev Author Line
1 207 jeremybenn
/*
2
 * crt0_cygmon.S -- Minimal startup file for MN10300 targets running Cygmon.
3
 *
4
 * Copyright (c) 1995, 1996, 1997, 2000 Red Hat, Inc.
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
/*
18
 * This file contains the minimal startup code necessary.
19
 * This will not do any hardware initialization.  It is assumed that we are talking to Cygmon
20
 * and therefore the hardware will be initialized properly.
21
 */
22
 
23
/*
24
 * Set up some room for a stack. We just grab a chunk of memory.
25
 */
26
#define STACK_SIZE  0x4000
27
#define GLOBAL_SIZE 0x2000
28
 
29
#define STARTUP_STACK_SIZE      0x0100
30
 
31
        .comm   __memsize, 12
32
        .comm   __lstack, STARTUP_STACK_SIZE
33
        .comm   __stackbase,4
34
 
35
        .section .text
36
        .global _start
37
_start:
38
        /*
39
         * Setup a small stack so we can run some C code,
40
         * and get the usable memory size.
41
         */
42
        mov     __lstack,a0
43
        add     STARTUP_STACK_SIZE-4,a0
44
        mov     a0,sp
45
 
46
        /*
47
         * zero out the bss section.
48
         */
49
        .global __memsize
50
        .global _get_mem_info
51
zerobss:
52
        mov     __bss_start, a0                         # These variables are defined in the linker script
53
        mov     _end, a1
54
 
55
        cmp     a0, a1                                  # If no bss, then do nothing
56
        beq     7f
57
 
58
        clr     d0
59
3:
60
        movbu   d0,(a0)                                 # Clear a byte and bump pointer
61
        inc     a0
62
        cmp     a0, a1
63
        bne     3b
64
 
65
7:
66
        /*
67
         * Setup the stack pointer --
68
         *    get_mem_info returns the top of memory, so just use that In
69
         *    addition, we must subtract 24 bytes for the 3 8 byte
70
         *    arguments to main, in case main wants to write them back to
71
         *    the stack.  The caller is supposed to allocate stack space
72
         *    for parameters in registers in the old MIPS ABIs.  We must
73
         *    do this even though we aren't passing arguments, because
74
         *    main might be declared to have them.
75
         *    Some ports need a larger alignment for the stack, so we
76
         *    subtract 32, which satisifes the stack for the arguments and
77
         *    keeps the stack pointer better aligned.
78
         */
79
        mov     __memsize, d0
80
        call    _get_mem_info,[],0
81
 
82
        sub     32, a0
83
        mov     a0, sp
84
 
85
        mov     __stackbase, a1
86
        mov     a0, (a1)                                # keep this for future ref
87
 
88
        call    ___main,[],0                            # Call __main to run ctors/dtors
89
        clr     d0
90
        clr     d1
91
        mov     d0, (4,sp)
92
        call    _main,[],0                              # Call main program
93
        call    _exit,[],0
94
 
95
/* EOF crt0_cygmon.S */

powered by: WebSVN 2.1.0

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