|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Shared run-loop state + cross-TU run helpers (ra8_emulator internal). More...
#include <stdint.h>#include <time.h>#include <unicorn/unicorn.h>#include "board_overlay.h"#include "board_view.h"#include "emu_run.h"#include "ra8_attributes.h"Go to the source code of this file.
Data Structures | |
| struct | run_loop_t |
| The whole run's mutable state, threaded through the phase helpers. More... | |
Functions | |
| bool | priv_run_inner (uc_engine *uc, uint32_t vtor_base, uint32_t *run_pc_io, uc_err *err_out) |
| Run one outer chunk's inner exception-resolve loop. | |
| void | priv_run_report (const run_loop_t *st) |
| Print the run-end report (stop summary, verdict, –dump-sym probes). | |
| void | priv_run_write_outputs (const run_loop_t *st) |
| Write the –ppm snapshot and the –record summary line. | |
| void | priv_run_hold_view (const run_loop_t *st) |
| Hold the live window on the final frame until the user closes it. | |
| int | priv_run_cleanup (const run_loop_t *st) |
| Save the SD image, close owned descriptors + engine, map the exit code. | |
Shared run-loop state + cross-TU run helpers (ra8_emulator internal).
The chunked run phase is split across three translation units to keep each under the file-size bar: emu_run.c (setup + the per-chunk phase helpers + the driver), emu_run_inner.c (the inner exception-resolve loop) and emu_run_report.c (the run-end report + finalize). This internal header carries the pieces those TUs share: the run_loop_t mutable state bundle and the RA8_PRIV declarations of the helpers called across the split. It is NOT part of the ra8_emulator public surface (unlike emu_run.h).
Definition in file emu_run_internal.h.
| int priv_run_cleanup | ( | const run_loop_t * | st | ) |
Save the SD image, close owned descriptors + engine, map the exit code.
Defined in emu_run_report.c; called by emu_run_and_report as the final teardown step.
| [in] | st | The run state (surface, engine, stop flags). |
| k_emu_exit_ok | Clean run-to-budget. |
| k_emu_exit_bkpt | Firmware executed a BKPT. |
| k_emu_exit_fault | Emulation fault ended the run. |
| k_emu_exit_timeout | Wall-clock budget reached. |
st owns the surface descriptor, engine, and image being closed. Definition at line 328 of file emu_run_report.c.
References board_sd_save(), run_loop_t::cfg, emu_run_cfg_t::elf, emu_cpu1_close(), emu_exc_bkpt_hit(), emu_memmap_close(), emu_memmap_detach(), emu_presentation_close(), run_loop_t::err, k_emu_exit_bkpt, k_emu_exit_fault, k_emu_exit_ok, k_emu_exit_timeout, emu_run_cfg_t::memory, emu_run_cfg_t::presentation, priv_emu_elf_source_close(), emu_run_cfg_t::save_sd_path, run_loop_t::timed_out, and emu_run_cfg_t::uc.
Referenced by emu_run_and_report().
| void priv_run_hold_view | ( | const run_loop_t * | st | ) |
Hold the live window on the final frame until the user closes it.
Defined in emu_run_report.c; called by emu_run_and_report. Inert in headless mode.
| [in] | st | The run state (window + presentation surface). |
st reflects its outcome. st->view is a live window or NULL. Definition at line 309 of file emu_run_report.c.
References board_view_close(), board_view_present(), board_view_pump(), build_composite(), run_loop_t::cfg, run_loop_t::closed, k_view_idle_us, run_loop_t::presentation, priv_emu_io_errf(), emu_run_cfg_t::uc, run_loop_t::view, and emu_run_cfg_t::win_title.
Referenced by emu_run_and_report().
| bool priv_run_inner | ( | uc_engine * | uc, |
| uint32_t | vtor_base, | ||
| uint32_t * | run_pc_io, | ||
| uc_err * | err_out ) |
Run one outer chunk's inner exception-resolve loop.
Runs a chunk, then services exceptions to a steady state before the next chunk (zero-time relaunches, EXC_RETURN unstack + tail-chain, MPU / div-0 fault synthesis, tick / PendSV take). Returns once the full budget elapsed with nothing pending, or on a fault / BKPT / stop request. Defined in emu_run_inner.c; called by the run loop in emu_run.c.
| [in,out] | uc | Unicorn engine. |
| [in] | vtor_base | VTOR fallback for exception vectoring. |
| [in,out] | run_pc_io | Resume PC in, final PC out. |
| [out] | err_out | Final uc_emu_start status for the report. |
| true | The outer loop breaks and reports the stop cause. |
| false | The chunk resolved cleanly; the outer loop continues. |
run_pc_io holds a valid resume PC. run_pc_io and err_out reflect the loop's final state. Definition at line 217 of file emu_run_inner.c.
References emu_exc_clear_pendsv_stop(), internal_run_inner_budget(), internal_run_inner_check_stops(), internal_run_inner_take_exception(), k_inner_break, k_inner_continue, and k_run_inner_max.
Referenced by internal_run_loop_run_chunk().
| void priv_run_report | ( | const run_loop_t * | st | ) |
Print the run-end report (stop summary, verdict, –dump-sym probes).
Defined in emu_run_report.c; called by emu_run_and_report after the run loop returns.
| [in] | st | The run state (final counters + flags). |
st reflects its outcome. Definition at line 264 of file emu_run_report.c.
References run_loop_t::cfg, run_loop_t::chunks, emu_view_mark_stopped(), run_loop_t::err, run_loop_t::guards, run_guards_t::idle_stop_chunks, run_loop_t::idle_stopped, internal_run_print_dump_syms(), internal_run_print_stop_summary(), internal_run_print_verdict(), run_guards_t::max_chunks, run_loop_t::prof_stopped, run_loop_t::run_pc, run_loop_t::stop_sym_hit, run_loop_t::timed_out, emu_run_cfg_t::uc, run_loop_t::usb_stopped, and run_guards_t::wall_s.
Referenced by emu_run_and_report().
| void priv_run_write_outputs | ( | const run_loop_t * | st | ) |
Write the –ppm snapshot and the –record summary line.
Defined in emu_run_report.c; called by emu_run_and_report.
| [in] | st | The run state (presentation surface + output paths). |
st reflects its outcome. Definition at line 285 of file emu_run_report.c.
References build_composite(), run_loop_t::cfg, run_loop_t::comp_h, run_loop_t::comp_w, emu_presentation_workspace_t::fd, k_record_fps, emu_run_cfg_t::ppm_path, run_loop_t::presentation, priv_emu_io_errf(), run_loop_t::rec_frames, emu_run_cfg_t::record_dir, emu_run_cfg_t::uc, emu_run_cfg_t::win_title, and write_ppm().
Referenced by emu_run_and_report().