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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [simtest/] [rom/] [romboot.s] - Blame information for rev 97

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

Line No. Rev Author Line
1 9 hellwig
;
2
; romboot.s -- the ROM bootstrap
3
;
4
 
5
        .set    termbase,0xF0300000     ; terminal base address
6
        .set    diskbase,0xF0400000     ; disk base address
7
        .set    diskbuffer,0xF0480000   ; disk buffer address
8
        .set    virtbase,0xC0000000     ; base of kernel virtual addresses
9
        .set    virtboot,0xC0000000     ; where to start the bootstrap sector
10
        .set    stacktop,0xC0100000     ; where the stack is located
11
 
12
        .set    PSW,0
13
        .set    TLB_INDEX,1
14
        .set    TLB_ENTRY_HI,2
15
        .set    TLB_ENTRY_LO,3
16
        .set    TLB_ENTRIES,32
17
 
18
        .code
19
 
20
reset:
21
        j       start
22
 
23
interrupt:
24
        j       interrupt
25
 
26
miss:
27
        j       miss
28
 
29
start:
30
        mvts    $0,PSW                   ; disable interrupts and user mode
31
        mvts    $0,TLB_ENTRY_LO          ; invalidate all TLB entries
32
        add     $8,$0,virtbase           ; by impossible virtual page number
33
        add     $9,$0,$0
34
        add     $10,$0,TLB_ENTRIES
35
tlblp:
36
        mvts    $8,TLB_ENTRY_HI
37
        mvts    $9,TLB_INDEX
38
        tbwi
39
        add     $8,$8,0x1000            ; all entries must be different
40
        add     $9,$9,1
41
        bne     $9,$10,tlblp
42
        add     $29,$0,stacktop          ; set stack pointer
43
        add     $4,$0,signon             ; show sign-on message
44
        jal     mout
45
cmdlp:
46
        add     $4,$0,prompt             ; show prompt
47
        jal     mout
48
        jal     echo
49
        sub     $8,$2,0x0D              ; '<ret>'?
50
        beq     $8,$0,rcmdlp
51
        sub     $8,$2,'b'               ; 'b'?
52
        beq     $8,$0,boot
53
        add     $4,$0,'?'                ; unknown command
54
        jal     cout
55
rcmdlp:
56
        jal     crlf
57
        j       cmdlp
58
 
59
boot:
60
        jal     crlf
61
        add     $8,$0,diskbase           ; check if disk present
62
        add     $9,$0,1000000            ; retry count
63
boot1:
64
        ldw     $16,$8,0         ; get status
65
        and     $10,$16,0x20            ; check if disk ready
66
        bne     $10,$0,boot2             ; ready - exit loop
67
        sub     $9,$9,1
68
        bne     $9,$0,boot1              ; try again
69
        j       nodsk                   ; enough retries - error
70
boot2:
71
        ldw     $16,$8,12               ; check if capacity greater than 0
72
        beq     $16,$0,nodsk             ; no - report error
73
        add     $4,$0,dfmsg              ; say that we found a disk
74
        jal     mout
75
        add     $4,$16,$0                ; and how many sectors it has
76
        jal     wout
77
        add     $4,$0,sctmsg
78
        jal     mout
79
        add     $8,$0,diskbase           ; try to load the boot sector
80
        add     $9,$0,1                  ; sector count
81
        stw     $9,$8,4
82
        add     $9,$0,0                   ; first sector
83
        stw     $9,$8,8
84
        add     $9,$0,1                  ; start command
85
        stw     $9,$8,0
86
dskwt:
87
        ldw     $9,$8,0
88
        and     $9,$9,0x10              ; done?
89
        beq     $9,$0,dskwt
90
        ldw     $9,$8,0
91
        and     $9,$9,0x08              ; error?
92
        bne     $9,$0,dskerr
93
        add     $8,$0,diskbuffer ; copy sector
94
        add     $9,$0,virtboot
95
        add     $10,$0,512
96
dskcp:
97
        ldw     $11,$8,0
98
        stw     $11,$9,0
99
        add     $8,$8,4
100
        add     $9,$9,4
101
        sub     $10,$10,4
102
        bne     $10,$0,dskcp
103
        add     $8,$0,virtboot           ; signature present?
104
        ldbu    $9,$8,512-2
105
        sub     $9,$9,0x55
106
        bne     $9,$0,nosig
107
        ldbu    $9,$8,512-1
108
        sub     $9,$9,0xAA
109
        bne     $9,$0,nosig
110
        jalr    $8                      ; finally... lift off
111
        j       cmdlp                   ; in case we ever return to here
