I got a question about vectored trap handling. Long story short:
- Traps can be either sync exceptions or async interrupts
- In vectored mode the vector table is accessed like this:
- Exceptions: PC = BASE (fixed entry point)
- IRQs: PC = BASE+4*CAUSE (vectored) Problem is that of course if CAUSE = 0 there is ambiguity. Since CAUSE = 0 hold true for user-software interrupts, the manuale (sec 3.1.7) says:
When vectored interrupts are enabled, interrupt cause 0, which corresponds to user-mode soft- ware interrupts, are vectored to the same location as synchronous exceptions. This ambiguity does not arise in practice, since user-mode software interrupts are either disabled or delegated to a less-privileged mode
Now, I understand that in M-mode, U-interrupts are disabled. But what if an exception arrives while I'm in U-mode? Am I missing something like that exceptions are handled in M-mode only? Also, I don't understand why there is no ambiguity if the handler is exactly the same. Shouldn't software test if the trap occured because of an exception or the user-software interrupt?