mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 05:42:05 +08:00
nuttx/sim: Sim_rptun support configuring whether the master will automatically boot slave
Signed-off-by: yintao <yintao@xiaomi.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
df98320c2c
commit
cb105192c7
@@ -42,6 +42,16 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Determine master-slave relationship when configuring with multiple cores */
|
||||
|
||||
#ifdef CONFIG_RPTUN
|
||||
# define SIM_RPTUN_MASTER (1 << 0) /* As the master */
|
||||
# define SIM_RPTUN_SLAVE (0 << 0) /* As the slave */
|
||||
|
||||
# define SIM_RPTUN_BOOT (1 << 1) /* As the master and boot the slave */
|
||||
# define SIM_RPTUN_NOBOOT (0 << 1) /* As the master but not boot the slave */
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SMP_NCPUS
|
||||
# define CONFIG_SMP_NCPUS 1
|
||||
#endif
|
||||
@@ -362,7 +372,7 @@ void sim_netdriver_loop(void);
|
||||
/* sim_rptun.c **************************************************************/
|
||||
|
||||
#ifdef CONFIG_RPTUN
|
||||
int sim_rptun_init(const char *shmemname, const char *cpuname, bool master);
|
||||
int sim_rptun_init(const char *shmemname, const char *cpuname, int master);
|
||||
#endif
|
||||
|
||||
/* sim_hcisocket.c **********************************************************/
|
||||
|
||||
@@ -59,7 +59,7 @@ struct sim_rptun_dev_s
|
||||
struct rptun_dev_s rptun;
|
||||
rptun_callback_t callback;
|
||||
void *arg;
|
||||
bool master;
|
||||
int master;
|
||||
unsigned int seq;
|
||||
struct sim_rptun_shmem_s *shmem;
|
||||
struct simple_addrenv_s addrenv[2];
|
||||
@@ -179,13 +179,17 @@ static int sim_rptun_start(struct rptun_dev_s *dev)
|
||||
struct sim_rptun_dev_s, rptun);
|
||||
pid_t pid;
|
||||
|
||||
pid = host_posix_spawn(sim_rptun_get_cpuname(dev), NULL, NULL);
|
||||
if (pid < 0)
|
||||
if (priv->master & SIM_RPTUN_BOOT)
|
||||
{
|
||||
return pid;
|
||||
pid = host_posix_spawn(sim_rptun_get_cpuname(dev), NULL, NULL);
|
||||
if (pid < 0)
|
||||
{
|
||||
return pid;
|
||||
}
|
||||
|
||||
priv->pid = pid;
|
||||
}
|
||||
|
||||
priv->pid = pid;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -194,12 +198,15 @@ static int sim_rptun_stop(struct rptun_dev_s *dev)
|
||||
struct sim_rptun_dev_s *priv = container_of(dev,
|
||||
struct sim_rptun_dev_s, rptun);
|
||||
|
||||
priv->shmem->cmdm = SIM_RPTUN_STOP << SIM_RPTUN_SHIFT;
|
||||
if (priv->master & SIM_RPTUN_BOOT)
|
||||
{
|
||||
priv->shmem->cmdm = SIM_RPTUN_STOP << SIM_RPTUN_SHIFT;
|
||||
|
||||
host_waitpid(priv->pid);
|
||||
host_waitpid(priv->pid);
|
||||
|
||||
host_freeshmem(priv->shmem);
|
||||
priv->shmem = NULL;
|
||||
host_freeshmem(priv->shmem);
|
||||
priv->shmem = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -321,7 +328,7 @@ static const struct rptun_ops_s g_sim_rptun_ops =
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sim_rptun_init(const char *shmemname, const char *cpuname, bool master)
|
||||
int sim_rptun_init(const char *shmemname, const char *cpuname, int master)
|
||||
{
|
||||
struct sim_rptun_dev_s *dev;
|
||||
int ret;
|
||||
|
||||
@@ -463,9 +463,10 @@ int sim_bringup(void)
|
||||
|
||||
#ifdef CONFIG_RPTUN
|
||||
#ifdef CONFIG_SIM_RPTUN_MASTER
|
||||
sim_rptun_init("server-proxy", "proxy", true);
|
||||
sim_rptun_init("server-proxy", "proxy",
|
||||
SIM_RPTUN_MASTER | SIM_RPTUN_NOBOOT);
|
||||
#else
|
||||
sim_rptun_init("server-proxy", "server", false);
|
||||
sim_rptun_init("server-proxy", "server", SIM_RPTUN_SLAVE);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEV_RPMSG
|
||||
|
||||
Reference in New Issue
Block a user