Commit | Line | Data |
---|---|---|
c5c77ba1 JK |
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 | ||
94723907 | 13 | #include <linux/semaphore.h> |
c3ea8a72 | 14 | |
6e8c37df | 15 | /* Message Queue type is a structure */ |
d16791bf | 16 | struct message { |
78d50f94 | 17 | void *buf; |
d3ff0580 | 18 | u32 len; |
33561161 | 19 | struct message *next; |
d16791bf | 20 | }; |
6e8c37df | 21 | |
5ba89554 | 22 | struct message_queue { |
9b849fd9 | 23 | struct semaphore sem; |
3c09bb2e | 24 | spinlock_t lock; |
c700cab3 | 25 | bool exiting; |
ec815ec5 | 26 | u32 recv_count; |
f9d26e21 | 27 | struct message *msg_list; |
5ba89554 | 28 | }; |
6e8c37df | 29 | |
c5c77ba1 JK |
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 | |
6b05fcc9 | 38 | * @return Error code indicating success/failure |
c5c77ba1 JK |
39 | * @author syounan |
40 | * @date 30 Aug 2010 | |
41 | * @version 1.0 | |
42 | */ | |
2cc08b4f | 43 | int wilc_mq_create(struct message_queue *mq); |
c5c77ba1 JK |
44 | |
45 | /*! | |
46 | * @brief Sends a message | |
6b05fcc9 | 47 | * @details Sends a message, this API will block until the message is |
c5c77ba1 JK |
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 | |
6b05fcc9 | 55 | * @return Error code indicating success/failure |
c5c77ba1 JK |
56 | * @author syounan |
57 | * @date 30 Aug 2010 | |
58 | * @version 1.0 | |
59 | */ | |
5eb35975 | 60 | int wilc_mq_send(struct message_queue *mq, |
5ba89554 | 61 | const void *pvSendBuffer, u32 u32SendBufferSize); |
c5c77ba1 JK |
62 | |
63 | /*! | |
64 | * @brief Receives a message | |
6b05fcc9 | 65 | * @details Receives a message, this API will block until a message is |
c5c77ba1 JK |
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 | |
6b05fcc9 | 74 | * @return Error code indicating success/failure |
c5c77ba1 JK |
75 | * @author syounan |
76 | * @date 30 Aug 2010 | |
77 | * @version 1.0 | |
78 | */ | |
5ba89554 CL |
79 | int wilc_mq_recv(struct message_queue *pHandle, |
80 | void *pvRecvBuffer, u32 u32RecvBufferSize, | |
81 | u32 *pu32ReceivedLength); | |
c5c77ba1 JK |
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 | |
6b05fcc9 | 87 | * @return Error code indicating success/failure |
c5c77ba1 JK |
88 | * @author syounan |
89 | * @date 30 Aug 2010 | |
90 | * @version 1.0 | |
91 | */ | |
d742f67e | 92 | int wilc_mq_destroy(struct message_queue *mq); |
c5c77ba1 JK |
93 | |
94 | #endif |