Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/devices/plic.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,8 @@ void plic_delete(plic_t *plic)
{
free(plic);
}

void plic_reset(plic_t *plic)
{
memset(plic, 0, sizeof(plic_t));
}
3 changes: 3 additions & 0 deletions src/devices/plic.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ plic_t *plic_new();

/* delete a PLIC instance */
void plic_delete(plic_t *plic);

/* reset a PLIC instance */
void plic_reset(plic_t *plic);
5 changes: 5 additions & 0 deletions src/devices/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,8 @@ void u8250_delete(u8250_state_t *uart)
{
free(uart);
}

void u8250_reset(u8250_state_t *uart)
{
memset(uart, 0, sizeof(u8250_state_t));
}
3 changes: 3 additions & 0 deletions src/devices/uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ u8250_state_t *u8250_new();

/* delete a UART instance */
void u8250_delete(u8250_state_t *uart);

/* reset a UART instance */
void u8250_reset(u8250_state_t *uart);
8 changes: 6 additions & 2 deletions src/devices/virtio-blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,12 @@ uint32_t *virtio_blk_init(virtio_blk_state_t *vblk,
vblk->disk_fd = -1;

/* Allocate memory for the private member */
vblk->priv = calloc(1, sizeof(struct virtio_blk_config));
assert(vblk->priv);
if (vblk->priv) { /* check for reboot */
memset(vblk->priv, 0, sizeof(struct virtio_blk_config));
} else {
vblk->priv = calloc(1, sizeof(struct virtio_blk_config));
assert(vblk->priv);
}

/* No disk image is provided */
if (!disk_file) {
Expand Down
20 changes: 18 additions & 2 deletions src/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,6 @@ static void rv_check_interrupt(riscv_t *rv)
vm_attr_t *attr = PRIV(rv);
if (peripheral_update_ctr-- == 0) {
peripheral_update_ctr = 64;

#if defined(__EMSCRIPTEN__)
escape_seq:
#endif
Expand Down Expand Up @@ -1148,7 +1147,24 @@ void rv_step(void *arg)
/* find or translate a block for starting PC */
const uint64_t cycles_target = rv->csr_cycle + cycles;

/* loop until hitting the cycle target */
#if RV32_HAS(SYSTEM) && !RV32_HAS(ELF_LOADER)
/* Set up the jump point for handling reboots */
if (setjmp(rv->reboot_jmp) != 0) {
/* longjmp to here after a reboot happens */
#if !RV32_HAS(JIT)
need_clear_block_map = false;
#endif
is_branch_taken = false;
reloc_enable_mmu_jalr_addr = 0;
reloc_enable_mmu = false;
need_retranslate = false;
need_handle_signal = false;
prev = NULL;
last_pc = 0;
}
#endif

/* loop until hitting the cycle target or hart is halted */
while (rv->csr_cycle < cycles_target && !rv->halt) {
#if RV32_HAS(SYSTEM) && !RV32_HAS(ELF_LOADER)
/* check for any interrupt after every block emulation */
Expand Down
Loading
Loading