|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
The chunked emulation run loop, report and exit-code mapping. More...
#include <stdint.h>#include <unicorn/unicorn.h>#include "board_view.h"#include "emu_elf.h"#include "emu_memmap.h"#include "emu_presentation.h"#include "ra8_attributes.h"Go to the source code of this file.
Data Structures | |
| struct | emu_run_cfg_t |
| Everything setup hands the run loop: engine, image, CLI products. More... | |
| struct | run_guards_t |
| The run-guard knobs (env-tunable budgets + stop conditions). More... | |
Enumerations | |
| enum | emu_budget_t : uint32_t { k_run_chunk_insns = 500000U , k_low_power_div = 4U , k_run_max_chunks = 40000U , k_idle_spin_insns = 2U , k_op_branch_self = 0xE7FEU , k_op_wfi = 0xBF30U , k_op_cpsie_i = 0xB662U , k_op_bn_mask = 0xF800U , k_op_bn_base = 0xE000U , k_op_bn_imm = 0x07FFU , k_bn_imm_sext_shl = 21U , k_bn_imm_sext_shr = 20U , k_idle_scan_fwd = 8U , k_idle_loop_max = 32U , k_run_wall_s = 120U , k_run_inner_max = 4096U , k_env_strtol_base = 10U } |
| enum | emu_exit_t : int { k_emu_exit_ok = 0 , k_emu_exit_fault = 1 , k_emu_exit_bkpt = 2 , k_emu_exit_timeout = 3 } |
| Process exit codes for the #67 run-every-example matrix. More... | |
| enum | emu_misc_t : uint32_t { k_thumb_op5_shift = 11U , k_thumb_op5_mask = 0x1FU , k_thumb32_op5_min = 0x1DU , k_cs_op_shift = 12U , k_cs_op_mask = 0x3U , k_max_panel_px = k_emu_presentation_max_panel_px , k_record_dir_mode = 0755U , k_dump_sym_max = 8U , k_sectors_per_mib = 2048U } |
| Named constants for ELF parsing, Thumb decode, and assorted literals. More... | |
| enum | emu_size_t : uint64_t { k_bytes_per_sector = 512ULL , k_size_kib = 1024ULL , k_sd_u32_max = 0xFFFFFFFFULL , k_fat32_min_mib = 512ULL } |
| 64-bit byte/size units used by –sd-new card sizing. More... | |
Functions | |
| run_guards_t | run_read_guards (const emu_run_cfg_t *cfg, const board_view_t *view) |
| Read the run-guard environment knobs (see run_guards_t). | |
| int | emu_run_and_report (const emu_run_cfg_t *cfg) |
| Run the firmware to a stop condition, print the report, map the exit code. | |
The chunked emulation run loop, report and exit-code mapping.
Owns everything after setup: the streamed presentation surface, the run-guard environment knobs (RA8_EMU_WALL_S / MAX_CHUNKS / IDLE_STOP / USB_STOP / USBH_STOP / STOP_ON / STOP_PC / CLICK_SETTLE / the profiler idle-stop tunables), the chunked run loop with its inner exception-resolve loop and seven stop conditions, the run-end report, and the process exit-code mapping the #67 run-every-example matrix keys on. The shared run budgets and assorted sizing constants live here so both the setup banner and the loop read one definition.
Split out of the ra8_emulator main translation unit; behaviour unchanged.
Definition in file emu_run.h.
| enum emu_budget_t : uint32_t |
| enum emu_exit_t : int |
Process exit codes for the #67 run-every-example matrix.
The matrix keys off the process exit code (not the injected error sink banner): a clean run-to-budget returns success; a firmware BKPT, an emulation fault, or the wall-clock timeout each return a distinct non-zero code so a wedged or trapped run is distinguishable from a healthy one.
| enum emu_misc_t : uint32_t |
Named constants for ELF parsing, Thumb decode, and assorted literals.
| enum emu_size_t : uint64_t |
| int emu_run_and_report | ( | const emu_run_cfg_t * | cfg | ) |
Run the firmware to a stop condition, print the report, map the exit code.
Uses the caller-prepared raw-fd presentation surface (window / –ppm / –record / –click), reads the run-guard environment knobs, executes the chunked run loop – one SysTick period per outer chunk, exceptions resolved to a steady state by the inner loop, cpu1 interleaved, seven stop conditions – then prints the run-end report (stop cause, telemetry, peripheral summaries, MMIO table, –dump-sym probes), writes the –ppm / –record outputs, holds the live window until closed, saves the SD image, closes owned descriptors and the engine, and returns the #67 matrix exit code.
| [in] | cfg | The setup products (see emu_run_cfg_t). |
| 0 | Clean run-to-budget (no fault / BKPT / timeout). |
| 1 | Emulation fault / invalid access ended the run. |
| 2 | Firmware executed a BKPT (assert / give-up). |
| 3 | Wall-clock budget reached before a clean stop. |
cfg is fully populated and its engine is ready to run. Definition at line 852 of file emu_run.c.
References internal_run_loop(), internal_run_loop_setup(), priv_run_cleanup(), priv_run_hold_view(), priv_run_report(), and priv_run_write_outputs().
Referenced by internal_main_run_loaded().
| run_guards_t run_read_guards | ( | const emu_run_cfg_t * | cfg, |
| const board_view_t * | view ) |
Read the run-guard environment knobs (see run_guards_t).
Moved verbatim from the run preamble: every default, override precedence and –view/–record interaction is unchanged, including the –record-secs chunk bound and the RA8_EMU_STOP_PC hand-off to the profiler.
| [in] | cfg | The run configuration (record/click fields). |
| [in] | view | The live window handle (NULL when headless). |
| (by | value) Every field holds its default or env override. |
cfg outlives the call. Definition at line 255 of file emu_run_guards.c.
References internal_guard_apply_stop_pc(), internal_guard_env_u32(), internal_guard_env_u32_headless(), internal_guard_read_prof_idle(), internal_guard_read_stop_on(), internal_guard_read_wall(), internal_guard_setup_record(), k_click_settle_chunks, k_run_max_chunks, k_run_wall_s, and k_view_max_chunks.
Referenced by internal_run_loop_setup().