[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-forge Branch: master Commit: 4cc52aaa1794cc25f3069f80818490e71498d56c URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=4cc52aaa1794cc25f3069f80818490e71498d56c Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 965 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 6 files changed, 396 insertions(+), 599 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index 1254ce5..f18659a 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index a3154d1..76e9155 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "internal.h" #include "thread.h" #include "signal.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct rtdm_fd fd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,37 +167,21 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } -struct lostage_memfree { - struct ipipe_work_header work; /* Must be first. */ - void *mem; - size_t memsize; -}; - -static void lostage_mq_memfree(struct ipipe_work_header *work) +static inline void mq_destroy(struct cobalt_mq *mq) { - struct lostage_memfree *rq; - - rq = container_of(work, struct lostage_memfree, work); - free_pages_exact(rq->mem, rq->memsize); -} - -static inline void mq_destroy(cobalt_mq_t *mq) -{ - struct lostage_memfree freework = { - .work = { - .size = sizeof(freework), - .handler = lostage_mq_memfree, - }, - .mem = mq->mem, - .memsize = mq->memsize, - }; int resched; spl_t s; +#if XENO_DEBUG(COBALT) + printk(XENO_INFO "deleting Cobalt message queue \"/%s\"\n", mq->name); +#endif + xnlock_get_irqsave(&nklock, s); resched = (xnsynch_destroy(&mq->receivers) == XNSYNCH_RESCHED); resched = (xnsynch_d
[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-forge Branch: next Commit: 4cc52aaa1794cc25f3069f80818490e71498d56c URL: http://git.xenomai.org/?p=xenomai-forge.git;a=commit;h=4cc52aaa1794cc25f3069f80818490e71498d56c Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 965 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 6 files changed, 396 insertions(+), 599 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index 1254ce5..f18659a 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index a3154d1..76e9155 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "internal.h" #include "thread.h" #include "signal.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct rtdm_fd fd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,37 +167,21 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } -struct lostage_memfree { - struct ipipe_work_header work; /* Must be first. */ - void *mem; - size_t memsize; -}; - -static void lostage_mq_memfree(struct ipipe_work_header *work) +static inline void mq_destroy(struct cobalt_mq *mq) { - struct lostage_memfree *rq; - - rq = container_of(work, struct lostage_memfree, work); - free_pages_exact(rq->mem, rq->memsize); -} - -static inline void mq_destroy(cobalt_mq_t *mq) -{ - struct lostage_memfree freework = { - .work = { - .size = sizeof(freework), - .handler = lostage_mq_memfree, - }, - .mem = mq->mem, - .memsize = mq->memsize, - }; int resched; spl_t s; +#if XENO_DEBUG(COBALT) + printk(XENO_INFO "deleting Cobalt message queue \"/%s\"\n", mq->name); +#endif + xnlock_get_irqsave(&nklock, s); resched = (xnsynch_destroy(&mq->receivers) == XNSYNCH_RESCHED); resched = (xnsynch_des
[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-gch Branch: for-forge Commit: 44aff3a4cdb98adaa6adef04cb7bcb6214100752 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=44aff3a4cdb98adaa6adef04cb7bcb6214100752 Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 983 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/select.c | 19 +- kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 7 files changed, 407 insertions(+), 625 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index c67c0cf..125cb75 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index 1cafb15..46c5539 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -31,6 +31,7 @@ #include #include +#include #include #include "internal.h" #include "thread.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct xnfd xnfd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,37 +167,21 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } -struct lostage_memfree { - struct ipipe_work_header work; /* Must be first. */ - void *mem; - size_t memsize; -}; - -static void lostage_mq_memfree(struct ipipe_work_header *work) +static inline void mq_destroy(struct cobalt_mq *mq) { - struct lostage_memfree *rq; - - rq = container_of(work, struct lostage_memfree, work); - free_pages_exact(rq->mem, rq->memsize); -} - -static inline void mq_destroy(cobalt_mq_t *mq) -{ - struct lostage_memfree freework = { - .work = { - .size = sizeof(freework), - .handler = lostage_mq_memfree, - }, - .mem = mq->mem, - .memsize = mq->memsize, - }; int resched; spl_t s; +#if XENO_DEBUG(COBALT) + printk(XENO_INFO "deleting Cobalt message queue \"/%s\"\n", mq->name); +#endif + xnlock_get_irqsave(&nklock, s); resched = (xnsynch_destroy(&mq->receivers) == XNSYNCH_RESCHED);
[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-gch Branch: for-forge Commit: 3146549320a3906588ba7330a0234d664736d195 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=3146549320a3906588ba7330a0234d664736d195 Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 983 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/select.c | 19 +- kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 7 files changed, 407 insertions(+), 625 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index c67c0cf..125cb75 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index 1cafb15..46c5539 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -31,6 +31,7 @@ #include #include +#include #include #include "internal.h" #include "thread.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct xnfd xnfd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,37 +167,21 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } -struct lostage_memfree { - struct ipipe_work_header work; /* Must be first. */ - void *mem; - size_t memsize; -}; - -static void lostage_mq_memfree(struct ipipe_work_header *work) +static inline void mq_destroy(struct cobalt_mq *mq) { - struct lostage_memfree *rq; - - rq = container_of(work, struct lostage_memfree, work); - free_pages_exact(rq->mem, rq->memsize); -} - -static inline void mq_destroy(cobalt_mq_t *mq) -{ - struct lostage_memfree freework = { - .work = { - .size = sizeof(freework), - .handler = lostage_mq_memfree, - }, - .mem = mq->mem, - .memsize = mq->memsize, - }; int resched; spl_t s; +#if XENO_DEBUG(COBALT) + printk(XENO_INFO "deleting Cobalt message queue \"/%s\"\n", mq->name); +#endif + xnlock_get_irqsave(&nklock, s); resched = (xnsynch_destroy(&mq->receivers) == XNSYNCH_RESCHED);
[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-gch Branch: for-forge Commit: 7bf60c48da57dedb56fb6f80f0346d98a54f9e5d URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=7bf60c48da57dedb56fb6f80f0346d98a54f9e5d Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 983 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/select.c | 19 +- kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 7 files changed, 407 insertions(+), 625 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index c67c0cf..125cb75 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index 1cafb15..46c5539 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -31,6 +31,7 @@ #include #include +#include #include #include "internal.h" #include "thread.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct xnfd xnfd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,37 +167,21 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } -struct lostage_memfree { - struct ipipe_work_header work; /* Must be first. */ - void *mem; - size_t memsize; -}; - -static void lostage_mq_memfree(struct ipipe_work_header *work) +static inline void mq_destroy(struct cobalt_mq *mq) { - struct lostage_memfree *rq; - - rq = container_of(work, struct lostage_memfree, work); - free_pages_exact(rq->mem, rq->memsize); -} - -static inline void mq_destroy(cobalt_mq_t *mq) -{ - struct lostage_memfree freework = { - .work = { - .size = sizeof(freework), - .handler = lostage_mq_memfree, - }, - .mem = mq->mem, - .memsize = mq->memsize, - }; int resched; spl_t s; +#if XENO_DEBUG(COBALT) + printk(XENO_INFO "deleting Cobalt message queue \"/%s\"\n", mq->name); +#endif + xnlock_get_irqsave(&nklock, s); resched = (xnsynch_destroy(&mq->receivers) == XNSYNCH_RESCHED);
[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-gch Branch: for-forge Commit: 24c08ef09231d296ce362a75699db724c748fe88 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=24c08ef09231d296ce362a75699db724c748fe88 Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 983 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/select.c | 19 +- kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 7 files changed, 407 insertions(+), 625 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index c67c0cf..125cb75 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index 1cafb15..46c5539 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -31,6 +31,7 @@ #include #include +#include #include #include "internal.h" #include "thread.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct xnfd xnfd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,37 +167,21 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } -struct lostage_memfree { - struct ipipe_work_header work; /* Must be first. */ - void *mem; - size_t memsize; -}; - -static void lostage_mq_memfree(struct ipipe_work_header *work) +static inline void mq_destroy(struct cobalt_mq *mq) { - struct lostage_memfree *rq; - - rq = container_of(work, struct lostage_memfree, work); - free_pages_exact(rq->mem, rq->memsize); -} - -static inline void mq_destroy(cobalt_mq_t *mq) -{ - struct lostage_memfree freework = { - .work = { - .size = sizeof(freework), - .handler = lostage_mq_memfree, - }, - .mem = mq->mem, - .memsize = mq->memsize, - }; int resched; spl_t s; +#if XENO_DEBUG(COBALT) + printk(XENO_INFO "deleting Cobalt message queue \"/%s\"\n", mq->name); +#endif + xnlock_get_irqsave(&nklock, s); resched = (xnsynch_destroy(&mq->receivers) == XNSYNCH_RESCHED);
[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-gch Branch: for-forge Commit: 76edad1b625c4152eea73e403327a6a3a5b408b4 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=76edad1b625c4152eea73e403327a6a3a5b408b4 Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 983 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/select.c | 19 +- kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 7 files changed, 407 insertions(+), 625 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index c67c0cf..125cb75 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index 1cafb15..46c5539 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -31,6 +31,7 @@ #include #include +#include #include #include "internal.h" #include "thread.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct xnfd xnfd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,37 +167,21 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } -struct lostage_memfree { - struct ipipe_work_header work; /* Must be first. */ - void *mem; - size_t memsize; -}; - -static void lostage_mq_memfree(struct ipipe_work_header *work) +static inline void mq_destroy(struct cobalt_mq *mq) { - struct lostage_memfree *rq; - - rq = container_of(work, struct lostage_memfree, work); - free_pages_exact(rq->mem, rq->memsize); -} - -static inline void mq_destroy(cobalt_mq_t *mq) -{ - struct lostage_memfree freework = { - .work = { - .size = sizeof(freework), - .handler = lostage_mq_memfree, - }, - .mem = mq->mem, - .memsize = mq->memsize, - }; int resched; spl_t s; +#if XENO_DEBUG(COBALT) + printk(XENO_INFO "deleting Cobalt message queue \"/%s\"\n", mq->name); +#endif + xnlock_get_irqsave(&nklock, s); resched = (xnsynch_destroy(&mq->receivers) == XNSYNCH_RESCHED);
[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-gch Branch: for-forge Commit: 4bf0cc4b496d2b110250f8774dec7f05ff742cb5 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=4bf0cc4b496d2b110250f8774dec7f05ff742cb5 Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 985 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/select.c | 19 +- kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 7 files changed, 409 insertions(+), 625 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index c67c0cf..125cb75 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index 1cafb15..60d22d4 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -31,6 +31,7 @@ #include #include +#include #include #include "internal.h" #include "thread.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct xnfd xnfd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,37 +167,21 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } -struct lostage_memfree { - struct ipipe_work_header work; /* Must be first. */ - void *mem; - size_t memsize; -}; - -static void lostage_mq_memfree(struct ipipe_work_header *work) +static inline void mq_destroy(struct cobalt_mq *mq) { - struct lostage_memfree *rq; - - rq = container_of(work, struct lostage_memfree, work); - free_pages_exact(rq->mem, rq->memsize); -} - -static inline void mq_destroy(cobalt_mq_t *mq) -{ - struct lostage_memfree freework = { - .work = { - .size = sizeof(freework), - .handler = lostage_mq_memfree, - }, - .mem = mq->mem, - .memsize = mq->memsize, - }; int resched; spl_t s; +#if XENO_DEBUG(COBALT) + printk(XENO_INFO "deleting Cobalt message queue \"/%s\"\n", mq->name); +#endif + xnlock_get_irqsave(&nklock, s); resched = (xnsynch_destroy(&mq->receivers) == XNSYNCH_RESCHED);
[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-gch Branch: for-forge Commit: 73dacbe87be44f273d7133deb60ea64ce160999c URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=73dacbe87be44f273d7133deb60ea64ce160999c Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 985 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/select.c | 19 +- kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 7 files changed, 409 insertions(+), 625 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index c67c0cf..125cb75 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index 1cafb15..60d22d4 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -31,6 +31,7 @@ #include #include +#include #include #include "internal.h" #include "thread.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct xnfd xnfd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,37 +167,21 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } -struct lostage_memfree { - struct ipipe_work_header work; /* Must be first. */ - void *mem; - size_t memsize; -}; - -static void lostage_mq_memfree(struct ipipe_work_header *work) +static inline void mq_destroy(struct cobalt_mq *mq) { - struct lostage_memfree *rq; - - rq = container_of(work, struct lostage_memfree, work); - free_pages_exact(rq->mem, rq->memsize); -} - -static inline void mq_destroy(cobalt_mq_t *mq) -{ - struct lostage_memfree freework = { - .work = { - .size = sizeof(freework), - .handler = lostage_mq_memfree, - }, - .mem = mq->mem, - .memsize = mq->memsize, - }; int resched; spl_t s; +#if XENO_DEBUG(COBALT) + printk(XENO_INFO "deleting Cobalt message queue \"/%s\"\n", mq->name); +#endif + xnlock_get_irqsave(&nklock, s); resched = (xnsynch_destroy(&mq->receivers) == XNSYNCH_RESCHED);
[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-gch Branch: for-forge Commit: 90a01cde63cc61bd2af7e1e01b0b09b36e86460e URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=90a01cde63cc61bd2af7e1e01b0b09b36e86460e Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 954 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/select.c | 19 +- kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 7 files changed, 401 insertions(+), 602 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index f8d1511..ba7904d 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index 1cafb15..db65093 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -31,6 +31,7 @@ #include #include +#include #include #include "internal.h" #include "thread.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct xnfd xnfd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,6 +167,8 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } @@ -176,7 +187,7 @@ static void lostage_mq_memfree(struct ipipe_work_header *work) free_pages_exact(rq->mem, rq->memsize); } -static inline void mq_destroy(cobalt_mq_t *mq) +static inline void mq_destroy(struct cobalt_mq *mq) { struct lostage_memfree freework = { .work = { @@ -189,6 +200,10 @@ static inline void mq_destroy(cobalt_mq_t *mq) int resched; spl_t s; +#if XENO_DEBUG(COBALT) + printk(XENO_INFO "deleting Cobalt message queue \"/%s\"\n", mq->name); +#endif + xnlock_get_irqsave(&nklock, s); resched = (xnsynch_destroy(&mq->receivers) == XNSYNCH_RESCHED); resched = (xnsynch_destroy(&mq->senders) == XNSYNCH_RESCHED) || resched; @@ -197,11 +212,116 @@ static inline void mq_destroy(cobalt_mq_t *mq) xnselect_destroy(&mq->read_select); xnselect_destroy(&mq->write_select); ipipe_post_work_root(&freework, work); + xnregistry_remove(mq->handle); + xnfree(mq); if (resched)
[Xenomai-git] Gilles Chanteperdrix : cobalt/mq: rebase on registry and common fd
Module: xenomai-gch Branch: for-forge Commit: be426b46db57df744ec7c38cbe36a81221b4aae9 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=be426b46db57df744ec7c38cbe36a81221b4aae9 Author: Gilles Chanteperdrix Date: Tue Dec 24 15:42:42 2013 +0100 cobalt/mq: rebase on registry and common fd Also remove the cobalt_mq_send and cobalt_mq_receive syscall as the timed versions can be called with a NULL timeout pointer. --- include/cobalt/uapi/syscall.h |4 +- kernel/cobalt/posix/mqueue.c | 943 + kernel/cobalt/posix/mqueue.h | 11 - kernel/cobalt/posix/process.h |1 - kernel/cobalt/posix/select.c | 19 +- kernel/cobalt/posix/syscall.c |4 - lib/cobalt/mq.c | 10 +- 7 files changed, 392 insertions(+), 600 deletions(-) diff --git a/include/cobalt/uapi/syscall.h b/include/cobalt/uapi/syscall.h index f8d1511..ba7904d 100644 --- a/include/cobalt/uapi/syscall.h +++ b/include/cobalt/uapi/syscall.h @@ -56,9 +56,9 @@ #define sc_cobalt_mq_unlink 33 #define sc_cobalt_mq_getattr34 #define sc_cobalt_mq_setattr35 -#define sc_cobalt_mq_send 36 +/* 36 unimplemented */ #define sc_cobalt_mq_timedsend 37 -#define sc_cobalt_mq_receive38 +/* 38 unimplemented */ #define sc_cobalt_mq_timedreceive 39 #define sc_cobalt_thread_probe 40 #define sc_cobalt_sched_minprio 41 diff --git a/kernel/cobalt/posix/mqueue.c b/kernel/cobalt/posix/mqueue.c index 1cafb15..d4a944c 100644 --- a/kernel/cobalt/posix/mqueue.c +++ b/kernel/cobalt/posix/mqueue.c @@ -31,6 +31,7 @@ #include #include +#include #include #include "internal.h" #include "thread.h" @@ -51,8 +52,9 @@ struct mq_attr { }; struct cobalt_mq { - cobalt_node_t nodebase; -#define node2mq(naddr) container_of(naddr, cobalt_mq_t, nodebase) + unsigned magic; + + struct list_head link; struct xnsynch receivers; struct xnsynch senders; @@ -68,13 +70,20 @@ struct cobalt_mq { struct cobalt_thread *target; struct mq_attr attr; - struct list_head link; /* link in mqq */ + + unsigned refs; + char name[COBALT_MAXNAME]; + xnhandle_t handle; DECLARE_XNSELECT(read_select); DECLARE_XNSELECT(write_select); }; -typedef struct cobalt_mq cobalt_mq_t; +struct cobalt_mqd { + long flags; + struct cobalt_mq *mq; + struct xnfd xnfd; +}; struct cobalt_msg { struct list_head link; @@ -83,8 +92,6 @@ struct cobalt_msg { char data[0]; }; -static struct list_head cobalt_mqq; - struct cobalt_mqwait_context { struct xnthread_wait_context wc; struct cobalt_msg *msg; @@ -95,7 +102,9 @@ static struct mq_attr default_attr = { .mq_msgsize = 8192, }; -static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) +static struct list_head cobalt_mqq; + +static inline struct cobalt_msg *mq_msg_alloc(struct cobalt_mq *mq) { if (list_empty(&mq->avail)) return NULL; @@ -103,12 +112,12 @@ static inline struct cobalt_msg *mq_msg_alloc(cobalt_mq_t *mq) return list_get_entry(&mq->avail, struct cobalt_msg, link); } -static inline void mq_msg_free(cobalt_mq_t *mq, struct cobalt_msg * msg) +static inline void mq_msg_free(struct cobalt_mq *mq, struct cobalt_msg * msg) { list_add(&msg->link, &mq->avail); /* For earliest re-use of the block. */ } -static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) +static inline int mq_init(struct cobalt_mq *mq, const struct mq_attr *attr) { unsigned i, msgsize, memsize; char *mem; @@ -158,6 +167,8 @@ static inline int mq_init(cobalt_mq_t *mq, const struct mq_attr *attr) mq->target = NULL; xnselect_init(&mq->read_select); xnselect_init(&mq->write_select); + mq->magic = COBALT_MQ_MAGIC; + mq->refs = 2; return 0; } @@ -176,7 +187,7 @@ static void lostage_mq_memfree(struct ipipe_work_header *work) free_pages_exact(rq->mem, rq->memsize); } -static inline void mq_destroy(cobalt_mq_t *mq) +static inline void mq_destroy(struct cobalt_mq *mq) { struct lostage_memfree freework = { .work = { @@ -197,11 +208,112 @@ static inline void mq_destroy(cobalt_mq_t *mq) xnselect_destroy(&mq->read_select); xnselect_destroy(&mq->write_select); ipipe_post_work_root(&freework, work); + xnregistry_remove(mq->handle); + xnfree(mq); if (resched) xnsched_run(); } +static int mq_unref_inner(struct cobalt_mq *mq, spl_t s) +{ + int destroy; + + destroy = --mq->refs == 0; + xnlock_put_irqrestore(&nklock, s); + + if (destroy) + mq_destroy(mq); + + return destroy; +} + +static void mqd_destroy(struct xnfd *xnfd) +{ + struct cobalt_mqd *mqd = container_of(xnfd, struct cobalt_mqd, xnfd);