OpenAMP Library  353
rpmsg_internal.h
Go to the documentation of this file.
1 /*
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * $FreeBSD$
5  */
6 
7 #ifndef _RPMSG_INTERNAL_H_
8 #define _RPMSG_INTERNAL_H_
9 
10 #include <stdint.h>
11 #include <openamp/rpmsg.h>
12 
13 #if defined __cplusplus
14 extern "C" {
15 #endif
16 
17 #ifdef RPMSG_DEBUG
18 #include <metal/log.h>
19 
20 #define RPMSG_ASSERT(_exp, _msg) do { \
21  if (!(_exp)) { \
22  metal_log(METAL_LOG_EMERGENCY, \
23  "FATAL: %s - "_msg, __func__); \
24  metal_assert(_exp); \
25  } \
26  } while (0)
27 #else
28 #define RPMSG_ASSERT(_exp, _msg) metal_assert(_exp)
29 #endif
30 
31 /* Mask to get the rpmsg buffer held counter from rpmsg_hdr reserved field */
32 #define RPMSG_BUF_HELD_SHIFT 16
33 #define RPMSG_BUF_HELD_MASK (0xFFFFU << RPMSG_BUF_HELD_SHIFT)
34 
35 #define RPMSG_LOCATE_HDR(p) \
36  ((struct rpmsg_hdr *)((unsigned char *)(p) - sizeof(struct rpmsg_hdr)))
37 #define RPMSG_LOCATE_DATA(p) ((unsigned char *)(p) + sizeof(struct rpmsg_hdr))
38 
47 };
48 
54 METAL_PACKED_BEGIN
55 struct rpmsg_hdr {
57  uint32_t src;
58 
60  uint32_t dst;
61 
63  uint32_t reserved;
64 
66  uint16_t len;
67 
69  uint16_t flags;
71 
81 METAL_PACKED_BEGIN
82 struct rpmsg_ns_msg {
85 
87  uint32_t addr;
88 
90  uint32_t flags;
92 
93 int rpmsg_send_ns_message(struct rpmsg_endpoint *ept, unsigned long flags);
94 
95 struct rpmsg_endpoint *rpmsg_get_endpoint(struct rpmsg_device *rvdev,
96  const char *name, uint32_t addr,
97  uint32_t dest_addr);
99  struct rpmsg_endpoint *ept,
100  const char *name,
101  uint32_t src, uint32_t dest,
104 
105 static inline struct rpmsg_endpoint *
107 {
108  return rpmsg_get_endpoint(rdev, NULL, addr, RPMSG_ADDR_ANY);
109 }
110 
122 void rpmsg_ept_incref(struct rpmsg_endpoint *ept);
123 
134 void rpmsg_ept_decref(struct rpmsg_endpoint *ept);
135 
136 #if defined __cplusplus
137 }
138 #endif
139 
140 #endif /* _RPMSG_INTERNAL_H_ */
#define RPMSG_NAME_SIZE
Definition: rpmsg.h:28
void(* rpmsg_ns_unbind_cb)(struct rpmsg_endpoint *ept)
Definition: rpmsg.h:55
#define RPMSG_ADDR_ANY
Definition: rpmsg.h:33
int(* rpmsg_ept_cb)(struct rpmsg_endpoint *ept, void *data, size_t len, uint32_t src, void *priv)
Definition: rpmsg.h:52
static struct rpmsg_endpoint * rpmsg_get_ept_from_addr(struct rpmsg_device *rdev, uint32_t addr)
Definition: rpmsg_internal.h:106
int rpmsg_send_ns_message(struct rpmsg_endpoint *ept, unsigned long flags)
Definition: rpmsg.c:138
METAL_PACKED_BEGIN struct rpmsg_hdr METAL_PACKED_END
rpmsg_ns_flags
dynamic name service announcement flags
Definition: rpmsg_internal.h:42
@ RPMSG_NS_DESTROY
A known remote service was just destroyed.
Definition: rpmsg_internal.h:46
@ RPMSG_NS_CREATE
A new remote service was just created.
Definition: rpmsg_internal.h:44
void rpmsg_register_endpoint(struct rpmsg_device *rdev, struct rpmsg_endpoint *ept, const char *name, uint32_t src, uint32_t dest, rpmsg_ept_cb cb, rpmsg_ns_unbind_cb ns_unbind_cb, void *priv)
Definition: rpmsg.c:302
struct rpmsg_endpoint * rpmsg_get_endpoint(struct rpmsg_device *rvdev, const char *name, uint32_t addr, uint32_t dest_addr)
Definition: rpmsg.c:259
void rpmsg_ept_decref(struct rpmsg_endpoint *ept)
Definition: rpmsg.c:107
void rpmsg_ept_incref(struct rpmsg_endpoint *ept)
Definition: rpmsg.c:101
Representation of a RPMsg device.
Definition: rpmsg.h:133
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_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
Common header for all RPMsg messages.
Definition: rpmsg_internal.h:55
uint32_t dst
Destination address.
Definition: rpmsg_internal.h:60
uint16_t flags
Message flags.
Definition: rpmsg_internal.h:69
uint32_t src
Source address.
Definition: rpmsg_internal.h:57
uint32_t reserved
Reserved for future use.
Definition: rpmsg_internal.h:63
uint16_t len
Length of payload (in bytes)
Definition: rpmsg_internal.h:66
Dynamic name service announcement message.
Definition: rpmsg_internal.h:82
char name[RPMSG_NAME_SIZE]
Name of the remote service that is being published.
Definition: rpmsg_internal.h:84
uint32_t addr
Endpoint address of the remote service that is being published.
Definition: rpmsg_internal.h:87
uint32_t flags
Indicates whether service is created or destroyed.
Definition: rpmsg_internal.h:90