15 #include <metal/compiler.h>
16 #include <metal/mutex.h>
17 #include <metal/list.h>
18 #include <metal/utilities.h>
23 #if defined __cplusplus
28 #define RPMSG_NAME_SIZE (32)
29 #define RPMSG_ADDR_BMP_SIZE (128)
31 #define RPMSG_NS_EPT_ADDR (0x35)
32 #define RPMSG_RESERVED_ADDRESSES (1024)
33 #define RPMSG_ADDR_ANY 0xFFFFFFFF
36 #define RPMSG_SUCCESS 0
37 #define RPMSG_ERROR_BASE -2000
38 #define RPMSG_ERR_NO_MEM (RPMSG_ERROR_BASE - 1)
39 #define RPMSG_ERR_NO_BUFF (RPMSG_ERROR_BASE - 2)
40 #define RPMSG_ERR_PARAM (RPMSG_ERROR_BASE - 3)
41 #define RPMSG_ERR_DEV_STATE (RPMSG_ERROR_BASE - 4)
42 #define RPMSG_ERR_BUFF_SIZE (RPMSG_ERROR_BASE - 5)
43 #define RPMSG_ERR_INIT (RPMSG_ERROR_BASE - 6)
44 #define RPMSG_ERR_ADDR (RPMSG_ERROR_BASE - 7)
45 #define RPMSG_ERR_PERM (RPMSG_ERROR_BASE - 8)
46 #define RPMSG_EOPNOTSUPP (RPMSG_ERROR_BASE - 9)
53 size_t len, uint32_t src,
void *
priv);
57 const char *name, uint32_t dest);
94 struct metal_list
node;
104 uint32_t src, uint32_t dst,
105 const void *data,
int len,
int wait);
115 uint32_t *len,
int wait);
119 uint32_t src, uint32_t dst,
120 const void *data,
int len);
179 uint32_t dst,
const void *data,
int len,
226 int len, uint32_t dst)
254 uint32_t src, uint32_t dst,
255 const void *data,
int len)
302 int len, uint32_t dst)
329 uint32_t src, uint32_t dst,
330 const void *data,
int len)
388 uint32_t *len,
int wait);
470 uint32_t dst,
const void *data,
int len);
502 const void *data,
int len, uint32_t dst)
539 const void *data,
int len)
577 const char *name, uint32_t src, uint32_t dest,
603 #if defined __cplusplus
#define RPMSG_NAME_SIZE
Definition: rpmsg.h:28
static int rpmsg_sendto(struct rpmsg_endpoint *ept, const void *data, int len, uint32_t dst)
Send a message across to the remote processor, specify dst.
Definition: rpmsg.h:225
void(* rpmsg_ns_unbind_cb)(struct rpmsg_endpoint *ept)
Definition: rpmsg.h:55
#define RPMSG_ERR_PARAM
Definition: rpmsg.h:40
#define RPMSG_ADDR_BMP_SIZE
Definition: rpmsg.h:29
int rpmsg_get_rx_buffer_size(struct rpmsg_endpoint *ept)
Get RPMsg Rx buffer size.
Definition: rpmsg.c:227
static int rpmsg_send(struct rpmsg_endpoint *ept, const void *data, int len)
Send a message across to the remote processor.
Definition: rpmsg.h:198
#define RPMSG_ADDR_ANY
Definition: rpmsg.h:33
void(* rpmsg_ns_bind_cb)(struct rpmsg_device *rdev, const char *name, uint32_t dest)
Definition: rpmsg.h:56
int rpmsg_send_offchannel_nocopy(struct rpmsg_endpoint *ept, uint32_t src, uint32_t dst, const void *data, int len)
Send a message in tx buffer reserved by rpmsg_get_tx_payload_buffer() across to the remote processor.
Definition: rpmsg.c:242
void rpmsg_hold_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf)
Holds the rx buffer for usage outside the receive callback.
Definition: rpmsg.c:155
static int rpmsg_sendto_nocopy(struct rpmsg_endpoint *ept, const void *data, int len, uint32_t dst)
Sends a message in tx buffer allocated by rpmsg_get_tx_payload_buffer() across to the remote processo...
Definition: rpmsg.h:501
static int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, uint32_t src, uint32_t dst, const void *data, int len)
Send a message using explicit src/dst addresses.
Definition: rpmsg.h:328
static int rpmsg_send_offchannel(struct rpmsg_endpoint *ept, uint32_t src, uint32_t dst, const void *data, int len)
Send a message using explicit src/dst addresses.
Definition: rpmsg.h:253
void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
Destroy rpmsg endpoint and unregister it from rpmsg device.
Definition: rpmsg.c:379
void rpmsg_release_rx_buffer(struct rpmsg_endpoint *ept, void *rxbuf)
Releases the rx buffer for future reuse in vring.
Definition: rpmsg.c:168
int rpmsg_release_tx_buffer(struct rpmsg_endpoint *ept, void *txbuf)
Releases unused buffer.
Definition: rpmsg.c:181
void * rpmsg_get_tx_payload_buffer(struct rpmsg_endpoint *ept, uint32_t *len, int wait)
Gets the tx buffer for message payload.
Definition: rpmsg.c:196
static int rpmsg_trysend(struct rpmsg_endpoint *ept, const void *data, int len)
Send a message across to the remote processor.
Definition: rpmsg.h:275
int rpmsg_create_ept(struct rpmsg_endpoint *ept, struct rpmsg_device *rdev, const char *name, uint32_t src, uint32_t dest, rpmsg_ept_cb cb, rpmsg_ns_unbind_cb ns_unbind_cb)
Create rpmsg endpoint and register it to rpmsg device.
Definition: rpmsg.c:324
int rpmsg_send_offchannel_raw(struct rpmsg_endpoint *ept, uint32_t src, uint32_t dst, const void *data, int len, int wait)
Send a message across to the remote processor, specifying source and destination address.
Definition: rpmsg.c:120
int rpmsg_get_tx_buffer_size(struct rpmsg_endpoint *ept)
Get RPMsg Tx buffer size.
Definition: rpmsg.c:212
void(* rpmsg_ept_release_cb)(struct rpmsg_endpoint *ept)
Definition: rpmsg.h:54
static unsigned int is_rpmsg_ept_ready(struct rpmsg_endpoint *ept)
Check if the rpmsg endpoint ready to send.
Definition: rpmsg.h:598
static int rpmsg_trysendto(struct rpmsg_endpoint *ept, const void *data, int len, uint32_t dst)
Send a message across to the remote processor, specify dst.
Definition: rpmsg.h:301
int(* rpmsg_ept_cb)(struct rpmsg_endpoint *ept, void *data, size_t len, uint32_t src, void *priv)
Definition: rpmsg.h:52
static int rpmsg_send_nocopy(struct rpmsg_endpoint *ept, const void *data, int len)
Send a message in tx buffer reserved by rpmsg_get_tx_payload_buffer() across to the remote processor.
Definition: rpmsg.h:538
RPMsg device operations.
Definition: rpmsg.h:101
void(* release_rx_buffer)(struct rpmsg_device *rdev, void *rxbuf)
Release RPMsg RX buffer.
Definition: rpmsg.h:111
int(* send_offchannel_nocopy)(struct rpmsg_device *rdev, uint32_t src, uint32_t dst, const void *data, int len)
Send RPMsg data without copy.
Definition: rpmsg.h:118
int(* send_offchannel_raw)(struct rpmsg_device *rdev, uint32_t src, uint32_t dst, const void *data, int len, int wait)
Send RPMsg data.
Definition: rpmsg.h:103
int(* release_tx_buffer)(struct rpmsg_device *rdev, void *txbuf)
Release RPMsg TX buffer.
Definition: rpmsg.h:123
int(* get_tx_buffer_size)(struct rpmsg_device *rdev)
Get RPMsg TX buffer size.
Definition: rpmsg.h:129
void(* hold_rx_buffer)(struct rpmsg_device *rdev, void *rxbuf)
Hold RPMsg RX buffer.
Definition: rpmsg.h:108
int(* get_rx_buffer_size)(struct rpmsg_device *rdev)
Get RPMsg RX buffer size.
Definition: rpmsg.h:126
Representation of a RPMsg device.
Definition: rpmsg.h:133
metal_mutex_t lock
Mutex lock for RPMsg management.
Definition: rpmsg.h:145
bool support_ns
Create/destroy namespace message.
Definition: rpmsg.h:157
unsigned long bitmap[metal_bitmap_longs(RPMSG_ADDR_BMP_SIZE)]
Table endpoint address allocation.
Definition: rpmsg.h:141
rpmsg_ns_bind_cb ns_bind_cb
Callback handler for name service announcement without local epts waiting to bind.
Definition: rpmsg.h:148
struct rpmsg_device_ops ops
RPMsg device operations.
Definition: rpmsg.h:154
unsigned int bitnext
Definition: rpmsg.h:142
struct metal_list endpoints
List of endpoints.
Definition: rpmsg.h:135
struct rpmsg_endpoint ns_ept
Name service endpoint.
Definition: rpmsg.h:138
rpmsg_ns_bind_cb ns_unbind_cb
Callback handler for name service announcement, called when remote ept is destroyed.
Definition: rpmsg.h:151
Structure that binds a local RPMsg address to its user.
Definition: rpmsg.h:65
struct rpmsg_device * rdev
Pointer to the RPMsg device.
Definition: rpmsg.h:70
void * priv
Private data for the driver's use.
Definition: rpmsg.h:97
char name[RPMSG_NAME_SIZE]
Name of the service supported.
Definition: rpmsg.h:67
rpmsg_ept_release_cb release_cb
Callback to inform the user that the endpoint allocation can be safely removed.
Definition: rpmsg.h:82
rpmsg_ept_cb cb
User rx callback, return value of this callback is reserved for future use, for now,...
Definition: rpmsg.h:88
uint32_t addr
Local address of the endpoint.
Definition: rpmsg.h:73
rpmsg_ns_unbind_cb ns_unbind_cb
Endpoint service unbind callback, called when remote ept is destroyed.
Definition: rpmsg.h:91
uint32_t dest_addr
Address of the default remote endpoint binded.
Definition: rpmsg.h:76
uint32_t refcnt
Reference count for determining whether the endpoint can be deallocated.
Definition: rpmsg.h:79
struct metal_list node
Endpoint node.
Definition: rpmsg.h:94