1
2#include <asm/core.h>
3#include <asm/regs.h>
4#include <asm/asmmacro.h>
5#include <asm/cacheasm.h>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28#define STACK_SIZE 32768
29#define HEAP_SIZE (131072*4)
30
31
32
33
34 .section .start, "ax"
35
36 .globl __start
37
38__start:
39 entry sp, 32
40 _call0 _start
41__start_a0:
42 .align 4
43
44 .section .text, "ax"
45 .literal_position
46 .begin literal_prefix .text
47
48
49
50 .globl _start
51_start:
52
53
54
55 movi a4, 1
56 wsr a4, ps
57 rsync
58
59 rsr a5, windowbase
60 ssl a5
61 sll a4, a4
62 wsr a4, windowstart
63 rsync
64
65 movi a4, 0x00040000
66 wsr a4, ps
67 rsync
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 movi a4, __start
84 movi a5, __start_a0
85 add a4, a0, a4
86 sub a0, a4, a5
87
88 movi a4, __start
89 movi a5, __reloc_end
90
91
92
93
94
95 mov.n a7, a0
96 mov.n a8, a4
97
981:
99 l32i a10, a7, 0
100 l32i a11, a7, 4
101 s32i a10, a8, 0
102 s32i a11, a8, 4
103 l32i a10, a7, 8
104 l32i a11, a7, 12
105 s32i a10, a8, 8
106 s32i a11, a8, 12
107 addi a8, a8, 16
108 addi a7, a7, 16
109 blt a8, a5, 1b
110
111
112
113
114
115
116 ___flush_dcache_all a5 a6
117
118#endif
119
120 ___invalidate_icache_all a5 a6
121 isync
122
123 movi a11, _reloc
124 jx a11
125
126 .globl _reloc
127_reloc:
128
129
130
131
132
133
134
135
136
137
138
139
140 movi a6, _param_start
141 add a3, a2, a3
1422:
143 l32i a8, a2, 0
144 s32i a8, a6, 0
145 addi a2, a2, 4
146 addi a6, a6, 4
147 blt a2, a3, 2b
148#endif
149
150
151 movi a6, __bss_start
152 movi a7, __bss_end
153 movi.n a5, 0
1543:
155 s32i a5, a6, 0
156 addi a6, a6, 4
157 blt a6, a7, 3b
158
159 movi a5, -16
160 movi a1, _stack + STACK_SIZE
161 and a1, a1, a5
162
163
164
165
166
167
168
169 movi a3, __image_load
170 sub a4, a3, a4
171 add a8, a0, a4
172
173
174
175
176 movi a6, _image_start
177 movi a10, _image_end
178 movi a7, 0x1000000
179 sub a11, a10, a6
180 movi a9, complen
181 s32i a11, a9, 0
182
183 movi a0, 0
184
185
186
187
188
189
190 .extern gunzip
191 movi a4, gunzip
192 beqz a4, 1f
193
194 callx4 a4
195
196 j 2f
197
198
199
200
201
202
203
204
2051:
206 l32i a9, a8, 0
207 l32i a11, a8, 4
208 s32i a9, a6, 0
209 s32i a11, a6, 4
210 l32i a9, a8, 8
211 l32i a11, a8, 12
212 s32i a9, a6, 8
213 s32i a11, a6, 12
214 addi a6, a6, 16
215 addi a8, a8, 16
216 blt a6, a10, 1b
217
218
219
2202:
221
222
223 ___flush_dcache_all a5 a6
224
225#endif
226
227 ___invalidate_icache_all a5 a6
228
229 isync
230
231
232
233 movi a0, _image_start
234 jx a0
235
236 .align 16
237 .data
238 .globl avail_ram
239avail_ram:
240 .long _heap
241 .globl end_avail
242end_avail:
243 .long _heap + HEAP_SIZE
244
245 .comm _stack, STACK_SIZE
246 .comm _heap, HEAP_SIZE
247
248 .globl end_avail
249 .comm complen, 4
250
251 .end literal_prefix
252