mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Align stack pointer to 16 bytes, needed if UVM32_MEMORY_SIZE is not multiple of 16.
On memory rd trap, set appropriate error code
This commit is contained in:
parent
ac1975a820
commit
b83fc74c8d
1 changed files with 6 additions and 1 deletions
|
|
@ -74,7 +74,7 @@ void uvm32_init(uvm32_state_t *vmst) {
|
||||||
// setup stack pointer
|
// setup stack pointer
|
||||||
// la sp, _sstack
|
// la sp, _sstack
|
||||||
// addi sp,sp,-16
|
// addi sp,sp,-16
|
||||||
vmst->core.regs[2] = (MINIRV32_RAM_IMAGE_OFFSET + UVM32_MEMORY_SIZE) - 16;
|
vmst->core.regs[2] = ((MINIRV32_RAM_IMAGE_OFFSET + UVM32_MEMORY_SIZE) & ~0xF) - 16; // 16 byte align stack
|
||||||
vmst->core.regs[10] = 0x00; //hart ID
|
vmst->core.regs[10] = 0x00; //hart ID
|
||||||
vmst->core.regs[11] = 0;
|
vmst->core.regs[11] = 0;
|
||||||
vmst->core.extraflags |= 3; // Machine-mode.
|
vmst->core.extraflags |= 3; // Machine-mode.
|
||||||
|
|
@ -190,6 +190,7 @@ uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter)
|
||||||
|
|
||||||
// check data fits in ram
|
// check data fits in ram
|
||||||
if (mem_offset > UVM32_MEMORY_SIZE) {
|
if (mem_offset > UVM32_MEMORY_SIZE) {
|
||||||
|
|
||||||
setStatusErr(vmst, UVM32_ERR_INTERNAL_CORE);
|
setStatusErr(vmst, UVM32_ERR_INTERNAL_CORE);
|
||||||
setup_err_evt(vmst, evt);
|
setup_err_evt(vmst, evt);
|
||||||
}
|
}
|
||||||
|
|
@ -212,6 +213,10 @@ uint32_t uvm32_run(uvm32_state_t *vmst, uvm32_evt_t *evt, uint32_t instr_meter)
|
||||||
break;
|
break;
|
||||||
} // end switch(syscall)
|
} // end switch(syscall)
|
||||||
} break; // end ecall
|
} break; // end ecall
|
||||||
|
case 6:
|
||||||
|
setStatusErr(vmst, UVM32_ERR_MEM_RD);
|
||||||
|
setup_err_evt(vmst, evt);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
// unhandled exception
|
// unhandled exception
|
||||||
setStatusErr(vmst, UVM32_ERR_INTERNAL_CORE);
|
setStatusErr(vmst, UVM32_ERR_INTERNAL_CORE);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue