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

Subversion Repositories thor

[/] [thor/] [trunk/] [software/] [source/] [boot.asm] - Blame information for rev 54

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

Line No. Rev Author Line
1 24 robfinch
 
2
; ============================================================================
3
;        __
4
;   \\__/ o\    (C) 2015  Robert Finch, Stratford
5
;    \  __ /    All rights reserved.
6
;     \/_//     robfinch@finitron.ca
7
;       ||
8
;
9
;
10
; This source file is free software: you can redistribute it and/or modify
11
; it under the terms of the GNU Lesser General Public License as published
12
; by the Free Software Foundation, either version 3 of the License, or
13
; (at your option) any later version.
14
;
15
; This source file is distributed in the hope that it will be useful,
16
; but WITHOUT ANY WARRANTY; without even the implied warranty of
17
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
; GNU General Public License for more details.
19
;
20
; You should have received a copy of the GNU General Public License
21
; along with this program.  If not, see .
22
;
23
; ============================================================================
24
;
25
.include "C:\Cores4\Thor\trunk\software\FMTK\source\kernel\FMTK_Equates.inc"
26
 
27
SCRSZ   EQU     2604
28
_BS             EQU     0x07
29
CR      EQU     0x0D            ;ASCII equates
30
LF      EQU     0x0A
31
TAB     EQU     0x09
32
CTRLC   EQU     0x03
33
CTRLH   EQU     0x08
34
CTRLI   EQU     0x09
35
CTRLJ   EQU     0x0A
36
CTRLK   EQU     0x0B
37
CTRLM   EQU 0x0D
38
CTRLS   EQU     0x13
39
CTRLX   EQU     0x18
40
XON             EQU     0x11
41
XOFF    EQU     0x13
42
ESC             EQU     0x1B
43
 
44
SC_TAB          EQU             $0D
45
SC_LSHIFT       EQU             $12
46
SC_RSHIFT       EQU             $59
47
SC_KEYUP        EQU             $F0
48
SC_EXTEND       EQU             $E0
49
SC_CTRL         EQU             $14
50
SC_ALT          EQU             $11
51
SC_DEL          EQU             $71             ; extend
52
SC_LCTRL        EQU             $58
53
SC_NUMLOCK      EQU             $77
54
SC_SCROLLLOCK   EQU     $7E
55
SC_CAPSLOCK     EQU             $58
56
 
57
E_BadFuncno    EQU       1
58
BIOS_E_Timeout EQU       2
59
E_Unsupported  EQU       3
60
 
61
BIOS_STACKTOP           EQU             $3bf8
62
INT_STACK                       EQU             $37f8
63
VIDEO_BIOS_STACKTOP     EQU             $3ff8
64
 
65
IOBASE_ADDR     EQU             0xFFD00000
66
IOLMT           EQU             0x100000
67
LEDS            EQU             0xC0600
68
TEXTSCR         EQU             0x00000
69
TEXTSCR2        EQU             0x10000
70
TEXTREG         EQU             0xA0000
71
TEXTREG2        EQU             0xA0040
72
TEXT_COLS       EQU             0x0
73
TEXT_ROWS       EQU             0x2
74
TEXT_CURPOS     EQU             0x16
75
KEYBD           EQU             0xC0000
76
 
77
PIC_IS          EQU             0xC0FC0
78
PIC_IE          EQU             0xC0FC8
79
PIC_ES          EQU             0xC0FE0
80
PIC_ESR         EQU             0xC0FE8         ; edge sense reset
81
 
82
                bss
83
                org             $C00000
84
                dw              0                                ; the first word is unused
85
Milliseconds    dw              0
86
m_w                             dh              0
87
m_z                             dh              0
88
FMTK_SchedulerIRQ_vec   dw      0
89
Running_                dw              0
90
;IOFocusNdx_            dw              0
91
;iof_switch_            db              0
92
                align   8
93
NextRdy_                dw              0
94
PrevRdy_                dw              0
95
 
96
KeyState1               db              0
97
KeyState2               db              0
98
KeybdLEDs               db              0
99
KeybdWaitFlag   db              0
100
                align   2
101
KeybdHead               db              0
102
KeybdTail               db              0
103
KeybdBufSz              db              0
104
KeybdBuf                fill.b  128,0
105
                align   2
106
CursorX                 dc              0
107
CursorY                 dc              0
108
VideoPos                dc              0
109
                align   4
110
NormAttr                dh              0
111
Vidregs                 dh              0
112
Vidptr                  dh              0
113
EscState                dc              0
114
Textrows                dc              0
115
Textcols                dc              0
116
                align   8
