ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
board_console.h File Reference

Multi-channel console log store backing the board view's tabbed console. More...

#include <stdint.h>
Include dependency graph for board_console.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  board_console_ch_t : uint32_t {
  k_board_console_ch_all = 0U ,
  k_board_console_ch_uart = 1U ,
  k_board_console_ch_itm = 2U ,
  k_board_console_ch_rtt = 3U ,
  k_board_console_ch_spi = 4U ,
  k_board_console_ch_i2c = 5U ,
  k_board_console_ch_can = 6U ,
  k_board_console_ch_usb = 7U ,
  k_board_console_ch_sd = 8U ,
  k_board_console_ch_ospi = 9U ,
  k_board_console_ch_i2s = 10U ,
  k_board_console_ch_adc = 11U ,
  k_board_console_ch_dac = 12U ,
  k_board_console_ch_gpio = 13U ,
  k_board_console_ch_dma = 14U ,
  k_board_console_ch_net = 15U ,
  k_board_console_ch_count = 16U
}
 Console channels the board view exposes as tabs. More...
enum  board_console_dims_t : uint32_t {
  k_board_console_line_cap = 128U ,
  k_board_console_ring_depth = 64U
}
 Fixed ring geometry (mirrors the overlay line cap + SCI ring depth). More...

Functions

const char * board_console_name (board_console_ch_t ch)
 Short display name for a channel (the tab caption).
void board_console_push (board_console_ch_t ch, const char *line)
 Append one completed line to a channel ring and the ALL ring.
uint32_t board_console_count (board_console_ch_t ch)
 Count of lines currently retained in a channel ring.
uint32_t board_console_total (board_console_ch_t ch)
 Monotonic count of lines ever pushed to a channel.
const char * board_console_line (board_console_ch_t ch, uint32_t back)
 Fetch a retained line by age (0 = newest) from a channel.
void board_console_reset (void)
 Clear every channel ring (called on a warm reboot).

Detailed Description

Multi-channel console log store backing the board view's tabbed console.

The emulator surfaces firmware activity through many distinct endpoints: the SCI_B serial console ([uart] SCIn:), the CoreSight ITM/SWO trace port ([itm]), the SEGGER RTT up-buffer drain ([rtt]), and one lane per modelled I/O protocol – SPI, I2C, CAN, USB, SD, OSPI, I2S, ADC, DAC, GPIO, DMA, and the virtual network peer. These are genuinely different wires, so this module keeps one fixed-capacity scrollback ring per channel plus an aggregate ALL ring that interleaves every channel in arrival order. The board view renders one channel at a time behind a clickable tab bar, exactly like a logic analyser splits its lanes.

The store is the single source of truth for console text: the SCI model routes each completed UART line here, main.c routes each completed ITM line here, and the overlay reads back the active channel's lines to paint the console panel. It owns no Unicorn engine and no AppKit dependency – it is plain C over static ring buffers (no malloc after init), so it builds and tests on any host and the tabbed console stays deterministic / headlessly verifiable.

Since
0.1.0

Definition in file board_console.h.

Enumeration Type Documentation

◆ board_console_ch_t

enum board_console_ch_t : uint32_t

Console channels the board view exposes as tabs.

k_board_console_ch_all is the interleaved aggregate of every other channel in arrival order; the remaining values are the per-endpoint lanes. Adding a lane is a one-line change here (insert before k_board_console_ch_count) plus a matching board_console_name entry – the rings, the tab bar, and the hit-test all size themselves off k_board_console_ch_count.

Invariant
k_board_console_ch_all is 0 so a plain loop from 1 walks the source lanes only, leaving ALL to receive its copies via board_console_push.
Enumerator
k_board_console_ch_all 

Aggregate of all lanes (arrival order).

k_board_console_ch_uart 

SCI_B serial console ([uart] SCIn:).

k_board_console_ch_itm 

CoreSight ITM/SWO trace ([itm]).

k_board_console_ch_rtt 

SEGGER RTT up-buffer 0 drain ([rtt]).

