Files
bs_explorer/src/modules/svf/svf_glue.c
François 831bd7c129 svf: extract player core into standalone libsvf, keep bscan glue
The SVF player now lives in electronics/libsvf behind a five-function
JTAG ops table, shared with the wifi_jtag_programmer Zephyr firmware.
src/modules/svf/ shrinks to the bscan_*-backed port (bs_svf_play),
which also keeps the FTDI stale-FIFO warm-up. Local checkout override:
-DFETCHCONTENT_SOURCE_DIR_SVF=<path>.
2026-06-13 00:14:07 +02:00

59 lines
1.6 KiB
C

/*
* bs_explorer glue for libsvf: maps the svf_jtag_ops port onto the
* bscan_* TAP primitives.
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include <unistd.h>
#include "svf_glue.h"
#include "bscan/bscan.h"
static int ops_tap_reset(void *ctx)
{
return bscan_tap_reset((jtag_core *)ctx);
}
static int ops_shift_ir(void *ctx, const uint8_t *tdi, uint8_t *tdo, int nbits)
{
return bscan_shift_ir((jtag_core *)ctx, tdi, tdo, nbits);
}
static int ops_shift_dr(void *ctx, const uint8_t *tdi, uint8_t *tdo, int nbits)
{
return bscan_shift_dr((jtag_core *)ctx, tdi, tdo, nbits);
}
static int ops_idle_cycles(void *ctx, int ncycles)
{
return bscan_idle_cycles((jtag_core *)ctx, ncycles);
}
static void ops_delay_us(void *ctx, unsigned long us)
{
(void)ctx;
usleep((useconds_t)us);
}
static const svf_jtag_ops bscan_svf_ops = {
.tap_reset = ops_tap_reset,
.shift_ir = ops_shift_ir,
.shift_dr = ops_shift_dr,
.idle_cycles = ops_idle_cycles,
.delay_us = ops_delay_us,
};
int bs_svf_play(jtag_core *jc, const char *path,
svf_log_fn log, void *user, svf_stats *stats)
{
/* Warm up the link before the first real scan: the FTDI MPSSE's first
* data read after a fresh open returns stale FIFO content. The normal
* Viveris flow hides this (jtag_scan/autoinit runs first); do a
* throwaway reset + DR read so a standalone svf_play is reliable. */
uint8_t junk[4];
bscan_tap_reset(jc);
bscan_shift_dr(jc, NULL, junk, 32);
return svf_play_file(&bscan_svf_ops, jc, path, log, user, stats);
}