117
reg_save                fill.w  64,0
118
creg_save               fill.w  16,0
119
sreg_save               fill.w  16,0
120
preg_save               dw              0
121
 
122
 
123
rxfull     EQU      1
124
Uart_ms         db      0
125
Uart_txxonoff   db      0
126
Uart_rxhead     dc      0
127
Uart_rxtail     dc      0
128
Uart_rxflow     db      0
129
Uart_rxrts      db      0
130
Uart_rxdtr      db      0
131
Uart_rxxon      db      0
132
Uart_foff       dc      0
133
Uart_fon        dc      0
134
Uart_txrts      db      0
135
Uart_txdtr      db      0
136
Uart_txxon      db      0
137
Uart_rxfifo     fill.b  512,0
138
 
139
NUMWKA          fill.b  64,0
140
 
141
        code 17 bits
142
        org             $FFFC0000
143
 
144
;------------------------------------------------------------------------------
145
; Reset Point
146
;------------------------------------------------------------------------------
147
 
148
cold_start:
149
                ; Initialize segment registers for flat model
150
                mtspr   zs,r0
151
                ldis    zs.lmt,#-1
152
                mtspr   ds,r0
153
                ldis    ds.lmt,#-1
154
                mtspr   es,r0
155
                ldis    es.lmt,#-1
156
                mtspr   fs,r0
157
                ldis    fs.lmt,#-1
158
                mtspr   gs,r0
159
                ldis    gs.lmt,#-1
160
                ldis    hs,#IOBASE_ADDR
161
                ldis    hs.lmt,#IOLMT
162
 
163
                ; set SS:SP
164
                ldi             r31,#$03ef8             ; initialize kernel SP
165
                ldi             sp,#sys_stacks_+511*8
166
                mtspr   ss,r0
167
                ldis    ss.lmt,#-1
168
 
169
                ; switch processor to full speed
170
                stp             #$FFFF
171
 
172
                ; set interrupt table at $1000
173
                ldis    c12,#$1000
174
 
175
                ; set all vectors to the uninitialized interrupt vector
176
                mov             r4,r0
177
                ldis    lc,#255         ; 256 vectors to set
178
su1:
179
                ldi             r1,#uii_jmp
180
                mov             r2,r4
181
                bsr             set_vector      ; trashes r2,r3
182
                addui   r4,r4,#1
183
                loop    su1
184
 
185
                ; setup break vector
186
                lla             r1,cs:brk_jmp
187
                ldi             r2,#0
188
                bsr             set_vector
189
 
190
                ; setup system scheduler vector
191
                ; points to an RTE at startup
192
                lla             r1,cs:tms_jmp
193
                ldi             r2,#2
194
                bsr             set_vector
195
                lla             r1,cs:rte_jmp
196
                ldi             r2,#3
197
                bsr             set_vector
198
 
199
                ; setup Video BIOS vector
200
                lla             r1,cs:vb_jmp
201
                ldi             r2,#10
202
                bsr             set_vector
203
 
204
                ; setup NMI vector
205
                lla             r1,cs:nmi_jmp
206
                ldi             r2,#254
207
                bsr             set_vector
208
 
209
                lla             r1,cs:svc_jmp
210
                ldi             r2,#190
211
                bsr             set_vector
212
                lla             r1,cs:rsc_jmp
213
                ldi             r2,#191
214
                bsr             set_vector
215
 
216
                ; spurious interrupt
217
                ;
218
                lla             r1,cs:spur_jmp
219
                ldi             r2,#192
220
                bsr             set_vector
221
 
222
                ; setup MSI vector
223
                sh              r0,Milliseconds
224
                lla             r1,cs:msi_jmp
225
                ldi             r2,#193
226
                bsr             set_vector
227
 
228
                ; setup BTNU vector
229
                lla             r1,cs:btnu_jmp
230
                ldi             r2,#200
231
                bsr             set_vector
232
 
233
                ; setup KM vector
234
                lla             r1,cs:km_jmp
235
                ldi             r2,#245
236
                bsr             set_vector
237
 
238
                ; setup data bus error vector
239
                lla             r1,cs:dbe_jmp
240
                ldi             r2,#251
241
                bsr             set_vector
242
 
243
                ldi             r1,#JCB_Array
244
                sw              r1,zs:RunningJCB_
245
                sw              r1,zs:IOFocusNdx_       ; set I/O focus to BIOS
246
                ldi             r1,#TCB_Array
247
                sw              r1,zs:RunningTCB_
248
                sb              r0,zs:iof_switch_       ; reset switch flag
249
                mov             tr,r0
250
;               bsr             KeybdInit
251
 
