From 6e55812e59d2128d2ce5a0739d39b555a646e173 Mon Sep 17 00:00:00 2001 From: yintao Date: Mon, 24 Jun 2024 17:10:12 +0800 Subject: [PATCH] drivers/rpmsg: Add get_local_cpuname in router get_local_cpuname ops support for rpmsg router Signed-off-by: yintao --- drivers/rpmsg/rpmsg_router.h | 1 + drivers/rpmsg/rpmsg_router_edge.c | 7 ++++++- drivers/rpmsg/rpmsg_router_hub.c | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/rpmsg/rpmsg_router.h b/drivers/rpmsg/rpmsg_router.h index a57977a32b..6f7a9288b4 100644 --- a/drivers/rpmsg/rpmsg_router.h +++ b/drivers/rpmsg/rpmsg_router.h @@ -47,6 +47,7 @@ begin_packed_struct struct rpmsg_router_s { uint32_t tx_len; uint32_t rx_len; + char cpuname[RPMSG_ROUTER_CPUNAME_LEN]; } end_packed_struct; #endif /* CONFIG_RPMSG_ROUTER */ diff --git a/drivers/rpmsg/rpmsg_router_edge.c b/drivers/rpmsg/rpmsg_router_edge.c index 573145fab7..bdc78d4f93 100644 --- a/drivers/rpmsg/rpmsg_router_edge.c +++ b/drivers/rpmsg/rpmsg_router_edge.c @@ -67,6 +67,7 @@ struct rpmsg_router_edge_s struct rpmsg_s rpmsg; struct rpmsg_device rdev; struct rpmsg_device *hubdev; + char localcpu[RPMSG_ROUTER_CPUNAME_LEN]; char remotecpu[RPMSG_ROUTER_CPUNAME_LEN]; /* Tx/Rx buffer size */ @@ -114,7 +115,10 @@ static const struct rpmsg_ops_s g_rpmsg_router_edge_ops = static FAR const char * rpmsg_router_edge_get_local_cpuname(FAR struct rpmsg_s *rpmsg) { - return NULL; + FAR struct rpmsg_router_edge_s *edge = + (FAR struct rpmsg_router_edge_s *)rpmsg; + + return edge->localcpu; } /**************************************************************************** @@ -570,6 +574,7 @@ static int rpmsg_router_cb(FAR struct rpmsg_endpoint *ept, strlcpy(edge->remotecpu, ept->name + RPMSG_ROUTER_NAME_LEN, sizeof(edge->remotecpu)); + strlcpy(edge->localcpu, msg->cpuname, sizeof(edge->localcpu)); edge->rx_len = msg->rx_len; edge->tx_len = msg->tx_len; edge->hubdev = ept->rdev; diff --git a/drivers/rpmsg/rpmsg_router_hub.c b/drivers/rpmsg/rpmsg_router_hub.c index 3d0a303500..b7f43aa517 100644 --- a/drivers/rpmsg/rpmsg_router_hub.c +++ b/drivers/rpmsg/rpmsg_router_hub.c @@ -325,6 +325,7 @@ static void rpmsg_router_bound(FAR struct rpmsg_endpoint *ept) rpmsg_get_tx_buffer_size(hub->ept[1 - i].rdev)); msg.rx_len = MIN(rpmsg_get_tx_buffer_size(hub->ept[i].rdev), rpmsg_get_rx_buffer_size(hub->ept[1 - i].rdev)); + strlcpy(msg.cpuname, hub->cpuname[i], sizeof(msg.cpuname)); ret = rpmsg_send(&hub->ept[i], &msg, sizeof(msg)); DEBUGASSERT(ret >= 0); }