source: rtems/c/src/lib/libbsp/mips/csb350/start/start.S @ c499856

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 * start.S -- startup file for Cogent CSB350 Au1100 based board
3 *
4 *  Copyright (c) 2005 by Cogent Computer Systems
5 *  Written by Jay Monkman <jtm@lopingdog.com>
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.org/license/LICENSE.
10 *
11 */
12
13#include <rtems/asm.h>
14#include <bsp/regs.h>
15
16        .text
17        .align  2
18
19/* Without the following nop, GDB thinks _start is a data variable.
20 * This is probably a bug in GDB in handling a symbol that is at the
21 * start of the .text section.
22 */
23        nop
24
25        .globl  _start
26        .ent    _start
27_start:
28        .set    noreorder
29
30        /* Get the address of start into $5 in a position independent
31         * fashion. This lets us know whether we have been relocated or not.
32         */
33        $LF1 = . + 8
34        bal     $LF1
35        nop
36_branch:
37        move    $5, $31                 /* $5 == where are we */
38        li      $6, 0x8800000c          /* $6 == where we want to be */
39
40        li      v0, SR_CU1|SR_PE|SR_FR|SR_KX|SR_SX|SR_UX
41        mtc0    v0, C0_SR
42        mtc0    zero, C0_CAUSE
43
441:
45        li      v0, SR_PE|SR_FR|SR_KX|SR_SX|SR_UX
46        mtc0    v0, C0_SR
472:
48/* Fix high bits, if any, of the PC so that exception handling
49   doesn't get confused.  */
50        la v0, 3f
51        jr      v0
52        nop
533:
54        la gp, _gp                      /* set the global data pointer */
55        .end _start
56
57/*
58 * zero out the bss section.
59 */
60        .globl  __memsize
61        .globl  zerobss
62        .ent    zerobss
63zerobss:
64        la v0, _fbss
65        la v1, _end
663:
67        sw      zero,0(v0)
68        bltu    v0,v1,3b
69        addiu   v0,v0,4                 /* executed in delay slot */
70
71        la      t0, _stack_init         /* initialize stack so we */
72        /* We must subtract 24 bytes for the 3 8 byte arguments to main, in
73           case main wants to write them back to the stack.  The caller is
74           supposed to allocate stack space for parameters in registers in
75           the old MIPS ABIs.  We must do this even though we aren't passing
76           arguments, because main might be declared to have them.
77
78           Some ports need a larger alignment for the stack, so we subtract
79           32, which satisifes the stack for the arguments and keeps the
80           stack pointer better aligned.  */
81        subu    t0,t0,32
82        move    sp,t0                   /* set stack pointer */
83        .end    zerobss
84
85        .globl  exit .text
86        .globl  init
87        .ent    init
88init:
89
90        move    a0,zero                 /* set command line to 0 */
91        jal     boot_card               /* call the program start function */
92        nop
93
94        /* fall through to the "exit" routine */
95        jal     _sys_exit               /* call libc exit to run the G++ */
96                                        /* destructors */
97        move    a0,v0                   /* pass through the exit code */
98        .end    init
99
100/*
101 * _sys_exit -- Exit from the application. Normally we cause a user trap
102 *          to return to the ROM monitor for another run. NOTE: This is
103 *          the only other routine we provide in the crt0.o object, since
104 *          it may be tied to the "_start" routine. It also allows
105 *          executables that contain a complete world to be linked with
106 *          just the crt0.o object.
107 */
108        .globl  _sys_exit
109        .ent _sys_exit
110_sys_exit:
1117:
112#ifdef GCRT0
113        jal     _mcleanup
114        nop
115#endif
116        /* break inst. can cope with 0xfffff, but GAS limits the range: */
117        break   1023
118        nop
119        b       7b                      /* but loop back just in-case */
120        nop
121        .end _sys_exit
122
123/* EOF crt0.S */
Note: See TracBrowser for help on using the repository browser.