252
;               jsr             FMTKInitialize_
253
 
254
                ; Initialize PIC
255
                ldi             r1,#%00000111           ; nmi, time slice interrupt is edge sensitive
256
                sh              r1,hs:PIC_ES
257
                ldi             r1,#%000000111          ; enable time slice interrupt, msi, nmi
258
                sh              r1,hs:PIC_IE
259
 
260
                ; Initialize random number generator
261
                ; m_z and m_w must not be zero
262
                ldi             r1,#$88888888
263
                sh              r1,m_w
264
                ldi             r1,#$77777777
265
                sh              r1,m_z
266
 
267
                mov             r1,r0
268
                mov             r2,r0
269
                mov             r3,r0
270
                mov             r4,r0
271
                mov             r5,r0
272
 
273
                ldi             r1,#1
274
                sc              r1,hs:LEDS
275
 
276
                tlbwrreg DMA,r0                         ; clear TLB miss registers
277
                tlbwrreg IMA,r0
278
                ldi                     r1,#2                   ; 2 wired registers
279
                tlbwrreg        Wired,r1
280
                ldi                     r1,#$2                  ; 64kiB page size
281
                tlbwrreg        PageSize,r1
282
 
283
                ; setup the first translation
284
                ; virtual page $FFFF0000 maps to physical page $FFFF0000
285
                ; This places the BIOS ROM at $FFFFxxxx in the memory map
286
                ldi                     r1,#$80000101   ; ASID=zero, G=1,valid=1
287
                tlbwrreg        ASID,r1
288
                ldi                     r1,#$0FFFF
289
                tlbwrreg        VirtPage,r1
290
                tlbwrreg        PhysPage,r1
291
                tlbwrreg        Index,r0                ; select way #0
292
                tlbwi                                           ; write to TLB entry group #0 with hold registers
293
 
294
                ; setup second translation
295
                ; virtual page 0 maps to physical page 0
296
                ldi                     r1,#$80000101   ; ASID=zero, G=1,valid=1
297
                tlbwrreg        ASID,r1
298
                tlbwrreg        VirtPage,r0
299
                tlbwrreg        PhysPage,r0
300
                ldi                     r1,#8                   ; select way#1
301
                tlbwrreg        Index,r1
302
                tlbwi                                           ; write to TLB entry group #0 with hold registers
303
 
304
                ; turn on the TLB
305
;               tlben
306
 
307
                ; enable maskable interrupts
308
                ; Interrupts also are not enabled until an RTI instruction is executed.
309
                ; there will likely be a timer interrupt outstanding so this
310
                ; should go to the timer IRQ.
311
                cli
312
 
313
                ; now globally enable interrupts using the RTI instruction, this will also
314
                ; switch to core to application/user mode.
315
                ldis    c14,#j1                 ; c14 contains RTI return address
316
                sync
317
                rti
318
j1:
319
                ldi             r1,#2
320
                sc              r1,hs:LEDS
321
                sb              r0,EscState
322
                bsr             SerialInit
323
;               bsr             Debugger
324
                ldi             r2,#msgStartup
325
                ldis    lc,#msgStartupEnd-msgStartup-1
326
j3:
327
;               lbu             r1,[r2]
328
;               addui   r2,r2,#1
329
;               tst             p0,r1
330
;p0.eq  br              j2
331
;               bsr             SerialPutChar
332
;               loop    j3
333
j2:
334
                bsr             VideoInit
335
                bsr             VBClearScreen
336
;               bsr             VBClearScreen2
337
                ldi             r1,#3
338
                sc              r1,hs:LEDS
339
                mov             r1,r0
340
                mov             r2,r0
341
                ldi             r6,#2           ; Set Cursor Pos
342
                sys             #10
343
                ldi             r1,#6
344
                sc              r1,hs:LEDS
345
                bsr             alphabet
346
                lla             r1,cs:msgStartup        ; convert to linear address
347
                ldi             r6,#$14
348
                sys             #10
349
 
350
;------------------------------------------------------------------------------
351
;------------------------------------------------------------------------------
352
; Monitor
353
;------------------------------------------------------------------------------
354
;------------------------------------------------------------------------------
355
 
356
Monitor:
357
                lla             r1,cs:msgMonitor
358
                bsr             VBDisplayString
359
 
360
                ; Display monitor prompt
361
.prompt:
362
                ldi             r1,#CR
363
                bsr             VBDisplayChar
364
                ldi             r1,#LF
365
                bsr             VBDisplayChar
366
                ldi             r1,#'$'
367
                bsr             VBDisplayChar
368
                bsr             CursorOn
369
.getkey:
370
                bsr             KeybdGetCharWait
