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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [monitor/] [monitor/] [boards/] [simulator/] [start.s] - Blame information for rev 331

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 189 hellwig
;
2
; start.s -- ECO32 ROM monitor startup and support routines
3
;
4
 
5
;       .set    CIO_CTL,0x00            ; set console to keyboard/display
6
        .set    CIO_CTL,0x03            ; set console to serial line 0
7
 
8
        .set    dmapaddr,0xC0000000     ; base of directly mapped addresses
9
        .set    stacktop,0xC0010000     ; monitor stack is at top of 64K
10
 
11
        .set    PSW,0                    ; reg # of PSW
12
        .set    V_SHIFT,27              ; interrupt vector ctrl bit
13
        .set    V,1 << V_SHIFT
14
 
15
        .set    TLB_INDEX,1             ; reg # of TLB Index
16
        .set    TLB_ENTRY_HI,2          ; reg # of TLB EntryHi
17
        .set    TLB_ENTRY_LO,3          ; reg # of TLB EntryLo
18
        .set    TLB_ENTRIES,32          ; number of TLB entries
19
        .set    BAD_ADDRESS,4           ; reg # of bad address reg
20
        .set    BAD_ACCESS,5            ; reg # of bad access reg
21
 
22
        .set    USER_CONTEXT_SIZE,38*4  ; size of user context
23
 
24
;***************************************************************
25
 
26
        .import _ecode
27
        .import _edata
28
        .import _ebss
29
 
30
        .import kbdinit
31
        .import kbdinchk
32
        .import kbdin
33
 
34
        .import dspinit
35
        .import dspoutchk
36
        .import dspout
37
 
38
        .import ser0init
39
        .import ser0inchk
40
        .import ser0in
41
        .import ser0outchk
42
        .import ser0out
43
 
44
        .import ser1init
45
        .import ser1inchk
46
        .import ser1in
47
        .import ser1outchk
48
        .import ser1out
49
 
50
        .import dskinitctl
51
        .import dskcapctl
52
        .import dskioctl
53
 
54
        .import dskinitser
55
        .import dskcapser
56
        .import dskioser
57
 
58
        .import main
59
 
60
        .export _bcode
61
        .export _bdata
62
        .export _bbss
63
 
64
        .export setcon
65
        .export cinchk
66
        .export cin
67
        .export coutchk
68
        .export cout
69
        .export dskcap
70
        .export dskio
71
 
72
        .export getTLB_HI
73
        .export getTLB_LO
74
        .export setTLB
75
 
76
        .export saveState
77
        .export monitorReturn
78
 
79
        .import userContext
80
        .export resume
81
 
82
;***************************************************************
83
 
84
        .code
85
_bcode:
86
 
87
        .data
88
_bdata:
89
 
90
        .bss
91
_bbss:
92
 
93
;***************************************************************
94
 
95
        .code
96
        .align  4
97
 
98
startup:
99
        j       start
100
 
101
interrupt:
102 200 hellwig
        j       debug
103 189 hellwig
 
104
userMiss:
105 200 hellwig
        j       debug
106 189 hellwig
 
107 200 hellwig
monitor:
108
        j       debug
109
 
110 189 hellwig
;***************************************************************
111
 
112
        .code
113
        .align  4
114
 
115
setcon:
116
        j       setcio
117
 
118
cinchk:
119
        j       cichk
120
 
121
cin:
122
        j       ci
123
 
124
coutchk:
125
        j       cochk
126
 
127
cout:
128
        j       co
129
 
130
dskcap:
131
        j       dcap
132
 
133
dskio:
134
        j       dio
135
 
136 200 hellwig
reserved_11:
137
        j       reserved_11
138 189 hellwig
 
139 200 hellwig
reserved_12:
140
        j       reserved_12
141 189 hellwig
 
142 200 hellwig
reserved_13:
143
        j       reserved_13
144 189 hellwig
 
145 200 hellwig
reserved_14:
146
        j       reserved_14
147 189 hellwig
 
148 200 hellwig
reserved_15:
149
        j       reserved_15
150 189 hellwig
 
151
;***************************************************************
152
 
153
        .code
154
        .align  4
155
 
156
start:
157
        ; let irq/exc vectors point to RAM
158
        add     $8,$0,V
