wilc_msgqueue.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef __WILC_MSG_QUEUE_H__
  2. #define __WILC_MSG_QUEUE_H__
  3. /*!
  4. * @file wilc_msgqueue.h
  5. * @brief Message Queue OS wrapper functionality
  6. * @author syounan
  7. * @sa wilc_oswrapper.h top level OS wrapper file
  8. * @date 30 Aug 2010
  9. * @version 1.0
  10. */
  11. #include <linux/semaphore.h>
  12. /* Message Queue type is a structure */
  13. typedef struct __Message_struct {
  14. void *pvBuffer;
  15. u32 u32Length;
  16. struct __Message_struct *pstrNext;
  17. } Message;
  18. typedef struct __MessageQueue_struct {
  19. struct semaphore hSem;
  20. spinlock_t strCriticalSection;
  21. bool bExiting;
  22. u32 u32ReceiversCount;
  23. Message *pstrMessageList;
  24. } WILC_MsgQueueHandle;
  25. /*!
  26. * @brief Creates a new Message queue
  27. * @details Creates a new Message queue, if the feature
  28. * CONFIG_WILC_MSG_QUEUE_IPC_NAME is enabled and pstrAttrs->pcName
  29. * is not Null, then this message queue can be used for IPC with
  30. * any other message queue having the same name in the system
  31. * @param[in,out] pHandle handle to the message queue object
  32. * @param[in] pstrAttrs Optional attributes, NULL for default
  33. * @return Error code indicating sucess/failure
  34. * @author syounan
  35. * @date 30 Aug 2010
  36. * @version 1.0
  37. */
  38. int wilc_mq_create(WILC_MsgQueueHandle *pHandle);
  39. /*!
  40. * @brief Sends a message
  41. * @details Sends a message, this API will block unil the message is
  42. * actually sent or until it is timedout (as long as the feature
  43. * CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and pstrAttrs->u32Timeout
  44. * is not set to WILC_OS_INFINITY), zero timeout is a valid value
  45. * @param[in] pHandle handle to the message queue object
  46. * @param[in] pvSendBuffer pointer to the data to send
  47. * @param[in] u32SendBufferSize the size of the data to send
  48. * @param[in] pstrAttrs Optional attributes, NULL for default
  49. * @return Error code indicating sucess/failure
  50. * @author syounan
  51. * @date 30 Aug 2010
  52. * @version 1.0
  53. */
  54. int wilc_mq_send(WILC_MsgQueueHandle *pHandle,
  55. const void *pvSendBuffer, u32 u32SendBufferSize);
  56. /*!
  57. * @brief Receives a message
  58. * @details Receives a message, this API will block unil a message is
  59. * received or until it is timedout (as long as the feature
  60. * CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and pstrAttrs->u32Timeout
  61. * is not set to WILC_OS_INFINITY), zero timeout is a valid value
  62. * @param[in] pHandle handle to the message queue object
  63. * @param[out] pvRecvBuffer pointer to a buffer to fill with the received message
  64. * @param[in] u32RecvBufferSize the size of the receive buffer
  65. * @param[out] pu32ReceivedLength the length of received data
  66. * @param[in] pstrAttrs Optional attributes, NULL for default
  67. * @return Error code indicating sucess/failure
  68. * @author syounan
  69. * @date 30 Aug 2010
  70. * @version 1.0
  71. */
  72. int wilc_mq_recv(WILC_MsgQueueHandle *pHandle,
  73. void *pvRecvBuffer, u32 u32RecvBufferSize,
  74. u32 *pu32ReceivedLength);
  75. /*!
  76. * @brief Destroys an existing Message queue
  77. * @param[in] pHandle handle to the message queue object
  78. * @param[in] pstrAttrs Optional attributes, NULL for default
  79. * @return Error code indicating sucess/failure
  80. * @author syounan
  81. * @date 30 Aug 2010
  82. * @version 1.0
  83. */
  84. int wilc_mq_destroy(WILC_MsgQueueHandle *pHandle);
  85. #endif