371
                bsr             VBDisplayChar
372
                cmpi    p0,r1,#CR
373
p0.ne   br              .getkey
374
                bsr             CursorOff
375
                lcu             r1,CursorY
376
                lcu             r7,Textcols
377
                mtspr   lc,r7                           ; use loop counter as safety
378
                mulu    r10,r1,r7                       ; pos = row * cols
379
                _4addu  r10,r10,r0                      ; pos *= 4
380
.0001:
381
                bsr             MonGetch1                       ; get character skipping spaces
382
                cmpi    p0,r1,#'$'                      ; skip over prompt
383
p0.eq   br              .0001
384
                cmpi    p0,r1,#'d'                      ; debug ?
385
p0.eq   bsr             Debugger
386
p0.eq   br              .prompt
387
                cmpi    p0,r1,#'g'
388
p0.eq   bsr             GoGraphics
389
p0.eq   br              .prompt
390
                cmpi    p0,r1,#'t'
391
p0.eq   bsr             MonGetch
392
p0.eq   cmpi    p0,r1,#'x'
393
p0.eq   bsr             GoText
394
p0.eq   br              .prompt
395
                cmpi    p0,r1,'r'
396
p0.eq   bsr             RandomDots
397
p0.eq   br              .prompt
398
                cmpi    p0,r1,#'c'
399
p0.eq   bsr             VBClearScreen
400
p0.eq   mov             r1,r0
401
p0.eq   mov             r2,r0
402
p0.eq   ldi             r6,#2
403
p0.eq   sys             #10
404
                br              .prompt
405
 
406
;------------------------------------------------------------------------------
407
; Returns:
408
;       r1  ascii code for character
409
;       r10 incremented
410
;   lc  decremented
411
;------------------------------------------------------------------------------
412
 
413
MonGetch:
414
                addui   r31,r31,#-8
415
                sws             c1,[r31]
416
                lhu             r1,hs:[r10]
417
                andi    r1,r1,#$3ff
418
                bsr             VBScreenToAscii
419
                addui   r10,r10,#4
420
                loop    .0001                   ; decrement loop counter
421
.0001:
422
                lws             c1,[r31]
423
                addui   r31,r31,#8
424
                rts
425
 
426
;------------------------------------------------------------------------------
427
; Returns:
428
;       r1  ascii code for character
429
;       r10 incremented by number of spaces + 1
430
;   lc  decremented by number of spaces + 1
431
;------------------------------------------------------------------------------
432
 
433
MonGetch1:
434
                addui   r31,r31,#-8
435
                sws             c1,[r31]
436
.0001:
437
                lhu             r1,hs:[r10]
438
                andi    r1,r1,#$3ff
439
                bsr             VBScreenToAscii
440
                addui   r10,r10,#4
441
                cmpi    p0,r1,#' '
442
p0.leu  loop    .0001
443
                lws             c1,[r31]
444
                addui   r31,r31,#8
445
                rts
446
 
447
;------------------------------------------------------------------------------
448
; Go into graphics mode, four lines of text at bottom.
449
;------------------------------------------------------------------------------
450
 
451
GoGraphics:
452
                lhu             r3,Vidregs
453
                ldi             r1,#4
454
                sc              r1,Textrows
455
                sh              r1,hs:4[r3]             ; # rows
456
                ldi             r1,#240
457
                sh              r1,hs:12[r3]    ; window top
458
                mov             r1,r0                   ; reset cursor position
459
                mov             r2,r0
460
                ldi             r6,#2
461
                sys             #10
462
                rts
463
 
464
;------------------------------------------------------------------------------
465
; Go back to full text mode.
466
;------------------------------------------------------------------------------
467
 
468
GoText:
469
                lhu             r3,Vidregs
470
                ldi             r1,#31
471
                sc              r1,Textrows
472
                sh              r1,hs:4[r3]             ; # rows
473
                ldi             r1,#17
474
                sh              r1,hs:12[r3]    ; window top
475
                mov             r1,r0                   ; reset cursor position
476
                mov             r2,r0
477
                ldi             r6,#2
478
                sys             #10
479
                rts
480
 
481
// ----------------------------------------------------------------------------
482
// Uses George Marsaglia's multiply method
483
//
484
// m_w = ;    /* must not be zero */
485
// m_z = ;    /* must not be zero */
486
//
487
// uint get_random()
488
// {
489
//     m_z = 36969 * (m_z & 65535) + (m_z >> 16);
490
//     m_w = 18000 * (m_w & 65535) + (m_w >> 16);
491
//     return (m_z << 16) + m_w;  /* 32-bit result */
492
// }
493
// ----------------------------------------------------------------------------
494
//
495
gen_rand:
496
                addui   r31,r31,#-8
