2 * crt0_redboot.S -- Minimal startup file for MN10300 targets running Redboot.
4 * Copyright (c) 2001 Red Hat, Inc.
5 * Derived from crt0_cygmon.S - Copyright (c) 1995, 1996, 1997, 2000 Red Hat, Inc.
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
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.
25 * Set up some room for a stack. We just grab a chunk of memory.
27 #define STACK_SIZE 0x4000
28 #define GLOBAL_SIZE 0x2000
30 #define STARTUP_STACK_SIZE 0x0100
33 .comm __lstack, STARTUP_STACK_SIZE
40 * Setup a small stack so we can run some C code,
41 * and get the usable memory size.
44 add STARTUP_STACK_SIZE-4,a0
48 * zero out the bss section.
53 mov __bss_start, a0 # These variables are defined in the linker script
56 cmp a0, a1 # If no bss, then do nothing
61 movbu d0,(a0) # Clear a byte and bump pointer
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.
81 call _get_mem_info,[],0
87 mov a0, (a1) # keep this for future ref
89 call ___main,[],0 # Call __main to run ctors/dtors
93 or 0x0800,psw # Enable interrupts
94 call _main,[],0 # Call main program
97 /* EOF crt0_redboot.S */