forked from EmbeddedRPC/erpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
erpc_rpmsg_tty_rtos_transport.hpp
161 lines (142 loc) · 5.42 KB
/
erpc_rpmsg_tty_rtos_transport.hpp
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/*
* Copyright (c) 2016, Freescale Semiconductor, Inc.
* Copyright 2020 NXP
* All rights reserved.
*
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _EMBEDDED_RPC__RPMSG_LITE_TTY_RTOS_TRANSPORT_H_
#define _EMBEDDED_RPC__RPMSG_LITE_TTY_RTOS_TRANSPORT_H_
#include "erpc_crc16.hpp"
#include "erpc_framed_transport.hpp"
#include "erpc_message_buffer.hpp"
#include "erpc_rpmsg_lite_base.hpp"
extern "C" {
#include "rpmsg_lite.h"
#include "rpmsg_queue.h"
}
/*!
* @addtogroup rpmsg_tty_rtos_transport
* @{
* @file
*/
////////////////////////////////////////////////////////////////////////////////
// Definitions
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Classes
////////////////////////////////////////////////////////////////////////////////
namespace erpc {
/*!
* @brief Transport that uses RPMsg zero copy RTOS API for interprocessor
* messaging.
*
* @ingroup rpmsg_tty_rtos_transport
*/
class RPMsgTTYRTOSTransport : public FramedTransport, public RPMsgBase
{
public:
/*!
* @brief Constructor.
*
* This function initializes object attributes.
*/
RPMsgTTYRTOSTransport(void);
/*!
* @brief RPMsgRTOSTransport destructor
*/
virtual ~RPMsgTTYRTOSTransport(void);
/*!
* @brief This function call RPMsg rtos init function - as RPMsg master
*
* @param[in] src_addr Source address.
* @param[in] dst_addr Destination address.
* @param[in] base_address RPMsg base address in the shared memory.
* @param[in] length RPMsg shared memory region length.
* @param[in] rpmsg_link_id Selection between what cores the communication
* will occur.
*
* @retval kErpcStatus_Success When rpmsg init function was executed
* successfully.
* @retval kErpcStatus_InitFailed When rpmsg init function wasn't executed
* successfully.
*/
virtual erpc_status_t init(uint32_t src_addr, uint32_t dst_addr, void *base_address, uint32_t length,
uint32_t rpmsg_link_id);
/*!
* @brief This function call RPMsg rtos init function - as RPMsg remote
*
* @param[in] src_addr Source address.
* @param[in] dst_addr Destination address.
* @param[in] base_address RPMsg base address in the shared memory.
* @param[in] rpmsg_link_id Selection between what cores the communication
* will occur.
* @param[in] ready_cb Callback called after RPMsg init is done and the core
* is ready.
* @param[in] nameservice_name Name of the nameservice channel to be announced
* to the other core.
*
* @retval kErpcStatus_Success When rpmsg init function was executed
* successfully.
* @retval kErpcStatus_InitFailed When rpmsg init function wasn't executed
* successfully.
*/
virtual erpc_status_t init(uint32_t src_addr, uint32_t dst_addr, void *base_address, uint32_t rpmsg_link_id,
void (*ready_cb)(void), char *nameservice_name);
protected:
uint32_t m_dst_addr; /*!< Destination address used by rpmsg. */
rpmsg_queue_handle m_rpmsg_queue; /*!< Handle of RPMsg queue. */
struct rpmsg_lite_endpoint *m_rpmsg_ept; /*!< Pointer to RPMsg Lite Endpoint structure. */
using FramedTransport::underlyingReceive;
using FramedTransport::underlyingSend;
/*!
* @brief Adds ability to framed transport to overwrite MessageBuffer when receiving data.
*
* Usually we don't want to do that.
*
* @param message MessageBuffer to send.
* @param size size of message to send.
* @param offset data start address offset
*
* @return erpc_status_t kErpcStatus_Success when it finished successful otherwise error.
*/
virtual erpc_status_t underlyingReceive(MessageBuffer *message, uint32_t size, uint32_t offset) override;
/*!
* @brief Adds ability to framed transport to overwrite MessageBuffer when sending data.
*
* Usually we don't want to do that.
*
* @param message MessageBuffer to send.
* @param size size of message to send.
* @param offset data start address offset
*
* @return erpc_status_t kErpcStatus_Success when it finished successful otherwise error.
*/
virtual erpc_status_t underlyingSend(MessageBuffer *message, uint32_t size, uint32_t offset) override;
/*!
* @brief This function read data.
*
* @param[inout] data Preallocated buffer for receiving data.
* @param[in] size Size of data to read.
*
* @retval #kErpcStatus_Success When data was read successfully.
* @retval #kErpcStatus_ReceiveFailed When reading data ends with error.
* @retval #kErpcStatus_ConnectionClosed Peer closed the connection.
*/
virtual erpc_status_t underlyingReceive(uint8_t *data, uint32_t size) override;
/*!
* @brief This function writes data.
*
* @param[in] data Buffer to send.
* @param[in] size Size of data to send.
*
* @retval #kErpcStatus_Success When data was written successfully.
* @retval #kErpcStatus_SendFailed When writing data ends with error.
* @retval #kErpcStatus_ConnectionClosed Peer closed the connection.
*/
virtual erpc_status_t underlyingSend(const uint8_t *data, uint32_t size) override;
};
} // namespace erpc
/*! @} */
#endif // _EMBEDDED_RPC__RPMSG_LITE_TTY_RTOS_TRANSPORT_H_