497
                sw              r2,[r31]
498
                lhu             r1,m_z
499
                mului   r2,r1,#36969
500
                shrui   r1,r1,#16
501
                addu    r2,r2,r1
502
                sh              r2,m_z
503
 
504
                lhu             r1,m_w
505
                mului   r2,r1,#18000
506
                shrui   r1,r1,#16
507
                addu    r2,r2,r1
508
                sh              r2,m_w
509
rand:
510
                lhu             r1,m_z
511
                shli    r1,r1,#16
512
                addu    r1,r1,r2
513
                lw              r2,[r31]
514
                addui   r31,r31,#8
515
                rts
516
 
517
// ----------------------------------------------------------------------------
518
// Display random dots on the graphics screen.
519
// ----------------------------------------------------------------------------
520
 
521
RandomDots:
522
                addui   r31,r31,#-8
523
                sws             c1,[r31]                ; stack the return address
524
                mov             r4,r0
525
.0001:
526
                bsr             gen_rand                ; get random bitmap memory location
527
                modui   r2,r1,#172032   ; mod the memory size
528
                _2addui r2,r2,#$FFA00000        ; *2 for 16 bit data, generate address
529
                bsr             gen_rand                ; get random color
530
                modui   r3,r1,#$1000    ; limit to 12 bits
531
                sc              r3,zs:[r2]              ; store color in memory
532
                addui   r4,r4,#1                ; increment loop index
533
                andi    r4,r4,#$FFF             ;
534
                tst             p1,r4                   ; check if time to check for keypress
535
p1.ne   br              .0001
536
                bsr             KeybdGetCharNoWait      ; try get a key, but don't wait
537
                tst             p1,r1                   ; branch if no key pressed
538
p1.lt   br              RandomDots.0001
539
                lws             c1,[r31]                ; restore return address
540
                addui   r31,r31,#8
541
                rts
542
 
543
;------------------------------------------------------------------------------
544
 
545
msgStartup:
546
                byte    "Thor Test System Starting...",CR,LF,0
547
msgStartupEnd:
548
msgMonitor:
549
                byte    CR,LF
550
                byte    "d  - run debugger",CR,LF
551
                byte    "g  - graphics mode",CR,LF
552
                byte    "tx - text mode",CR,LF
553
                byte    "r  - random dots",CR,LF
554
                byte    0
555
 
556
bad_ram:
557
                ldi             r1,#'B'
558
                bsr             VBAsciiToScreen
559
                ori             r1,r1,#%011000000_111111111_00_00000000
560
                sh              r1,hs:TEXTSCR+16
561
.bram1: br              .bram1
562
 
563
;------------------------------------------------------------------------------
564
; alphabet:
565
;
566
; Display the alphabet across the top of the screen.
567
;------------------------------------------------------------------------------
568
 
569
alphabet:
570
                addui   sp,sp,#-8
571
                sws             c1,[sp]                 ; store off return address
572
                ldi             r5,#'A'                 ; the first char
573
                ldi             r3,#TEXTSCR             ; screen address
574
                ldis    lc,#25                  ; 25 chars
575
.0001:
576
                mov             r1,r5                   ; r1 = ascii letter
577
                bsr             VBAsciiToScreen ; r1 = screen char
578
                lhu             r2,NormAttr             ; r2 = attribute
579
                or              r1,r1,r2                ; r1 = screen char + attribute
580
                sh              r1,hs:[r3]              ; store r1 to screen
581
                addui   r5,r5,#1                ; increment to next char
582
                addui   r3,r3,#4                ; increment to next screen loc
583
                loop    .0001                   ; loop back
584
                lws             c1,[sp]                 ; restore return address
585
                addui   sp,sp,#8
586
                rts
587
 
588
;------------------------------------------------------------------------------
589
; Set interrupt vector
590
;
591
; Parameters:
592
;       r1 = linear address of jump code
593
;       r2 = vector number to set
594
; Trashes: r2,r3,r5,p0
595
;------------------------------------------------------------------------------
596
 
597
set_vector:
598
                mfspr   r3,c12                  ; get base address of interrupt table
599
                _16addu r2,r2,r3
600
                lh              r3,zs:[r1]
601
                cmpi    p0,r3,#$003F6F01        ; unitialized interrupt number load
602
p0.eq   shli    r5,r2,#18
603
p0.eq   or              r3,r3,r5
604
                sh              r3,zs:[r2]
605
                lh              r3,zs:4[r1]
606
                sh              r3,zs:4[r2]
