bootmain.S
4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#include "leon.h"
/* #define RAMSIZE 0x1000000 */
#ifndef RAMSIZE
#define RAMSIZE 128*1024
#endif
/* #define RAMSIZE 0x1000 */
#define RAMEND (CRAM + RAMSIZE)
.seg "text"
.proc 0
.align 4
! .global _hardreset
!_hardreset:
.global boot
boot:
por:
flush
set 0x10c0, %g1 ! init IU
! set 0x00c0, %g1 ! init IU
mov %g1, %psr
mov %g0, %wim
mov %g0, %tbr
mov %g0, %y
nop
set _text_start,%g1
mov %g1, %tbr
set PREGS, %g7 ! on-chip register base address
set 0x1000f, %g1
st %g1, [%g7 + CCTRL]
ld [%g7 + ECTRL], %g1
and %g1, 0x100, %g1
sll %g1, 1, %g2
or %g1, %g2, %g1
set 0x0f0000, %g2
or %g1, %g2, %g1
st %g1, [%g7 + ECTRL]
ld [%g7 + MCFG1], %g1
and %g1, 0x3ff, %g1
st %g1, [%g7 + MCFG1]
and %g1, 0x300, %g1
ld [%g7 + IOREG], %g2
srl %g2, 4, %g3
and %g3, 3, %g3
or %g1, %g3, %g1
set 0x04080000, %g3 ! initialise memory config registers
or %g3, %g1, %g1
st %g1, [%g7 + MCFG1]
sll %g2, 4, %g3
and %g3, 0x70, %g1
and %g2, 0x0c0, %g3
srl %g3, 4, %g3
or %g3, %g1, %g1
srl %g3, 2, %g3
or %g3, %g1, %g1
set 0x800, %g3
or %g3, %g1, %g1
andcc %g2, 3, %g0
bne 1f
nop
add %g1, 0x200, %g1
1:
! set 0xd5384000, %g3
! or %g3, %g1, %g1
! st %g1, [%g7 + MCFG2]
set -1, %g3
st %g0, [%g7 + FADDR]
st %g0, [%g7 + MSTAT]
st %g0, [%g7 + WPROT1]
st %g0, [%g7 + WPROT2]
st %g3, [%g7 + SRLD]
st %g3, [%g7 + SCNT]
st %g0, [%g7 + TCTRL0]
st %g3, [%g7 + TRLD0]
st %g3, [%g7 + TCNT0]
st %g0, [%g7 + TCTRL1]
st %g3, [%g7 + TRLD1]
st %g3, [%g7 + TCNT1]
st %g3, [%g7 + USCAL0]
st %g3, [%g7 + UCTRL0]
st %g0, [%g7 + USTAT0]
st %g3, [%g7 + USCAL1]
st %g3, [%g7 + UCTRL1]
st %g0, [%g7 + USTAT1]
st %g0, [%g7 + WPROT1]
st %g0, [%g7 + WPROT2]
st %g0, [%g7 + IOREG]
st %g0, [%g7 + IOICONF]
st %g0, [%g7 + IFORCE]
st %g0, [%g7 + IMASK]
st %g0, [%g7 + IPEND]
st %g3, [%g7 + ICLEAR]
st %g0, [%g7 + IMASK2]
st %g0, [%g7 + IPEND2]
st %g3, [%g7 + ICLEAR2]
st %g0, [%g7 + ISTAT2]
ba 2f ! ld [%g7 + ECTRL], %g2 ! if LEON-FT, then clear %asr16
nop ! srl %g2, RFE_CONF_BIT, %g3
andcc %g3, RFE_CONF_MASK, %g3
be 2f
nop
mov %g0, %asr16
2:
ld [%g7 + LCONF], %g2 ! load LEON configuration register
srl %g2, 20, %g3
and %g3, 0x1f, %g3
mov %g0, %g4
mov %g0, %g5
mov %g0, %g6
1:
mov %g0, %l0
mov %g0, %l1
mov %g0, %l2
mov %g0, %l3
mov %g0, %l4
mov %g0, %l5
mov %g0, %l6
mov %g0, %l7
mov %g0, %o0
mov %g0, %o1
mov %g0, %o2
mov %g0, %o3
mov %g0, %o4
mov %g0, %o5
mov %g0, %o6
mov %g0, %o7
subcc %g3, 1, %g3
bge 1b
save
srl %g2, FPU_CONF_BIT, %g3
andcc %g3, FPU_CONF_MASK, %g0
be 3f
set zerodword, %g4
st %g0, [%g4]
st %g0, [%g4+4]
nop
ld [%g4], %fsr
ldd [%g4], %f0
ldd [%g4], %f2
ldd [%g4], %f4
ldd [%g4], %f6
ldd [%g4], %f8
ldd [%g4], %f10
ldd [%g4], %f12
ldd [%g4], %f14
ldd [%g4], %f16
ldd [%g4], %f18
ldd [%g4], %f20
ldd [%g4], %f22
ldd [%g4], %f24
ldd [%g4], %f26
ldd [%g4], %f28
ldd [%g4], %f30
ba 3f
mov %g0,%g4
3:
set 0x40000000, %o1
set 0x80000000, %o2
set 0x80f003a7, %o3
st %o3, [%o2+0x28]
/*
set 1, %o3
st %o3, [%o2+4]
set 2, %o3
st %o3, [%o2+4]
st %o3, [%o2+4]
set 0x80100000, %o3
st %o3, [%o2+4]
nop
nop
nop
nop
ldda [%o1] 0, %o4
set 0x76543210, %o3
st %o3, [%o1+0]
st %o3, [%o1+4]
st %o3, [%o1+8]
std %o2, [%o1+0]
ld [%o1+0], %o4
ld [%o1+4], %o4
1:
ldda [%o1] 0, %o4
ldda [%o1] 0, %o4
call 0x40000000
nop
ba 1b
st %g0, [%o1+0x10]
sth %o3, [%o1+0x10]
ld [%o1+0x10], %o4
st %g0, [%o1+0x14]
sth %o3, [%o1+0x16]
ld [%o1+0x14], %o4
st %g0, [%o1+0x18]
stub %o3, [%o1+0x18]
stub %o3, [%o1+0x19]
stub %o3, [%o1+0x1a]
stub %o3, [%o1+0x1b]
ld [%o1+0x18], %o4
*/
/*
set 0x20000000, %o1
set 0x01234567, %o3
st %o3, [%o1+96]
sth %o3, [%o1+98]
stb %o3, [%o1+99]
ld [%o1+96], %o2
st %o2, [%o1+96]
lduh [%o1+96], %o3
sth %o3, [%o1+96]
lduh [%o1+98], %o3
sth %o3, [%o1+98]
ldub [%o1+96], %o4
stb %o4, [%o1+96]
ldub [%o1+97], %o4
stb %o4, [%o1+97]
ldub [%o1+98], %o4
stb %o4, [%o1+98]
ldub [%o1+99], %o4
stb %o4, [%o1+99]
*/
mov 2, %g1
mov %g1, %wim
! set 0x10e0, %g1 ! enable traps
! set 0x00c0, %g1 ! enable traps
set 0x10e0, %g1 ! enable traps
mov %g1, %psr
nop; nop; nop;
set CRAM + RAMSIZE - 16, %g3
! set CRAM + (4*1024) - 16, %g3
! set CRAM + (192*1024) - 16, %g3
! set SDRAM + (256*1024) - 16, %g3
mov %g3, %fp
sub %g3, 96, %sp
set main, %g1
jmp %g1
nop
.seg "data"
zerodword:
.word 0
.word 0
.align 32