Skip to content

Commit ab58cd2

Browse files
committed
Emulate OpenSBI for System Timer
1 parent 2983d31 commit ab58cd2

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

riscv_cpu.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
11301130
flag = 1;
11311131
flag = (cause & CAUSE_INTERRUPT) == 0;
11321132
//// Previously: if (cause == CAUSE_SUPERVISOR_ECALL || cause == CAUSE_ILLEGAL_INSTRUCTION)
1133-
if (cause == CAUSE_USER_ECALL) ////
1133+
if (cause == CAUSE_SUPERVISOR_ECALL || cause == CAUSE_USER_ECALL) ////
11341134
flag = 0;
11351135
#endif
11361136
if (flag) {
@@ -1149,9 +1149,7 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
11491149
//// Begin Test: Emulate OpenSBI for System Timer
11501150
if (cause == CAUSE_SUPERVISOR_ECALL) {
11511151
puts("TODO: Emulate OpenSBI for System Timer");
1152-
printf("Before pc=%p\n", s->pc); ////
11531152
s->pc += 4; // Jump to the next instruction (ret)
1154-
printf("After pc=%p\n", s->pc); ////
11551153
return;
11561154
}
11571155
//// End Test
@@ -1170,11 +1168,7 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
11701168
if (cause & CAUSE_INTERRUPT)
11711169
causel |= (target_ulong)1 << (s->cur_xlen - 1);
11721170

1173-
//// TODO: ECALL from Supervisor Mode should go to Machine Mode. Fix mideleg / medeleg
1174-
// if (cause == CAUSE_SUPERVISOR_ECALL) { deleg = 0; }////
1175-
11761171
if (deleg) {
1177-
puts("raise_exception2: smode"); dump_regs(s);////
11781172
s->scause = causel;
11791173
s->sepc = s->pc;
11801174
s->stval = tval;
@@ -1196,13 +1190,8 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
11961190
s->mstatus &= ~MSTATUS_MIE;
11971191
set_priv(s, PRV_M);
11981192
s->pc = s->mtvec;
1199-
1200-
puts("raise_exception2: mmode"); dump_regs(s);////
1201-
// s->mepc += 4;////
1202-
// sleep(4);////
12031193
}
12041194
//// Begin Test: Quit if cause=2, otherwise it will loop forever
1205-
if (cause == 2 && tval == 0xc0102573ul) { s->pc += 4; return; } // Ignore `rdtime a0`
12061195
if (cause == 2) { puts("tinyemu: Unknown mcause 2, quitting"); exit(1); }
12071196
//// End Test
12081197
}

0 commit comments

Comments
 (0)