@@ -1130,7 +1130,7 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
1130
1130
flag = 1 ;
1131
1131
flag = (cause & CAUSE_INTERRUPT ) == 0 ;
1132
1132
//// 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 ) ////
1134
1134
flag = 0 ;
1135
1135
#endif
1136
1136
if (flag ) {
@@ -1149,9 +1149,7 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
1149
1149
//// Begin Test: Emulate OpenSBI for System Timer
1150
1150
if (cause == CAUSE_SUPERVISOR_ECALL ) {
1151
1151
puts ("TODO: Emulate OpenSBI for System Timer" );
1152
- printf ("Before pc=%p\n" , s -> pc ); ////
1153
1152
s -> pc += 4 ; // Jump to the next instruction (ret)
1154
- printf ("After pc=%p\n" , s -> pc ); ////
1155
1153
return ;
1156
1154
}
1157
1155
//// End Test
@@ -1170,11 +1168,7 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
1170
1168
if (cause & CAUSE_INTERRUPT )
1171
1169
causel |= (target_ulong )1 << (s -> cur_xlen - 1 );
1172
1170
1173
- //// TODO: ECALL from Supervisor Mode should go to Machine Mode. Fix mideleg / medeleg
1174
- // if (cause == CAUSE_SUPERVISOR_ECALL) { deleg = 0; }////
1175
-
1176
1171
if (deleg ) {
1177
- puts ("raise_exception2: smode" ); dump_regs (s );////
1178
1172
s -> scause = causel ;
1179
1173
s -> sepc = s -> pc ;
1180
1174
s -> stval = tval ;
@@ -1196,13 +1190,8 @@ static void raise_exception2(RISCVCPUState *s, uint32_t cause,
1196
1190
s -> mstatus &= ~MSTATUS_MIE ;
1197
1191
set_priv (s , PRV_M );
1198
1192
s -> pc = s -> mtvec ;
1199
-
1200
- puts ("raise_exception2: mmode" ); dump_regs (s );////
1201
- // s->mepc += 4;////
1202
- // sleep(4);////
1203
1193
}
1204
1194
//// Begin Test: Quit if cause=2, otherwise it will loop forever
1205
- if (cause == 2 && tval == 0xc0102573ul ) { s -> pc += 4 ; return ; } // Ignore `rdtime a0`
1206
1195
if (cause == 2 ) { puts ("tinyemu: Unknown mcause 2, quitting" ); exit (1 ); }
1207
1196
//// End Test
1208
1197
}
0 commit comments