diff --git a/drivers/rptun/rptun_ivshmem.c b/drivers/rptun/rptun_ivshmem.c index d736b6c8b2..34ad6030b1 100644 --- a/drivers/rptun/rptun_ivshmem.c +++ b/drivers/rptun/rptun_ivshmem.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -285,6 +286,38 @@ static int rptun_ivshmem_register_callback(FAR struct rptun_dev_s *dev, return 0; } +/**************************************************************************** + * Name: rptun_ivshmem_check_cmd + ****************************************************************************/ + +static void rptun_ivshmem_check_cmd(FAR struct rptun_ivshmem_dev_s *priv) +{ + FAR struct rptun_cmd_s *rptun_cmd = RPTUN_RSC2CMD(&priv->shmem->rsc); + uint32_t cmd; + + if (priv->master) + { + cmd = RPTUN_GET_CMD(rptun_cmd->cmd_slave); + rptun_cmd->cmd_slave = RPTUN_CMD(RPTUN_CMD_DEFAULT, 0); + } + else + { + cmd = RPTUN_GET_CMD(rptun_cmd->cmd_master); + rptun_cmd->cmd_master = RPTUN_CMD(RPTUN_CMD_DEFAULT, 0); + } + + switch (cmd) + { + case RPTUN_CMD_RESTART: +#ifdef CONFIG_BOARDCTL_RESET + board_reset(0); +#endif + break; + default: + break; + } +} + /**************************************************************************** * Name: rptun_ivshmem_interrupt ****************************************************************************/ @@ -293,6 +326,8 @@ static int rptun_ivshmem_interrupt(int irq, FAR void *context, FAR void *arg) { FAR struct rptun_ivshmem_dev_s *priv = arg; + rptun_ivshmem_check_cmd(priv); + if (priv->callback != NULL) { priv->callback(priv->arg, RPTUN_NOTIFY_ALL); @@ -311,6 +346,8 @@ static void rptun_ivshmem_wdog(wdparm_t arg) (FAR struct rptun_ivshmem_dev_s *)arg; bool should_notify = false; + rptun_ivshmem_check_cmd(priv); + if (priv->master && priv->seq != priv->shmem->seqs) { priv->seq = priv->shmem->seqs; diff --git a/include/nuttx/rptun/rptun.h b/include/nuttx/rptun/rptun.h index 0dc1cf3fcd..1cbe39894a 100644 --- a/include/nuttx/rptun/rptun.h +++ b/include/nuttx/rptun/rptun.h @@ -47,9 +47,11 @@ #define RPTUN_NOTIFY_ALL (UINT32_MAX - 0) +#define RPTUN_CMD_DEFAULT 0x0 #define RPTUN_CMD_PANIC 0x1 #define RPTUN_CMD_STOP 0x2 #define RPTUN_CMD_READY 0x3 +#define RPTUN_CMD_RESTART 0x4 #define RPTUN_CMD_MASK 0xffff #define RPTUN_CMD_SHIFT 16