112
 
113
nodsk:
114
        add     $4,$0,dnfmsg             ; there is no disk
115
        jal     mout
116
        j       cmdlp
117
 
118
dskerr:
119
        add     $4,$0,demsg              ; disk error
120
        jal     mout
121
        j       cmdlp
122
 
123
nosig:
124
        add     $4,$0,nsgmsg             ; no signature
125
        jal     mout
126
        j       cmdlp
127
 
128
crlf:
129
        sub     $29,$29,4
130
        stw     $31,$29,0
131
        add     $4,$0,0x0D
132
        jal     cout
133
        add     $4,$0,0x0A
134
        jal     cout
135
        ldw     $31,$29,0
136
        add     $29,$29,4
137
        jr      $31
138
 
139
mout:
140
        sub     $29,$29,8
141
        stw     $31,$29,4
142
        stw     $16,$29,0
143
        add     $16,$4,$0
144
mout1:
145
        ldbu    $4,$16,0
146
        beq     $4,$0,mout2
147
        jal     cout
148
        add     $16,$16,1
149
        j       mout1
150
mout2:
151
        ldw     $16,$29,0
152
        ldw     $31,$29,4
153
        add     $29,$29,8
154
        jr      $31
155
 
156
wout:
157
        sub     $29,$29,8
158
        stw     $31,$29,4
159
        stw     $16,$29,0
160
        add     $16,$4,$0
161
        slr     $4,$16,16
162
        jal     hout
163
        add     $4,$16,$0
164
        jal     hout
165
        ldw     $16,$29,0
166
        ldw     $31,$29,4
167
        add     $29,$29,8
168
        jr      $31
169
 
170
hout:
171
        sub     $29,$29,8
172
        stw     $31,$29,4
173
        stw     $16,$29,0
174
        add     $16,$4,$0
175
        slr     $4,$16,8
176
        jal     bout
177
        add     $4,$16,$0
178
        jal     bout
179
        ldw     $16,$29,0
180
        ldw     $31,$29,4
181
        add     $29,$29,8
182
        jr      $31
183
 
184
bout:
185
        sub     $29,$29,8
186
        stw     $31,$29,4
187
        stw     $16,$29,0
188
        add     $16,$4,$0
189
        slr     $4,$16,4
190
        jal     nout
191
        add     $4,$16,$0
192
        jal     nout
193
        ldw     $16,$29,0
194
        ldw     $31,$29,4
195
        add     $29,$29,8
196
        jr      $31
197
 
198
nout:
199
        sub     $29,$29,4
200
        stw     $31,$29,0
201
        and     $4,$4,0x0F
202
        add     $4,$4,0x30
203
        sub     $8,$4,0x3A
204
        blt     $8,$0,nout1
205
        add     $4,$4,7
206
nout1:
207
        jal     cout
208
        ldw     $31,$29,0
209
        add     $29,$29,4
210
        jr      $31
211
 
212
cin:
213
        add     $8,$0,termbase
214
cin1:
215
        ldw     $9,$8,0
216
        and     $9,$9,1
217
        beq     $9,$0,cin1
218
        ldw     $2,$8,4
219
        jr      $31
220
 
221
cout:
222
        add     $8,$0,termbase
223
cout1:
224
        ldw     $9,$8,8
225
        and     $9,$9,1
226
        beq     $9,$0,cout1
227
        stw     $4,$8,12
228
        jr      $31
229
 
230
echo:
231
        sub     $29,$29,4
232
        stw     $31,$29,0
233
        jal     cin
234
        add     $4,$0,$2
235
        jal     cout
236
        ldw     $31,$29,0
237
        add     $29,$29,4
238
        jr      $31
239
 
240
signon:
241
        .byte   0x0D, 0x0A
242
        .byte   "ROM Bootstrap Version 1"
243
        .byte   0x0D, 0x0A, 0x0D, 0x0A, 0
244
 
245
prompt:
246
        .byte   "#"
247
        .byte   0
248
 
249
dnfmsg:
250
        .byte   "Disk not found!"
251
        .byte   0x0D, 0x0A, 0
252
 
253
dfmsg:
254
        .byte   "Disk with 0x"
255
        .byte   0
256
 
257
sctmsg:
258
        .byte   " sectors found, booting..."
259
        .byte   0x0D, 0x0A, 0
260
 
261
demsg:
262
        .byte   "Disk error!"
263
        .byte   0x0D, 0x0A, 0
264
 
265
nsgmsg:
266
        .byte   "MBR signature missing!"
267
        .byte   0x0D, 0x0A, 0

powered by: WebSVN 2.1.0

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