You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2023/09/06 14:06:02 UTC
[nuttx] branch master updated: nuttx/sim: Sim_rptun support configuring whether the master will automatically boot slave
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new cb105192c7 nuttx/sim: Sim_rptun support configuring whether the master will automatically boot slave
cb105192c7 is described below
commit cb105192c7ede15d51ffb047f2025fd59341fc35
Author: yintao <yi...@xiaomi.com>
AuthorDate: Thu Aug 31 23:44:48 2023 +0800
nuttx/sim: Sim_rptun support configuring whether the master will automatically boot slave
Signed-off-by: yintao <yi...@xiaomi.com>
---
arch/sim/src/sim/sim_internal.h | 12 +++++++++++-
arch/sim/src/sim/sim_rptun.c | 27 +++++++++++++++++----------
boards/sim/sim/sim/src/sim_bringup.c | 5 +++--
3 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/arch/sim/src/sim/sim_internal.h b/arch/sim/src/sim/sim_internal.h
index cb5cccdb14..c62b78d538 100644
--- a/arch/sim/src/sim/sim_internal.h
+++ b/arch/sim/src/sim/sim_internal.h
@@ -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 **********************************************************/
diff --git a/arch/sim/src/sim/sim_rptun.c b/arch/sim/src/sim/sim_rptun.c
index df35dae7cb..b88f05de7d 100644
--- a/arch/sim/src/sim/sim_rptun.c
+++ b/arch/sim/src/sim/sim_rptun.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;
diff --git a/boards/sim/sim/sim/src/sim_bringup.c b/boards/sim/sim/sim/src/sim_bringup.c
index 057180a3c3..b7c1343546 100644
--- a/boards/sim/sim/sim/src/sim_bringup.c
+++ b/boards/sim/sim/sim/src/sim_bringup.c
@@ -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