1 #ifndef __WILC_MSG_QUEUE_H__
2 #define __WILC_MSG_QUEUE_H__
5 * @file wilc_msgqueue.h
6 * @brief Message Queue OS wrapper functionality
8 * @sa wilc_oswrapper.h top level OS wrapper file
13 #include <linux/semaphore.h>
15 /* Message Queue type is a structure */
16 typedef struct __Message_struct {
19 struct __Message_struct *pstrNext;
22 typedef struct __MessageQueue_struct {
23 struct semaphore hSem;
24 spinlock_t strCriticalSection;
26 u32 u32ReceiversCount;
27 Message *pstrMessageList;
28 } WILC_MsgQueueHandle;
31 * @brief Creates a new Message queue
32 * @details Creates a new Message queue, if the feature
33 * CONFIG_WILC_MSG_QUEUE_IPC_NAME is enabled and pstrAttrs->pcName
34 * is not Null, then this message queue can be used for IPC with
35 * any other message queue having the same name in the system
36 * @param[in,out] pHandle handle to the message queue object
37 * @param[in] pstrAttrs Optional attributes, NULL for default
38 * @return Error code indicating success/failure
43 int wilc_mq_create(WILC_MsgQueueHandle *pHandle);
46 * @brief Sends a message
47 * @details Sends a message, this API will block until the message is
48 * actually sent or until it is timedout (as long as the feature
49 * CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and pstrAttrs->u32Timeout
50 * is not set to WILC_OS_INFINITY), zero timeout is a valid value
51 * @param[in] pHandle handle to the message queue object
52 * @param[in] pvSendBuffer pointer to the data to send
53 * @param[in] u32SendBufferSize the size of the data to send
54 * @param[in] pstrAttrs Optional attributes, NULL for default
55 * @return Error code indicating success/failure
60 int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
61 const void *pvSendBuffer, u32 u32SendBufferSize);
64 * @brief Receives a message
65 * @details Receives a message, this API will block until a message is
66 * received or until it is timedout (as long as the feature
67 * CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and pstrAttrs->u32Timeout
68 * is not set to WILC_OS_INFINITY), zero timeout is a valid value
69 * @param[in] pHandle handle to the message queue object
70 * @param[out] pvRecvBuffer pointer to a buffer to fill with the received message
71 * @param[in] u32RecvBufferSize the size of the receive buffer
72 * @param[out] pu32ReceivedLength the length of received data
73 * @param[in] pstrAttrs Optional attributes, NULL for default
74 * @return Error code indicating success/failure
79 int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
80 void *pvRecvBuffer, u32 u32RecvBufferSize,
81 u32 *pu32ReceivedLength);
84 * @brief Destroys an existing Message queue
85 * @param[in] pHandle handle to the message queue object
86 * @param[in] pstrAttrs Optional attributes, NULL for default
87 * @return Error code indicating success/failure
92 int wilc_mq_destroy(WILC_MsgQueueHandle *pHandle);