159
        mvts    $8,PSW
160
 
161
        ; initialize TLB
162
        mvts    $0,TLB_ENTRY_LO          ; invalidate all TLB entries
163
        add     $8,$0,dmapaddr           ; by impossible virtual page number
164
        mvts    $8,TLB_ENTRY_HI
165
        add     $8,$0,$0
166
        add     $9,$0,TLB_ENTRIES
167
tlbloop:
168
        mvts    $8,TLB_INDEX
169
        tbwi
170
        add     $8,$8,1
171
        bne     $8,$9,tlbloop
172
 
173
        ; copy data segment
174
        add     $10,$0,_bdata            ; lowest dst addr to be written to
175
        add     $8,$0,_edata             ; one above the top dst addr
176
        sub     $9,$8,$10               ; $9 = size of data segment
177
        add     $9,$9,_ecode            ; data is waiting right after code
178
        j       cpytest
179
cpyloop:
180
        ldw     $11,$9,0         ; src addr in $9
181
        stw     $11,$8,0         ; dst addr in $8
182
cpytest:
183
        sub     $8,$8,4                 ; downward
184
        sub     $9,$9,4
185
        bgeu    $8,$10,cpyloop
186
 
187
        ; clear bss segment
188
        add     $8,$0,_bbss              ; start with first word of bss
189
        add     $9,$0,_ebss              ; this is one above the top
190
        j       clrtest
191
clrloop:
192
        stw     $0,$8,0                   ; dst addr in $8
193
        add     $8,$8,4                 ; upward
194
clrtest:
195
        bltu    $8,$9,clrloop
196
 
197
        ; initialize I/O
198
        add     $29,$0,stacktop          ; setup monitor stack
199 331 hellwig
        add     $4,$0,CIO_CTL            ; set console
200
        jal     setcio
201
        ldbu    $8,$0,cioctl             ; get control byte
202
        and     $8,$8,0x01              ; keyboard input wanted?
203
        bne     $8,$0,nokbd              ; no - then don't touch
204
        jal     kbdinit                 ; else init keyboard
205
nokbd:
206
        ldbu    $8,$0,cioctl             ; get control byte
207
        and     $8,$8,0x02              ; display output wanted?
208
        bne     $8,$0,nodsp              ; no - then don't touch
209
        jal     dspinit                 ; else init display
210
nodsp:
211 189 hellwig
        jal     ser0init                ; init serial line 0
212
        jal     ser1init                ; init serial line 1
213
        jal     dskinitctl              ; init disk (controller)
214
        jal     dskinitser              ; init disk (serial line)
215
 
216
        ; call main
217
        jal     main                    ; enter command loop
218
 
219
        ; main should never return
220
        j       start                   ; just to be sure...
221
 
222
;***************************************************************
223
 
224
        .code
225
        .align  4
226
 
227
        ; Word getTLB_HI(int index)
228
getTLB_HI:
229
        mvts    $4,TLB_INDEX
230
        tbri
231
        mvfs    $2,TLB_ENTRY_HI
232
        jr      $31
233
 
234
        ; Word getTLB_LO(int index)
235
getTLB_LO:
236
        mvts    $4,TLB_INDEX
237
        tbri
238
        mvfs    $2,TLB_ENTRY_LO
239
        jr      $31
240
 
241
        ; void setTLB(int index, Word entryHi, Word entryLo)
242
setTLB:
243
        mvts    $4,TLB_INDEX
244
        mvts    $5,TLB_ENTRY_HI
245
        mvts    $6,TLB_ENTRY_LO
246
        tbwi
247
        jr      $31
248
 
249
;***************************************************************
250
 
251
        .data
252
        .align  4
253
 
254
cioctl:
255
        .byte   0
256
 
257
        .code
258
        .align  4
259
 
260
        ; void setcon(Byte ctl)
261
setcio:
262
        stb     $4,$0,cioctl
263
        j       $31
264
 
265
        ; int cinchk(void)
266
cichk:
267
        ldbu    $8,$0,cioctl
268
        and     $8,$8,0x01
269
        bne     $8,$0,cichk1
270
        j       kbdinchk
271
cichk1:
272
        j       ser0inchk
273
 
274
        ; char cin(void)
