54typedef enum : uint64_t {
61typedef enum : uint32_t {
71typedef enum : uint32_t {
141 if (
emu_mem_read(uc, addr, &v,
sizeof(v)) != UC_ERR_OK) {
181 if ((buf == 0U) || (size == 0U) || (size > (uint32_t)
k_rtt_size_sane)) {
184 return (wr < size) && (rd < size);
215 if (hit ==
nullptr) {
219 const uint64_t cb = stage_addr + (uint64_t)(hit -
s_rtt_stage);
224 left -= (uint64_t)(hit - p) + 1U;
291 const char c = (char)
byte;
343 if ((buf == 0U) || (size == 0U) || (size > (uint32_t)
k_rtt_size_sane) || (wr >= size) ||
344 (rd >= size) || (wr == rd)) {
347 const uint32_t avail = (wr > rd) ? (wr - rd) : ((size - rd) + wr);
351 const uint32_t first = ((size - rd) < n) ? (size - rd) : n;
362 for (uint32_t i = 0U; i < got; i++) {
365 rd = (rd + got) % size;
368 s_rtt.drained += got;
393 if (
s_rtt.cb_addr == 0U) {
398 if (
s_rtt.cb_addr == 0U) {
401 s_rtt.scan_gap *= 2U;
443 if (
s_rtt.cb_addr == 0U) {
447 " SEGGER RTT : control block @0x%08llX, drained %u byte(s), %u line(s)\n",
448 (
unsigned long long)
s_rtt.cb_addr,
503typedef enum : uint32_t {
517 .name =
"SEGGER RTT",
Multi-channel console log store backing the board view's tabbed console.
void board_console_push(board_console_ch_t ch, const char *line)
Append one completed line to a channel ring and the ALL ring.
@ k_board_console_ch_rtt
SEGGER RTT up-buffer 0 drain ([rtt]).
Decentralized peripheral-block registry for the board emulator core.
void board_periph_register_block(const board_periph_block_t *block)
Register a peripheral block's descriptor with the core registry.
static RA8_INTERNAL uint64_t internal_rtt_match_stage(uc_engine *uc, uint64_t stage_addr, uint64_t len)
Match the staged bytes for a validated control-block ID.
static RA8_INTERNAL void internal_rtt_line_feed(uint8_t byte)
Feed one drained byte into the line assembler.
static const char s_k_rtt_id[k_rtt_id_len]
The 10-byte control-block ID a debug probe scans RAM for.
static RA8_INTERNAL void internal_rtt_block_register(void)
Self-register the RTT drain model before main (host constructor).
rtt_scan_window_t
SRAM window the control-block scan covers (mirrors main.c's map).
@ k_rtt_scan_step
Bytes staged per scan sub-read.
@ k_rtt_scan_base
On-chip SRAM base (dual-core banks).
@ k_rtt_scan_span
The full 4 MiB window main.c maps.
static RA8_INTERNAL void internal_rtt_reset(void)
Reset the RTT drain model to power-on state (warm reboot).
static RA8_INTERNAL void internal_rtt_mmio_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
MMIO write stub – never dispatched (this block owns no window).
static RA8_INTERNAL void internal_rtt_scan(uc_engine *uc)
Scan the emulated SRAM window for the RTT control-block ID.
static const board_periph_block_t s_k_rtt_block
This block's descriptor: tick/reset/report only, no MMIO window.
rtt_order_t
Per-tick order slot for the RTT drain (right after the SCI console).
@ k_rtt_block_order
After SCI (30), before the core IRQ section (35).
static RA8_INTERNAL void internal_rtt_report(void)
End-of-run RTT section: block address + drained totals.
rtt_tune_t
Model tuning: scan cadence, sanity caps, and line assembly.
@ k_rtt_drain_max
Bytes drained per tick (bounded).
@ k_rtt_id_len
Length of the "SEGGER RTT" ID match.
@ k_rtt_scan_first_tick
Ticks before the first RAM scan.
@ k_rtt_line_max
Chars buffered before a forced flush.
@ k_rtt_max_up_sane
Reject max_up above this (garbage).
@ k_rtt_scan_max_gap
Backoff cap between fruitless scans.
@ k_rtt_size_sane
Reject ring sizes above 1 MiB.
static RA8_INTERNAL uint64_t internal_rtt_mmio_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read stub – never dispatched (this block owns no window).
static RA8_INTERNAL void internal_rtt_tick(uc_engine *uc)
Per-chunk advance: discover the control block, then keep it drained.
static RA8_INTERNAL bool internal_rtt_cb_valid(uc_engine *uc, uint64_t cb_addr)
Validate a candidate control block beyond its ID match.
static RA8_INTERNAL void internal_rtt_drain(uc_engine *uc)
Drain up-buffer 0 of the discovered control block, host-style.
static RA8_INTERNAL uint32_t internal_rtt_rd32(uc_engine *uc, uint64_t addr)
Read a 32-bit little-endian word from emulated memory.
static uint8_t s_rtt_seg[k_rtt_drain_max]
Staging buffer for the per-tick ring drain (bounded segments).
static uint8_t s_rtt_stage[(uint32_t) k_rtt_scan_step+(uint32_t) k_rtt_id_len]
Staging buffer for scan sub-reads (step + ID overlap carry).
rtt_cb_layout_t
Control-block field offsets (SEGGER_RTT.h, 32-bit target layout).
@ k_rtt_up_off_wr
u32 write offset (target-owned).
@ k_rtt_up_off_size
u32 ring capacity in bytes.
@ k_rtt_off_max_up
u32 count of up-buffers (after id[16]).
@ k_rtt_up_off_rd
u32 read offset (host-owned; we advance).
@ k_rtt_up_off_buf
u8* ring storage pointer within a desc.
@ k_rtt_off_up0
Up-buffer 0 descriptor (after max_down).
Bounded raw-descriptor I/O seam for the RA8 emulator.
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_outf(const char *format,...)
Format bounded text and write it to the injected output descriptor.
uc_err emu_mem_read(uc_engine *uc, uint64_t address, void *bytes, size_t count)
Read guest memory through the central access seam.
uc_err emu_mem_write(uc_engine *uc, uint64_t address, const void *bytes, size_t count)
Write guest memory through the central access seam.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
void * memchr(const void *s, int c, size_t n)
Locate a byte in a memory area.
int memcmp(const void *a, const void *b, size_t n)
Compare bytes in two memory areas.
A modelled peripheral block's self-description for the core registry.
RTT drain-model state (discovery, line assembly, observability).
uint32_t line_len
Chars buffered in line.
uint32_t scan_gap
Current backoff gap between scans.
uint32_t lines
Completed lines surfaced.
uint64_t cb_addr
Control-block address (0 = not found).
char line[k_rtt_line_max+1U]
In-flight (not yet newline-ended) line.
uint32_t ticks
Ticks elapsed (scan cadence clock).
uint32_t next_scan
Tick of the next discovery scan.
uint32_t drained
Total bytes drained from up-buffer 0.