drivers/rpmsg: Add get_local_cpuname in router

get_local_cpuname ops support for rpmsg router

Signed-off-by: yintao <yintao@xiaomi.com>
This commit is contained in:
yintao 2024-06-24 17:10:12 +08:00 committed by Xiang Xiao
parent 4a356f6f6d
commit 6e55812e59
3 changed files with 8 additions and 1 deletions

View File

@ -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 */

View File

@ -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;

View File

@ -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);
}