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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [newlib-1.18.0/] [libgloss/] [mt/] [crt0-64-001.S] - Blame information for rev 833

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
; crt0_2.s - Startup code for the mrisc1. This code initializes the C
2
;              run-time model.
3
;
4
; 12Nov01 (DJK) - The return code from main was not being passed to exit().
5
;                   Now it is passed as a parameter in R1.
6
;
7
; 10Sep01 (DJK) - The function exit() does not return. However, in the
8
;                   the case of device error (if the halt bit does not
9
;                   function properly, for instance), then a catch loop
10
;                   has been added.
11
;
12
;
13
; Copyright 2001, 2002, 2003, 2004 Morpho Technologies, Inc.
14
;
15
 
16
        ; Create a label for the start of the eh_frame section.
17
        .section .eh_frame
18
__eh_frame_begin:
19
 
20
        .equ    HALT_REG, 0x300
21
        .section .text
22
        .global _start
23
_start:
24
        ;; Initialize the stack pointer
25
        ldui    sp, #%hi16(__stack)
26
        addui   sp, sp, #%lo16(__stack)
27
        or      fp, sp, sp
28
 
29
        ;; Copy data from ROM to Frame Buffer (on-chip memory)
30
        ldui    r9, #%hi16(_fbdata_start)
31
        ori     r9, r9, #%lo16(_fbdata_start)
32
        ldui    r10, #%hi16(_fbdata_end)
33
        ori     r10, r10, #%lo16(_fbdata_end)
34
        ldui    r11, #%hi16(__FRAME_BUFFER_START)
35
        brle    r10, r9, .Lnext1
36
        ori     r11, r11, #%lo16(__FRAME_BUFFER_START)
37
.Lcpy0:
38
        ldw     r5, r9, #$0
39
        addi    r9, r9, #$4
40
        stw     r5, r11, #$0
41
        brlt    r9, r10, .Lcpy0
42
        addi    r11, r11, #$4
43
 
44
.Lnext1:
45
        ;; Copy data from ROM to External Memory (off-chip memory)
46
        ldui    r9, #%hi16(_extdata_start)
47
        ori     r9, r9, #%lo16(_extdata_start)
48
        ldui    r10, #%hi16(_extdata_end)
49
        ori     r10, r10, #%lo16(_extdata_end)
50
        ldui    r11, #%hi16(__EXTERNAL_MEMORY_START)
51
        brle    r10, r9, .Lnext2
52
        ori     r11, r11, #%lo16(__EXTERNAL_MEMORY_START)
53
.Lcpy1:
54
        ldw     r5, r9, #$0
55
        addi    r9, r9, #$4
56
        stw     r5, r11, #$0
57
        brlt    r9, r10, .Lcpy1
58
        addi    r11, r11, #$4
59
 
60
 
61
.Lnext2:
62
        ;; Zero the bss space
63
        ldui    r9, #%hi16(__bss_start)
64
        addui   r9, r9, #%lo16(__bss_start)
65
        ldui    r10, #%hi16(__bss_end)
66
        addui   r10, r10, #%lo16(__bss_end)
67
        or      r0, r0, r0
68
        brle    r10, r9, .Lnext3
69
        or      r0, r0, r0
70
.Lcpy2:
71
        stw     r0, r9, #0
72
        addi    r9, r9, #4
73
        or      r0, r0, r0      ; nop
74
        brle    r9, r10, .Lcpy2
75
        or      r0, r0, r0      ; nop
76
 
77
.Lnext3:
78
        ;; Zero the external memory bss section
79
        ldui    r9, #%hi16(_extbss_start)
80
        ori     r9, r9, #%lo16(_extbss_start)
81
        ldui    r10, #%hi16(_extbss_end)
82
        ori     r10, r10, #%lo16(_extbss_end)
83
        or      r0, r0, r0
84
        brle    r10, r9, .Lnext4
85
        or      r0, r0, r0
86
.Lcpy3:
87
        stw     r0, r9, #$0
88
        addi    r9, r9, #$4
89
        or      r0, r0, r0
90
        brle    r9, r10, .Lcpy3
91
        or      r0, r0, r0
92
 
93
.Lnext4:
94
        ;; Call global and static constructors
95
        ldui    r10, #%hi16(_init)
96
        ori     r10, r10, #%lo16(_init)
97
        or      r0, r0, r0      ; nop
98
        jal     r14, r10
99
        or      r0, r0, r0      ; nop
100
 
101
        ;;  Setup destructors to be called from exit.
102
        ;;  (Just in case main never returns....)
103
        ldui    r10, #%hi16(atexit)
104
        ori     r10, r10, #%lo16(atexit)
105
        ldui    r1, #%hi16(_fini)
106
        ori     r1, r1, #%lo16(_fini)
107
        or      r0, r0, r0      ; nop
108
        jal     r14, r10
109
        or      r0, r0, r0      ; nop
110
 
111
        ;;  Initialise argc, argv and envp to empty
112
        addi    r1, r0, #0
113
        addi    r2, r0, #0
114
        addi    r3, r0, #0
115
 
116
        ;; Call main
117
        ldui    r10, #%hi16(main)
118
        ori     r10, r10, #%lo16(main)
119
        or      r0, r0, r0      ; nop
120
        jal     r14, r10
121
        or      r0, r0, r0      ; nop
122
 
123
        ;; DJK - Added 12Nov01. Pass main's return value to exit.
124
        or      r1, r11, r0
125
 
126
        ;; Jump to exit
127
        ldui    r10, #%hi16(exit)
128
        ori     r10, r10, #%lo16(exit)
129
        or      r0, r0, r0      ; nop
130
        jal     r14, r10
131
        or      r0, r0, r0      ; nop
132
 
133
        ;; Exit does not return, however, this code is to catch an
134
        ;;   error if it does. Set the processor into sleep mode.
135
        ori     r1, r0, #$1
136
        stw     r1, r0, #HALT_REG
137
        or      r0, r0, r0
138
        or      r0, r0, r0
139
        or      r0, r0, r0
140
        or      r0, r0, r0
141
        or      r0, r0, r0
142
.Lend:
143
        jmp .Lend
144
        or      r0, r0, r0

powered by: WebSVN 2.1.0

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