aboutsummaryrefslogtreecommitdiff
path: root/interface/include/os_wrapper/msg_queue.h
blob: ac69773f10c550ba0157bd58539a6871c1e6f75c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 *
 */

#ifndef __OS_WRAPPER_MSG_QUEUE_H__
#define __OS_WRAPPER_MSG_QUEUE_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>

#include "common.h"

/**
 * \brief Create and initialize a message queue
 *
 * \param[in] msg_size        The maximum message size in bytes
 * \param[in] msg_count       The maximum number of messages in queue
 *
 * \return Returns handle of the message queue created, or NULL in case of error
 */
void *os_wrapper_msg_queue_create(size_t msg_size, uint8_t msg_count);

/**
 * \brief Send a message via message queue
 *
 * \param[in] mq_handle       The handle of message queue
 * \param[in] msg_ptr         The pointer to the message to be sent
 *
 * \return \ref OS_WRAPPER_SUCCESS if the message is successfully sent, or
 *         \ref OS_WRAPPER_ERROR in case of error
 *
 * \note The message size must be the same as the value set in
 *       \ref os_wrapper_msg_queue_create.
 *
 * \note Time out value is not specified here. Whether the function is blocked
 *       or returns instantly depends on the actual implementation and usage
 *       scenario.
 */
int32_t os_wrapper_msg_queue_send(void *mq_handle,
                                  const void *msg_ptr);

/**
 * \brief Receive a message from message queue
 *
 * \param[in] mq_handle       The handle of message queue
 * \param[in] msg_ptr         The pointer to buffer for message to be received
 *
 * \return \ref OS_WRAPPER_SUCCESS if the message is successfully received, or
 *         \ref OS_WRAPPER_ERROR in case of error
 *
 * \note The message size is the same as the value set in
 *       \ref os_wrapper_msg_queue_create.
 *
 * \note The function should be blocked until a message is received from message
 *       queue, unless an error occurs.
 */
int32_t os_wrapper_msg_queue_receive(void *mq_handle,
                                     void *msg_ptr);

#ifdef __cplusplus
}
#endif

#endif /* __OS_WRAPPER_MSG_QUEUE_H__ */