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

Subversion Repositories ion

[/] [ion/] [trunk/] [src/] [common/] [c_startup.s] - Blame information for rev 238

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 173 ja_rd
#-------------------------------------------------------------------------------
2
# startup.s -- C startup code common to all C programs.
3
#
4
# This code does the following:
5
# 1.- Initialize the stack at the end of the bss area
6
# 2.- Clear the bss area
7
# 3.- Move the data section from FLASH to RAM (if applicable)
8
# 4.- Call main()
9
# 5.- Freeze in endless loop after main() returns, if it does
10
#
11
# The code does not initialize the caches or the hardware and does not include
12
# the reset or trap vectors.
13
#
14
# This code was inherited from OpenCores' Plasma project.
15
#-------------------------------------------------------------------------------
16
 
17
    # The stack size can be defined from the assembler command line
18
    # FIXME should use info from the link script
19
    .ifndef STACK_SIZE
20
    .set    STACK_SIZE,         1024        # by default, reserve 1KB
21
    .endif
22
 
23
    # Reserve space for regular stack (BSS segment)
24
    .comm init_stack, STACK_SIZE
25
 
26
    .text
27
    .align 2
28
    .global entry
29
    .ent    entry
30
entry:
31
    .set noreorder
32
 
33
    # (The linker script defined these symbols)
34
    la      $gp, _gp                # initialize global pointer
35
    la      $5, __bss_start         # $5 = .sbss_start
36
    la      $4, _end                # $2 = .bss_end
37
    la      $sp, init_stack+STACK_SIZE-24 #initialize stack pointer
38
 
39
    # Clear BSS area
40
$BSS_CLEAR:
41
    sw      $0, 0($5)
42
    slt     $3, $5, $4
43
    bnez    $3, $BSS_CLEAR
44
    addiu   $5, $5, 4
45
 
46
    # Move data section image from flash to RAM, if necessary.
47
    la      $a0,data_start
48
    la      $a1,data_load_start
49
    beq     $a1,$a0,move_data_section_done
50
    nop
51
    la      $s0,data_size
52
    beqz    $s0,move_data_section_done
53
    nop
54
move_data_section_loop:
55
    lw      $t0,0($a1)
56
    addiu   $a1,$a1,4
57
    sw      $t0,0($a0)
58
    addiu   $a0,$a0,4
59 238 ja_rd
    bgtz    $s0,move_data_section_loop
60 173 ja_rd
    addiu   $s0,$s0,-4
61
move_data_section_done:
62
 
63
    jal     main                    # init done; call main()
64
    nop
65
$L1:
66
    j       $L1
67
    nop
68
 
69
    .end     entry
70 238 ja_rd
 

powered by: WebSVN 2.1.0

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