CA Chap6 IO
CA Chap6 IO
CA Chap6 IO
Processor Devices
Control Output
Memory
Datapath Input
Interrupts
Processor
Cache
Graphics Network
Disk Disk
❑ Example MTTF:
Seagate ST33000655SS: 1,400,000 hours @25°C
Samsung 860 EVO SSD: 1,500,000 hours
li $s0, KEY_CODE
li $s1, KEY_READY
WaitForKey: lw $t1, 0($k1) # check data available
beq $t1, $zero, WaitForKey # if $t1 == 0 then Polling
ReadKey: lw $t0, 0($k0)
Exception
Interrupt
MIPS Status register ($12 in C0)
enable
mode
User
level
Interrupt mask
15 8 4 1 0
- Determines who can interrupt the processor (if Interrupt enable is 0,
none can interrupt)
MIPS Cause register ($13 in C0)
Branch Pending Exception
delay interrupts codes
31 15 8 6 2
- To enable a Pending interrupt, the correspond bit in the Interrupt
mask must be 1
- Once an interrupt occurs, the OS can find the reason in the
Exception codes field
IT3283, Fall 2022 35
Interrupt handling
❑ When an interrupt occurred: MIPS branch to interrupt
service routine located at 0x80000180 ➔ use directive
.ktext for interrupt service routine (ISR).
❑ Inside ISR
Check for interrupt source in Cause[6..2]
EPC ($14) stores return address
Exit from ISR with instruction eret (exception return). This
basically restores PC with value in EPC.
.data
Message: .asciiz "Someone's pressed a button.\n"
# MAIN Procedure
.text
main:
# Enable Digital Lab Sim keyboard interrupt
li $t1, IN_ADRESS_HEXA_KEYBOARD
li $t3, 0x80 # bit 7 for interrupt
sb $t3, 0($t1)
Loop: nop
nop
nop
nop
b Loop # Wait for interrupt
end_main: