mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 10:46:28 +08:00
rptun: move rptun cmd definition before the resource table
Because locate the command at the end the resource table is unfriendly when we want to support multi virtio devices instead only one virtio rpmsg device. Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
This commit is contained in:
@@ -372,18 +372,18 @@ static bool rptun_is_recursive(FAR struct rptun_priv_s *priv)
|
||||
|
||||
static void rptun_command(FAR struct rptun_priv_s *priv)
|
||||
{
|
||||
FAR struct rptun_rsc_s *rsc = priv->rproc.rsc_table;
|
||||
FAR struct rptun_cmd_s *rptun_cmd = RPTUN_RSC2CMD(priv->rproc.rsc_table);
|
||||
uint32_t cmd;
|
||||
|
||||
if (RPTUN_IS_MASTER(priv->dev))
|
||||
{
|
||||
cmd = rsc->cmd_slave;
|
||||
rsc->cmd_slave = 0;
|
||||
cmd = rptun_cmd->cmd_slave;
|
||||
rptun_cmd->cmd_slave = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd = rsc->cmd_master;
|
||||
rsc->cmd_master = 0;
|
||||
cmd = rptun_cmd->cmd_master;
|
||||
rptun_cmd->cmd_master = 0;
|
||||
}
|
||||
|
||||
switch (RPTUN_GET_CMD(cmd))
|
||||
@@ -678,7 +678,7 @@ static int rptun_ioctl(FAR struct rpmsg_s *rpmsg, int cmd, unsigned long arg)
|
||||
static void rptun_panic(FAR struct rpmsg_s *rpmsg)
|
||||
{
|
||||
FAR struct rptun_priv_s *priv = (FAR struct rptun_priv_s *)rpmsg;
|
||||
FAR struct rptun_rsc_s *rsc = priv->rproc.rsc_table;
|
||||
FAR struct rptun_cmd_s *cmd = RPTUN_RSC2CMD(priv->rproc.rsc_table);
|
||||
|
||||
if (priv->dev->ops->panic != NULL)
|
||||
{
|
||||
@@ -688,11 +688,11 @@ static void rptun_panic(FAR struct rpmsg_s *rpmsg)
|
||||
|
||||
if (RPTUN_IS_MASTER(priv->dev))
|
||||
{
|
||||
rsc->cmd_master = RPTUN_CMD(RPTUN_CMD_PANIC, 0);
|
||||
cmd->cmd_master = RPTUN_CMD(RPTUN_CMD_PANIC, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
rsc->cmd_slave = RPTUN_CMD(RPTUN_CMD_PANIC, 0);
|
||||
cmd->cmd_slave = RPTUN_CMD(RPTUN_CMD_PANIC, 0);
|
||||
}
|
||||
|
||||
rptun_notify(&priv->rproc, RPTUN_NOTIFY_ALL);
|
||||
|
||||
@@ -142,6 +142,7 @@ rptun_ivshmem_get_resource(FAR struct rptun_dev_s *dev)
|
||||
{
|
||||
FAR struct rptun_ivshmem_dev_s *priv =
|
||||
(FAR struct rptun_ivshmem_dev_s *)dev;
|
||||
FAR struct rptun_cmd_s *cmd = RPTUN_RSC2CMD(&priv->shmem->rsc);
|
||||
|
||||
priv->raddrenv[0].da = 0;
|
||||
priv->raddrenv[0].size = priv->shmem_size;
|
||||
@@ -152,18 +153,17 @@ rptun_ivshmem_get_resource(FAR struct rptun_dev_s *dev)
|
||||
|
||||
/* Wait untils salve is ready */
|
||||
|
||||
while (RPTUN_GET_CMD(priv->shmem->rsc.cmd_slave) != RPTUN_CMD_READY)
|
||||
while (RPTUN_GET_CMD(cmd->cmd_slave) != RPTUN_CMD_READY)
|
||||
{
|
||||
usleep(1000);
|
||||
}
|
||||
|
||||
priv->shmem->rsc.cmd_slave = 0;
|
||||
cmd->cmd_slave = 0;
|
||||
priv->shmem->basem = (uint64_t)(uintptr_t)priv->shmem;
|
||||
}
|
||||
else
|
||||
{
|
||||
FAR struct rptun_rsc_s *rsc = &priv->shmem->rsc;
|
||||
|
||||
memset(priv->shmem, 0, priv->shmem_size);
|
||||
|
||||
rsc->rsc_tbl_hdr.ver = 1;
|
||||
@@ -188,10 +188,10 @@ rptun_ivshmem_get_resource(FAR struct rptun_dev_s *dev)
|
||||
rsc->rpmsg_vring1.notifyid = RSC_NOTIFY_ID_ANY;
|
||||
rsc->config.r2h_buf_size = CONFIG_RPTUN_IVSHMEM_BUFFSIZE;
|
||||
rsc->config.h2r_buf_size = CONFIG_RPTUN_IVSHMEM_BUFFSIZE;
|
||||
rsc->cmd_master = 0;
|
||||
|
||||
priv->shmem->rsc_size = sizeof(struct rptun_rsc_s);
|
||||
priv->shmem->rsc.cmd_slave = RPTUN_CMD_READY;
|
||||
cmd->cmd_master = 0;
|
||||
cmd->cmd_slave = RPTUN_CMD(RPTUN_CMD_READY, 0);
|
||||
|
||||
/* Wait untils master is ready, salve need use master base to
|
||||
* initialize addrenv.
|
||||
|
||||
Reference in New Issue
Block a user