|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Board-view presentation: frames, composition, input routing, panels. More...
#include <stdint.h>#include <unicorn/unicorn.h>#include "board_overlay.h"#include "emu_presentation.h"#include "ra8_attributes.h"Go to the source code of this file.
Data Structures | |
| struct | board_panel_t |
| Display descriptor loaded from a flat key=value panel file. More... | |
Enumerations | |
| enum | emu_sw_pin_t : uint8_t { k_emu_sw_port = 0U , k_emu_sw1_pin = 9U , k_emu_sw2_pin = 8U } |
| EK-RA8D2 user-switch GPIO coordinates (active-low): SW1 P009, SW2 P008. More... | |
| enum | view_cfg_t : uint32_t { k_view_default_w = 1024U , k_view_default_h = 600U , k_view_present_every = 16U , k_view_max_chunks = 4000000U , k_view_idle_us = 16000U , k_view_frame_us = 16000U , k_view_yield_us = 2000U , k_us_per_s = 1000000U , k_ns_per_us = 1000U , k_uart_log_max = 64U , k_reboot_settle = 1500U , k_record_ms_per_sec = 1000U , k_record_fps = 20U , k_record_every = 50U } |
| enum | board_primary_core_t : uint8_t { k_core_m85 = 0U , k_core_m33 = 1U } |
| Which core the firmware targets: gates the M85-only instruction seams. More... | |
| enum | panel_rotate_t : uint32_t { k_rotate_0 = 0U , k_rotate_90 = 90U , k_rotate_180 = 180U , k_rotate_270 = 270U } |
| Display rotation (degrees clockwise) applied to the panel for viewing. More... | |
| enum | panel_limits_t : uint32_t { k_strtol_base10 = 10U , k_panel_line_max = 256U , k_panel_name_max = 64U , k_panel_dim_max = 4096U } |
Functions | |
| int | write_ppm (const char *path, const emu_presentation_workspace_t *presentation) |
| Write an RGB565 frame to a binary PPM (P6) for headless inspection. | |
| 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. | |
| 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 | apply_battery_click (board_overlay_btn_t btn, uint16_t cx, uint16_t disp_w) |
| Apply a POWER-section click to the fuel-gauge / core model. | |
| 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. | |
| 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. | |
| bool | load_panel (const char *path, board_panel_t *out) |
| Load a panel descriptor (name / width / height) from a TOML-ish file. | |
| void | emu_view_publish (uint32_t pc, uint32_t chunks) |
| Publish the run-loop telemetry the board view shows. | |
| void | emu_view_mark_stopped (uint32_t pc) |
Mark the run ended: the held frame shows "parked" at pc. | |
| void | emu_view_wheel (int32_t notches) |
| Page the console scrollback by mouse-wheel notches. | |
| void | emu_view_select_console_tab (uint32_t tab_idx) |
Switch the visible console channel to tab_idx (tab-bar click). | |
| void | emu_view_reset_console (void) |
| Reset the console-scrollback view (warm-reboot support). | |
| board_primary_core_t | emu_primary_core (void) |
| The primary core the firmware targets (label + seam gating). | |
| void | emu_set_primary_core (board_primary_core_t core) |
| Select the primary core (CLI –primary-core). | |
| bool | emu_low_power (void) |
| Whether the M33 4:1-slower low-power clock model is active. | |
| void | emu_set_low_power (bool on) |
| Set the low-power clock model (CLI –low-power / GUI toggle). | |
Board-view presentation: frames, composition, input routing, panels.
Everything the emulator presents or routes for a human: the GLCDC frame build from live register state, the RGB565 -> PPM writer, the status sidebar snapshot, panel rotation and click unrotation, the on-screen switch / battery / console-tab click routing shared by the live window and the headless –click, the panel descriptor loader, the console-scrollback view state, and the core-control state (primary core label + the M33 low-power clock model) the GUI toggles live.
Split out of the ra8_emulator main translation unit; behaviour unchanged.
Definition in file emu_view.h.
| enum board_primary_core_t : uint8_t |
Which core the firmware targets: gates the M85-only instruction seams.
| Enumerator | |
|---|---|
| k_core_m85 | Cortex-M85 primary (default): MVE/long-shift seams armed. |
| k_core_m33 | Cortex-M33 primary: the M85-only instruction seams stay off. |
Definition at line 63 of file emu_view.h.
| enum emu_sw_pin_t : uint8_t |
EK-RA8D2 user-switch GPIO coordinates (active-low): SW1 P009, SW2 P008.
| Enumerator | |
|---|---|
| k_emu_sw_port | Both user switches sit on PORT0. |
| k_emu_sw1_pin | SW1 -> P009. |
| k_emu_sw2_pin | SW2 -> P008. |
Definition at line 35 of file emu_view.h.
| enum panel_limits_t : uint32_t |
| Enumerator | |
|---|---|
| k_strtol_base10 | Base-10 radix for strtol parses. |
| k_panel_line_max | Max panel-config line length. |
| k_panel_name_max | Max panel name (incl NUL). |
| k_panel_dim_max | Sanity cap on a panel dimension. |
Definition at line 84 of file emu_view.h.
| enum panel_rotate_t : uint32_t |
Display rotation (degrees clockwise) applied to the panel for viewing.
The firmware always renders at its compiled resolution; –rotate only turns the emulated panel for display (e.g. a 1024x600 landscape app shown as a 600x1024 portrait), so a vertically-mounted screen can be previewed. Clicks are mapped back to native coordinates via unrotate_click.
| Enumerator | |
|---|---|
| k_rotate_0 | Native orientation. |
| k_rotate_90 | 90 deg clockwise (-> portrait). |
| k_rotate_180 | Upside down. |
| k_rotate_270 | 90 deg counter-clockwise. |
Definition at line 77 of file emu_view.h.
| enum view_cfg_t : uint32_t |
Definition at line 42 of file emu_view.h.
| 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 / core model.
A click on the battery slider track maps the click column to a 0..100 percent and writes it while preserving the charge state; a click on the CHG toggle flips charging while preserving SOC; the CORE low-power button flips the M33 4:1-clock model live. Shared by the live window and the headless --click so both behave alike.
| [in] | btn | The POWER button hit (slider, CHG, or low-power). |
| [in] | cx | Click column in composite pixels (for the slider map). |
| [in] | disp_w | Displayed panel width (the sidebar origin). |
btn is one of the POWER-section buttons. Apply a POWER-section click to the fuel-gauge / core model.
A click on the battery slider track maps the click column to a 0..100 percent (board_overlay_battery_pct_at) and writes it while preserving the charge state; a click on the CHG toggle flips charging while preserving SOC. Shared by the live window and the headless --click so both behave alike.
| [in] | btn | The POWER button hit (battery slider or CHG toggle). |
| [in] | cx | Click column in composite pixels (for the slider map). |
| [in] | disp_w | Displayed panel width (the sidebar origin). |
Definition at line 289 of file emu_view.c.
References board_overlay_battery_pct_at(), board_periph_battery_get(), board_periph_battery_set(), k_board_overlay_btn_batt_chg, k_board_overlay_btn_battery, k_board_overlay_btn_lowpower, and s_low_power.
Referenced by internal_run_loop_tick_inputs(), internal_run_loop_view(), and route_click().
| 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.
Clears and fills the fd-backed composite, copies the live GLCDC layer through bounded rotation tiles, then renders the exact legacy sidebar through its clipped rectangle sink.
| [in,out] | uc | Unicorn engine (read for the GLCDC framebuffer). |
| [in,out] | presentation | Owned fd and caller-owned tile scratch. |
| [in] | app_name | Window / app title for the sidebar caption. |
| true | The exact composite is ready. |
| false | An engine read or raw-fd sink operation failed. |
presentation is active, open, and outlives the operation. Definition at line 371 of file emu_view.c.
References internal_fill_status(), and priv_emu_view_surface_build().
Referenced by internal_run_loop_record(), internal_run_view_maybe_present(), priv_run_hold_view(), and priv_run_write_outputs().
| bool emu_low_power | ( | void | ) |
Whether the M33 4:1-slower low-power clock model is active.
| false | Full-speed (M85 clock) modelling. |
Whether the m33 4:1-slower low-power clock model is active; this step is contained within the emu view model and uses bounded caller or module-owned storage.
Whether the M33 4:1-slower low-power clock model is active.
Definition at line 645 of file emu_view.c.
References s_low_power.
Referenced by internal_main_load_primary(), and internal_run_inner_budget().
| board_primary_core_t emu_primary_core | ( | void | ) |
The primary core the firmware targets (label + seam gating).
| k_core_m85 | Default: the M85-only instruction seams are armed. |
| k_core_m33 | –primary-core m33: the M85 seams stay off. |
The primary core the firmware targets (label + seam gating); this step is contained within the emu view model and uses bounded caller or module-owned storage.
The primary core the firmware targets (label + seam gating).
Definition at line 633 of file emu_view.c.
References s_primary_core.
Referenced by internal_main_install_run_seams(), and internal_main_load_primary().
| void emu_set_low_power | ( | bool | on | ) |
Set the low-power clock model (CLI –low-power / GUI toggle).
| [in] | on | true to shrink the chunk budget by the 4:1 clock ratio. |
on. Set the low-power clock model (cli –low-power / gui toggle); this step is contained within the emu view model and uses bounded caller or module-owned storage.
Set the low-power clock model (CLI –low-power / GUI toggle).
Definition at line 651 of file emu_view.c.
References s_low_power.
Referenced by internal_args_try_mode().
| void emu_set_primary_core | ( | board_primary_core_t | core | ) |
Select the primary core (CLI –primary-core).
| [in] | core | The core to model. |
core. Select the primary core (cli –primary-core); this step is contained within the emu view model and uses bounded caller or module-owned storage.
Select the primary core (CLI –primary-core).
Definition at line 639 of file emu_view.c.
References s_primary_core.
Referenced by internal_args_try_mode().
| void emu_view_mark_stopped | ( | uint32_t | pc | ) |
Mark the run ended: the held frame shows "parked" at pc.
| [in] | pc | Final program counter. |
pc. Mark the run ended: the held frame shows "parked" at pc; this step is contained within the emu view model and uses bounded caller or module-owned storage.
Mark the run ended: the held frame shows "parked" at pc.
Definition at line 591 of file emu_view.c.
References s_view_pc, and s_view_running.
Referenced by priv_run_report().
| void emu_view_publish | ( | uint32_t | pc, |
| uint32_t | chunks ) |
Publish the run-loop telemetry the board view shows.
| [in] | pc | Current program counter. |
| [in] | chunks | Emulation-chunk counter. |
Publish the run-loop telemetry the board view shows; this step is contained within the emu view model and uses bounded caller or module-owned storage.
Publish the run-loop telemetry the board view shows.
Definition at line 584 of file emu_view.c.
References s_view_chunks, and s_view_pc.
Referenced by internal_run_loop_prologue().
| void emu_view_reset_console | ( | void | ) |
Reset the console-scrollback view (warm-reboot support).
Reset the console-scrollback view (warm-reboot support); this step is contained within the emu view model and uses bounded caller or module-owned storage.
Reset the console-scrollback view (warm-reboot support).
Definition at line 624 of file emu_view.c.
References k_board_console_ch_all, s_view_autoscroll, s_view_console_ch, s_view_log_seen, and s_view_scroll.
Referenced by warm_reboot().
| void emu_view_select_console_tab | ( | uint32_t | tab_idx | ) |
Switch the visible console channel to tab_idx (tab-bar click).
Resets the scrollback to the live tail of the newly selected channel, exactly as a tab click in the window does; the headless –click classification shares this path.
| [in] | tab_idx | The board_console channel index selected. |
tab_idx is a valid board_console channel. Switch the visible console channel to tab_idx (tab-bar click).
Definition at line 615 of file emu_view.c.
References board_console_total(), s_view_autoscroll, s_view_console_ch, s_view_log_seen, and s_view_scroll.
Referenced by internal_run_classify_click().
| void emu_view_wheel | ( | int32_t | notches | ) |
Page the console scrollback by mouse-wheel notches.
Scrolling up reveals older lines AND pauses autoscroll (so new output no longer yanks the view to the bottom); scrolling back down to the tail re-enables autoscroll. The status snapshot clamps the offset and holds the absolute position while paused.
| [in] | notches | Wheel notches (positive = up / older lines). |
Page the console scrollback by mouse-wheel notches.
Definition at line 598 of file emu_view.c.
References s_view_autoscroll, and s_view_scroll.
Referenced by internal_run_loop_view().
| bool load_panel | ( | const char * | path, |
| board_panel_t * | out ) |
Load a panel descriptor (name / width / height) from a TOML-ish file.
A flat key = value panel descriptor (see tools/ra8_emulator/panels/), so the board emulator becomes whatever display a config describes – not just the EK-RA8D2 1024x600. The raw descriptor backend rejects files over 4096 bytes, reads into a fixed stack buffer, and parses bounded lines without allocation. Blank lines and '#' comments are ignored and quotes are stripped from the name.
| [in] | path | Panel config path. |
| [out] | out | Filled descriptor on success. |
| false | The file was unreadable or the dimensions were out of range. |
out is non-null. path is NUL-terminated. out holds the descriptor; on false a diagnostic printed. < Maximum accepted panel-description byte count.
Definition at line 550 of file emu_view.c.
References board_panel_t::height, internal_parse_panel(), k_emu_io_ok, k_panel_dim_max, memset(), priv_emu_io_close(), priv_emu_io_errf(), priv_emu_io_open_read(), priv_emu_io_read_exact(), emu_io_result_t::status, and board_panel_t::width.
Referenced by internal_main_apply_panel().
| 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.
A console-tab click switches the visible channel; a console-body click toggles autoscroll; an on-screen SW1/SW2 presses that user switch (active-low); a POWER click drives the battery / low-power model; any other click is unrotated and injected as a GT911 touch – the same path the firmware's real ra8_touch_read drains. Shared by the live window and the headless --click so both behave alike.
| [in] | cx | Click column in composite pixels. |
| [in] | cy | Click row in composite pixels. |
| [in] | panel_w | Native panel width (for the touch unrotate). |
| [in] | panel_h | Native panel height (for the touch unrotate). |
| [in] | disp_w | Displayed panel width (the sidebar origin). |
| [in] | rotate_deg | Active display rotation. |
| k_board_overlay_btn_none | The click was injected as a touch. |
An on-screen SW1 / SW2 button toggles that user switch (active-low); any other click is mapped back through unrotate_click and injected as a GT911 touch – the same path the firmware's real ra8_touch_read drains. This is shared by the live window and the headless --click so both behave alike.
| [in] | cx | Click column in composite pixels. |
| [in] | cy | Click row in composite pixels. |
| [in] | panel_w | Native panel width (for the touch unrotate). |
| [in] | panel_h | Native panel height (for the touch unrotate). |
| [in] | disp_w | Displayed panel width (the sidebar origin for buttons). |
| [in] | rotate_deg | Active display rotation. |
Definition at line 326 of file emu_view.c.
References apply_battery_click(), board_console_total(), board_overlay_hit_button(), board_overlay_hit_console_tab(), board_periph_touch_inject(), k_board_console_ch_count, k_board_overlay_btn_batt_chg, k_board_overlay_btn_battery, k_board_overlay_btn_console, k_board_overlay_btn_lowpower, k_board_overlay_btn_none, s_view_autoscroll, s_view_console_ch, s_view_log_seen, s_view_scroll, set_switch(), and unrotate_click().
Referenced by internal_run_loop_view().
| void set_switch | ( | board_overlay_btn_t | btn, |
| bool | pressed ) |
Toggle a user switch's pressed level (active-low) for an on-screen button.
SW1/SW2 are momentary push-buttons wired active-low: held down drives the pin LOW, released returns it HIGH. Driving the level directly makes a click behave as a real button (press on mouse-down, release on mouse-up), not a latching switch.
| [in] | btn | The overlay button hit (SW1 or SW2). |
| [in] | pressed | true while held down, false on release. |
btn is one of the switch buttons. pressed. Definition at line 266 of file emu_view.c.
References board_periph_gpio_set_input(), k_board_overlay_btn_sw2, k_emu_sw1_pin, k_emu_sw2_pin, k_emu_sw_port, and pin.
Referenced by internal_run_loop_tick_inputs(), internal_run_loop_view(), and route_click().
| 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.
| [in] | cx | Click column in displayed-panel pixels. |
| [in] | cy | Click row in displayed-panel pixels. |
| [in] | panel_w | Native panel width. |
| [in] | panel_h | Native panel height. |
| [in] | deg | Active display rotation (0/90/180/270). |
| [out] | nx | Receives the native column. |
| [out] | ny | Receives the native row. |
nx and ny are non-null. deg is one of the panel_rotate_t values. Map a click in the rotated displayed panel back to native panel coords; this step is contained within the emu view model and uses bounded caller or module-owned storage.
Definition at line 242 of file emu_view.c.
References k_rotate_180, k_rotate_270, and k_rotate_90.
Referenced by internal_run_loop_tick_inputs(), and route_click().
| int write_ppm | ( | const char * | path, |
| const emu_presentation_workspace_t * | presentation ) |
Write an RGB565 frame to a binary PPM (P6) for headless inspection.
Uses bounded RGB conversion plus a synced sibling transaction so a failed export cannot replace an existing target with a partial image.
| [in] | path | Output file path. |
| [in] | presentation | Open fd-backed RGB565 composite to stream. |
| 0 | The frame was written. |
| -1 | Transaction creation, raw write, sync, or publication failed. |
presentation is open and holds the full composite. path names a writable location. Definition at line 300 of file emu_view_surface.c.
References emu_presentation_workspace_t::composite_height, emu_presentation_workspace_t::composite_width, emu_io_txn_t::fd, emu_presentation_workspace_t::fd, internal_write_ppm_pixels(), k_emu_io_ok, priv_emu_io_filef(), priv_emu_io_txn_abort(), priv_emu_io_txn_begin(), priv_emu_io_txn_commit(), and emu_io_result_t::status.
Referenced by internal_run_loop_record(), and priv_run_write_outputs().