wm_wl_mbox.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * @file wm_wl_mbox.h
  3. *
  4. * @brief mailbox (mbox) APIs
  5. *
  6. * @author dave
  7. *
  8. * Copyright (c) 2015 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef __TLS_WL_MBOX_H__
  11. #define __TLS_WL_MBOX_H__
  12. #include "wm_type_def.h"
  13. #include "wm_osal.h"
  14. /** max value of time out */
  15. #define SYS_ARCH_TIMEOUT 0xffffffffUL
  16. /** pointer to the mailbox */
  17. typedef tls_os_queue_t * tls_mbox_t;
  18. /**
  19. * @brief Create a malibox
  20. *
  21. * @param[out] *mbox pointer to the mailbox
  22. * @param[in] size size of mailbox
  23. *
  24. * @retval TLS_OS_SUCCESS success
  25. * @retval TLS_OS_ERROR failed
  26. *
  27. * @note None
  28. */
  29. s8 tls_mbox_new(tls_mbox_t *mbox, int size);
  30. /**
  31. * @brief Check if an mbox is valid/allocated
  32. *
  33. * @param[in] mbox pointer to the mailbox
  34. *
  35. * @retval 0 invalid
  36. * @retval 1 valid
  37. *
  38. * @note None
  39. */
  40. int tls_mbox_valid(tls_mbox_t mbox);
  41. /**
  42. * @brief Sends a message to a mailbox
  43. *
  44. * @param[in] mbox pointer to the mailbox
  45. * @param[in] *msg pointer to the message to be post
  46. *
  47. * @return None
  48. *
  49. * @note None
  50. */
  51. void tls_mbox_post(tls_mbox_t mbox, void *msg);
  52. /**
  53. * @brief Posts the msg to the mailbox.
  54. *
  55. * @param[in] mbox pointer to the mailbox
  56. * @param[in] *msg pointer to the message to be post
  57. *
  58. * @retval TLS_OS_SUCCESS success
  59. * @retval TLS_OS_ERROR failed
  60. *
  61. * @note this function have to block until the "msg" is really posted.
  62. */
  63. s8 tls_mbox_trypost(tls_mbox_t mbox, void *msg);
  64. /**
  65. * @brief Waits for a message within specified time
  66. *
  67. * @param[in] mbox pointer to the mailbox
  68. * @param[out] **msg pointer to the message to be received
  69. * @param[in] timeout the specified time
  70. *
  71. * @retval SYS_ARCH_TIMEOUT time out
  72. * @retval other time of elapsed
  73. *
  74. * @note None
  75. */
  76. u32 tls_arch_mbox_fetch(tls_mbox_t mbox, void **msg, u32 timeout);
  77. #endif