ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
emu_elf_reboot.c File Reference

Warm-reboot orchestration over an open streaming ELF source. More...

#include "board_console.h"
#include "board_net.h"
#include "board_periph.h"
#include "emu_console.h"
#include "emu_elf.h"
#include "emu_exc.h"
#include "emu_host_io_internal.h"
#include "emu_memmap.h"
#include "emu_mpu.h"
#include "emu_seams.h"
#include "emu_view.h"
Include dependency graph for emu_elf_reboot.c:

Go to the source code of this file.

Functions

uint32_t warm_reboot (uc_engine *uc, const emu_elf_source_t *elf, bool trace)
 Warm-reboot the firmware: re-run from the reset vector in place.

Detailed Description

Warm-reboot orchestration over an open streaming ELF source.

Restores PT_LOAD bytes through the bounded loader, resets models, and restarts from the vector table without changing source ownership.

Since
0.1.0

Definition in file emu_elf_reboot.c.

Function Documentation

◆ warm_reboot()

uint32_t warm_reboot ( uc_engine * uc,
const emu_elf_source_t * elf,
bool trace )

Warm-reboot the firmware: re-run from the reset vector in place.

Mirrors a Cortex-M reset without tearing down the Unicorn engine. Restores the code image and the .data initial values by re-writing the ELF's PT_LOAD segments (the firmware's own Reset_Handler then re-zeroes .bss and re-copies .data), re-reads SP/PC from the vector table, resets the peripheral models (the reset-cause RSTSRn and the VBATT backup domain deliberately survive their reset hooks, so the reboot cause and battery-backed state persist), and clears the host-side exception / scheduler bookkeeping so the next boot starts clean. The installed Unicorn hooks persist across this, so they are NOT re-added, and one-shot CLI input (–keys / –input / –usb-in) is NOT re-injected.

Parameters
[in,out]ucUnicorn engine to reboot (kept alive).
[in]elfOpen firmware source whose segments are re-loaded.
[in]traceWhether –trace is active (forwarded to the models).
Returns
The reset-vector PC to resume the run loop from (Thumb bit set).
Return values
0The image re-load failed; the caller must end the run.
Precondition
The same elf loaded successfully at startup and remains open.
The engine is idle (between chunks).
Postcondition
On success the core state matches a fresh boot of the image.
Note
Not thread-safe; the emulator is single-threaded host-side.
See also
load_elf() Performs the segment re-write.
Since
0.1.0
Postcondition
Ownership of caller-supplied storage is unchanged.

Definition at line 24 of file emu_elf_reboot.c.

References board_console_reset(), board_net_init(), board_periph_init(), emu_console_reset(), emu_div0_clear_fault(), emu_div0_disarm(), emu_exc_reset(), emu_mem_read(), emu_memmap_mram_base(), emu_mpu_clear_fault(), emu_view_reset_console(), k_xpsr_t_bit, load_elf(), and priv_emu_io_errf().

Referenced by internal_run_loop_prologue(), and internal_run_loop_run_chunk().