Breaking out of the loop on WFI was intended to let other threads run
when the current thread has no work to do. There's no advantage to doing
so on CSR writes, and the unintentional change in thread interleaving
broke some test programs that relied on short timer periods.
STATE.pc = __npc; \
} while(0)
+#define wfi() \
+ do { set_pc_and_serialize(npc); \
+ npc = PC_SERIALIZE_WFI; \
+ } while(0)
+
#define serialize() set_pc_and_serialize(npc)
/* Sentinel PC values to serialize simulator pipeline */
#define PC_SERIALIZE_BEFORE 3
#define PC_SERIALIZE_AFTER 5
+#define PC_SERIALIZE_WFI 7
#define invalid_pc(pc) ((pc) & 1)
/* Convenience wrappers to simplify softfloat code sequences */
if (unlikely(invalid_pc(pc))) { \
switch (pc) { \
case PC_SERIALIZE_BEFORE: state.serialized = true; break; \
- case PC_SERIALIZE_AFTER: n = ++instret; break; \
+ case PC_SERIALIZE_AFTER: ++instret; break; \
+ case PC_SERIALIZE_WFI: n = ++instret; break; \
default: abort(); \
} \
pc = state.pc; \
require_privilege(get_field(STATE.mstatus, MSTATUS_TW) ? PRV_M : PRV_S);
-set_pc_and_serialize(npc);
+wfi();