87 const char* sd_l =
nullptr;
91 const bool sd_gb = (sd_b >= gib_bytes);
92 const unsigned long sd_sz =
93 sd_gb ? (
unsigned long)(sd_b / gib_bytes) : (
unsigned long)(sd_b / mib_bytes);
94 const char* sd_u = sd_gb ?
"GB" :
"MB";
95 if (sd_att && (sd_f != 0U)) {
96 (void)
priv_emu_io_errf(
" SD card : %lu %s FAT%u '%s' (created by --sd-new)\n",
100 (sd_l !=
nullptr) ? sd_l :
"");
127 uc_strerror(st->
err),
128 st->
timed_out ?
" (wall-clock budget reached)" :
"",
131 st->
stop_sym_hit ?
" (--stop-sym threshold reached)" :
"",
135 (void)
priv_emu_io_errf(
" => firmware executed a BKPT @ 0x%08X (deliberate trap: "
136 "Default_Handler / failed assert / fault give-up)\n",
144 "(M85 vector ops the M33 "
150 "emulated (M85 hardware-loop "
155 (void)
priv_emu_io_errf(
" exceptions : %u PendSV %u SVCall (real Cortex-M entry/return)\n",
158 (void)
priv_emu_io_errf(
" touch clicks : %u drained via ra8_touch -> I3C -> GT911\n",
198 (void)
priv_emu_io_errf(
" => ra8_emulator TRUNCATED by the wall-clock guard at chunk %u of %u "
199 "(%.0fs CPU-time elapsed); this is NOT a full-budget run (host "
200 "overloaded -- see #168).\n",
208 (void)
priv_emu_io_errf(
" => firmware EXECUTED to the run budget (idle steady-state: no "
209 "observable change for %u chunks, stopped at chunk %u).\n",
213 (void)
priv_emu_io_errf(
" => firmware EXECUTED to the run budget (USB enumerated: device "
214 "CONFIGURED, stopped at chunk %u).\n",
218 "invalid opcode / fault).\n");
244 for (uint32_t d = 0U; d < cfg->
dump_sym_n; d++) {
312 if (st->
view ==
nullptr) {
320 (void)
priv_emu_io_errf(
"ra8_emulator: run ended; close the window to exit\n");
338 (void)uc_close(cfg->
uc);
344 }
else if (st->
err != UC_ERR_OK) {
349 return (
int)exit_code;
Virtual network peer for ra8_emulator – talks TCP/IP to the firmware.
void board_net_report(void)
Print the end-of-run network summary (link / ARP / ping / TCP).
Register-accurate peripheral-model framework for the board emulator.
uint8_t board_periph_sci_console_channel(void)
The SCI channel the EK-RA8D2 console (J-Link OB VCOM) uses.
void board_periph_report(uc_engine *uc)
Print the peripheral-model section of the end-of-run summary.
uint32_t board_periph_touch_reported(void)
Count of touch contacts the firmware has drained from the GT911 model.
SD-card-over-SPI device model for ra8_emulator (attached to SPI_B).
bool board_sd_save(const char *path)
Transactionally publish the current SD-card image to a file.
void board_sd_info(bool *attached, uint64_t *bytes, uint8_t *fat_bits, const char **label)
Read back the attached card's summary (for the status view / report).
Minimal self-contained macOS window for the board emulator.
bool board_view_pump(board_view_t *view)
Drain pending UI events; report whether the window was closed.
void board_view_present(board_view_t *view, emu_presentation_workspace_t *presentation)
Snapshot an RGB565 fd surface and request a redraw.
void board_view_close(board_view_t *view)
Close the window and release its resources.
Emulator text-console surfaces: UART echo, ITM/SWO echo, escapes.
void console_flush_line(uint8_t channel)
Flush the pending [uart] line to injected output sink with its channel prefix.
Second-core (cpu1, Cortex-M33) engine: release watch, boot, stepping.
void emu_cpu1_close(emu_memmap_workspace_t *memory)
Detach and close the optional cpu1 engine.
Private raw-descriptor ELF source operations.
emu_elf_io_result_t priv_emu_elf_source_close(emu_elf_source_t *source)
Close and invalidate one independently owned ELF source.
Shared Unicorn engine access utilities for the board emulator.
Cortex-M exception model constants and interfaces for ra8_emulator.
bool emu_exc_bkpt_hit(void)
Whether the firmware executed a BKPT (deliberate trap / give-up).
uint32_t emu_exc_pendsv_takes(void)
PendSV exceptions taken this run (report + idle signature).
uint32_t emu_exc_bkpt_pc(void)
PC of the BKPT that halted the run.
uint32_t emu_exc_svc_takes(void)
SVCall exceptions taken this run (report + idle signature).
uint32_t emu_exc_systick_fires(void)
SysTick exceptions taken this run (report telemetry).
Bounded raw-descriptor I/O seam for the RA8 emulator.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
bool emu_memmap_detach(emu_memmap_workspace_t *workspace, uc_engine *uc)
Remove one engine binding before closing that Unicorn engine.
bool emu_memmap_close(emu_memmap_workspace_t *workspace)
Release every host aperture mapping after all engines detached.
uc_err emu_mem_read(uc_engine *uc, uint64_t address, void *bytes, size_t count)
Read guest memory through the central access seam.
Sparse MMIO model of the Renesas peripheral space.
void emu_mmio_print_counts(void)
Print the run-end MMIO counters line to injected error sink.
void emu_mmio_print_bgc_and_table(void)
Print the BG_BGC witness and the per-address MMIO table to injected error sink.
bool emu_presentation_close(emu_presentation_workspace_t *workspace)
Close one owned presentation descriptor and invalidate the workspace.
Firmware profiler (RA8_EMU_PROFILE): sampling, hooks, reports.
void prof_report(void)
Print the top hot functions (by wall time or instruction count).
emu_exit_t
Process exit codes for the #67 run-every-example matrix.
@ k_emu_exit_ok
Clean run-to-budget (no fault/BKPT/timeout).
@ k_emu_exit_bkpt
Firmware executed a BKPT (assert/give-up).
@ k_emu_exit_timeout
Wall-clock budget reached before a clean stop.
@ k_emu_exit_fault
Emulation fault / invalid access ended it.
@ k_size_kib
One kibibyte (k suffix multiplier).
Shared run-loop state + cross-TU run helpers (ra8_emulator internal).
static RA8_INTERNAL void internal_run_print_dump_syms(uc_engine *uc, const emu_run_cfg_t *cfg)
Print each –dump-sym probe's value from emulated memory.
void priv_run_report(const run_loop_t *st)
Print the run-end report (stop summary, verdict, –dump-sym probes).
static RA8_INTERNAL void internal_run_print_stop_summary(uc_engine *uc, const run_stop_t *st)
Print the stop banner, telemetry counters and peripheral summaries.
static RA8_INTERNAL void internal_run_print_sd_summary(void)
Print the attached microSD summary line of the run report.
void priv_run_write_outputs(const run_loop_t *st)
Write the –ppm snapshot and the –record summary line.
static RA8_INTERNAL void internal_run_print_verdict(const run_stop_t *st)
Print the run verdict: TRUNCATED warning or EXECUTED-to-budget.
int priv_run_cleanup(const run_loop_t *st)
Save the SD image, close owned descriptors + engine, map the exit code.
void priv_run_hold_view(const run_loop_t *st)
Hold the live window on the final frame until the user closes it.
Armv8.1-M instruction-emulation seams (M85 ops on Unicorn's M33).
uint64_t emu_mve_emulated_count(void)
Count of MVE instructions emulated this run (run-end telemetry).
uint64_t emu_lob_emulated_count(void)
Count of LOB (DLS/LE) instructions emulated this run (telemetry).
Board-view presentation: frames, composition, input routing, panels.
void emu_view_mark_stopped(uint32_t pc)
Mark the run ended: the held frame shows "parked" at pc.
@ k_record_fps
Recorded frames per emulated second.
@ k_view_idle_us
~60 Hz idle pump after the run ends.
int write_ppm(const char *path, const emu_presentation_workspace_t *presentation)
Write an RGB565 frame to a binary PPM (P6) for headless inspection.
bool build_composite(uc_engine *uc, emu_presentation_workspace_t *presentation, const char *app_name)
Stream the panel and status sidebar into a raw-fd surface.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
int fd
Owned unlinked descriptor, or -1.
Everything setup hands the run loop: engine, image, CLI products.
const char * record_dir
–record directory (NULL when unused).
const char * win_title
Window / sidebar caption.
emu_elf_source_t * elf
Open caller-owned firmware source.
const char * ppm_path
–ppm output path (NULL when unused).
uc_engine * uc
The prepared cpu0 engine.
const uint32_t * dump_sym_addrs
–dump-sym resolved addresses.
const char * save_sd_path
–save-sd dump path (NULL when unused).
emu_memmap_workspace_t * memory
Authoritative aliased-memory backing.
const char *const * dump_sym_names
–dump-sym names (argv-backed).
uint32_t dump_sym_n
Count of –dump-sym entries.
emu_presentation_workspace_t * presentation
Owned streamed frame surface.
uint32_t max_chunks
Outer-chunk budget.
uint32_t idle_stop_chunks
Idle steady-state stop (0 = off).
double wall_s
CPU-time guard bound, seconds.
The whole run's mutable state, threaded through the phase helpers.
bool timed_out
Wall-clock guard fired.
emu_presentation_workspace_t * presentation
Owned raw-fd presentation surface.
bool usb_stopped
USB / banner early stop fired.
uint16_t comp_h
Composite (panel + sidebar) height.
bool closed
Live window was closed.
board_view_t * view
Live window (NULL when headless).
run_guards_t guards
Env-tunable budgets + stop conditions.
uint32_t rec_frames
–record frames written.
bool prof_stopped
Profiler stop fired.
const emu_run_cfg_t * cfg
Setup products (engine, image, CLI knobs).
uint32_t run_pc
Current resume PC.
uint16_t comp_w
Composite (panel + sidebar) width.
bool idle_stopped
Idle steady-state stop fired.
bool stop_sym_hit
–stop-sym threshold reached.
uc_err err
Latest uc_emu_start status.
uint32_t chunks
Outer chunks executed so far.
How the run ended: final engine status plus every stop flag.
uc_err err
Final uc_emu_start status.
bool idle_stopped
Idle steady-state stop fired.
uint32_t chunks
Outer chunks executed.
bool usb_stopped
USB early stop (CONFIGURED / STOP_ON hit).
bool stop_sym_hit
–stop-sym threshold reached.
uint32_t max_chunks
The chunk budget in force.
uint32_t run_pc
PC where the run stopped.
bool prof_stopped
Profiler compute-idle stop fired.
bool timed_out
Wall-clock guard fired (truncated run).
double wall_s
The wall-clock bound in force (seconds).
uint32_t idle_stop_chunks
RA8_EMU_IDLE_STOP window (0 = off).