607
                lh              r3,zs:8[r1]
608
                sh              r3,zs:8[r2]
609
                lh              r3,zs:12[r1]
610
                sh              r3,zs:12[r2]
611
                rts
612
 
613
.include "c:\cores4\thor\trunk\software\FMTK\source\kernel\FMTKc.s"
614
.include "c:\cores4\thor\trunk\software\FMTK\source\kernel\FMTKmsg.s"
615
.include "c:\cores4\thor\trunk\software\FMTK\source\kernel\TCB.s"
616
.include "c:\cores4\thor\trunk\software\FMTK\source\kernel\IOFocusc.s"
617
.include "c:\cores4\thor\trunk\software\FMTK\source\kernel\console.s"
618
.include "c:\cores4\thor\trunk\software\FMTK\source\kernel\keybd.s"
619
.include "c:\cores4\thor\trunk\software\FMTK\source\kernel\PIC.s"
620
.include "c:\cores4\thor\trunk\software\FMTK\source\kernel\LockSemaphore.s"
621
.include "c:\cores4\thor\trunk\software\FMTK\source\kernel\UnlockSemaphore.s"
622
.include "c:\cores4\thor\trunk\software\FMTK\source\shell.s"
623
.include "c:\cores4\thor\trunk\software\FMTK\source\memmgnt.s"
624
.include "c:\cores4\thor\trunk\software\c64libc\source\stdio.s"
625
.include "c:\cores4\thor\trunk\software\c64libc\source\ctype.s"
626
.include "c:\cores4\thor\trunk\software\c64libc\source\string.s"
627
;.include "c:\cores4\thor\trunk\software\c64libc\source\prtdbl.s"
628
.include "c:\cores4\thor\trunk\software\c64libc\source\Thor\getCPU.s"
629
.include "c:\cores4\thor\trunk\software\c64libc\source\Thor\outb.s"
630
.include "c:\cores4\thor\trunk\software\c64libc\source\Thor\outc.s"
631
.include "c:\cores4\thor\trunk\software\c64libc\source\Thor\outh.s"
632
.include "c:\cores4\thor\trunk\software\c64libc\source\Thor\outw.s"
633
.include "video.asm"
634
.include "serial.asm"
635
.include "keyboard_codes.asm"
636
.include "keybd2.asm"
637
;.include "keyboard.asm"
638
.include "debugger.asm"
639
 
640
;------------------------------------------------------------------------------
641
; BTNU IRQ routine.
642
;
643
;------------------------------------------------------------------------------
644
;
645
btnu_rout:
646
                sync
647
                addui   r31,r31,#-24
648
                sw              r1,[r31]
649
                sws             hs,8[r31]
650
                sws             hs.lmt,16[r31]
651
 
652
                ; set I/O segment
653
                ldis    hs,#$FFD00000
654
                ldis    hs.lmt,#$100000
655
 
656
                ; update on-screen IRQ live indicator
657
                inc.h   hs:TEXTSCR+312
658
 
659
                ; restore regs and return
660
                lw              r1,[r31]
661
                lws             hs,8[r31]
662
                lws             hs.lmt,16[r31]
663
                addui   r31,r31,#24
664
                sync
665
                rti
666
 
667
;------------------------------------------------------------------------------
668
;------------------------------------------------------------------------------
669
 
670
spur_rout:
671
                sync
672
                addui   r31,r31,#-24
673
                sw              r1,[r31]
674
                sws             hs,8[r31]
675
                sws             hs.lmt,16[r31]
676
 
677
                ; set I/O segment
678
                ldis    hs,#$FFD00000
679
                ldis    hs.lmt,#$100000
680
 
681
;               ldi             r1,#18
682
;               sc              r1,hs:LEDS
683
 
684
                ; update on-screen IRQ live indicator
685
                inc.h   hs:TEXTSCR+316
686
 
687
                ; restore regs and return
688
                lw              r1,[r31]
689
                lws             hs,8[r31]
690
                lws             hs.lmt,16[r31]
691
                addui   r31,r31,#24
692
                sync
693
                rti
694
 
695
;------------------------------------------------------------------------------
696
; Uninitialized interrupt
697
;------------------------------------------------------------------------------
698
uii_rout:
699
                sync
700
                addui   r31,r31,#-24
701
                sw              r1,[r31]
702
                sws             hs,8[r31]
703
                sws             hs.lmt,16[r31]
704
 
705
                ; set I/O segment
706
                ldis    hs,#$FFD00000
707
                ldis    hs.lmt,#$100000
708
 
709
                ; update on-screen IRQ live indicator
710
                ldi             r1,#'U'|%011000000_111111111_00_00000000
