s = set_field(s, MSTATUS_MPP, PRV_U);
p->set_privilege(prev_prv);
p->set_csr(CSR_MSTATUS, s);
+fprintf(stderr, "CSR SVSTATE: %x\n", svstate);
p->set_csr(CSR_SV_STATE, svstate);
msv.vl = msv.mvl = 0;
ssv.vl = ssv.mvl = 0;
usv.vl = usv.mvl = 0;
- // SUBVL all 1
+ // SUBVL all 1, including in xesvstate
msv.subvl = 1;
ssv.subvl = 1;
usv.subvl = 1;
+ mesvstate = sesvstate = 0;
#endif
}
case CSR_SV_CFG:
return (state.sv().state_bank) | (state.sv().state_size<<3);
case CSR_SV_STATE:
- return (state.sv().vl-1) | ((state.sv().mvl-1)<<6) |
- (state.sv().srcoffs<<12) | (state.sv().destoffs<<18) |
- ((state.sv().subvl-1)<<24) |
- (state.sv().ssvoffs<<26) | (state.sv().dsvoffs<<28);
+ fprintf(stderr, "get CSR_SV_STATE vl %d mvl %d subvl %d\n",
+ state.sv().vl,
+ state.sv().mvl,
+ state.sv().subvl);
+ return ((std::max((int)state.sv().vl, 1))-1) |
+ ((std::max((int)state.sv().mvl, 1)-1)<<6) |
+ (state.sv().srcoffs<<12) |
+ (state.sv().destoffs<<18) |
+ ((std::max((int)state.sv().subvl, 1)-1)<<24) |
+ (state.sv().ssvoffs<<26) |
+ (state.sv().dsvoffs<<28);
case CSR_SV_MVL:
return state.sv().mvl;
case CSR_SV_SUBVL: