add isr support for cv32e41p

This commit is contained in:
Pascal Cotret 2022-02-14 22:09:46 +01:00
parent 86373605ce
commit d506b4418e
1 changed files with 34 additions and 0 deletions

View File

@ -76,6 +76,40 @@ void isr(void)
#define ECALL 11
#define RISCV_TEST
void isr(void)
{
unsigned int cause = csrr(mcause) & IRQ_MASK;
if (csrr(mcause) & 0x80000000) {
#ifndef UART_POLLING
if (cause == (UART_INTERRUPT+FIRQ_OFFSET)){
uart_isr();
}
#endif
} else {
#ifdef RISCV_TEST
int gp;
asm volatile ("mv %0, gp" : "=r"(gp));
printf("E %d\n", cause);
if (cause == INVINST) {
printf("Inv Instr\n");
for(;;);
}
if (cause == ECALL) {
printf("Ecall (gp: %d)\n", gp);
csrw(mepc, csrr(mepc)+4);
}
#endif
}
}
#elif defined(__cv32e41p__)
#define FIRQ_OFFSET 16
#define IRQ_MASK 0x7FFFFFFF
#define INVINST 2
#define ECALL 11
#define RISCV_TEST
void isr(void)
{
unsigned int cause = csrr(mcause) & IRQ_MASK;