ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
emu_run.h
Go to the documentation of this file.
1
21
22#pragma once
23
24#include <stdint.h>
25#include <unicorn/unicorn.h>
26
27#include "board_view.h"
28#include "emu_elf.h"
29#include "emu_memmap.h"
30#include "emu_presentation.h"
31#include "ra8_attributes.h"
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
66
82
87typedef enum : uint32_t {
88 /* Thumb / conditional-select instruction decode. */
93 k_cs_op_mask = 0x3U,
94 /* Assorted. */
100
102typedef enum : uint64_t {
104 k_size_kib = 1024ULL,
105 k_sd_u32_max = 0xFFFFFFFFULL,
107} emu_size_t;
108
122typedef struct {
123 uc_engine* uc;
125 uint32_t initial_pc;
126 uint32_t vtor_base;
132 const char* ppm_path;
133 const char* record_dir;
134 uint32_t record_secs;
135 uint32_t rotate_deg;
137 const char* save_sd_path;
138 uint32_t stop_sym_addr;
140 const char* const* dump_sym_names;
141 const uint32_t* dump_sym_addrs;
142 uint32_t dump_sym_n;
143 uint16_t view_w;
144 uint16_t view_h;
145 const char* win_title;
149
164typedef struct {
166 uint32_t max_chunks;
167 double wall_s;
172 const char* stop_on;
174 uint32_t prof_idle_need;
175 uint32_t prof_idle_arm;
177
199
228int emu_run_and_report(const emu_run_cfg_t* cfg);
229
230#ifdef __cplusplus
231}
232#endif
Minimal self-contained macOS window for the board emulator.
struct board_view board_view_t
Opaque desktop-window handle (defined in board_view.m).
Definition board_view.h:31
ELF32 image services for the board emulator (load / symbols / vectors).
Shared aliased-memory backing and Unicorn memory-map bindings.
struct emu_memmap_workspace emu_memmap_workspace_t
Independent aperture backing with at most two engine bindings.
Bounded raw-descriptor presentation surface and scratch workspace.
@ k_emu_presentation_max_panel_px
Largest panel dimension.
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.
Definition emu_run.c:852
emu_exit_t
Process exit codes for the #67 run-every-example matrix.
Definition emu_run.h:76
@ k_emu_exit_ok
Clean run-to-budget (no fault/BKPT/timeout).
Definition emu_run.h:77
@ k_emu_exit_bkpt
Firmware executed a BKPT (assert/give-up).
Definition emu_run.h:79
@ k_emu_exit_timeout
Wall-clock budget reached before a clean stop.
Definition emu_run.h:80
@ k_emu_exit_fault
Emulation fault / invalid access ended it.
Definition emu_run.h:78
emu_budget_t
Definition emu_run.h:37
@ k_run_inner_max
Per-chunk exception-resolve relaunch cap.
Definition emu_run.h:63
@ k_env_strtol_base
Decimal base for env-var integer parse.
Definition emu_run.h:64
@ k_op_wfi
Thumb wfi (wait-for-interrupt).
Definition emu_run.h:53
@ k_idle_loop_max
Largest idle loop (bytes) that may hold PC.
Definition emu_run.h:61
@ k_run_wall_s
Wall-clock safety bound (seconds).
Definition emu_run.h:62
@ k_run_chunk_insns
Instructions per emulation chunk.
Definition emu_run.h:38
@ k_run_max_chunks
Chunk budget.
Definition emu_run.h:42
@ k_low_power_div
Low-power: shrink the chunk budget by.
Definition emu_run.h:39
@ k_idle_scan_fwd
Halfwords scanned ahead for a loop edge.
Definition emu_run.h:60
@ k_bn_imm_sext_shl
Shift imm11 bit10 up to bit31 (sign bit).
Definition emu_run.h:58
@ k_bn_imm_sext_shr
Arith >> sign-extends and scales imm by 2.
Definition emu_run.h:59
@ k_op_bn_mask
Mask selecting a Thumb T2 b.n opcode.
Definition emu_run.h:55
@ k_idle_spin_insns
Budget when the core is parked on a wait-for-interrupt spin (a "b ." self-branch, wfi,...
Definition emu_run.h:47
@ k_op_branch_self
Thumb "b ." (branch-to-self idle loop).
Definition emu_run.h:52
@ k_op_bn_base
Thumb T2 unconditional b.n base value.
Definition emu_run.h:56
@ k_op_cpsie_i
Thumb cpsie i (re-enable IRQ in a poll).
Definition emu_run.h:54
@ k_op_bn_imm
Thumb T2 b.n imm11 field mask.
Definition emu_run.h:57
emu_misc_t
Named constants for ELF parsing, Thumb decode, and assorted literals.
Definition emu_run.h:87
@ k_cs_op_shift
CSEL-family op = hw2[13:12].
Definition emu_run.h:92
@ k_record_dir_mode
mkdir mode for the –record dir.
Definition emu_run.h:96
@ k_sectors_per_mib
512-byte sectors per MiB (–sd-new).
Definition emu_run.h:98
@ k_max_panel_px
Largest –size dimension.
Definition emu_run.h:95
@ k_thumb32_op5_min
op5 >= this -> 32-bit instruction.
Definition emu_run.h:91
@ k_thumb_op5_mask
5-bit op5 field.
Definition emu_run.h:90
@ k_thumb_op5_shift
op5 = hw0[15:11].
Definition emu_run.h:89
@ k_cs_op_mask
2-bit op field.
Definition emu_run.h:93
@ k_dump_sym_max
Max –dump-sym globals per run.
Definition emu_run.h:97
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).
emu_size_t
64-bit byte/size units used by –sd-new card sizing.
Definition emu_run.h:102
@ k_fat32_min_mib
FAT32 default threshold, in MiB.
Definition emu_run.h:106
@ k_bytes_per_sector
SD logical sector size in bytes.
Definition emu_run.h:103
@ k_size_kib
One kibibyte (k suffix multiplier).
Definition emu_run.h:104
@ k_sd_u32_max
32-bit sector-count ceiling.
Definition emu_run.h:105
Annotation-attribute framework macros for ra8-firmware.
One independently owned immutable raw-descriptor ELF source.
Definition emu_elf.h:91
One independent owned surface plus non-owning bounded scratch.
Everything setup hands the run loop: engine, image, CLI products.
Definition emu_run.h:122
int click_y
–click row (composite pixels).
Definition emu_run.h:131
int click_x
–click column (composite pixels).
Definition emu_run.h:130
const char * record_dir
–record directory (NULL when unused).
Definition emu_run.h:133
bool want_click
–click armed.
Definition emu_run.h:129
const char * win_title
Window / sidebar caption.
Definition emu_run.h:145
bool want_view
–view (live window requested).
Definition emu_run.h:128
emu_elf_source_t * elf
Open caller-owned firmware source.
Definition emu_run.h:124
uint32_t initial_pc
Reset-vector PC (Thumb bit set).
Definition emu_run.h:125
bool want_trace
–trace (forwarded to warm reboots).
Definition emu_run.h:127
const char * ppm_path
–ppm output path (NULL when unused).
Definition emu_run.h:132
uint32_t stop_sym_thresh
–stop-sym threshold value.
Definition emu_run.h:139
uc_engine * uc
The prepared cpu0 engine.
Definition emu_run.h:123
const uint32_t * dump_sym_addrs
–dump-sym resolved addresses.
Definition emu_run.h:141
const char * save_sd_path
–save-sd dump path (NULL when unused).
Definition emu_run.h:137
uint32_t rotate_deg
–rotate display rotation.
Definition emu_run.h:135
uint32_t stop_sym_addr
–stop-sym resolved address (0 = off).
Definition emu_run.h:138
int reboot_count
–reboot N scheduled warm reboots.
Definition emu_run.h:136
emu_memmap_workspace_t * memory
Authoritative aliased-memory backing.
Definition emu_run.h:147
uint16_t view_h
Panel height in pixels.
Definition emu_run.h:144
uint32_t vtor_base
VTOR fallback (the MRAM vector base).
Definition emu_run.h:126
uint32_t record_secs
–record-secs bound (0 = unbounded).
Definition emu_run.h:134
const char *const * dump_sym_names
–dump-sym names (argv-backed).
Definition emu_run.h:140
uint32_t dump_sym_n
Count of –dump-sym entries.
Definition emu_run.h:142
emu_presentation_workspace_t * presentation
Owned streamed frame surface.
Definition emu_run.h:146
uint16_t view_w
Panel width in pixels.
Definition emu_run.h:143
The run-guard knobs (env-tunable budgets + stop conditions).
Definition emu_run.h:164
uint32_t max_chunks
Outer-chunk budget.
Definition emu_run.h:166
bool wall_guard_on
false: WALL_S=0 disabled the guard.
Definition emu_run.h:168
uint32_t prof_idle_arm
Chunks before the profiler stop arms.
Definition emu_run.h:175
const char * stop_on
Console-banner stop substring (or NULL).
Definition emu_run.h:172
uint32_t click_settle_chunks
Post-click drain window (chunks).
Definition emu_run.h:165
uint32_t idle_stop_chunks
Idle steady-state stop (0 = off).
Definition emu_run.h:169
uint32_t prof_idle_insns
Profiler idle chunk threshold.
Definition emu_run.h:173
uint32_t usbh_stop_settle
USB host-mode early-stop settle.
Definition emu_run.h:171
uint32_t prof_idle_need
Consecutive idle chunks that stop.
Definition emu_run.h:174
double wall_s
CPU-time guard bound, seconds.
Definition emu_run.h:167
uint32_t usb_stop_settle
USB device-mode early-stop settle.
Definition emu_run.h:170