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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [libgloss/] [mt/] [crt0-ms2.S] - Blame information for rev 829

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
; crt0.s - Startup code for the ms2. This code initializes the C
2
;              run-time model.
3
;
4
;
5
; Copyright 2001, 2002, 2003, 2004 Morpho Technologies
6
;
7
 
8
        ; Create a label for the start of the eh_frame section.
9
        .section .eh_frame
10
__eh_frame_begin:
11
 
12
        .text
13
        .global _start
14
_start:
15
        ;; Initialize the stack pointer
16
        ldui    sp, #%hi16(__stack)
17
        addui   sp, sp, #%lo16(__stack)
18
        or      fp, sp, sp
19
        ;; Zero the bss space
20
        ldui    r9, #%hi16(__bss_start)
21
        addui   r9, r9, #%lo16(__bss_start)
22
        ldui    r10, #%hi16(__bss_end)
23
        addui   r10, r10, #%lo16(__bss_end)
24
        or      r0, r0, r0
25
        brle    r10, r9, .Lnext1
26
        or      r0, r0, r0
27
.Lcpy0:
28
        stw     r0, r9, #0
29
        addi    r9, r9, #4
30
        or      r0, r0, r0      ; nop
31
        brle    r9, r10, .Lcpy0
32
        or      r0, r0, r0      ; nop
33
 
34
.Lnext1:
35
        ;; Copy data from ROM to Frame Buffer (on-chip memory)
36
        ldui    r9, #%hi16(_fbdata_start)
37
        ori     r9, r9, #%lo16(_fbdata_start)
38
        ldui    r10, #%hi16(_fbdata_end)
39
        ori     r10, r10, #%lo16(_fbdata_end)
40
        ldui    r11, #%hi16(_fbdata_vma)
41
        brle    r10, r9, .Lnext2
42
        ori     r11, r11, #%lo16(_fbdata_vma)
43
.Lcpy1:
44
        ldw     r5, r9, #$0
45
        addi    r9, r9, #$4
46
        stw     r5, r11, #$0
47
        brlt    r9, r10, .Lcpy1
48
        addi    r11, r11, #$4
49
 
50
.Lnext2:
51
        ;; Zero the frame buffer bss section
52
        ldui    r9, #%hi16(_fbbss_start)
53
        ori     r9, r9, #%lo16(_fbbss_start)
54
        ldui    r10, #%hi16(_fbbss_end)
55
        ori     r10, r10, #%lo16(_fbbss_end)
56
        or      r0, r0, r0
57
        brle    r10, r9, .Lnext3
58
        or      r0, r0, r0
59
.Lcpy2:
60
        stw     r0, r9, #$0
61
        addi    r9, r9, #$4
62
        or      r0, r0, r0
63
        brle    r9, r10, .Lcpy2
64
        or      r0, r0, r0
65
 
66
.Lnext3:
67
        ;; Copy data from ROM to SRAM (another on-chip memory)
68
        ldui    r9, #%hi16(_sram_data_start)
69
        ori     r9, r9, #%lo16(_sram_data_start)
70
        ldui    r10, #%hi16(_sram_data_end)
71
        ori     r10, r10, #%lo16(_sram_data_end)
72
        ldui    r11, #%hi16(_sram_data_vma)
73
        brle    r10, r9, .Lnext4
74
        ori     r11, r11, #%lo16(_sram_data_vma)
75
.Lcpy3:
76
        ldw     r5, r9, #$0
77
        addi    r9, r9, #$4
78
        stw     r5, r11, #$0
79
        brlt    r9, r10, .Lcpy3
80
        addi    r11, r11, #$4
81
 
82
.Lnext4:
83
        ;; Call global and static constructors
84
        ldui    r10, #%hi16(_init)
85
        ori     r10, r10, #%lo16(_init)
86
        or      r0, r0, r0      ; nop
87
        or      r0, r0, r0      ; nop, added 06Sep05
88
        jal     r14, r10
89
        or      r0, r0, r0      ; nop
90
 
91
        ;; Call main
92
        ldui    r10, #%hi16(main)
93
        ori     r10, r10, #%lo16(main)
94
        or      r0, r0, r0      ; nop
95
        or      r0, r0, r0      ; nop, added 06Sep05
96
        jal     r14, r10
97
        or      r0, r0, r0      ; nop
98
 
99
        ;; DJK - Added 12Nov01. Pass main's return value to exit.
100
        or      r1, r11, r0
101
 
102
        ;; Jump to exit
103
        ldui    r10, #%hi16(exit)
104
        ori     r10, r10, #%lo16(exit)
105
        or      r0, r0, r0      ; nop
106
        or      r0, r0, r0      ; nop, added 06Sep05
107
        jal     r14, r10
108
        or      r0, r0, r0      ; nop
109
 
110
        ;; Exit does not return, however, this code is to catch an
111
        ;;   error if it does. Set the processor into sleep mode.
112
        ori     r1, r0, #$1
113
        stw     r1, r0, #%lo16(_DEBUG_HALT_REG)
114
        or      r0, r0, r0
115
        or      r0, r0, r0
116
        or      r0, r0, r0
117
        or      r0, r0, r0
118
        or      r0, r0, r0
119
.Lend:
120
        jmp .Lend
121
        or      r0, r0, r0

powered by: WebSVN 2.1.0

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