1 #ifndef __WILC_MSG_QUEUE_H__
2 #define __WILC_MSG_QUEUE_H__
3 
4 /*!
5  *  @file	wilc_msgqueue.h
6  *  @brief	Message Queue OS wrapper functionality
7  *  @author	syounan
8  *  @sa		wilc_oswrapper.h top level OS wrapper file
9  *  @date	30 Aug 2010
10  *  @version	1.0
11  */
12 
13 #include <linux/semaphore.h>
14 
15 /* Message Queue type is a structure */
16 typedef struct __Message_struct {
17 	void *pvBuffer;
18 	u32 u32Length;
19 	struct __Message_struct *pstrNext;
20 } Message;
21 
22 typedef struct __MessageQueue_struct {
23 	struct semaphore hSem;
24 	spinlock_t strCriticalSection;
25 	bool bExiting;
26 	u32 u32ReceiversCount;
27 	Message *pstrMessageList;
28 } WILC_MsgQueueHandle;
29 
30 /*!
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 sucess/failure
39  *  @author		syounan
40  *  @date		30 Aug 2010
41  *  @version		1.0
42  */
43 int wilc_mq_create(WILC_MsgQueueHandle *pHandle);
44 
45 /*!
46  *  @brief		Sends a message
47  *  @details		Sends a message, this API will block unil 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 sucess/failure
56  *  @author		syounan
57  *  @date		30 Aug 2010
58  *  @version		1.0
59  */
60 int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
61 			     const void *pvSendBuffer, u32 u32SendBufferSize);
62 
63 /*!
64  *  @brief		Receives a message
65  *  @details		Receives a message, this API will block unil 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 sucess/failure
75  *  @author		syounan
76  *  @date		30 Aug 2010
77  *  @version		1.0
78  */
79 int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
80 			     void *pvRecvBuffer, u32 u32RecvBufferSize,
81 			     u32 *pu32ReceivedLength);
82 
83 /*!
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 sucess/failure
88  *  @author		syounan
89  *  @date		30 Aug 2010
90  *  @version		1.0
91  */
92 int wilc_mq_destroy(WILC_MsgQueueHandle *pHandle);
93 
94 #endif
95