Mistake on this page?
Report an issue in GitHub or email us
wsf_msg.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file wsf_msg.h
4  *
5  * \brief Message passing service.
6  *
7  * Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 #ifndef WSF_MSG_H
25 #define WSF_MSG_H
26 
27 #include "wsf_queue.h"
28 #include "wsf_os.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 /*! \addtogroup WSF_MSG_API
35  * \{ */
36 
37 /**************************************************************************************************
38  Function Declarations
39 **************************************************************************************************/
40 
41 /*************************************************************************************************/
42 /*!
43  * \brief Allocate a data message buffer to be sent with WsfMsgSend().
44  *
45  * \param len Message length in bytes.
46  * \param tailroom Tailroom length in bytes.
47  *
48  * \return Pointer to data message buffer or NULL if allocation failed.
49  */
50 /*************************************************************************************************/
51 void *WsfMsgDataAlloc(uint16_t len, uint8_t tailroom);
52 
53 /*************************************************************************************************/
54 /*!
55  * \brief Allocate a message buffer to be sent with WsfMsgSend().
56  *
57  * \param len Message length in bytes.
58  *
59  * \return Pointer to message buffer or NULL if allocation failed.
60  */
61 /*************************************************************************************************/
62 void *WsfMsgAlloc(uint16_t len);
63 
64 /*************************************************************************************************/
65 /*!
66  * \brief Free a message buffer allocated with WsfMsgAlloc().
67  *
68  * \param pMsg Pointer to message buffer.
69  */
70 /*************************************************************************************************/
71 void WsfMsgFree(void *pMsg);
72 
73 /*************************************************************************************************/
74 /*!
75  * \brief Send a message to an event handler.
76  *
77  * \param handlerId Event handler ID.
78  * \param pMsg Pointer to message buffer.
79  */
80 /*************************************************************************************************/
81 void WsfMsgSend(wsfHandlerId_t handlerId, void *pMsg);
82 
83 /*************************************************************************************************/
84 /*!
85  * \brief Enqueue a message.
86  *
87  * \param pQueue Pointer to queue.
88  * \param handlerId Set message handler ID to this value.
89  * \param pMsg Pointer to message buffer.
90  */
91 /*************************************************************************************************/
92 void WsfMsgEnq(wsfQueue_t *pQueue, wsfHandlerId_t handlerId, void *pMsg);
93 
94 /*************************************************************************************************/
95 /*!
96  * \brief Dequeue a message.
97  *
98  * \param pQueue Pointer to queue.
99  * \param pHandlerId Handler ID of returned message; this is a return parameter.
100  *
101  * \return Pointer to message that has been dequeued or NULL if queue is empty.
102  */
103 /*************************************************************************************************/
104 void *WsfMsgDeq(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId);
105 
106 /*************************************************************************************************/
107 /*!
108  * \brief Get the next message without removing it from the queue.
109  *
110  * \param pQueue Pointer to queue.
111  * \param pHandlerId Handler ID of returned message; this is a return parameter.
112  *
113  * \return Pointer to the next message on the queue or NULL if queue is empty.
114  */
115 /*************************************************************************************************/
116 void *WsfMsgPeek(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId);
117 
118 /*************************************************************************************************/
119 /*!
120  * \brief Get the Nth message without removing it from the queue.
121  *
122  * \param pQueue Pointer to queue.
123  * \param n Nth item from the top (0 = top element).
124  * \param pHandlerId Handler ID of returned message; this is a return parameter.
125  *
126  * \return Pointer to the next message on the queue or NULL if queue is empty.
127  */
128 /*************************************************************************************************/
129 void *WsfMsgNPeek(wsfQueue_t *pQueue, uint8_t n, wsfHandlerId_t *pHandlerId);
130 
131 /*! \} */ /* WSF_MSG_API */
132 
133 #ifdef __cplusplus
134 };
135 #endif
136 
137 #endif /* WSF_MSG_H */
void * WsfMsgNPeek(wsfQueue_t *pQueue, uint8_t n, wsfHandlerId_t *pHandlerId)
Get the Nth message without removing it from the queue.
void WsfMsgEnq(wsfQueue_t *pQueue, wsfHandlerId_t handlerId, void *pMsg)
Enqueue a message.
void WsfMsgSend(wsfHandlerId_t handlerId, void *pMsg)
Send a message to an event handler.
uint8_t wsfHandlerId_t
Event handler ID data type.
Definition: wsf_os.h:80
Queue structure.
Definition: wsf_queue.h:46
void * WsfMsgPeek(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId)
Get the next message without removing it from the queue.
void * WsfMsgAlloc(uint16_t len)
Allocate a message buffer to be sent with WsfMsgSend().
void * WsfMsgDataAlloc(uint16_t len, uint8_t tailroom)
Allocate a data message buffer to be sent with WsfMsgSend().
General purpose queue service.
void WsfMsgFree(void *pMsg)
Free a message buffer allocated with WsfMsgAlloc().
Software foundation OS API.
void * WsfMsgDeq(wsfQueue_t *pQueue, wsfHandlerId_t *pHandlerId)
Dequeue a message.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.