xdebug

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 050b143acadd580ca8491c5cc14e0813dbfe0e4c
parent 2c19382b4b7c497a833edc5124a23e4433f1ce63
Author: Brian Swetland <swetland@frotz.net>
Date:   Tue, 28 Feb 2023 01:55:41 -0800

transport: introduce dc_q_init()

This gives us a logical place to handle error recovery
from the previous transactions, reattachment, etc.

Fixes a bug where the queue was not being cleared out
on transfer errors.

Diffstat:
Msrc/transport.c | 9+++++++++
Msrc/transport.h | 3+++
2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/transport.c b/src/transport.c @@ -139,6 +139,11 @@ static void dc_q_clear(DC* dc) { dc->txbuf[2] = 0; // Count 0 initially } +void dc_q_init(DC* dc) { + // TODO: handle error cleanup, re-attach, etc + dc_q_clear(dc); +} + int dc_q_exec(DC* dc) { // fprintf(stderr, "Q EXEC\n"); // if we're already in error, don't generate more usb traffic @@ -294,18 +299,22 @@ void dc_q_ap_wr(DC* dc, unsigned apaddr, uint32_t val) { // convenience wrappers for single reads and writes int dc_dp_rd(DC* dc, unsigned dpaddr, uint32_t* val) { + dc_q_init(dc); dc_q_dp_rd(dc, dpaddr, val); return dc_q_exec(dc); } int dc_dp_wr(DC* dc, unsigned dpaddr, uint32_t val) { + dc_q_init(dc); dc_q_dp_wr(dc, dpaddr, val); return dc_q_exec(dc); } int dc_ap_rd(DC* dc, unsigned apaddr, uint32_t* val) { + dc_q_init(dc); dc_q_ap_rd(dc, apaddr, val); return dc_q_exec(dc); } int dc_ap_wr(DC* dc, unsigned apaddr, uint32_t val) { + dc_q_init(dc); dc_q_ap_wr(dc, apaddr, val); return dc_q_exec(dc); } diff --git a/src/transport.h b/src/transport.h @@ -17,6 +17,9 @@ void dc_q_dp_wr(dctx_t* dc, unsigned dpaddr, uint32_t val); void dc_q_ap_rd(dctx_t* dc, unsigned apaddr, uint32_t* val); void dc_q_ap_wr(dctx_t* dc, unsigned apaddr, uint32_t val); +// prepare for a set of transactions +void dc_q_init(dctx_t* dc); + // execute any outstanding transactions, return final status int dc_q_exec(dctx_t* dc);