I'm trying to get exception handling running on a MIPS32R2 CPU. To be specific a Broadcom BCM5356 SoC on some cheap wifi router.
Whenever I'm triggering an exception(tried with: syscall instruction, division through 0 or UART interrupt) the system freezes. It doesn't seem to jump to the exception handler, and it doesn't execute the instructions after the one that caused the exception.
Right now all the assembler exception handler does is writing 'c' characters to the UART in an infinite loop for testing purposes, but I don't receive any of them(if I call the exception handler manually I see the expected output, so that should work).
I'm testing on real hardware and debugging through serial/UART output.
What my kernel is doing so far is:
- - Setting up the stack
- Jumping to C code where I have a tiny printf() implementation outputting text over the UART
- clear the CP0 Status and Cause registers
- memcpy() the exception handler to the general exception handler address, which should be 0x80000180(also tried 0x8000000 and 0x80000200)
- trigger exception with either:- * syscall instruction. system freezes
* division by 0. when I trigger with div by 0, sometimes I receive an infinite stream of 'a' characters. I have double checked and verified that nowhere in my code I'm sending these characters, and I don't know where they're coming from.
* enabling the IE bit and the IM bit corresponding to the UART in CP0_STATUS and triggering an UART interrupt. system freezes
- * syscall instruction. system freezes
I read the Exception handling parts in the MIPS32 manual Volume 3 and can't find anything that I might be doing wrong. Any hints are very much appreciated!
- Thomas