summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMin Xu <min.xu@min-info.net>2014-10-25 14:45:47 +0200
committerHarald Welte <laforge@gnumonks.org>2014-11-11 22:30:53 +0100
commit3b7035dcd9564b4980b33e674d722f547a488308 (patch)
treef5cc7d71931a4fb9c6d8543d0c6080db0eec48bb
parent3c85f8de8d394eaea5ed7f6e2675201d079e227b (diff)
req_ctx: Use consistent numeric range for REQ_CTX_STATE
... which will allow us to check for invalid states by a simple 'greater than' check later on.
-rw-r--r--firmware/src/os/pcd_enumerate.c6
-rw-r--r--firmware/src/os/req_ctx.h39
2 files changed, 24 insertions, 21 deletions
diff --git a/firmware/src/os/pcd_enumerate.c b/firmware/src/os/pcd_enumerate.c
index 3a7397f..65ae9d9 100644
--- a/firmware/src/os/pcd_enumerate.c
+++ b/firmware/src/os/pcd_enumerate.c
@@ -99,8 +99,10 @@ struct epstate {
};
static const struct epstate epstate[] = {
- [0] = { .state_busy = RCTX_STATE_INVALID },
- [1] = { .state_busy = RCTX_STATE_INVALID },
+ [0] = { .state_busy = RCTX_STATE_UDP_EP0_BUSY,
+ .state_pending = RCTX_STATE_UDP_EP0_PENDING },
+ [1] = { .state_busy = RCTX_STATE_UDP_EP1_BUSY,
+ .state_pending = RCTX_STATE_UDP_EP1_PENDING },
[2] = { .state_busy = RCTX_STATE_UDP_EP2_BUSY,
.state_pending = RCTX_STATE_UDP_EP2_PENDING },
[3] = { .state_busy = RCTX_STATE_UDP_EP3_BUSY,
diff --git a/firmware/src/os/req_ctx.h b/firmware/src/os/req_ctx.h
index 94b5c5a..7401243 100644
--- a/firmware/src/os/req_ctx.h
+++ b/firmware/src/os/req_ctx.h
@@ -20,25 +20,26 @@ struct req_ctx {
u_int8_t *data;
};
-#define RCTX_STATE_FREE 0xfe
-#define RCTX_STATE_UDP_RCV_BUSY 0x01
-#define RCTX_STATE_UDP_RCV_DONE 0x02
-#define RCTX_STATE_MAIN_PROCESSING 0x03
-#define RCTX_STATE_RC632IRQ_BUSY 0x04
-
-#define RCTX_STATE_UDP_EP2_PENDING 0x10
-#define RCTX_STATE_UDP_EP2_BUSY 0x11
-
-#define RCTX_STATE_UDP_EP3_PENDING 0x12
-#define RCTX_STATE_UDP_EP3_BUSY 0x13
-
-#define RCTX_STATE_SSC_RX_BUSY 0x20
-
-#define RCTX_STATE_LIBRFID_BUSY 0x30
-
-#define RCTX_STATE_PIOIRQ_BUSY 0x80
-
-#define RCTX_STATE_INVALID 0xff
+#define RCTX_STATE_FREE 0
+#define RCTX_STATE_UDP_RCV_BUSY 1
+#define RCTX_STATE_UDP_RCV_DONE 2
+#define RCTX_STATE_MAIN_PROCESSING 3
+#define RCTX_STATE_RC632IRQ_BUSY 4
+#define RCTX_STATE_UDP_EP2_PENDING 5
+#define RCTX_STATE_UDP_EP2_BUSY 6
+#define RCTX_STATE_UDP_EP3_PENDING 7
+#define RCTX_STATE_UDP_EP3_BUSY 8
+#define RCTX_STATE_SSC_RX_BUSY 9
+#define RCTX_STATE_LIBRFID_BUSY 10
+#define RCTX_STATE_PIOIRQ_BUSY 11
+#define RCTX_STATE_INVALID 12
+// Nominally UNUSED states
+#define RCTX_STATE_UDP_EP0_PENDING 13
+#define RCTX_STATE_UDP_EP0_BUSY 14
+#define RCTX_STATE_UDP_EP1_PENDING 15
+#define RCTX_STATE_UDP_EP1_BUSY 16
+// Count of the number of STATES
+#define RCTX_STATE_COUNT 17
extern struct req_ctx __ramfunc *req_ctx_find_get(int large, unsigned long old_state, unsigned long new_state);
extern struct req_ctx *req_ctx_find_busy(void);
personal git repositories of Harald Welte. Your mileage may vary