source: trunk/libs/newlib/src/libgloss/mn10300/crt0_redboot.S @ 612

Last change on this file since 612 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 2.7 KB
Line 
1/*
2 * crt0_redboot.S -- Minimal startup file for MN10300 targets running Redboot.
3 *
4 * Copyright (c) 2001 Red Hat, Inc.
5 * Derived from crt0_cygmon.S - Copyright (c) 1995, 1996, 1997, 2000 Red Hat, Inc.
6 *
7 * The authors hereby grant permission to use, copy, modify, distribute,
8 * and license this software and its documentation for any purpose, provided
9 * that existing copyright notices are retained in all copies and that this
10 * notice is included verbatim in any distributions. No written agreement,
11 * license, or royalty fee is required for any of the authorized uses.
12 * Modifications to this software may be copyrighted by their authors
13 * and need not follow the licensing terms described here, provided that
14 * the new terms are clearly indicated on the first page of each file where
15 * they apply.
16 */
17
18/*
19 * This file contains the minimal startup code necessary.
20 * This will not do any hardware initialization.  It is assumed that we are talking to Redboot
21 * and therefore the hardware will be initialized properly.
22 */
23
24/*
25 * Set up some room for a stack. We just grab a chunk of memory.
26 */
27#define STACK_SIZE  0x4000
28#define GLOBAL_SIZE 0x2000
29
30#define STARTUP_STACK_SIZE      0x0100
31
32        .comm   __memsize, 12
33        .comm   __lstack, STARTUP_STACK_SIZE
34        .comm   __stackbase,4
35
36        .section .text
37        .global _start
38_start:
39        /*
40         * Setup a small stack so we can run some C code,
41         * and get the usable memory size.
42         */
43        mov     __lstack,a0
44        add     STARTUP_STACK_SIZE-4,a0
45        mov     a0,sp
46
47        /*
48         * zero out the bss section.
49         */
50        .global __memsize
51        .global _get_mem_info
52zerobss:
53        mov     __bss_start, a0                         # These variables are defined in the linker script
54        mov     _end, a1
55
56        cmp     a0, a1                                  # If no bss, then do nothing
57        beq     7f
58
59        clr     d0
603:
61        movbu   d0,(a0)                                 # Clear a byte and bump pointer
62        inc     a0
63        cmp     a0, a1
64        bne     3b
65
667:
67        /*
68         * Setup the stack pointer --
69         *    get_mem_info returns the top of memory, so just use that In
70         *    addition, we must subtract 24 bytes for the 3 8 byte
71         *    arguments to main, in case main wants to write them back to
72         *    the stack.  The caller is supposed to allocate stack space
73         *    for parameters in registers in the old MIPS ABIs.  We must
74         *    do this even though we aren't passing arguments, because
75         *    main might be declared to have them.
76         *    Some ports need a larger alignment for the stack, so we
77         *    subtract 32, which satisifes the stack for the arguments and
78         *    keeps the stack pointer better aligned.
79         */
80        mov     __memsize, d0
81        call    _get_mem_info,[],0
82
83        sub     32, a0
84        mov     a0, sp
85
86        mov     __stackbase, a1
87        mov     a0, (a1)                                # keep this for future ref
88
89        call    ___main,[],0                            # Call __main to run ctors/dtors
90        clr     d0
91        clr     d1
92        mov     d0, (4,sp)
93        or      0x0800,psw                              # Enable interrupts
94        call    _main,[],0                              # Call main program
95        call    _exit,[],0
96       
97/* EOF crt0_redboot.S */
Note: See TracBrowser for help on using the repository browser.