169 const uint32_t max_scroll =
199 if (line ==
nullptr) {
252 *ny = (uint16_t)(panel_h - 1U - cx);
254 *nx = (uint16_t)(panel_w - 1U - cx);
255 *ny = (uint16_t)(panel_h - 1U - cy);
257 *nx = (uint16_t)(panel_w - 1U - cy);
294 bool charging =
false;
300 bool charging =
false;
337 uint32_t tab_idx = 0U;
373 const char* app_name)
393 const char c = s[n - 1U];
394 if ((c !=
' ') && (c !=
'\t') && (c !=
'\r') && (c !=
'\n')) {
428 while ((*p ==
' ') || (*p ==
'\t')) {
431 if ((*p ==
'#') || (*p ==
'\0') || (*p ==
'\n') || (*p ==
'\r')) {
434 char* eq =
strchr(p,
'=');
440 while ((*v ==
' ') || (*v ==
'\t')) {
469 if ((n >= 2U) && (s[0] ==
'"') && (s[n - 1U] ==
'"')) {
473 if (n >=
sizeof(out->
name)) {
474 n =
sizeof(out->
name) - 1U;
499 if (
strncmp(key,
"width",
sizeof(
"width")) == 0) {
501 }
else if (
strncmp(key,
"height",
sizeof(
"height")) == 0) {
503 }
else if (
strncmp(key,
"name",
sizeof(
"name")) == 0) {
528 while (*line !=
'\0') {
529 char*
const end =
strchr(line,
'\n');
530 if (end !=
nullptr) {
541 if (end ==
nullptr) {
553 k_panel_file_cap = 4096U,
555 if ((path ==
nullptr) || (out ==
nullptr)) {
558 (void)
memset(out, 0,
sizeof(*out));
561 ((uint64_t)file.size > k_panel_file_cap)) {
565 (void)
priv_emu_io_errf(
"ra8_emulator: cannot open panel config %s\n", path);
568 const size_t length = (size_t)file.size;
569 char config[k_panel_file_cap + 1U];
571 config[length] =
'\0';
577 (void)
priv_emu_io_errf(
"ra8_emulator: panel %s: width/height missing or out of range\n", path);
603 }
else if (notches < 0) {
604 const uint32_t dec = (uint32_t)(-notches);
Multi-channel console log store backing the board view's tabbed console.
const char * board_console_line(board_console_ch_t ch, uint32_t back)
Fetch a retained line by age (0 = newest) from a channel.
uint32_t board_console_count(board_console_ch_t ch)
Count of lines currently retained in a channel ring.
const char * board_console_name(board_console_ch_t ch)
Short display name for a channel (the tab caption).
uint32_t board_console_total(board_console_ch_t ch)
Monotonic count of lines ever pushed to a channel.
board_console_ch_t
Console channels the board view exposes as tabs.
@ k_board_console_ch_all
Aggregate of all lanes (arrival order).
@ k_board_console_ch_count
Channel count (ring + tab array size).
board_overlay_btn_t board_overlay_hit_button(uint16_t x, uint16_t y, uint16_t panel_w)
Classify a composite-space click against the sidebar's on-screen buttons.
board_overlay_btn_t
On-screen sidebar control a click landed on.
@ k_board_overlay_btn_sw2
On-screen SW2 (P008) push-button.
@ k_board_overlay_btn_console
Console panel: toggle autoscroll.
@ k_board_overlay_btn_battery
Battery slider track: set SOC.
@ k_board_overlay_btn_batt_chg
Battery CHG button: toggle charge.
@ k_board_overlay_btn_none
Click did not land on a control.
@ k_board_overlay_btn_lowpower
CORE low-power toggle button.
bool board_overlay_hit_console_tab(uint16_t x, uint16_t y, uint16_t panel_w, uint32_t tab_count, uint32_t *out_idx)
Map a composite-space click on the console tab bar to a tab index.
@ k_overlay_console_tabs_max
Tab-bar capacity (channels = tabs).
@ k_overlay_line_cap
Max chars copied per console line.
@ k_overlay_console_rows
Console lines shown (newest at bottom).
bool board_overlay_battery_pct_at(uint16_t x, uint16_t panel_w, uint8_t *out_pct)
Map a click column on the battery slider track to a 0..100 SOC percent.
@ k_overlay_led_count
LED1 / LED2 / LED3 (mirrors the BSP).
Register-accurate peripheral-model framework for the board emulator.
uint32_t board_periph_led_level(board_led_id_t led)
Read the last driven output level of a board LED.
void board_periph_battery_get(uint8_t *out_soc, bool *out_charging)
Read back the emulated battery state (for the status overlay).
bool board_periph_touch_last(uint16_t *x, uint16_t *y)
Report the coordinates of the most recently drained touch contact.
const char * board_periph_uart_last_line(void)
The most recent complete line the firmware transmitted over any SCI.
board_led_id_t
Board user-LED identity, mirrored from the EK-RA8D2 BSP.
uint32_t board_periph_uart_tx_total(void)
Total bytes the firmware has transmitted over all SCI channels.
uint32_t board_periph_irq_total(void)
Total NVIC interrupts the ICU has delivered in this run.
uint16_t board_periph_led_color_rgb565(board_led_id_t led)
The on-colour of a board LED as a packed RGB565 value.
void board_periph_battery_set(uint8_t soc_pct, bool charging)
Set the emulated battery state surfaced by the MAX17048 fuel gauge.
bool board_periph_gpio_get_input(uint8_t port, uint8_t pin)
Read the externally-injected input level of a GPIO pin.
void board_periph_gpio_set_input(uint8_t port, uint8_t pin, bool level)
Drive a GPIO pin's input level from outside the firmware.
void board_periph_touch_inject(uint16_t x, uint16_t y)
Arm a pending touch contact for the modelled GT911 device.
uint32_t board_periph_irq_count(uint32_t irq)
Number of times a given NVIC line was taken in this run.
SD-card-over-SPI device model for ra8_emulator (attached to SPI_B).
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).
USBFS controller model + a virtual USB host for the board emulator.
const char * board_usb_state_string(void)
One-line, human-readable USB device state for the board view.
Cortex-M exception model constants and interfaces for ra8_emulator.
Bounded raw-descriptor I/O seam for the RA8 emulator.
@ k_emu_io_ok
The complete operation succeeded.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
emu_io_result_t priv_emu_io_read_exact(int fd, void *buf, size_t count)
Read exactly count sequential bytes or report EOF/fault progress.
emu_io_result_t priv_emu_io_close(emu_io_file_t *file)
Close and invalidate an owned raw file descriptor.
emu_io_result_t priv_emu_io_open_read(const char *path, emu_io_file_t *file)
Open and stat a regular file for bounded raw reading.
Sparse MMIO model of the Renesas peripheral space.
uint32_t emu_mmio_writes(void)
Total peripheral MMIO writes this run (monotonic).
uint32_t emu_mmio_reads(void)
Total peripheral MMIO reads this run (monotonic).
static void internal_fill_status(board_status_t *st, const char *app_name)
Snapshot the live peripheral state into a board-view status struct.
void emu_set_primary_core(board_primary_core_t core)
Implementation of emu_set_primary_core() – plain state write.
static void internal_fill_status_console(board_status_t *st)
Perform fill status console for the emu view model.
static uint32_t internal_console_advance_scroll(uint32_t avail, uint32_t total)
Advance and clamp the console scroll offset, returning where to read.
static uint32_t s_view_log_seen
void apply_battery_click(board_overlay_btn_t btn, uint16_t cx, uint16_t disp_w)
Apply a POWER-section click to the fuel-gauge model.
void set_switch(board_overlay_btn_t btn, bool pressed)
Toggle a user switch's pressed level (active-low) for an on-screen button.
void emu_view_select_console_tab(uint32_t tab_idx)
Implementation of emu_view_select_console_tab() – tab switch.
static bool internal_parse_panel(char *text, board_panel_t *out)
Parse bounded panel-config text already loaded into memory.
static void internal_fill_status_hw(board_status_t *st, const char *app_name)
Snapshot the LED / USB / UART / IRQ / switch / battery / SD state.
bool emu_low_power(void)
Implementation of emu_low_power() – plain state read.
bool load_panel(const char *path, board_panel_t *out)
Load a panel descriptor (name / width / height) from a TOML-ish file.
static void internal_fill_console_tabs(board_status_t *st)
Populate the console tab-bar metadata in st.
static uint32_t s_view_pc
void emu_view_mark_stopped(uint32_t pc)
Implementation of emu_view_mark_stopped() – final held frame.
void emu_set_low_power(bool on)
Implementation of emu_set_low_power() – plain state write.
static void internal_panel_apply_kv(board_panel_t *out, const char *key, const char *val)
Apply one recognised key=value pair to out; unknown keys are ignored.
void emu_view_publish(uint32_t pc, uint32_t chunks)
Implementation of emu_view_publish() – run-loop telemetry.
static board_console_ch_t s_view_console_ch
static uint32_t s_view_scroll
static void internal_panel_set_name(board_panel_t *out, const char *val)
Copy the panel name value into out, stripping optional quotes.
void emu_view_wheel(int32_t notches)
Implementation of emu_view_wheel() – scrollback paging.
static uint32_t s_view_chunks
static board_primary_core_t s_primary_core
static bool internal_panel_split_kv(char *line, char **key, char **val)
Split one config line into a trimmed key / value pair, in place.
static void internal_panel_rstrip(char *s)
Trim trailing space/tab/CR/LF in place.
static bool s_view_autoscroll
static bool s_view_running
void emu_view_reset_console(void)
Implementation of emu_view_reset_console() – warm-reboot view reset.
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.
void unrotate_click(uint16_t cx, uint16_t cy, uint16_t panel_w, uint16_t panel_h, uint32_t deg, uint16_t *nx, uint16_t *ny)
Map a click in the rotated displayed panel back to native panel coords.
board_overlay_btn_t route_click(uint16_t cx, uint16_t cy, uint16_t panel_w, uint16_t panel_h, uint16_t disp_w, uint32_t rotate_deg)
Route a composite-space click to the right input model.
board_primary_core_t emu_primary_core(void)
Implementation of emu_primary_core() – plain state read.
Board-view presentation: frames, composition, input routing, panels.
@ k_emu_sw1_pin
SW1 -> P009.
@ k_emu_sw2_pin
SW2 -> P008.
@ k_emu_sw_port
Both user switches sit on PORT0.
@ k_rotate_90
90 deg clockwise (-> portrait).
@ k_rotate_270
90 deg counter-clockwise.
@ k_rotate_180
Upside down.
@ k_panel_dim_max
Sanity cap on a panel dimension.
@ k_panel_line_max
Max panel-config line length.
@ k_strtol_base10
Base-10 radix for strtol parses.
board_primary_core_t
Which core the firmware targets: gates the M85-only instruction seams.
@ k_core_m33
Cortex-M33 primary: the M85-only instruction seams stay off.
@ k_core_m85
Cortex-M85 primary (default): MVE/long-shift seams armed.
@ k_uart_log_max
Console ring depth (mirrors SCI model).
Internal streamed panel/composite builder seam.
bool priv_emu_view_surface_build(uc_engine *uc, emu_presentation_workspace_t *presentation, const board_status_t *status)
Build one exact fd-backed composite from live engine and status state.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
ra8_board_eth_pin_t pin
Pin.
int strncmp(const char *s1, const char *s2, size_t n)
Compare two strings up to a specified length.
void * memset(void *dst, int value, size_t n)
Fill memory with a constant byte value.
size_t strlen(const char *s)
Calculate string length.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
char * strchr(const char *s, int c)
Locate first occurrence of character in string.
const char * label
Short ASCII caption (e.g.
uint16_t color
RGB565 lit colour (blue / green / red).
bool on
True when the GPIO pin is driven high.
Display descriptor loaded from a flat key=value panel file.
uint16_t height
Pixel height.
uint16_t width
Pixel width.
char name[k_panel_name_max]
Name.
Live peripheral snapshot the status sidebar renders each frame.
uint16_t touch_y
Last touch Y (if any).
char console[k_overlay_console_rows][k_overlay_line_cap]
Visible lines (active tab).
const char * app_name
App / window title.
uint32_t console_ch_count
Tabs to draw (<= max).
bool battery_charging
Fuel gauge reports charge.
uint32_t irq1
IRQ1 taken count.
uint32_t mmio_writes
Modelled-peripheral MMIO writes served.
uint16_t touch_x
Last touch X (if any).
uint8_t battery_soc
Fuel-gauge SOC percent.
bool core_is_m33
Primary core is the M33.
uint32_t console_active_ch
Active tab index.
bool console_autoscroll
True = following live tail; false=paused.
board_led_status_t leds[k_overlay_led_count]
Per-LED indicator state.
uint32_t console_total
Total lines in the active channel ring.
uint32_t console_ch_count_lines[k_overlay_console_tabs_max]
Per-tab line count.
uint32_t uart_tx_total
Total UART TX bytes the firmware emitted.
uint32_t irq0
IRQ0 taken count.
uint64_t sd_bytes
SD card size in bytes (>4GB).
bool sw1_pressed
On-screen SW1 held down.
const char * uart_line
Last captured UART line.
bool sd_attached
A microSD card is attached.
uint32_t console_count
Visible lines populated (<= rows).
const char * console_ch_name[k_overlay_console_tabs_max]
Per-tab caption.
const char * sd_label
SD volume label (–sd-new).
bool low_power
Low-power (M33 4:1 clock) on.
uint32_t console_scroll
Lines scrolled back from newest (0=live).
uint8_t sd_fat_bits
12/16/32 if –sd-new, else 0.
uint32_t chunks
Emulation chunks run so far.
bool running
True while the run loop is live (not parked).
uint32_t pc
Current emulated program counter.
const char * usb_state
USB device state string.
uint32_t mmio_reads
Modelled-peripheral MMIO reads served.
bool has_touch
A touch has been drained.
bool sw2_pressed
On-screen SW2 held down.
uint32_t irq_total
Total NVIC IRQs taken.
Raw descriptor plus its stat-derived byte length.
emu_io_status_t status
Semantic completion status.
One independent owned surface plus non-owning bounded scratch.