From e20b34b5e94271f249e4c766e0ca2c115f1fbb78 Mon Sep 17 00:00:00 2001 From: Dennis Brentjes Date: Sat, 10 Oct 2026 10:09:27 +0200 Subject: [PATCH] gc_bba_test: report where ring frames actually are when t_dma fails t_dma said "p1 len 0x0002 implausible (RWP=11)", which names the symptom but not the cause: a length alone cannot distinguish an unwritten descriptor from a shifted read from a frame written at a page other than the one RRP points at. On failure it now walks all 15 ring pages, classifies each descriptor ('-' all-zero/never written, 'o' plausible length, 'x' non-zero but implausible, '?' read failed) and prints that map plus the 4 raw descriptor bytes at the RRP page. One run then shows which of those it is. Diagnostic only; no change to the pass/fail criterion or to any gateware. Co-Authored-By: Claude Opus 5 --- gc_bba_test/source/tests.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/gc_bba_test/source/tests.c b/gc_bba_test/source/tests.c index 6e99cd9..b87484b 100644 --- a/gc_bba_test/source/tests.c +++ b/gc_bba_test/source/tests.c @@ -375,8 +375,34 @@ static int t_dma(char *m, size_t n) buf[16], buf[17]); return 0; } - snprintf(m, n, "p%u len 0x%04X implausible (RWP=%u)", (unsigned)page, - (unsigned)dlen, (unsigned)(((u32)wp[1] << 8) | wp[0])); + /* Diagnostic: the length alone does not say WHERE the frames are. Walk + * all 15 ring pages and classify each descriptor, so one run shows + * whether the ring is empty, written at a different page than RRP says, + * or holding genuinely malformed descriptors: + * '-' all-zero (never written) 'o' plausible frame length + * 'x' non-zero but implausible '?' read failed + * Plus the raw 4 descriptor bytes at the RRP page. */ + { + char map[16]; + u32 pg; + u8 d[4]; + for (pg = 1; pg <= 15; pg++) { + u32 dl; + if (bba_stream((u16)(pg << 8), d, 4) < 0) { + map[pg - 1] = '?'; + continue; + } + dl = ((u32)d[2] << 8) | d[3]; + if (d[0] == 0 && d[1] == 0 && dl == 0) map[pg - 1] = '-'; + else if (dl > 4 && dl <= 1518) map[pg - 1] = 'o'; + else map[pg - 1] = 'x'; + } + map[15] = 0; + snprintf(m, n, "p%u len 0x%04X raw %02X %02X %02X %02X RWP=%u map %s", + (unsigned)page, (unsigned)dlen, + buf[0], buf[1], buf[2], buf[3], + (unsigned)(((u32)wp[1] << 8) | wp[0]), map); + } return 1; }