1

I am writing a kernel for the MIPS Malta board using QEMU and I am having difficulties getting keyboard interrupts to work. I've set the keyboard and display interrupt bits (bits 11 and 12) in the coprocessor 0 STATUS register and enabled interrupts by setting bit 0 as well. To my understanding, this should cause an interrupt when running the binary and pressing a key, but it doesn't.

I'm running Qemu with these flags

-M malta -m 256 -serial stdio -device usb-mouse -device usb-kbd -show-cursor

and this is the code that sets the interrupt enable bits

mfc0    T1, $12
li      T2, 0x1800
ori     T2, 0x1
or      T2, T2, T1
mtc0    T2, $12

Am I missing something in the above code segment? Do I have to enable interrupts for the keyboard in a device control register as well? Thankful for any help!

  • I'm not familiar with that board, but a simpler way to write the same sequence would be `mfc0 $t1, $12` / `ori $t2, $t1, 0x1801` / `mtfc $t2, $12`. `ori` supports a 16-bit immediate. (And if you did need to build a constant in another reg, `li` supports an arbitrary 32-bit value, so there's no sense in using `ori` on an `li` result. Unless maybe you meant to write `lui` to get `0x1800 << 16`? But no, you did say you wanted to set bits 11, 12, and 0. – Peter Cordes May 04 '18 at 16:35

0 Answers0