blob: ac69773f10c550ba0157bd58539a6871c1e6f75c [file] [log] [blame]
David Hucdc51fb2021-04-06 18:10:46 +08001/*
2 * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __OS_WRAPPER_MSG_QUEUE_H__
9#define __OS_WRAPPER_MSG_QUEUE_H__
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include <stddef.h>
16
17#include "common.h"
18
19/**
20 * \brief Create and initialize a message queue
21 *
22 * \param[in] msg_size The maximum message size in bytes
23 * \param[in] msg_count The maximum number of messages in queue
24 *
25 * \return Returns handle of the message queue created, or NULL in case of error
26 */
27void *os_wrapper_msg_queue_create(size_t msg_size, uint8_t msg_count);
28
29/**
30 * \brief Send a message via message queue
31 *
32 * \param[in] mq_handle The handle of message queue
33 * \param[in] msg_ptr The pointer to the message to be sent
34 *
35 * \return \ref OS_WRAPPER_SUCCESS if the message is successfully sent, or
36 * \ref OS_WRAPPER_ERROR in case of error
37 *
38 * \note The message size must be the same as the value set in
39 * \ref os_wrapper_msg_queue_create.
40 *
41 * \note Time out value is not specified here. Whether the function is blocked
42 * or returns instantly depends on the actual implementation and usage
43 * scenario.
44 */
45int32_t os_wrapper_msg_queue_send(void *mq_handle,
46 const void *msg_ptr);
47
48/**
49 * \brief Receive a message from message queue
50 *
51 * \param[in] mq_handle The handle of message queue
52 * \param[in] msg_ptr The pointer to buffer for message to be received
53 *
54 * \return \ref OS_WRAPPER_SUCCESS if the message is successfully received, or
55 * \ref OS_WRAPPER_ERROR in case of error
56 *
57 * \note The message size is the same as the value set in
58 * \ref os_wrapper_msg_queue_create.
59 *
60 * \note The function should be blocked until a message is received from message
61 * queue, unless an error occurs.
62 */
63int32_t os_wrapper_msg_queue_receive(void *mq_handle,
64 void *msg_ptr);
65
66#ifdef __cplusplus
67}
68#endif
69
70#endif /* __OS_WRAPPER_MSG_QUEUE_H__ */