k_board_console_ch_spi 

SPI_B transfer summaries.

k_board_console_ch_i2c 

I2C (IIC_B + RIIC) transfer summaries.

k_board_console_ch_can 

CAN-FD frame summaries.

k_board_console_ch_usb 

USBFS transfer / enumeration summaries.

k_board_console_ch_sd 

SD (SDHI + SD-over-SPI) block summaries.

k_board_console_ch_ospi 

Octal-SPI (xSPI) command summaries.

k_board_console_ch_i2s 

SSIE / I2S sample-block summaries.

k_board_console_ch_adc 

ADC_B conversion summaries.

k_board_console_ch_dac 

DAC_B output summaries.

k_board_console_ch_gpio 

GPIO / PORT pin-level transitions.

k_board_console_ch_dma 

DMAC + DTC transfer-complete summaries.

k_board_console_ch_net 

Ethernet / IPv4 / TCP packet summaries.

k_board_console_ch_count 

Channel count (ring + tab array size).

Definition at line 49 of file board_console.h.

◆ board_console_dims_t

enum board_console_dims_t : uint32_t

Fixed ring geometry (mirrors the overlay line cap + SCI ring depth).

Enumerator
k_board_console_line_cap 

Max chars stored per line (with NUL).

k_board_console_ring_depth 

Recent lines retained per channel.

Definition at line 70 of file board_console.h.

Function Documentation

◆ board_console_count()

uint32_t board_console_count ( board_console_ch_t ch)

Count of lines currently retained in a channel ring.

Saturates at k_board_console_ring_depth once the ring wraps. This is the number of valid back-indices for board_console_line on ch.

Parameters
[in]chChannel to query.
Returns
Lines held (0 .. k_board_console_ring_depth).
Return values
0ch is out of range or no line has been pushed yet.
Precondition
ch is a board_console_ch_t value.
The store has been zero-initialised (static lifetime guarantees it).
Postcondition
The store is left unchanged (pure query).
The result never exceeds k_board_console_ring_depth.
Note
Not thread-safe; ra8_emulator is single-threaded.
Since
0.1.0

Definition at line 207 of file board_console.c.

References k_board_console_ch_count, and s_rings.

Referenced by internal_fill_console_tabs(), and internal_fill_status_console().

◆ board_console_line()

const char * board_console_line ( board_console_ch_t ch,
uint32_t back )

Fetch a retained line by age (0 = newest) from a channel.

back counts backwards from the newest retained line: 0 is the most recent, 1 the one before it, up to board_console_count - 1. Older lines have aged out of the ring.

Parameters
[in]chChannel to read.
[in]backAge index (0 = newest).
Returns
Borrowed NUL-terminated line text, or NULL if back is too old.
Return values
NULLch out of range, or back >= board_console_count.
Precondition
ch is a board_console_ch_t value.
The returned pointer is used before the next board_console_push.
Postcondition
The store is left unchanged (pure query).
A non-NULL result points into the channel's static ring storage.
Note
Not thread-safe; ra8_emulator is single-threaded.
Since
0.1.0

Definition at line 223 of file board_console.c.

References console_ring_t::count, console_ring_t::head, k_board_console_ch_count, k_board_console_ring_depth, console_ring_t::lines, and s_rings.

Referenced by internal_fill_status_console(), and internal_run_stop_banner().

◆ board_console_name()

const char * board_console_name ( board_console_ch_t ch)

Short display name for a channel (the tab caption).

Returns a borrowed static string ("ALL" / "UART" / "ITM" / ...). The same names prefix each line in the ALL ring so the aggregate view stays legible, and the board view draws them as the tab captions.

Parameters
[in]chChannel to name (k_board_console_ch_all .. count-1).
Returns
Borrowed NUL-terminated name, or "?" if ch is out of range.
Return values
?ch is >= k_board_console_ch_count.
Precondition
ch is a board_console_ch_t value.
The returned pointer is read-only and outlives the call (static storage).
Postcondition
The returned pointer is never NULL.
The store is left unchanged (pure query).
Note
Not thread-safe; ra8_emulator is single-threaded.
Since
0.1.0

