diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig index c411757a2b3..a2f5b16d6cb 100644 --- a/arch/xtensa/Kconfig +++ b/arch/xtensa/Kconfig @@ -279,6 +279,14 @@ config XTENSA_SEMIHOSTING_HOSTFS This doesn't support some directory operations like readdir because of the limitations of semihosting mechanism. +config XTENSA_TARGET_ISS + bool "Target machine is Instruction Set Simulator" + default n + ---help--- + This setting determines whether the target is Cadence Instruction + Set Simulator, which might have some sepecial characteristics such + as how to open a file nonblock. + if XTENSA_SEMIHOSTING_HOSTFS config XTENSA_SEMIHOSTING_HOSTFS_CACHE_COHERENCE diff --git a/arch/xtensa/include/simcall.h b/arch/xtensa/include/simcall.h index da384904496..fa5397c9049 100644 --- a/arch/xtensa/include/simcall.h +++ b/arch/xtensa/include/simcall.h @@ -63,6 +63,11 @@ #define SIMCALL_O_RDWR 0x0002 #define SIMCALL_O_ACCMODE 0x0003 #define SIMCALL_O_APPEND 0x0400 +#ifdef CONFIG_XTENSA_TARGET_ISS +# define SIMCALL_O_NONBLOCK 0x0080 +#else +# define SIMCALL_O_NONBLOCK 0x0800 +#endif #define SIMCALL_O_CREAT 0x0040 #define SIMCALL_O_TRUNC 0x0200 #define SIMCALL_O_EXCL 0x0080 diff --git a/arch/xtensa/src/common/xtensa_hostfs.c b/arch/xtensa/src/common/xtensa_hostfs.c index eb0a1dfdca8..171aeae0dc7 100644 --- a/arch/xtensa/src/common/xtensa_hostfs.c +++ b/arch/xtensa/src/common/xtensa_hostfs.c @@ -97,6 +97,11 @@ int host_open(const char *pathname, int flags, int mode) simcall_flags |= SIMCALL_O_EXCL; } + if ((flags & O_NONBLOCK) != 0) + { + simcall_flags |= SIMCALL_O_NONBLOCK; + } + #ifdef CONFIG_XTENSA_SEMIHOSTING_HOSTFS_CACHE_COHERENCE up_clean_dcache(pathname, pathname + strlen(pathname) + 1); #endif