summaryrefslogtreecommitdiff
path: root/openpcd/firmware/src/os/req_ctx.c
diff options
context:
space:
mode:
author(no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-09-09 01:08:38 +0000
committer(no author) <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-09-09 01:08:38 +0000
commit520784c7ba6a8325e413a293ab11840d982ba87d (patch)
tree44ee93d44102d47014c6ff696ebc93e8de402e01 /openpcd/firmware/src/os/req_ctx.c
parentb0317c72667378333e1008c49559e974f3e7c15d (diff)
- major reorganization, split source tree in
- os: core "operating system" - pcd: PCD (reader) side - picc: PICC (transponder) side - rewrite linker script almost from scratch (for correct DFU operation) git-svn-id: https://svn.openpcd.org:2342/trunk@142 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'openpcd/firmware/src/os/req_ctx.c')
-rw-r--r--openpcd/firmware/src/os/req_ctx.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/openpcd/firmware/src/os/req_ctx.c b/openpcd/firmware/src/os/req_ctx.c
new file mode 100644
index 0000000..831d48e
--- /dev/null
+++ b/openpcd/firmware/src/os/req_ctx.c
@@ -0,0 +1,50 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <asm/bitops.h>
+#include <os/dbgu.h>
+#include <os/req_ctx.h>
+
+#include "../openpcd.h"
+
+/* FIXME: locking, FIFO order processing */
+
+static struct req_ctx req_ctx[NUM_REQ_CTX];
+
+struct req_ctx *req_ctx_find_get(unsigned long old_state, unsigned long new_state)
+{
+ unsigned long flags;
+ u_int8_t i;
+
+ for (i = 0; i < NUM_REQ_CTX; i++) {
+ local_irq_save(flags);
+ if (req_ctx[i].state == old_state) {
+ req_ctx[i].state = new_state;
+ local_irq_restore(flags);
+ return &req_ctx[i];
+ }
+ local_irq_restore(flags);
+ }
+
+ return NULL;
+}
+
+u_int8_t req_ctx_num(struct req_ctx *ctx)
+{
+ return ((void *)ctx - (void *)&req_ctx[0])/sizeof(*ctx);
+}
+
+void req_ctx_set_state(struct req_ctx *ctx, unsigned long new_state)
+{
+ unsigned long flags;
+
+ /* FIXME: do we need this kind of locking, we're UP! */
+ local_irq_save(flags);
+ ctx->state = new_state;
+ local_irq_restore(flags);
+}
+
+void req_ctx_put(struct req_ctx *ctx)
+{
+ req_ctx_set_state(ctx, RCTX_STATE_FREE);
+}
personal git repositories of Harald Welte. Your mileage may vary