 sttl Interrupt Processing
 pag

*
* This routine handles all IRQ interrupts
*
 if DBG_TRMI&DEBUG_CONTROL
IRQmsg00 fcc $d,'IRQ - D: ',0
IRQmsg01 fcc ', Y: ',0
IRQmsg02 fcc ', Stat: ',0
IRQmsg90 fcc $d,'Check IRQ, Dev: ',0
IRQmsg91 fcc ', Routine: ',0
 endif
*
IRQ_han
*-- Check for clock interrupt
 lda #CLKMSK get clock mask
 bita CLKSEL check clock int
 beq 00f no - try something else
 ldd CLKLAT reset timer interrupt
 jsr clkint go process interrupt
 lbra 99f exit
*
00 ldu #dev_tab scan devices
 ldd #0 start with device 0
10 ldx dev_addr,u get device address
 beq 20f jump if none there
 ldy dev_type,u get device type
 if DBG_TRMI&DEBUG_CONTROL
 jsr DB_msg
 fdb DBG_TRMI,15f
 pshs d,x,y,u
 ldx #IRQmsg90
 jsr DB_pdata
 ldd 2,s
 jsr DB_phex2
 ldx #IRQmsg91
 jsr DB_pdata
 ldd D_inthan,y
 jsr DB_phex2
 puls d,x,y,u
 endif
15 jsr [D_inthan,y] call interrupt poller/handler
 lbcs 99f exit if interrupt serviced
20 addd #1 next device
 leau DEV_SIZE,u
 cmpd #MAX_DEV any more devices?
 blo 10b
* Check for FIO Mailbox interrupt
 lda cpu_iopF see if mailbox interrupt
 beq 50f no - move on
 if DO_HISTORY
 jsr H_cpu record transaction in history Queue
 endif
 if DBG_INT&DEBUG_CONTROL
 jsr DB_msg
 fdb DBG_INT,25f
 pshs d,x,y,u
 ldx #IRQmsg10
 lbsr DB_pdata
 ldu #cpu_iop
0 lda ,u+
 lbsr DB_phex
 lbsr DB_outsp
 cmpu #cpu_iop3
 bls 0b
 puls d,x,y,u
 endif
25 ldx int_ptr input message pointer
 lda cpu_iop move message
 sta ,x+
 lda cpu_iop1
 sta ,x+
 lda cpu_iop2
 sta ,x+
 lda cpu_iop3
 sta ,x+
 tst irq_gen reset interrupt
 clr cpu_iopF indicate message consumed
 stx int_ptr update pointer
 ldy #int_buf get message from buffer
 lda 0,y -- Send interrupt command?
 cmpa #O_INTRPT
 bne 30f
 sty int_ptr reset pointer
 ldb 3,y get terminal #
 cmpb NUM_TRM is this a TTY device?
 bhs 99f no - ignore message
 jsr send_int
 bra 99f exit
*
30 ldx tsktab search for an available task
 ldb NUM_TSK Number of tasks in system
32 lda tsstat,x
 cmpa #TFREE looking for a "free" task
 beq 40f
 leax TSKSIZ,x
 decb
 bne 32b
 pshs d,x
 ldx #00f
 jsr DB_pdata
 jsr DB_main
 puls d,x
 ldb #E_SYSBSY can't process - IOP saturated!
 jsr fio_msg
 bra 99f exit
40 ldy #int_buf get message from buffer
 sty int_ptr reset pointer
 ldb ,y+ command byte
 stb tscmd,x save for task
 lda ,y+ sequence #
 sta tsseq,x
 ldb ,y+ command specific data
 stb tstval,x
 lda ,y+ associate with terminal
 sta tsdev,x
** -- Removed 2/21/85
** lda #RUNPRI make highest possible priority
** sta tsprir,x
 jsr makrdy make task ready to run
** ldx utask don't switch if this was the system running
** cmpx tsktab
** beq 99f
** jsr change -- whatever I was doing can wait...
 bra 99f exit
*
50 lbsr DB_check enter debugger?
 bcc 99f
 lbsr DB_main
*
99 rti return from interrupt
*
IRQmsg10 fcc $d,'IOP Got: ',0
00 fcc '-- No tasks!',0