711
                sh              r1,hs:TEXTSCR+320
712
 
713
                mov             r5,r63
714
                sc              r63,hs:LEDS
715
                bsr             DisplayAddr
716
 
717
                ldi             r6,#2
718
                ldi             r2,#0
719
                ldi             r7,#0
720
.0001:
721
                ldis    60,#18          ; set breakout index to 18
722
                sync
723
                mtspr   61,r7           ; select history reg #
724
                sync
725
                ldis    60,#16          ; set breakout index to 16
726
                sync
727
                mfspr   r5,61           ; get address
728
                bsr             DisplayAddr
729
                addui   r2,r2,#1
730
                ldis    60,#17          ; set breakout index to 17
731
                sync
732
                mfspr   r5,61           ; get address
733
                bsr             DisplayAddr
734
                addui   r2,r2,#1
735
                addui   r7,r7,#1
736
                cmpi    p0,r7,#63
737
p0.ltu  br              .0001
738
 
739
uii_hang:
740
                br              uii_hang
741
                ; restore regs and return
742
                lw              r1,[r31]
743
                lws             hs,8[r31]
744
                lws             hs.lmt,16[r31]
745
                addui   r31,r31,#24
746
                sync
747
                rti
748
 
749
;------------------------------------------------------------------------------
750
; Non-maskable interrupt routine.
751
;
752
;------------------------------------------------------------------------------
753
;
754
nmi_rout:
755
                sync
756
                addui   r31,r31,#-24
757
                sw              r1,[r31]
758
                sws             hs,8[r31]
759
                sws             hs.lmt,16[r31]
760
 
761
                ; set I/O segment
762
                ldis    hs,#$FFD00000
763
                ldis    hs.lmt,#$100000
764
 
765
                ldi             r1,#16
766
                sc              r1,hs:LEDS
767
 
768
                ; reset the edge sense circuit to re-enable interrupts
769
                ldi             r1,#0
770
                sh              r1,hs:PIC_ESR
771
 
772
                ; update on-screen IRQ live indicator
773
                lh              r1,hs:TEXTSCR+324
774
                addui   r1,r1,#1
775
                sh              r1,hs:TEXTSCR+324
776
 
777
                ; restore regs and return
778
                lw              r1,[r31]
779
                lws             hs,8[r31]
780
                lws             hs.lmt,16[r31]
781
                addui   r31,r31,#24
782
                sync
783
                rti
784
 
785
;------------------------------------------------------------------------------
786
; Millisecond (1024 Hz) interrupt routine.
787
;
788
;------------------------------------------------------------------------------
789
;
790
msi_rout:
791
                sync
792
                addui   sp,sp,#-32
793
                sw              r1,[sp]
794
                sws             hs,8[sp]
795
                sws             hs.lmt,16[sp]
796
                sws             c1,24[sp]
797
 
798
                ; set I/O segment
799
                ldis    hs,#$FFD00000
800
                ldis    hs.lmt,#$100000
801
 
802
                ldi             r1,#24
803
                sc              r1,hs:LEDS
804
 
805
                ; reset the edge sense circuit to re-enable interrupts
806
                ldi             r1,#1
807
                sh              r1,hs:PIC_ESR
808
 
809
                ; update milliseconds
810
                lw              r1,zs:Milliseconds
811
                addui   r1,r1,#1
812
                sw              r1,zs:Milliseconds
813
 
814
                ; restore regs and return
815
                lw              r1,[sp]
816
                lws             hs,8[sp]
817
                lws             hs.lmt,16[sp]
818
                lws             c1,24[sp]
819
                addui   sp,sp,#32
820
                sync
821
                rti
822
 
823
;------------------------------------------------------------------------------
824
; Time Slice IRQ routine.
825
;
826
;------------------------------------------------------------------------------
827
;
828
tms_rout:
829
                sync
830
                addui   r31,r31,#-24
831
                sw              r1,[r31]
832
                sws             hs,8[r31]
833
                sws             hs.lmt,16[r31]
834
 
835
                ; set I/O segment
836
                ldis    hs,#$FFD00000
837
                ldis    hs.lmt,#$100000
838
 
839
                ldi             r1,#32
840
                sc              r1,hs:LEDS
841
 
842
                ; reset the edge sense circuit to re-enable interrupts
843
                ldi             r1,#2
844
                sh              r1,hs:PIC_ESR
845
 
846
                ; update on-screen IRQ live indicator
847
                inc.h   hs:TEXTSCR+328
848
 
849
                ; restore regs and return
850
                lw              r1,[r31]
851
                lws             hs,8[r31]
