• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @file    wm_wl_mbox.h
18  *
19  * @brief   mailbox (mbox) APIs
20  *
21  * @author  dave
22  *
23  * Copyright (c) 2015 Winner Microelectronics Co., Ltd.
24  */
25 #ifndef __TLS_WL_MBOX_H__
26 #define __TLS_WL_MBOX_H__
27 
28 #include "wm_type_def.h"
29 #include "wm_osal.h"
30 
31 /** max value of time out */
32 #define SYS_ARCH_TIMEOUT 0xffffffffUL
33 
34 /** pointer to the mailbox */
35 typedef tls_os_queue_t *tls_mbox_t;
36 
37 /**
38  * @brief          Create a malibox
39  *
40  * @param[out]     *mbox              pointer to the mailbox
41  * @param[in]      size               size of mailbox
42  *
43  * @retval         TLS_OS_SUCCESS     success
44  * @retval         TLS_OS_ERROR       failed
45  *
46  * @note           None
47  */
48 s8 tls_mbox_new(tls_mbox_t *mbox, int size);
49 
50 /**
51  * @brief          Check if an mbox is valid/allocated
52  *
53  * @param[in]      mbox    pointer to the mailbox
54  *
55  * @retval         0       invalid
56  * @retval         1       valid
57  *
58  * @note           None
59  */
60 int tls_mbox_valid(tls_mbox_t mbox);
61 
62 /**
63  * @brief          Sends a message to a mailbox
64  *
65  * @param[in]      mbox    pointer to the mailbox
66  * @param[in]      *msg    pointer to the message to be post
67  *
68  * @return         None
69  *
70  * @note           None
71  */
72 void tls_mbox_post(tls_mbox_t mbox, void *msg);
73 
74 /**
75  * @brief          Posts the msg to the mailbox.
76  *
77  * @param[in]      mbox               pointer to the mailbox
78  * @param[in]      *msg               pointer to the message to be post
79  *
80  * @retval         TLS_OS_SUCCESS     success
81  * @retval         TLS_OS_ERROR       failed
82  *
83  * @note           this function have to block until the "msg" is really posted.
84  */
85 s8 tls_mbox_trypost(tls_mbox_t mbox, void *msg);
86 
87 /**
88  * @brief          Waits for a message within specified time
89  *
90  * @param[in]      mbox         pointer to the mailbox
91  * @param[out]     **msg        pointer to the message to be received
92  * @param[in]      timeout      the specified time
93  *
94  * @retval         SYS_ARCH_TIMEOUT     time out
95  * @retval         other                time of elapsed
96  *
97  * @note           None
98  */
99 u32 tls_arch_mbox_fetch(tls_mbox_t mbox, void **msg, u32 timeout);
100 
101 #endif
102 
103