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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [libgloss/] [mips/] [crt0.S] - Diff between revs 39 and 56

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 39 Rev 56
Line 27... Line 27...
#define STACK_SIZE  0x4000
#define STACK_SIZE  0x4000
#define GLOBAL_SIZE 0x2000
#define GLOBAL_SIZE 0x2000
 
 
#define STARTUP_STACK_SIZE      0x0100
#define STARTUP_STACK_SIZE      0x0100
 
 
 
/* This is for referencing addresses that are not in the .sdata or
 
   .sbss section under embedded-pic, or before we've set up gp.  */
 
#ifdef __mips_embedded_pic
 
# ifdef __mips64
 
#  define LA(t,x) la t,x-PICBASE ; daddu t,s0,t
 
# else
 
#  define LA(t,x) la t,x-PICBASE ; addu t,s0,t
 
# endif
 
#else /* __mips_embedded_pic */
 
# define LA(t,x) la t,x
 
#endif /* __mips_embedded_pic */
 
 
        .comm   __memsize, 12
        .comm   __memsize, 12
        .comm   __lstack, STARTUP_STACK_SIZE
        .comm   __lstack, STARTUP_STACK_SIZE
        .comm   __stackbase,4
        .comm   __stackbase,4
 
 
        .text
        .text
Line 44... Line 56...
 
 
        .globl  _start
        .globl  _start
        .ent    _start
        .ent    _start
_start:
_start:
        .set    noreorder
        .set    noreorder
 
#ifdef __mips_embedded_pic
 
        PICBASE = .+8
 
        bal     PICBASE
 
        nop
 
        move    s0,$31
 
#endif
 
 
        li      v0, SR_CU1|SR_PE|SR_FR|SR_KX|SR_SX|SR_UX
        li      v0, SR_CU1|SR_PE|SR_FR|SR_KX|SR_SX|SR_UX
        mtc0    v0, C0_SR
        mtc0    v0, C0_SR
        mtc0    zero, C0_CAUSE
        mtc0    zero, C0_CAUSE
 
 
/* Check for FPU presence */
/* Check for FPU presence */
Line 62... Line 81...
        nop
        nop
        bne     t0,t2,1f        /* check for match */
        bne     t0,t2,1f        /* check for match */
        nop
        nop
        bne     t1,zero,1f      /* double check */
        bne     t1,zero,1f      /* double check */
        nop
        nop
        j       2f              /* status register already correct  */
#ifndef __mips64  /* Clear the FR bit */
 
        li      v0, SR_CU1|SR_PE|SR_KX|SR_SX|SR_UX
 
        mtc0    v0, C0_SR
 
#endif
 
        j       2f
        nop
        nop
#endif
#endif
1:
1:
        li      v0, SR_PE|SR_FR|SR_KX|SR_SX|SR_UX
        li      v0, SR_PE|SR_FR|SR_KX|SR_SX|SR_UX
        mtc0    v0, C0_SR
        mtc0    v0, C0_SR
2:
2:
 
/* Fix high bits, if any, of the PC so that exception handling
 
   doesn't get confused.  */
 
        LA (v0, 3f)
 
        jr      v0
 
        nop
 
3:
 
        LA (gp, _gp)                            # set the global data pointer
        .end _start
        .end _start
 
 
/*
/*
 * zero out the bss section.
 * zero out the bss section.
 */
 */
Line 81... Line 111...
        .globl  __stack
        .globl  __stack
        .globl  __global
        .globl  __global
        .globl  zerobss
        .globl  zerobss
        .ent    zerobss
        .ent    zerobss
zerobss:
zerobss:
        la      v0, _fbss
        LA (v0, _fbss)
        la      v1, _end
        LA (v1, _end)
3:
3:
        sw      zero,0(v0)
        sw      zero,0(v0)
        bltu    v0,v1,3b
        bltu    v0,v1,3b
        addiu   v0,v0,4                         # executed in delay slot
        addiu   v0,v0,4                         # executed in delay slot
 
 
Line 95... Line 125...
        la      a0, __memsize                   # get the usable memory size
        la      a0, __memsize                   # get the usable memory size
        jal     get_mem_info
        jal     get_mem_info
        nop
        nop
 
 
        /* setup the stack pointer */
        /* setup the stack pointer */
        la      t0,__stack                      # is __stack set ?
        LA (t0, __stack)                        # is __stack set ?
        bne     t0,zero,4f
        bne     t0,zero,4f
        nop
        nop
 
 
        /* NOTE: a0[0] contains the amount of memory available, and
        /* NOTE: a0[0] contains the amount of memory available, and
                 not the last memory address. */
                 not the last memory address. */
Line 116... Line 146...
           32, which satisifes the stack for the arguments and keeps the
           32, which satisifes the stack for the arguments and keeps the
           stack pointer better aligned.  */
           stack pointer better aligned.  */
        subu    t0,t0,32                        # and generate a starting stack-pointer
        subu    t0,t0,32                        # and generate a starting stack-pointer
4:
4:
        move    sp,t0                           # set stack pointer
        move    sp,t0                           # set stack pointer
        la      gp,_gp                          # set the global data pointer
 
        sw      sp,__stackbase                  # keep this for future ref
        sw      sp,__stackbase                  # keep this for future ref
        .end    zerobss
        .end    zerobss
 
 
/*
/*
 * initialize target specific stuff. Only execute these
 * initialize target specific stuff. Only execute these
Line 132... Line 161...
        .globl  atexit .text
        .globl  atexit .text
        .globl  exit .text
        .globl  exit .text
        .globl  init
        .globl  init
        .ent    init
        .ent    init
init:
init:
        la      t9,hardware_init_hook           # init the hardware if needed
        LA (t9, hardware_init_hook)             # init the hardware if needed
        beq     t9,zero,6f
        beq     t9,zero,6f
        nop
        nop
        jal     t9
        jal     t9
        nop
        nop
6:
6:
        la      t9,software_init_hook           # init the software if needed
        LA (t9, software_init_hook)             # init the hardware if needed
        beq     t9,zero,7f
        beq     t9,zero,7f
        nop
        nop
        jal     t9
        jal     t9
        nop
        nop
7:
7:
        la      a0,__do_global_dtors
        LA (a0, __do_global_dtors)
        jal     atexit
        jal     atexit
        nop
        nop
 
 
#ifdef GCRT0
#ifdef GCRT0
        .globl  _ftext
        .globl  _ftext
        .globl  _extext
        .globl  _extext
        la      a0,_ftext
        LA (a0, _ftext)
        la      a1,_etext
        LA (a1, _etext)
        jal     monstartup
        jal     monstartup
        nop
        nop
#endif
#endif
 
 
 
        move    a0,zero                         # set argc to 0
        jal     main                            # call the program start function
        jal     main                            # call the program start function
        nop
        nop
 
 
        # fall through to the "exit" routine
        # fall through to the "exit" routine
        jal     exit                            # call libc exit to run the G++
        jal     exit                            # call libc exit to run the G++

powered by: WebSVN 2.1.0

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