Move mq_open.c, mq_close.c, and mq_unlink.c from sched/mqueue to fs/mqueue
This commit is contained in:
parent
e3fa34681b
commit
b0f80cc8db
@ -4,4 +4,11 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
if !DISABLE_MQUEUE
|
if !DISABLE_MQUEUE
|
||||||
|
|
||||||
|
config FS_MQUEUE_MPATH
|
||||||
|
string "Path to message queuee"
|
||||||
|
default "/var/mqueue"
|
||||||
|
---help---
|
||||||
|
The path to where POSIX message queues will exist in the VFS namespace.
|
||||||
|
|
||||||
endif # !DISABLE_MQUEUE
|
endif # !DISABLE_MQUEUE
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
ifneq ($(CONFIG_DISABLE_MQUEUE),y)
|
ifneq ($(CONFIG_DISABLE_MQUEUE),y)
|
||||||
|
|
||||||
#CSRCS +=
|
CSRCS += mq_open.c mq_close.c mq_unlink.c
|
||||||
|
|
||||||
# Include POSIX message queue build support
|
# Include POSIX message queue build support
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@
|
|||||||
|
|
||||||
ifneq ($(CONFIG_DISABLE_MQUEUE),y)
|
ifneq ($(CONFIG_DISABLE_MQUEUE),y)
|
||||||
|
|
||||||
MQUEUE_SRCS = mq_open.c mq_close.c mq_unlink.c mq_send.c mq_timedsend.c
|
MQUEUE_SRCS = mq_send.c mq_timedsend.c mq_sndinternal.c mq_receive.c
|
||||||
MQUEUE_SRCS += mq_sndinternal.c mq_receive.c mq_timedreceive.c mq_rcvinternal.c
|
MQUEUE_SRCS += mq_timedreceive.c mq_rcvinternal.c mq_initialize.c
|
||||||
MQUEUE_SRCS += mq_initialize.c mq_descreate.c mq_msgfree.c
|
MQUEUE_SRCS += mq_descreate.c mq_msgfree.c mq_msgqfree.c mq_release.c
|
||||||
MQUEUE_SRCS += mq_msgqfree.c mq_release.c mq_recover.c
|
MQUEUE_SRCS += mq_recover.c
|
||||||
|
|
||||||
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
|
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
|
||||||
MQUEUE_SRCS += mq_waitirq.c mq_notify.c
|
MQUEUE_SRCS += mq_waitirq.c mq_notify.c
|
||||||
|
@ -93,17 +93,17 @@ sq_queue_t g_desfree;
|
|||||||
* messages.
|
* messages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static mqmsg_t *g_msgalloc;
|
static struct mqueue_msg_s *g_msgalloc;
|
||||||
|
|
||||||
/* g_msgfreeirqalloc is a pointer to the start of the allocated block of
|
/* g_msgfreeirqalloc is a pointer to the start of the allocated block of
|
||||||
* messages.
|
* messages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static mqmsg_t *g_msgfreeirqalloc;
|
static struct mqueue_msg_s *g_msgfreeirqalloc;
|
||||||
|
|
||||||
/* g_desalloc is a list of allocated block of message queue descriptors. */
|
/* g_desalloc is a list of allocated block of message queue descriptors. */
|
||||||
|
|
||||||
static sq_queue_t g_desalloc;
|
static sq_queue_t g_desalloc;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@ -120,19 +120,22 @@ static sq_queue_t g_desalloc;
|
|||||||
*
|
*
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
static mqmsg_t *mq_msgblockalloc(sq_queue_t *queue, uint16_t nmsgs,
|
static struct mqueue_msg_s *
|
||||||
uint8_t alloc_type)
|
mq_msgblockalloc(FAR sq_queue_t *queue, uint16_t nmsgs,
|
||||||
|
uint8_t alloc_type)
|
||||||
{
|
{
|
||||||
mqmsg_t *mqmsgblock;
|
struct mqueue_msg_s *mqmsgblock;
|
||||||
|
|
||||||
/* The g_msgfree must be loaded at initialization time to hold the
|
/* The g_msgfree must be loaded at initialization time to hold the
|
||||||
* configured number of messages.
|
* configured number of messages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mqmsgblock = (mqmsg_t*)kmm_malloc(sizeof(mqmsg_t) * nmsgs);
|
mqmsgblock = (FAR struct mqueue_msg_s*)
|
||||||
|
kmm_malloc(sizeof(struct mqueue_msg_s) * nmsgs);
|
||||||
|
|
||||||
if (mqmsgblock)
|
if (mqmsgblock)
|
||||||
{
|
{
|
||||||
mqmsg_t *mqmsg = mqmsgblock;
|
struct mqueue_msg_s *mqmsg = mqmsgblock;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < nmsgs; i++)
|
for (i = 0; i < nmsgs; i++)
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
*
|
*
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
void mq_msgfree(FAR mqmsg_t *mqmsg)
|
void mq_msgfree(FAR struct mqueue_msg_s *mqmsg)
|
||||||
{
|
{
|
||||||
irqstate_t saved_state;
|
irqstate_t saved_state;
|
||||||
|
|
||||||
|
@ -87,12 +87,12 @@
|
|||||||
|
|
||||||
void mq_msgqfree(FAR struct mqueue_inode_s *msgq)
|
void mq_msgqfree(FAR struct mqueue_inode_s *msgq)
|
||||||
{
|
{
|
||||||
FAR mqmsg_t *curr;
|
FAR struct mqueue_msg_s *curr;
|
||||||
FAR mqmsg_t *next;
|
FAR struct mqueue_msg_s *next;
|
||||||
|
|
||||||
/* Deallocate any stranded messages in the message queue. */
|
/* Deallocate any stranded messages in the message queue. */
|
||||||
|
|
||||||
curr = (FAR mqmsg_t*)msgq->msglist.head;
|
curr = (FAR struct mqueue_msg_s*)msgq->msglist.head;
|
||||||
while (curr)
|
while (curr)
|
||||||
{
|
{
|
||||||
/* Deallocate the message structure. */
|
/* Deallocate the message structure. */
|
||||||
|
@ -154,11 +154,11 @@ int mq_verifyreceive(mqd_t mqdes, void *msg, size_t msglen)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR mqmsg_t *mq_waitreceive(mqd_t mqdes)
|
FAR struct mqueue_msg_s *mq_waitreceive(mqd_t mqdes)
|
||||||
{
|
{
|
||||||
FAR struct tcb_s *rtcb;
|
FAR struct tcb_s *rtcb;
|
||||||
FAR struct mqueue_inode_s *msgq;
|
FAR struct mqueue_inode_s *msgq;
|
||||||
FAR mqmsg_t *rcvmsg;
|
FAR struct mqueue_msg_s *rcvmsg;
|
||||||
|
|
||||||
/* Get a pointer to the message queue */
|
/* Get a pointer to the message queue */
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ FAR mqmsg_t *mq_waitreceive(mqd_t mqdes)
|
|||||||
|
|
||||||
/* Get the message from the head of the queue */
|
/* Get the message from the head of the queue */
|
||||||
|
|
||||||
while ((rcvmsg = (FAR mqmsg_t*)sq_remfirst(&msgq->msglist)) == NULL)
|
while ((rcvmsg = (FAR struct mqueue_msg_s*)sq_remfirst(&msgq->msglist)) == NULL)
|
||||||
{
|
{
|
||||||
/* The queue is empty! Should we block until there the above condition
|
/* The queue is empty! Should we block until there the above condition
|
||||||
* has been satisfied?
|
* has been satisfied?
|
||||||
@ -245,7 +245,8 @@ FAR mqmsg_t *mq_waitreceive(mqd_t mqdes)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
ssize_t mq_doreceive(mqd_t mqdes, mqmsg_t *mqmsg, void *ubuffer, int *prio)
|
ssize_t mq_doreceive(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg,
|
||||||
|
FAR void *ubuffer, int *prio)
|
||||||
{
|
{
|
||||||
FAR struct tcb_s *btcb;
|
FAR struct tcb_s *btcb;
|
||||||
irqstate_t saved_state;
|
irqstate_t saved_state;
|
||||||
|
@ -114,9 +114,9 @@
|
|||||||
|
|
||||||
ssize_t mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio)
|
ssize_t mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio)
|
||||||
{
|
{
|
||||||
FAR mqmsg_t *mqmsg;
|
FAR struct mqueue_msg_s *mqmsg;
|
||||||
irqstate_t saved_state;
|
irqstate_t saved_state;
|
||||||
ssize_t ret = ERROR;
|
ssize_t ret = ERROR;
|
||||||
|
|
||||||
DEBUGASSERT(up_interrupt_context() == false);
|
DEBUGASSERT(up_interrupt_context() == false);
|
||||||
|
|
||||||
|
@ -118,9 +118,9 @@
|
|||||||
int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio)
|
int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio)
|
||||||
{
|
{
|
||||||
FAR struct mqueue_inode_s *msgq;
|
FAR struct mqueue_inode_s *msgq;
|
||||||
FAR mqmsg_t *mqmsg = NULL;
|
FAR struct mqueue_msg_s *mqmsg = NULL;
|
||||||
irqstate_t saved_state;
|
irqstate_t saved_state;
|
||||||
int ret = ERROR;
|
int ret = ERROR;
|
||||||
|
|
||||||
/* Verify the input parameters -- setting errno appropriately
|
/* Verify the input parameters -- setting errno appropriately
|
||||||
* on any failures to verify.
|
* on any failures to verify.
|
||||||
|
@ -160,10 +160,10 @@ int mq_verifysend(mqd_t mqdes, const void *msg, size_t msglen, int prio)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
FAR mqmsg_t *mq_msgalloc(void)
|
FAR struct mqueue_msg_s *mq_msgalloc(void)
|
||||||
{
|
{
|
||||||
FAR mqmsg_t *mqmsg;
|
FAR struct mqueue_msg_s *mqmsg;
|
||||||
irqstate_t saved_state;
|
irqstate_t saved_state;
|
||||||
|
|
||||||
/* If we were called from an interrupt handler, then try to get the message
|
/* If we were called from an interrupt handler, then try to get the message
|
||||||
* from generally available list of messages. If this fails, then try the
|
* from generally available list of messages. If this fails, then try the
|
||||||
@ -174,12 +174,12 @@ FAR mqmsg_t *mq_msgalloc(void)
|
|||||||
{
|
{
|
||||||
/* Try the general free list */
|
/* Try the general free list */
|
||||||
|
|
||||||
mqmsg = (FAR mqmsg_t*)sq_remfirst(&g_msgfree);
|
mqmsg = (FAR struct mqueue_msg_s*)sq_remfirst(&g_msgfree);
|
||||||
if (!mqmsg)
|
if (!mqmsg)
|
||||||
{
|
{
|
||||||
/* Try the free list reserved for interrupt handlers */
|
/* Try the free list reserved for interrupt handlers */
|
||||||
|
|
||||||
mqmsg = (FAR mqmsg_t*)sq_remfirst(&g_msgfreeirq);
|
mqmsg = (FAR struct mqueue_msg_s*)sq_remfirst(&g_msgfreeirq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,14 +192,14 @@ FAR mqmsg_t *mq_msgalloc(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
saved_state = irqsave();
|
saved_state = irqsave();
|
||||||
mqmsg = (FAR mqmsg_t*)sq_remfirst(&g_msgfree);
|
mqmsg = (FAR struct mqueue_msg_s*)sq_remfirst(&g_msgfree);
|
||||||
irqrestore(saved_state);
|
irqrestore(saved_state);
|
||||||
|
|
||||||
/* If we cannot a message from the free list, then we will have to allocate one. */
|
/* If we cannot a message from the free list, then we will have to allocate one. */
|
||||||
|
|
||||||
if (!mqmsg)
|
if (!mqmsg)
|
||||||
{
|
{
|
||||||
mqmsg = (FAR mqmsg_t *)kmm_malloc((sizeof (mqmsg_t)));
|
mqmsg = (FAR struct mqueue_msg_s *)kmm_malloc((sizeof (struct mqueue_msg_s)));
|
||||||
|
|
||||||
/* Check if we got an allocated message */
|
/* Check if we got an allocated message */
|
||||||
|
|
||||||
@ -324,12 +324,13 @@ int mq_waitsend(mqd_t mqdes)
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int mq_dosend(mqd_t mqdes, FAR mqmsg_t *mqmsg, const void *msg, size_t msglen, int prio)
|
int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, FAR const void *msg,
|
||||||
|
size_t msglen, int prio)
|
||||||
{
|
{
|
||||||
FAR struct tcb_s *btcb;
|
FAR struct tcb_s *btcb;
|
||||||
FAR struct mqueue_inode_s *msgq;
|
FAR struct mqueue_inode_s *msgq;
|
||||||
FAR mqmsg_t *next;
|
FAR struct mqueue_msg_s *next;
|
||||||
FAR mqmsg_t *prev;
|
FAR struct mqueue_msg_s *prev;
|
||||||
irqstate_t saved_state;
|
irqstate_t saved_state;
|
||||||
|
|
||||||
/* Get a pointer to the message queue */
|
/* Get a pointer to the message queue */
|
||||||
@ -354,7 +355,7 @@ int mq_dosend(mqd_t mqdes, FAR mqmsg_t *mqmsg, const void *msg, size_t msglen, i
|
|||||||
* message. Each is list is maintained in ascending priority order.
|
* message. Each is list is maintained in ascending priority order.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (prev = NULL, next = (FAR mqmsg_t*)msgq->msglist.head;
|
for (prev = NULL, next = (FAR struct mqueue_msg_s*)msgq->msglist.head;
|
||||||
next && prio <= next->priority;
|
next && prio <= next->priority;
|
||||||
prev = next, next = next->next);
|
prev = next, next = next->next);
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ ssize_t mq_timedreceive(mqd_t mqdes, void *msg, size_t msglen,
|
|||||||
int *prio, const struct timespec *abstime)
|
int *prio, const struct timespec *abstime)
|
||||||
{
|
{
|
||||||
FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
|
FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
|
||||||
FAR mqmsg_t *mqmsg;
|
FAR struct mqueue_msg_s *mqmsg;
|
||||||
irqstate_t saved_state;
|
irqstate_t saved_state;
|
||||||
int ret = ERROR;
|
int ret = ERROR;
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio,
|
|||||||
{
|
{
|
||||||
FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
|
FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
|
||||||
FAR struct mqueue_inode_s *msgq;
|
FAR struct mqueue_inode_s *msgq;
|
||||||
FAR mqmsg_t *mqmsg = NULL;
|
FAR struct mqueue_msg_s *mqmsg = NULL;
|
||||||
irqstate_t saved_state;
|
irqstate_t saved_state;
|
||||||
int ret = ERROR;
|
int ret = ERROR;
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ enum mqalloc_e
|
|||||||
|
|
||||||
/* This structure describes one buffered POSIX message. */
|
/* This structure describes one buffered POSIX message. */
|
||||||
|
|
||||||
struct mqmsg
|
struct mqueue_msg_s
|
||||||
{
|
{
|
||||||
FAR struct mqmsg *next; /* Forward link to next message */
|
FAR struct mqmsg *next; /* Forward link to next message */
|
||||||
uint8_t type; /* (Used to manage allocations) */
|
uint8_t type; /* (Used to manage allocations) */
|
||||||
@ -101,8 +101,6 @@ struct mqmsg
|
|||||||
uint8_t mail[MQ_MAX_BYTES]; /* Message data */
|
uint8_t mail[MQ_MAX_BYTES]; /* Message data */
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct mqmsg mqmsg_t;
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Global Variables
|
* Global Variables
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -145,7 +143,7 @@ void mq_desblockalloc(void);
|
|||||||
|
|
||||||
mqd_t mq_descreate(FAR struct tcb_s* mtcb, FAR msgq_t* msgq, int oflags);
|
mqd_t mq_descreate(FAR struct tcb_s* mtcb, FAR msgq_t* msgq, int oflags);
|
||||||
FAR msgq_t *mq_findnamed(const char *mq_name);
|
FAR msgq_t *mq_findnamed(const char *mq_name);
|
||||||
void mq_msgfree(FAR mqmsg_t *mqmsg);
|
void mq_msgfree(FAR struct mqueue_msg_s *mqmsg);
|
||||||
void mq_msgqfree(FAR msgq_t *msgq);
|
void mq_msgqfree(FAR msgq_t *msgq);
|
||||||
|
|
||||||
/* mq_waitirq.c ************************************************************/
|
/* mq_waitirq.c ************************************************************/
|
||||||
@ -155,15 +153,16 @@ void mq_waitirq(FAR struct tcb_s *wtcb, int errcode);
|
|||||||
/* mq_rcvinternal.c ********************************************************/
|
/* mq_rcvinternal.c ********************************************************/
|
||||||
|
|
||||||
int mq_verifyreceive(mqd_t mqdes, void *msg, size_t msglen);
|
int mq_verifyreceive(mqd_t mqdes, void *msg, size_t msglen);
|
||||||
FAR mqmsg_t *mq_waitreceive(mqd_t mqdes);
|
FAR struct mqueue_msg_s *mq_waitreceive(mqd_t mqdes);
|
||||||
ssize_t mq_doreceive(mqd_t mqdes, mqmsg_t *mqmsg, void *ubuffer, int *prio);
|
ssize_t mq_doreceive(mqd_t mqdes, struct mqueue_msg_s *mqmsg, void *ubuffer,
|
||||||
|
int *prio);
|
||||||
|
|
||||||
/* mq_sndinternal.c ********************************************************/
|
/* mq_sndinternal.c ********************************************************/
|
||||||
|
|
||||||
int mq_verifysend(mqd_t mqdes, const void *msg, size_t msglen, int prio);
|
int mq_verifysend(mqd_t mqdes, const void *msg, size_t msglen, int prio);
|
||||||
FAR mqmsg_t *mq_msgalloc(void);
|
FAR struct mqueue_msg_s *mq_msgalloc(void);
|
||||||
int mq_waitsend(mqd_t mqdes);
|
int mq_waitsend(mqd_t mqdes);
|
||||||
int mq_dosend(mqd_t mqdes, FAR mqmsg_t *mqmsg, const void *msg,
|
int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, const void *msg,
|
||||||
size_t msglen, int prio);
|
size_t msglen, int prio);
|
||||||
|
|
||||||
/* mq_release.c ************************************************************/
|
/* mq_release.c ************************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user