Remove impossible states

This commit is contained in:
Toby Jaffey 2025-12-14 01:34:59 +00:00
parent a5305d64dc
commit 6adbc53ad9

View file

@ -339,9 +339,6 @@ uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter)
} else { } else {
if (vmst->_status == UVM32_STATUS_ERROR) { if (vmst->_status == UVM32_STATUS_ERROR) {
setup_err_evt(vmst, evt); setup_err_evt(vmst, evt);
} else {
setStatusErr(vmst, UVM32_ERR_INTERNAL_STATE);
setup_err_evt(vmst, evt);
} }
return orig_instr_meter - instr_meter; return orig_instr_meter - instr_meter;
} }
@ -414,12 +411,13 @@ uvm32_slice_t uvm32_arg_getslice_fixed(uvm32_state_t *vmst, uvm32_evt_t *evt, uv
} }
uint32_t _uvm32_extramLoad(void *userdata, uint32_t addr, uint32_t accessTyp) { uint32_t _uvm32_extramLoad(void *userdata, uint32_t addr, uint32_t accessTyp) {
uvm32_state_t *vmst = (uvm32_state_t *)userdata; uvm32_state_t *vmst = (uvm32_state_t *)userdata;
addr -= UVM32_EXTRAM_BASE; addr -= UVM32_EXTRAM_BASE;
if (vmst->_extram != NULL) { if (vmst->_extram != NULL) {
if (addr < vmst->_extramLen) { if (addr < vmst->_extramLen) {
// These are funct3 values for lX instructions
// Any other value will have caused UVM32_ERR_INTERNAL_CORE
switch(accessTyp) { switch(accessTyp) {
case 0: case 0:
return ((int8_t *)vmst->_extram)[addr]; return ((int8_t *)vmst->_extram)[addr];
@ -430,18 +428,19 @@ uint32_t _uvm32_extramLoad(void *userdata, uint32_t addr, uint32_t accessTyp) {
case 2: case 2:
return ((uint32_t *)vmst->_extram)[addr / 4]; return ((uint32_t *)vmst->_extram)[addr / 4];
break; break;
case 4:
return ((uint8_t *)vmst->_extram)[addr];
break;
case 5: case 5:
return ((uint16_t *)vmst->_extram)[addr/2]; return ((uint16_t *)vmst->_extram)[addr/2];
break; break;
default: // have a default case to keep coverage check happy
setStatusErr(vmst, UVM32_ERR_MEM_RD); // no other values are possible here
return 0; default: // fall through
case 4:
return ((uint8_t *)vmst->_extram)[addr];
break; break;
} }
} else { } else {
// Out of bounds
setStatusErr(vmst, UVM32_ERR_MEM_RD); setStatusErr(vmst, UVM32_ERR_MEM_RD);
} }
} }
@ -454,17 +453,16 @@ uint32_t _uvm32_extramStore(void *userdata, uint32_t addr, uint32_t val, uint32_
if (vmst->_extram != NULL) { if (vmst->_extram != NULL) {
if (addr < vmst->_extramLen) { if (addr < vmst->_extramLen) {
switch(accessTyp) { switch(accessTyp) {
case 0:
((uint8_t *)vmst->_extram)[addr] = val;
break;
case 1: case 1:
((uint16_t *)vmst->_extram)[addr/2] = val; ((uint16_t *)vmst->_extram)[addr/2] = val;
break; break;
case 2: case 2:
((uint32_t *)vmst->_extram)[addr/4] = val; ((uint32_t *)vmst->_extram)[addr/4] = val;
break; break;
default: // no other values are valid here and will be stopped above
setStatusErr(vmst, UVM32_ERR_MEM_WR); default: // fall through
case 0:
((uint8_t *)vmst->_extram)[addr] = val;
break; break;
} }
vmst->_extramDirty = true; vmst->_extramDirty = true;