Reputation: 231
Im writing an interrupt handler that takes keyboard interrupts and inputs them into a function in the program for a homework assignment. The current step I am on is:
Check the interrupt level. The MMIO Receiver Control interrupt is a hardware interrupt at level 1, which is the lowest (rightmost) bit in the interrupt masks in Fig. B.7.{1,2}, which is bit 8 = 0x0100. For this HW, we don’t care about any other interrupt levels, so if it doesn’t match this one, do nothing and exit.
I want to know how I go about that. So far my interrupt is like this:
.ktext 0x80000180
Interrupt:
sw $at, saveat
sw $a0, save0
sw $a1, save1
mfc0 $k0, $13 #$k0 = Cause
mfc0 $k1, $14 #$k1 = EPC
andi $k0, $k0, 0x003c # $k0 = Exception Code
bnez $k0, done # If its not equal 0, its not a keyboard interrupt, done
At this point I need to check the interrupt level, but I am unsure how this is actually done in code. Can anyone help me? Thanks!
Upvotes: 1
Views: 804
Reputation: 1967
If $k0 is your cause, I would assume that stores the level as well. What about doing something like this?
andi $t0, $k0, 0x003c # $t0 = Exception code, $k0 is preserved
bnez $t0, done #If its not equal 0, its not a keyboard interrupt, done
andi $t0, $k0, 0x0100 #Check to see if this bit is set in $k0
bnez $t0, done #If it is set, service the interrupt
#otherwise, go to done
#service the interrupt
done:
#clean up and exit
Upvotes: 2