|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Run-guard environment knob reader (see emu_run.h). More...
#include <stdio.h>#include <stdlib.h>#include <sys/stat.h>#include "emu_host_io_internal.h"#include "emu_prof.h"#include "emu_run.h"#include "emu_view.h"Go to the source code of this file.
Enumerations | |
| enum | : uint32_t { k_click_settle_chunks = 512U } |
| Default post-click drain window used when the env override is unset. More... | |
Functions | |
| static RA8_INTERNAL uint32_t | internal_guard_env_u32 (const char *name, uint32_t dflt) |
| Read a RA8_EMU_* env var as a positive decimal uint32. | |
| static RA8_INTERNAL uint32_t | internal_guard_env_u32_headless (const char *name, uint32_t dflt, const board_view_t *view) |
| Read a headless-only RA8_EMU_* positive uint32 knob. | |
| static RA8_INTERNAL void | internal_guard_read_wall (double *wall_s, bool *wall_guard_on) |
| Apply the RA8_EMU_WALL_S CPU-time guard override. | |
| static RA8_INTERNAL void | internal_guard_setup_record (const emu_run_cfg_t *cfg, const board_view_t *view, uint32_t *max_chunks) |
| Apply the –record chunk bound and create the frame directory. | |
| static RA8_INTERNAL const char * | internal_guard_read_stop_on (const board_view_t *view) |
| Resolve the RA8_EMU_STOP_ON console-banner stop substring. | |
| static RA8_INTERNAL void | internal_guard_apply_stop_pc (void) |
| Hand RA8_EMU_STOP_PC (if set) to the profiler stop hook. | |
| static RA8_INTERNAL void | internal_guard_read_prof_idle (uint32_t *insns, uint32_t *need, uint32_t *arm) |
| Read the profiler compute-idle early-stop tunables. | |
| 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). | |
Run-guard environment knob reader (see emu_run.h).
The RA8_EMU_* budget / stop-condition environment parsing that precedes the chunked run loop – moved verbatim out of the run TU so each of the two stays under the file-size bar. The contract lives on the declaration of run_read_guards() in emu_run.h.
Definition in file emu_run_guards.c.
| anonymous enum : uint32_t |
Default post-click drain window used when the env override is unset.
| Enumerator | |
|---|---|
| k_click_settle_chunks | Extra chunks after the click lands. |
Definition at line 26 of file emu_run_guards.c.
|
static |
Hand RA8_EMU_STOP_PC (if set) to the profiler stop hook.
Ends the run the first time PC reaches this address (effective in profile insn mode, via prof_insn_hook), letting the profiler cover exactly the boot path. The supplied address has its Thumb bit cleared.
Definition at line 200 of file emu_run_guards.c.
References emu_prof_set_stop_pc(), k_env_strtol_base, and RA8_INTERNAL.
Referenced by run_read_guards().
|
static |
Read a RA8_EMU_* env var as a positive decimal uint32.
Parses name with strtol (base k_env_strtol_base). A missing variable or a non-positive value leaves dflt in force, matching the "unset keeps the default" contract every budget knob documents.
| [in] | name | The environment variable name. |
| [in] | dflt | Value returned when unset or parsed as <= 0. |
dflt. | dflt | The variable is unset or did not parse to a positive integer. |
name is a valid NUL-terminated string. dflt or a strictly-positive parse result. Definition at line 51 of file emu_run_guards.c.
References k_env_strtol_base, and RA8_INTERNAL.
Referenced by internal_guard_env_u32_headless(), and run_read_guards().
|
static |
Read a headless-only RA8_EMU_* positive uint32 knob.
The idle / USB / MAX_CHUNKS stop knobs have no effect in –view (window-driven) mode; when view is live the override is ignored and dflt is returned, exactly as the inline env parsing did.
| [in] | name | The environment variable name. |
| [in] | dflt | Value returned when live-view or unset / non-positive. |
| [in] | view | The live window handle (NULL when headless). |
dflt when a window is open, otherwise internal_guard_env_u32. | dflt | A live –view window suppresses the override. |
name is a valid NUL-terminated string. view is NULL or a valid window handle. Definition at line 81 of file emu_run_guards.c.
References internal_guard_env_u32().
Referenced by run_read_guards().
|
static |
Read the profiler compute-idle early-stop tunables.
Once boot has fallen into the steady frame loop the firmware retires almost no instructions per chunk, whereas boot chunks are compute-heavy. Stop after need consecutive chunks that each retire fewer than insns instructions, armed only after arm chunks. All three are RA8_EMU_PROFILE_IDLE_* overridable (strtoul, base k_strtol_base10) so the boot window can be tuned per app.
| [out] | insns | Per-chunk insn count below which a chunk is idle. |
| [out] | need | Consecutive idle chunks that end the run. |
| [out] | arm | Chunks to run before the stop is armed. |
insns, need and arm are non-NULL. < Per-chunk insns below which a chunk is idle.
< Consecutive idle chunks that end the run.
< Chunks to run before the stop is armed.
Definition at line 231 of file emu_run_guards.c.
References k_strtol_base10.
Referenced by run_read_guards().
|
static |
Resolve the RA8_EMU_STOP_ON console-banner stop substring.
Stops the headless run as soon as the console UART's last line contains the substring – a generic "stop on a banner" guard for apps that loop forever after a success line. Empty, unset, or –view all disable it.
| [in] | view | The live window handle (NULL when headless). |
| NULL | RA8_EMU_STOP_ON is unset, empty, or a window is open. |
view is NULL or a valid window handle. Definition at line 176 of file emu_run_guards.c.
References RA8_INTERNAL.
Referenced by run_read_guards().
|
static |
Apply the RA8_EMU_WALL_S CPU-time guard override.
A positive value sets the bound in seconds; an explicit 0 DISABLES the guard (the #168 footgun fix – WALL_S=0 no longer silently falls back to the default), leaving the run bounded by chunks alone. Unset keeps both defaults untouched.
| [in,out] | wall_s | In: default bound; out: override when > 0. |
| [in,out] | wall_guard_on | In: true; out: false on an explicit WALL_S=0. |
wall_s and wall_guard_on are non-NULL and pre-seeded to defaults. wall_s holds the effective CPU-time bound in seconds. wall_guard_on is false iff RA8_EMU_WALL_S was exactly 0. Definition at line 107 of file emu_run_guards.c.
References k_env_strtol_base, and RA8_INTERNAL.
Referenced by run_read_guards().
|
static |
Apply the –record chunk bound and create the frame directory.
Headless –record-secs bounds the run to exactly the recording window (so the dumped frame sequence spans the requested emulated duration); then, whenever a record directory is set, the directory is created and the recording banner is printed. Both steps are inert when –record is off.
| [in] | cfg | The run configuration (record dir / seconds). |
| [in] | view | The live window handle (NULL when headless). |
| [in,out] | max_chunks | In: current budget; out: record-secs bound when set. |
cfg and max_chunks are non-NULL. view is NULL or a valid window handle. max_chunks equals the recording window. Definition at line 140 of file emu_run_guards.c.
References k_record_dir_mode, k_record_every, k_record_fps, k_record_ms_per_sec, priv_emu_io_errf(), RA8_INTERNAL, emu_run_cfg_t::record_dir, and emu_run_cfg_t::record_secs.
Referenced by run_read_guards().
| 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().