From ceddd67f270fe7da466e32e9bcd3d8a19ce55d57 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 27 Nov 2020 22:40:23 +0800 Subject: [PATCH] rpmsg: notify the user when the remote address is received without this notificaiton, user has to call is_rpmsg_ept_ready in a busy loop Signed-off-by: Xiang Xiao --- docs/rpmsg-design.md | 7 +++++++ lib/include/openamp/rpmsg.h | 3 +++ lib/rpmsg/rpmsg_virtio.c | 3 +++ 3 files changed, 13 insertions(+) diff --git a/docs/rpmsg-design.md b/docs/rpmsg-design.md index f28b78294..1091d251f 100644 --- a/docs/rpmsg-design.md +++ b/docs/rpmsg-design.md @@ -107,6 +107,13 @@ running on two processors. void (*rpmsg_ns_unbind_cb)(struct rpmsg_device *rdev, const char *name, uint32_t dest) ``` +* RPMsg endpoint name service binding callback. If user defines such callback, + when there is a name service announcement arrives, if there is a registered + endpoint found to bind to this name service, it will call this callback to + notify the user application about the remote has created the service.: + ``` + void (*rpmsg_ns_bind_cb)(struct rpmsg_endpoint *ept) + ``` * RPMsg endpoint name service unbind callback. If user defines such callback, when there is name service destroy arrives, it will call this callback to notify the user application about the remote has destroyed the service.: diff --git a/lib/include/openamp/rpmsg.h b/lib/include/openamp/rpmsg.h index 5b2d5bed8..49c22f13d 100644 --- a/lib/include/openamp/rpmsg.h +++ b/lib/include/openamp/rpmsg.h @@ -61,6 +61,8 @@ typedef void (*rpmsg_ns_bind_cb)(struct rpmsg_device *rdev, * @dest_addr: address of the default remote endpoint binded. * @cb: user rx callback, return value of this callback is reserved * for future use, for now, only allow RPMSG_SUCCESS as return value. + * @ns_bind_cb: end point service bind callback, called when remote + * ept address is received. * @ns_unbind_cb: end point service unbind callback, called when remote * ept is destroyed. * @node: end point node. @@ -75,6 +77,7 @@ struct rpmsg_endpoint { uint32_t addr; uint32_t dest_addr; rpmsg_ept_cb cb; + rpmsg_ns_unbind_cb ns_bind_cb; rpmsg_ns_unbind_cb ns_unbind_cb; struct metal_list node; void *priv; diff --git a/lib/rpmsg/rpmsg_virtio.c b/lib/rpmsg/rpmsg_virtio.c index cd08f40b7..5041315f7 100644 --- a/lib/rpmsg/rpmsg_virtio.c +++ b/lib/rpmsg/rpmsg_virtio.c @@ -601,6 +601,9 @@ static int rpmsg_virtio_ns_callback(struct rpmsg_endpoint *ept, void *data, } else { _ept->dest_addr = dest; metal_mutex_release(&rdev->lock); + /* notify application the endpoint has been bound */ + if (_ept->ns_bind_cb) + _ept->ns_bind_cb(_ept); } }