Handling Interrupts
There are two kinds of interrupts, trap vectors and PLIC interrupts, and you handle them using different methods.
Trap Vectors
Trap vectors trap interrupts or exceptions from the system. Read the Machine Cause
Register (mcause) to identify which type of interrupt or exception
fthe system is generating. Refer to "Machine Cause Register (mcause): 0x342" in the
data sheet for your SoC for a list of the exceptions and interrupts used for trap
vectors. The following flow chart explains how to handle trap vectors.
For CAUSE_MACHINE_EXTERNAL, it will call the subroutine to process the PLIC level interrupts.
PLIC Interrupts
The PLIC collects external interrupts and is also used for CAUSE_MACHINE_EXTERNAL cases. Read the interrupt claim registers (PLIC claim) to identify the source of the external interrupt. Refer to Address Map for a list of the interrupt IDs.
The following flow chart shows how the PLIC handles interrupts.The PLIC identifies the interrupt ID and processes the corresponding interrupts.