Skip to content

Commit

Permalink
Add Wait for Interrupt instruction (WFI)
Browse files Browse the repository at this point in the history
The Wait for Interrupt instruction (WFI) provides a hint to the
implementation that the current hart can be stalled until an
interrupt might need servicing. As well, Linux kernel might call
wait_for_interrupt() to enter idle state. In this commit, we
could simply make PC + 4 and not really enter idle state.

Related: sysprog21#310
  • Loading branch information
ChinYikMing committed Jul 21, 2024
1 parent 9759ad2 commit 8ac3c95
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,8 @@ static inline bool op_system(rv_insn_t *ir, const uint32_t insn)
ir->opcode = rv_insn_ebreak;
break;
case 0x105: /* WFI: Wait for Interrupt */
ir->opcode = rv_insn_wfi;
break;
case 0x002: /* URET: return from traps in U-mode */
case 0x202: /* HRET: return from traps in H-mode */
/* illegal instruction */
Expand Down
3 changes: 2 additions & 1 deletion src/rv32_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,9 @@ RVOP(
RVOP(
wfi,
{
PC += 4;
/* FIXME: Implement */
return false;
goto end_op;
},
GEN({
assert; /* FIXME: Implement */
Expand Down

0 comments on commit 8ac3c95

Please sign in to comment.