A method to generate N cycles of TCK with fixed values of TMS and TDI, jtagtap_cycles(), was added somewhat later than the other base methods to jtag_proc structure of function pointers. I have identified four places where this is used.
jtagtap_init()and equivalents, for emitting SWD LINERESET (50 cycles with TMS high), sometimes coded as a literal for-loop aroundjtagtap_next()or a prepared byte buffer.
github.com/blackmagic-debug/blackmagic@54ddc3505c/src/platforms/common/jtagtap.c (L54-L59)- jtag_scan.c:
jtag_sanity_check(), called as early asjtag_scan()=>jtag_discover()=>jtag_sanity_check(). I have touched this recently in #2178.github.com/blackmagic-debug/blackmagic@54ddc3505c/src/target/jtag_scan.c (L306-L307) - adiv5_jtag.c:
adiv5_jtag_raw_access(), for 8 idle cycles but only for ADI v6 JTAG-DP targets. Never encountered with ADI v5.github.com/blackmagic-debug/blackmagic@54ddc3505c/src/target/adiv5_jtag.c (L166-L170) - icepick.c:
icepick_router_handler(), for 10 idle cycles after reconfiguring type-D controller. Very target-specific.
github.com/blackmagic-debug/blackmagic@54ddc3505c/src/target/icepick.c (L135-L140)
None of these places are particularly hot code (intensively called during debug). The problem is that BMDA backends for FTDI MPSSE, J-Link, CMSIS-DAP never set the pointer, so it stays NULL (in a calloc()'ed struct), allowing one to inadvertently segfault BMDA mid-scan.
The obvious solutions are a) null-check the pointer at all callsites and fall back to jtagtap_next(); b) code the wrappers which invoke corresponding methods bound to jtagtap_next(). Which can then evolve into proper functions optimized for bit-packing and buffering characteristic for the protocols of these low-level adapters.
I've started at it in #2179 just to fix it until other usable or optimized implementations arrive. The CMSIS-DAP protocol is too convoluted for me to do it properly. J-Link HW_JTAG3 and FTDI MPSSE are easier.