275
ci:
276
        ldbu    $8,$0,cioctl
277
        and     $8,$8,0x01
278
        bne     $8,$0,ci1
279
        j       kbdin
280
ci1:
281
        j       ser0in
282
 
283
        ; int coutchk(void)
284
cochk:
285
        ldbu    $8,$0,cioctl
286
        and     $8,$8,0x02
287
        bne     $8,$0,cochk1
288
        j       dspoutchk
289
cochk1:
290
        j       ser0outchk
291
 
292
        ; void cout(char c)
293
co:
294
        ldbu    $8,$0,cioctl
295
        and     $8,$8,0x02
296
        bne     $8,$0,co1
297
        j       dspout
298
co1:
299
        j       ser0out
300
 
301
;***************************************************************
302
 
303
        .code
304
        .align  4
305
 
306
        ; int dskcap(int dskno)
307
dcap:
308
        bne     $4,$0,dcapser
309
        j       dskcapctl
310
dcapser:
311
        j       dskcapser
312
 
313
        ; int dskio(int dskno, char cmd, int sct, Word addr, int nscts)
314
dio:
315
        bne     $4,$0,dioser
316
        add     $4,$5,$0
317
        add     $5,$6,$0
318
        add     $6,$7,$0
319
        ldw     $7,$29,16
320
        j       dskioctl
321
dioser:
322
        add     $4,$5,$0
323
        add     $5,$6,$0
324
        add     $6,$7,$0
325
        ldw     $7,$29,16
326
        j       dskioser
327
 
328
;***************************************************************
329
 
330
        .code
331
        .align  4
332
 
333
        ; Bool saveState(MonitorState *msp)
334
        ; always return 'true' here
335
saveState:
336
        stw     $31,$4,0*4               ; return address
337
        stw     $29,$4,1*4              ; stack pointer
338
        stw     $16,$4,2*4              ; local variables
339
        stw     $17,$4,3*4
340
        stw     $18,$4,4*4
341
        stw     $19,$4,5*4
342
        stw     $20,$4,6*4
343
        stw     $21,$4,7*4
344
        stw     $22,$4,8*4
345
        stw     $23,$4,9*4
346
        add     $2,$0,1
347
        jr      $31
348
 
349
        ; load state when re-entering monitor
350
        ; this appears as if returning from saveState
351
        ; but the return value is 'false' here
352
loadState:
353
        ldw     $8,$0,monitorReturn
354
        beq     $8,$0,loadState          ; fatal error: monitor state lost
355
        ldw     $31,$8,0*4               ; return address
356
        ldw     $29,$8,1*4              ; stack pointer
357
        ldw     $16,$8,2*4              ; local variables
358
        ldw     $17,$8,3*4
359
        ldw     $18,$8,4*4
360
        ldw     $19,$8,5*4
361
        ldw     $20,$8,6*4
362
        ldw     $21,$8,7*4
363
        ldw     $22,$8,8*4
364
        ldw     $23,$8,9*4
365
        add     $2,$0,0
366
        jr      $31
367
 
368
        .bss
369
        .align  4
370
 
371
        ; extern MonitorState *monitorReturn
372
monitorReturn:
373
        .space  4
374
 
375
        ; extern UserContext userContext
376
userContext:
377
        .space  USER_CONTEXT_SIZE
378
 
379
;***************************************************************
380
 
381
        .code
382
        .align  4
383
 
384
        ; void resume(void)
385
        ; use userContext to load state
386
resume:
387
        mvts    $0,PSW
388 201 hellwig
        add     $24,$0,userContext
389 189 hellwig
        .nosyn
390 201 hellwig
        ldw     $8,$24,33*4             ; tlbIndex
391 189 hellwig
        mvts    $8,TLB_INDEX
392 201 hellwig
        ldw     $8,$24,34*4             ; tlbEntryHi
393 189 hellwig
        mvts    $8,TLB_ENTRY_HI
394 201 hellwig
        ldw     $8,$24,35*4             ; tlbEntryLo
395 189 hellwig
        mvts    $8,TLB_ENTRY_LO
396 201 hellwig
        ldw     $8,$24,36*4             ; badAddress
397 189 hellwig
        mvts    $8,BAD_ADDRESS
