Skip to content

Commit 8ac3c95

Browse files
committed
Add Wait for Interrupt instruction (WFI)
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: #310
1 parent 9759ad2 commit 8ac3c95

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/decode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,8 @@ static inline bool op_system(rv_insn_t *ir, const uint32_t insn)
835835
ir->opcode = rv_insn_ebreak;
836836
break;
837837
case 0x105: /* WFI: Wait for Interrupt */
838+
ir->opcode = rv_insn_wfi;
839+
break;
838840
case 0x002: /* URET: return from traps in U-mode */
839841
case 0x202: /* HRET: return from traps in H-mode */
840842
/* illegal instruction */

src/rv32_template.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,9 @@ RVOP(
982982
RVOP(
983983
wfi,
984984
{
985+
PC += 4;
985986
/* FIXME: Implement */
986-
return false;
987+
goto end_op;
987988
},
988989
GEN({
989990
assert; /* FIXME: Implement */

0 commit comments

Comments
 (0)