From e30a5f3790dbf7bce34783304d7e38840b7e2c7c Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 24 Nov 2021 22:23:14 +0800 Subject: [PATCH] arch/sim: Add new option to enable arch specific hostfs we have many different hostfs implementation now, so it's better to select the implementation explicitly, just like what we have done for arm(FS_HOSTFS vs. ARM_SEMIHOSTING_HOSTFS). Signed-off-by: Xiang Xiao --- arch/sim/Kconfig | 6 ++++++ arch/sim/src/Makefile | 4 +--- arch/xtensa/Kconfig | 13 +++++++++++-- arch/xtensa/src/common/xtensa_hostfs.c | 6 +++--- arch/xtensa/src/esp32/Make.defs | 2 +- arch/xtensa/src/esp32s2/Make.defs | 2 +- boards/sim/sim/sim/configs/alsa/defconfig | 1 + boards/sim/sim/sim/configs/libcxxtest/defconfig | 1 + boards/sim/sim/sim/configs/loadable/defconfig | 1 + boards/sim/sim/sim/configs/rpserver/defconfig | 1 + boards/sim/sim/sim/configs/tcpblaster/defconfig | 1 + boards/sim/sim/sim/configs/vpnkit/defconfig | 1 + 12 files changed, 29 insertions(+), 10 deletions(-) diff --git a/arch/sim/Kconfig b/arch/sim/Kconfig index 455abd4de3..74fbba8574 100644 --- a/arch/sim/Kconfig +++ b/arch/sim/Kconfig @@ -134,6 +134,12 @@ config SIM_WALLTIME_SIGNAL endchoice +config SIM_HOSTFS + bool "Simulated HostFS" + depends on FS_HOSTFS + ---help--- + Access host filesystem through HostFS. + choice prompt "Simulated Network Interface" default SIM_NETDEV diff --git a/arch/sim/src/Makefile b/arch/sim/src/Makefile index a549a50085..227106fcfb 100644 --- a/arch/sim/src/Makefile +++ b/arch/sim/src/Makefile @@ -207,8 +207,7 @@ ifeq ($(CONFIG_SIM_SOUND_ALSA),y) STDLIBS += -lasound endif -ifeq ($(CONFIG_FS_HOSTFS),y) -ifneq ($(CONFIG_FS_HOSTFS_RPMSG),y) +ifeq ($(CONFIG_SIM_HOSTFS),y) HOSTSRCS += up_hostfs.c hostfs.h: $(TOPDIR)/include/nuttx/fs/hostfs.h @@ -217,7 +216,6 @@ hostfs.h: $(TOPDIR)/include/nuttx/fs/hostfs.h up_hostfs.c: hostfs.h endif -endif COBJS = $(CSRCS:.c=$(OBJEXT)) diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index 83268aa987..3c5caeae54 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -220,9 +220,18 @@ config XTENSA_EXTMEM_BSS Adds a section and an attribute that allows to force variables into the external memory. -if CONFIG_FS_HOSTFS +config XTENSA_SEMIHOSTING_HOSTFS + bool "Semihosting HostFS" + depends on FS_HOSTFS + ---help--- + Mount HostFS through semihosting. -config XTENSA_HOSTFS_CACHE_COHERENCE + This doesn't support some directory operations like readdir because + of the limitations of semihosting mechanism. + +if XTENSA_SEMIHOSTING_HOSTFS + +config XTENSA_SEMIHOSTING_HOSTFS_CACHE_COHERENCE bool "Cache coherence in semihosting hostfs" depends on ARCH_DCACHE ---help--- diff --git a/arch/xtensa/src/common/xtensa_hostfs.c b/arch/xtensa/src/common/xtensa_hostfs.c index 20e62df51f..39fce29aa7 100644 --- a/arch/xtensa/src/common/xtensa_hostfs.c +++ b/arch/xtensa/src/common/xtensa_hostfs.c @@ -97,7 +97,7 @@ int host_open(const char *pathname, int flags, int mode) simcall_flags |= SIMCALL_O_EXCL; } -#ifdef CONFIG_XTENSA_HOSTFS_CACHE_COHERENCE +#ifdef CONFIG_XTENSA_SEMIHOSTING_HOSTFS_CACHE_COHERENCE up_clean_dcache(pathname, pathname + strlen(pathname) + 1); #endif return host_call(SIMCALL_SYS_OPEN, (int)pathname, simcall_flags, mode); @@ -110,7 +110,7 @@ int host_close(int fd) ssize_t host_read(int fd, void *buf, size_t count) { -#ifdef CONFIG_XTENSA_HOSTFS_CACHE_COHERENCE +#ifdef CONFIG_XTENSA_SEMIHOSTING_HOSTFS_CACHE_COHERENCE up_invalidate_dcache(buf, buf + count); #endif @@ -119,7 +119,7 @@ ssize_t host_read(int fd, void *buf, size_t count) ssize_t host_write(int fd, const void *buf, size_t count) { -#ifdef CONFIG_XTENSA_HOSTFS_CACHE_COHERENCE +#ifdef CONFIG_XTENSA_SEMIHOSTING_HOSTFS_CACHE_COHERENCE up_clean_dcache(buf, buf + count); #endif diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs index e8f901b665..d2a923c98e 100644 --- a/arch/xtensa/src/esp32/Make.defs +++ b/arch/xtensa/src/esp32/Make.defs @@ -64,7 +64,7 @@ ifeq ($(CONFIG_STACK_COLORATION),y) CMN_CSRCS += xtensa_checkstack.c endif -ifeq ($(CONFIG_FS_HOSTFS),y) +ifeq ($(CONFIG_XTENSA_SEMIHOSTING_HOSTFS),y) CMN_ASRCS += xtensa_simcall.S CMN_CSRCS += xtensa_hostfs.c endif diff --git a/arch/xtensa/src/esp32s2/Make.defs b/arch/xtensa/src/esp32s2/Make.defs index 3fde1cbf27..496a06163d 100644 --- a/arch/xtensa/src/esp32s2/Make.defs +++ b/arch/xtensa/src/esp32s2/Make.defs @@ -55,7 +55,7 @@ ifeq ($(CONFIG_STACK_COLORATION),y) CMN_CSRCS += xtensa_checkstack.c endif -ifeq ($(CONFIG_FS_HOSTFS),y) +ifeq ($(CONFIG_XTENSA_SEMIHOSTING_HOSTFS),y) CMN_ASRCS += xtensa_simcall.S CMN_CSRCS += xtensa_hostfs.c endif diff --git a/boards/sim/sim/sim/configs/alsa/defconfig b/boards/sim/sim/sim/configs/alsa/defconfig index b0d1880f39..c69a6b8131 100644 --- a/boards/sim/sim/sim/configs/alsa/defconfig +++ b/boards/sim/sim/sim/configs/alsa/defconfig @@ -48,6 +48,7 @@ CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_ONEXIT=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y +CONFIG_SIM_HOSTFS=y CONFIG_START_MONTH=6 CONFIG_START_YEAR=2008 CONFIG_SYSTEM_NSH=y diff --git a/boards/sim/sim/sim/configs/libcxxtest/defconfig b/boards/sim/sim/sim/configs/libcxxtest/defconfig index b5954e7a7a..f5501e900b 100644 --- a/boards/sim/sim/sim/configs/libcxxtest/defconfig +++ b/boards/sim/sim/sim/configs/libcxxtest/defconfig @@ -86,6 +86,7 @@ CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_ONEXIT=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y +CONFIG_SIM_HOSTFS=y CONFIG_SIM_NETDEV=y CONFIG_START_MONTH=6 CONFIG_START_YEAR=2008 diff --git a/boards/sim/sim/sim/configs/loadable/defconfig b/boards/sim/sim/sim/configs/loadable/defconfig index ac4acc8486..aa91b15cb0 100644 --- a/boards/sim/sim/sim/configs/loadable/defconfig +++ b/boards/sim/sim/sim/configs/loadable/defconfig @@ -44,6 +44,7 @@ CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_ONEXIT=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y +CONFIG_SIM_HOSTFS=y CONFIG_SIM_M32=y CONFIG_START_MONTH=6 CONFIG_START_YEAR=2008 diff --git a/boards/sim/sim/sim/configs/rpserver/defconfig b/boards/sim/sim/sim/configs/rpserver/defconfig index bf6c33e43a..d00884e187 100644 --- a/boards/sim/sim/sim/configs/rpserver/defconfig +++ b/boards/sim/sim/sim/configs/rpserver/defconfig @@ -62,6 +62,7 @@ CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_HPWORK=y CONFIG_SCHED_WAITPID=y CONFIG_SIG_DEFAULT=y +CONFIG_SIM_HOSTFS=y CONFIG_SIM_M32=y CONFIG_SIM_NETDEV=y CONFIG_SIM_NET_BRIDGE=y diff --git a/boards/sim/sim/sim/configs/tcpblaster/defconfig b/boards/sim/sim/sim/configs/tcpblaster/defconfig index 6ace500bc8..edb227541a 100644 --- a/boards/sim/sim/sim/configs/tcpblaster/defconfig +++ b/boards/sim/sim/sim/configs/tcpblaster/defconfig @@ -100,6 +100,7 @@ CONFIG_SCHED_ONEXIT=y CONFIG_SERIAL_TERMIOS=y CONFIG_SIG_DEFAULT=y CONFIG_SIG_EVTHREAD=y +CONFIG_SIM_HOSTFS=y CONFIG_STACK_COLORATION=y CONFIG_SYSLOG_BUFFER=y CONFIG_SYSLOG_CONSOLE=y diff --git a/boards/sim/sim/sim/configs/vpnkit/defconfig b/boards/sim/sim/sim/configs/vpnkit/defconfig index d82b8abfe8..d84490854b 100644 --- a/boards/sim/sim/sim/configs/vpnkit/defconfig +++ b/boards/sim/sim/sim/configs/vpnkit/defconfig @@ -81,6 +81,7 @@ CONFIG_SCHED_HAVE_PARENT=y CONFIG_SCHED_ONEXIT=y CONFIG_SCHED_WAITPID=y CONFIG_SDCLONE_DISABLE=y +CONFIG_SIM_HOSTFS=y CONFIG_SIM_NETDEV=y CONFIG_SIM_NETDEV_VPNKIT=y CONFIG_START_MONTH=6