Trap entry */
| 293 | |
| 294 | /* Trap entry */ |
| 295 | void handle_trap(rt_ubase_t scause, rt_ubase_t stval, rt_ubase_t sepc, |
| 296 | struct rt_hw_stack_frame *sp) |
| 297 | { |
| 298 | ENTER_TRAP; |
| 299 | rt_ubase_t id = __MASKVALUE(scause, __MASK(63UL)); |
| 300 | const char *msg; |
| 301 | |
| 302 | /* supervisor external interrupt */ |
| 303 | if ((SCAUSE_INTERRUPT & scause) && |
| 304 | SCAUSE_S_EXTERNAL_INTR == (scause & 0xff)) |
| 305 | { |
| 306 | rt_interrupt_enter(); |
| 307 | plic_handle_irq(); |
| 308 | rt_interrupt_leave(); |
| 309 | } |
| 310 | else if ((SCAUSE_INTERRUPT | SCAUSE_S_TIMER_INTR) == scause) |
| 311 | { |
| 312 | /* supervisor timer */ |
| 313 | rt_interrupt_enter(); |
| 314 | tick_isr(); |
| 315 | rt_interrupt_leave(); |
| 316 | } |
| 317 | else |
| 318 | { |
| 319 | if (SCAUSE_INTERRUPT & scause) |
| 320 | { |
| 321 | if (id < sizeof(Interrupt_Name) / sizeof(const char *)) |
| 322 | { |
| 323 | msg = Interrupt_Name[id]; |
| 324 | } |
| 325 | else |
| 326 | { |
| 327 | msg = "Unknown Interrupt"; |
| 328 | } |
| 329 | |
| 330 | LOG_E("Unhandled Interrupt %ld:%s\n", id, msg); |
| 331 | } |
| 332 | else |
| 333 | { |
| 334 | #ifdef ARCH_RISCV_VECTOR |
| 335 | if (scause == 0x2) |
| 336 | { |
| 337 | if (!(sp->sstatus & SSTATUS_VS) && |
| 338 | illegal_inst_recoverable(stval, sp)) |
| 339 | goto _exit; |
| 340 | } |
| 341 | #endif /* ARCH_RISCV_VECTOR */ |
| 342 | #ifdef RT_USING_SMART |
| 343 | if (!(sp->sstatus & 0x100) || (PAGE_FAULT && IN_USER_SPACE)) |
| 344 | { |
| 345 | handle_user(scause, stval, sepc, sp); |
| 346 | // if handle_user() return here, jump to u mode then |
| 347 | goto _exit; |
| 348 | } |
| 349 | #endif |
| 350 | |
| 351 | // handle kernel exception: |
| 352 | rt_kprintf("Unhandled Exception %ld:%s\n", id, |
nothing calls this directly
no test coverage detected