summaryrefslogtreecommitdiff
path: root/firmware/src/os
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/src/os')
-rw-r--r--firmware/src/os/pcd_enumerate.c4
-rw-r--r--firmware/src/os/req_ctx.c18
-rw-r--r--firmware/src/os/req_ctx.h1
3 files changed, 19 insertions, 4 deletions
diff --git a/firmware/src/os/pcd_enumerate.c b/firmware/src/os/pcd_enumerate.c
index 62f5809..a886377 100644
--- a/firmware/src/os/pcd_enumerate.c
+++ b/firmware/src/os/pcd_enumerate.c
@@ -180,8 +180,8 @@ int udp_refill_ep(int ep)
req_ctx_put(rctx);
return 0;
}
- DEBUGPCR("USBTx %08X, Len = %04u, Head 4/Tail 4 bytes: %02X %02X %02X %02X / %02X %02X %02X %02X",
- rctx->data, rctx->tot_len,
+ DEBUGPCR("USBT(D=%08X, L=%04u, P=$02u) H4/T4: %02X %02X %02X %02X / %02X %02X %02X %02X",
+ rctx->data, rctx->tot_len, req_ctx_count(epstate[ep].state_pending),
rctx->data[4], rctx->data[5], rctx->data[6], rctx->data[7],
rctx->data[rctx->tot_len - 4], rctx->data[rctx->tot_len - 3],
rctx->data[rctx->tot_len - 2], rctx->data[rctx->tot_len - 1]);
diff --git a/firmware/src/os/req_ctx.c b/firmware/src/os/req_ctx.c
index 2411f62..a1495d9 100644
--- a/firmware/src/os/req_ctx.c
+++ b/firmware/src/os/req_ctx.c
@@ -49,6 +49,7 @@ static struct req_ctx req_ctx[NUM_REQ_CTX];
/* queue of RCTX indexed by their current state */
static struct req_ctx *req_ctx_queues[RCTX_STATE_COUNT], *req_ctx_tails[RCTX_STATE_COUNT];
+static unsigned req_counts[RCTX_STATE_COUNT];
struct req_ctx __ramfunc *req_ctx_find_get(int large,
unsigned long old_state,
@@ -68,6 +69,7 @@ struct req_ctx __ramfunc *req_ctx_find_get(int large,
toReturn->next->prev = NULL;
else
req_ctx_tails[old_state] = NULL;
+ req_counts[old_state]--;
if ((toReturn->prev = req_ctx_tails[new_state]))
toReturn->prev->next = toReturn;
else
@@ -75,6 +77,7 @@ struct req_ctx __ramfunc *req_ctx_find_get(int large,
req_ctx_tails[new_state] = toReturn;
toReturn->state = new_state;
toReturn->next = NULL;
+ req_counts[new_state]++;
}
local_irq_restore(flags);
return toReturn;
@@ -104,7 +107,7 @@ void req_ctx_set_state(struct req_ctx *ctx, unsigned long new_state)
ctx->next->prev = ctx->prev;
else
req_ctx_tails[old_state] = ctx->prev;
-
+ req_counts[old_state]--;
if ((ctx->prev = req_ctx_tails[new_state]))
ctx->prev->next = ctx;
else
@@ -112,6 +115,7 @@ void req_ctx_set_state(struct req_ctx *ctx, unsigned long new_state)
req_ctx_tails[new_state] = ctx;
ctx->state = new_state;
ctx->next = NULL;
+ req_counts[new_state]++;
local_irq_restore(flags);
}
@@ -158,7 +162,7 @@ void req_ctx_put(struct req_ctx *ctx)
ctx->next->prev = ctx->prev;
else
req_ctx_tails[old_state] = ctx->prev;
-
+ req_counts[old_state]--;
if ((ctx->prev = req_ctx_tails[RCTX_STATE_FREE]))
ctx->prev->next = ctx;
else
@@ -166,9 +170,17 @@ void req_ctx_put(struct req_ctx *ctx)
req_ctx_tails[RCTX_STATE_FREE] = ctx;
ctx->state = RCTX_STATE_FREE;
ctx->next = NULL;
+ req_counts[RCTX_STATE_FREE]++;
local_irq_restore(intcFlags);
}
+unsigned int req_ctx_count(unsigned long state)
+{
+ if (state >= RCTX_STATE_COUNT)
+ return 0;
+ return req_counts[state];
+}
+
void req_ctx_init(void)
{
int i;
@@ -198,8 +210,10 @@ void req_ctx_init(void)
req_ctx_queues[RCTX_STATE_FREE] = req_ctx;
req_ctx_tails[RCTX_STATE_FREE] = req_ctx + NUM_REQ_CTX - 1;
+ req_counts[RCTX_STATE_FREE] = NUM_REQ_CTX;
for (i = RCTX_STATE_FREE + 1; i < RCTX_STATE_COUNT; i++) {
req_ctx_queues[i] = req_ctx_tails[i] = NULL;
+ req_counts[i] = 0;
}
}
diff --git a/firmware/src/os/req_ctx.h b/firmware/src/os/req_ctx.h
index 1e53fa4..b576ffe 100644
--- a/firmware/src/os/req_ctx.h
+++ b/firmware/src/os/req_ctx.h
@@ -47,5 +47,6 @@ extern struct req_ctx *req_ctx_find_busy(void);
extern void req_ctx_set_state(struct req_ctx *ctx, unsigned long new_state);
extern void req_ctx_put(struct req_ctx *ctx);
extern u_int8_t req_ctx_num(struct req_ctx *ctx);
+unsigned int req_ctx_count(unsigned long state);
#endif /* _REQ_CTX_H */
personal git repositories of Harald Welte. Your mileage may vary