852
                lws             hs.lmt,16[r31]
853
                addui   r31,r31,#24
854
                sync
855
                rte
856
 
857
;------------------------------------------------------------------------------
858
; Data bus error routine.
859
;
860
;
861
;------------------------------------------------------------------------------
862
;
863
dbe_rout:
864
                sync
865
                ldi             r31,#INT_STACK-24
866
                sw              r1,[r31]
867
                sws             hs,8[r31]
868
                sw              r5,16[r31]
869
 
870
                ; set I/O segment
871
                ldis    hs,#$FFD00000
872
 
873
                ldi             r1,#64
874
                sc              r1,hs:LEDS
875
 
876
                ; reset the bus error circuit to re-enable interrupts
877
                sh              r0,hs:$CFFE0
878
 
879
                ; update on-screen DBE indicator
880
                ldi             r1,'D'|%011000000_000000110_0000000000
881
                sh              r1,hs:TEXTSCR+320
882
 
883
                ; Advance the program to the next address
884
                mfspr   r5,c14
885
                bsr             DBGGetInsnLength
886
                addu    r1,r5,r1
887
                mtspr   c14,r1
888
 
889
                ; restore regs and return
890
                lw              r1,[r31]
891
                lws             hs,8[r31]
892
                lw              r5,16[r31]
893
                sync
894
                rti
895
 
896
;------------------------------------------------------------------------------
897
; Break routine
898
;
899
; Currently uses only registers in case memory is bad, and sets an indicator
900
; on-screen.
901
;------------------------------------------------------------------------------
902
;
903
brk_rout:
904
                sync
905
                ldi             r1,#'B'
906
                bsr             VBAsciiToScreen
907
                ori             r1,r1,#|%011000000_111111111_00_00000000
908
                sh              r1,zs:$FFD10140
909
                ldi             r1,#'R'
910
                bsr             VBAsciiToScreen
911
                ori             r1,r1,#|%011000000_111111111_00_00000000
912
                sh              r1,zs:$FFD10144
913
                ldi             r1,#'K'
914
                bsr             VBAsciiToScreen
915
                ori             r1,r1,#|%011000000_111111111_00_00000000
916
                sh              r1,zs:$FFD10148
917
                ldi             r2,#10
918
                ldi             r6,#0
919
                mfspr   r5,c13
920
                bsr             DisplayAddr
921
                ldi             r2,#10
922
                ldi             r6,#1
923
                mfspr   r5,c14
924
                bsr             DisplayAddr
925
                ldi             r6,#2
926
                ldi             r2,#0
927
                ldi             r7,#0
928
.0001:
929
                ldis    60,#18          ; set breakout index to 18
930
                sync
931
                mtspr   61,r7           ; select history reg #
932
                sync
933
                ldis    60,#16          ; set breakout index to 16
934
                sync
935
                mfspr   r5,61           ; get address
936
                bsr             DisplayAddr
937
                addui   r2,r2,#1
938
                ldis    60,#17          ; set breakout index to 17
939
                sync
940
                mfspr   r5,61           ; get address
941
                bsr             DisplayAddr
942
                addui   r2,r2,#1
943
                addui   r7,r7,#1
944
                cmpi    p0,r7,#63
945
p0.ltu  br              .0001
946
 
947
brk_lockup:
948
                br              brk_lockup[c0]
949
 
950
; code snippet to jump to the break routine, copied to the break vector
951
;
952
; vector table jumps
953
;
954
                align   8
955
brk_jmp:
956
                jmp             brk_rout[c0]
957
                align   8
958
tms_jmp:
959
                jmp             tms_rout[c0]
960
                align   8
961
msi_jmp:
962
                jmp             msi_rout[c0]
963
                align   8
964
nmi_jmp:
965
                jmp             nmi_rout[c0]
966
                align   8
967
uii_jmp:
968
                ldi             r63,#00
969
                jmp             uii_rout[c0]
970
                align   8
971
vb_jmp:
972
                jmp             VideoBIOSCall[c0]
973
                align   8
974
dbe_jmp:
975
                jmp             dbe_rout[c0]
976
                align   8
977
svc_jmp:
978
                jmp             save_context[c0]
979
                align   8
980
rsc_jmp:
981
                jmp             restore_context[c0]
982
                align   8
983
spur_jmp:
984
                jmp             spur_rout[c0]
985
                align   8
986
btnu_jmp:
987
                jmp             btnu_rout[c0]
988
                align   8
989
rti_jmp:
990
km_jmp:
991
                rti
992
                align   8
993
rte_jmp:
994
                rte
995
 
996
 

powered by: WebSVN 2.1.0

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