rv32emu icon indicating copy to clipboard operation
rv32emu copied to clipboard

Support trap handling during block emulation

Open ChinYikMing opened this issue 8 months ago • 7 comments

Trap might occurs during block emulation, for example, page fault. In order to handle trap, we have to temporarily escape from block and jump to the trap handler to handle the trap PC by PC. Once trap is handled, resume the previous execution flow where cause the trap. To support this, we leverage setjmp function to store the state and a flag called is_trapped to indicate the emulation is in a trap handling mode currently. The sret and mret implementation are refactored to control the corresponding CSR before get out from trap.

Some S-mode CSRs are added to riscv_internal to support S-mode. S-mode, and M-mode CSR helper macros are also introduced, so that the CSR can be manipulated in an easier manner.

Related: #310

ChinYikMing avatar Jun 24 '24 01:06 ChinYikMing