diff options
author | laforge <laforge@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2006-09-12 17:35:30 +0000 |
---|---|---|
committer | laforge <laforge@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2006-09-12 17:35:30 +0000 |
commit | d256545b2fd62d78910efcc6273c3b70abd3aa13 (patch) | |
tree | a05e17ec752cfbcc0b79fdbfba81fb949545a112 /firmware/src/os/req_ctx.c | |
parent | 04e0441914eeb25e042189679b55c9577fc96d2a (diff) |
move to new directory
git-svn-id: https://svn.openpcd.org:2342/trunk@191 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'firmware/src/os/req_ctx.c')
-rw-r--r-- | firmware/src/os/req_ctx.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/firmware/src/os/req_ctx.c b/firmware/src/os/req_ctx.c new file mode 100644 index 0000000..99d248b --- /dev/null +++ b/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 ((char *)ctx - (char *)&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); +} |