398 201 hellwig
        ldw     $8,$24,37*4             ; badAccess
399 189 hellwig
        mvts    $8,BAD_ACCESS
400 201 hellwig
        ;ldw    $0,$24,0*4              ; registers
401
        ldw     $1,$24,1*4
402
        ldw     $2,$24,2*4
403
        ldw     $3,$24,3*4
404
        ldw     $4,$24,4*4
405
        ldw     $5,$24,5*4
406
        ldw     $6,$24,6*4
407
        ldw     $7,$24,7*4
408
        ldw     $8,$24,8*4
409
        ldw     $9,$24,9*4
410
        ldw     $10,$24,10*4
411
        ldw     $11,$24,11*4
412
        ldw     $12,$24,12*4
413
        ldw     $13,$24,13*4
414
        ldw     $14,$24,14*4
415
        ldw     $15,$24,15*4
416
        ldw     $16,$24,16*4
417
        ldw     $17,$24,17*4
418
        ldw     $18,$24,18*4
419
        ldw     $19,$24,19*4
420
        ldw     $20,$24,20*4
421
        ldw     $21,$24,21*4
422
        ldw     $22,$24,22*4
423
        ldw     $23,$24,23*4
424
        ;ldw    $24,$24,24*4
425
        ldw     $25,$24,25*4
426
        ldw     $26,$24,26*4
427
        ldw     $27,$24,27*4
428
        ldw     $28,$24,28*4
429
        ldw     $29,$24,29*4
430
        ldw     $30,$24,30*4
431
        ldw     $31,$24,31*4
432
        ldw     $24,$24,32*4            ; psw
433
        mvts    $24,PSW
434 189 hellwig
        rfx
435
        .syn
436
 
437 200 hellwig
        ; debug entry
438 189 hellwig
        ; use userContext to store state
439 200 hellwig
debug:
440 189 hellwig
        .nosyn
441 201 hellwig
        ldhi    $24,userContext
442
        or      $24,$24,userContext
443
        stw     $0,$24,0*4                ; registers
444
        stw     $1,$24,1*4
445
        stw     $2,$24,2*4
446
        stw     $3,$24,3*4
447
        stw     $4,$24,4*4
448
        stw     $5,$24,5*4
449
        stw     $6,$24,6*4
450
        stw     $7,$24,7*4
451
        stw     $8,$24,8*4
452
        stw     $9,$24,9*4
453
        stw     $10,$24,10*4
454
        stw     $11,$24,11*4
455
        stw     $12,$24,12*4
456
        stw     $13,$24,13*4
457
        stw     $14,$24,14*4
458
        stw     $15,$24,15*4
459
        stw     $16,$24,16*4
460
        stw     $17,$24,17*4
461
        stw     $18,$24,18*4
462
        stw     $19,$24,19*4
463
        stw     $20,$24,20*4
464
        stw     $21,$24,21*4
465
        stw     $22,$24,22*4
466
        stw     $23,$24,23*4
467
        stw     $24,$24,24*4
468
        stw     $25,$24,25*4
469
        stw     $26,$24,26*4
470
        stw     $27,$24,27*4
471
        stw     $28,$24,28*4
472
        stw     $29,$24,29*4
473
        stw     $30,$24,30*4
474
        stw     $31,$24,31*4
475 189 hellwig
        mvfs    $8,PSW
476 201 hellwig
        stw     $8,$24,32*4             ; psw
477 189 hellwig
        mvfs    $8,TLB_INDEX
478 201 hellwig
        stw     $8,$24,33*4             ; tlbIndex
479 189 hellwig
        mvfs    $8,TLB_ENTRY_HI
480 201 hellwig
        stw     $8,$24,34*4             ; tlbEntryHi
481 189 hellwig
        mvfs    $8,TLB_ENTRY_LO
482 201 hellwig
        stw     $8,$24,35*4             ; tlbEntryLo
483 189 hellwig
        mvfs    $8,BAD_ADDRESS
484 201 hellwig
        stw     $8,$24,36*4             ; badAddress
485 189 hellwig
        mvfs    $8,BAD_ACCESS
486 201 hellwig
        stw     $8,$24,37*4             ; badAccess
487 189 hellwig
        .syn
488
        j       loadState

powered by: WebSVN 2.1.0

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