Definition at line 66 of file board_console.c.

References k_board_console_ch_count, and s_k_channel_names.

Referenced by internal_fill_console_tabs(), and internal_format_all_line().

◆ board_console_push()

void board_console_push ( board_console_ch_t ch,
const char * line )

Append one completed line to a channel ring and the ALL ring.

Copies line (bounded to k_board_console_line_cap, NUL-terminated) into the channel ch ring, then copies a "<NAME> <line>" prefixed form into the ALL ring so the aggregate view shows which endpoint each line came from. Calling with k_board_console_ch_all is rejected (ALL is populated only as the mirror of the source lanes, never directly).

Parameters
[in]chSource lane (must not be k_board_console_ch_all).
[in]lineCompleted line text (no trailing newline); copied, not retained.
Returns
Nothing.
Precondition
ch is a source lane in (k_board_console_ch_all, k_board_console_ch_count).
line is a valid NUL-terminated string.
Postcondition
On a valid call the channel ring and the ALL ring each gain one line.
Invalid ch / NULL line leave every ring unchanged.
Note
Not thread-safe; ra8_emulator is single-threaded.
Since
0.1.0

Definition at line 190 of file board_console.c.

References internal_format_all_line(), internal_ring_push(), k_board_console_ch_all, k_board_console_ch_count, k_board_console_line_cap, and s_rings.

Referenced by board_net_on_tx(), board_net_poll_rx(), internal_adc_convert_group(), internal_board_sd_begin_write(), internal_board_sd_stage_block(), internal_canfd_console_frame(), internal_ceu_do_capture(), internal_dac_write(), internal_dmac_run_transfer(), internal_dtc_run_transfer(), internal_eth_tx_kick_queue(), internal_i3c_close_transfer(), internal_npu_console_job(), internal_on_itm_stim_write(), internal_pdm_console_maybe(), internal_port_trace_leds(), internal_riic_close_transfer(), internal_rtt_line_feed(), internal_sci_capture_tx_line(), internal_sdhi_begin_read(), internal_sdhi_begin_write(), internal_spi_report(), internal_ssie_report(), internal_xspi_do_program(), internal_xspi_do_read(), and priv_usb_log_line().

◆ board_console_reset()

void board_console_reset ( void )

Clear every channel ring (called on a warm reboot).

Zeroes the head / count / total bookkeeping for all channels so a rebooted firmware starts with an empty console, matching the peripheral models' reset hooks. The line storage itself is left as-is (count gates all reads).

Returns
Nothing.
Precondition
Called from the single-threaded reset path (no concurrent push).
The store has been zero-initialised at least once (static lifetime).
Postcondition
Every channel reports board_console_count and board_console_total 0.
Subsequent board_console_line calls return NULL until a new push.
Note
Not thread-safe; ra8_emulator is single-threaded.
Since
0.1.0

Definition at line 238 of file board_console.c.

References k_board_console_ch_count, and s_rings.

Referenced by warm_reboot().

◆ board_console_total()

uint32_t board_console_total ( board_console_ch_t ch)

Monotonic count of lines ever pushed to a channel.

Unlike board_console_count (which caps at the ring depth) this keeps climbing, so the view can detect new arrivals while paused and hold its absolute scroll position.

Parameters
[in]chChannel to query.
Returns
Total lines ever pushed to ch since the last reset.
Return values
0ch is out of range or nothing has been pushed.
Precondition
ch is a board_console_ch_t value.
The store has been zero-initialised (static lifetime guarantees it).
Postcondition
The store is left unchanged (pure query).
The result is monotonic non-decreasing between resets.
Note
Not thread-safe; ra8_emulator is single-threaded.
Since
0.1.0

Definition at line 215 of file board_console.c.

References k_board_console_ch_count, and s_rings.

Referenced by emu_view_select_console_tab(), internal_fill_status_console(), and route_click().