From 0f5dc2fc6507ac38ad57e97d289eb8ff2cacc969 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 29 Aug 2014 16:23:46 -0600 Subject: [PATCH] Various changes/fixes to get configs/stm32f4discovery/kostest working after the big configuration renaming (and after a long period of bit rot) --- arch/arm/src/armv7-m/up_svcall.c | 1 + arch/arm/src/common/up_pthread_start.c | 5 +- arch/arm/src/common/up_signal_dispatch.c | 5 +- arch/arm/src/stm32/stm32_serial.c | 9 +- .../stm32f4discovery/kernel/up_userspace.c | 7 +- configs/stm32f4discovery/kostest/defconfig | 239 +++++++++++++----- include/errno.h | 44 ++-- include/nuttx/arch.h | 4 +- syscall/syscall_funclookup.c | 17 +- 9 files changed, 229 insertions(+), 102 deletions(-) diff --git a/arch/arm/src/armv7-m/up_svcall.c b/arch/arm/src/armv7-m/up_svcall.c index 80d07b4e50..ada12e61a0 100644 --- a/arch/arm/src/armv7-m/up_svcall.c +++ b/arch/arm/src/armv7-m/up_svcall.c @@ -46,6 +46,7 @@ #include #include +#include #ifdef CONFIG_LIB_SYSCALL # include diff --git a/arch/arm/src/common/up_pthread_start.c b/arch/arm/src/common/up_pthread_start.c index 31ccb80c1f..59fd7073b5 100644 --- a/arch/arm/src/common/up_pthread_start.c +++ b/arch/arm/src/common/up_pthread_start.c @@ -44,9 +44,8 @@ #include "svcall.h" #include "up_internal.h" -#if ((defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) || \ - defined(defined(CONFIG_BUILD_KERNEL)) && \ - !defined(CONFIG_DISABLE_PTHREAD) +#if ((defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ + defined(CONFIG_BUILD_KERNEL)) && !defined(CONFIG_DISABLE_PTHREAD) /**************************************************************************** * Pre-processor Definitions diff --git a/arch/arm/src/common/up_signal_dispatch.c b/arch/arm/src/common/up_signal_dispatch.c index 75725237f6..f0cf91a490 100644 --- a/arch/arm/src/common/up_signal_dispatch.c +++ b/arch/arm/src/common/up_signal_dispatch.c @@ -43,9 +43,8 @@ #include "svcall.h" #include "up_internal.h" -#if ((defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) || \ - defined(defined(CONFIG_BUILD_KERNEL)) && \ - !defined(CONFIG_DISABLE_SIGNALS) +#if ((defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ + defined(CONFIG_BUILD_KERNEL)) && !defined(CONFIG_DISABLE_SIGNALS) /**************************************************************************** * Pre-processor Definitions diff --git a/arch/arm/src/stm32/stm32_serial.c b/arch/arm/src/stm32/stm32_serial.c index 647b66bc94..42973bce15 100644 --- a/arch/arm/src/stm32/stm32_serial.c +++ b/arch/arm/src/stm32/stm32_serial.c @@ -177,7 +177,7 @@ /* The DMA buffer size when using RX DMA to emulate a FIFO. * * When streaming data, the generic serial layer will be called - * everytime the FIFO receives half this number of bytes. + * every time the FIFO receives half this number of bytes. */ # define RXDMA_BUFFER_SIZE 32 @@ -2426,8 +2426,6 @@ static void up_dma_rxcallback(DMA_HANDLE handle, uint8_t status, void *arg) } #endif -#endif /* HAVE UART */ - /**************************************************************************** * Name: up_pm_notify * @@ -2532,11 +2530,14 @@ static int up_pm_prepare(struct pm_callback_s *cb, enum pm_state_e pmstate) return OK; } #endif +#endif /* USE_SERIALDRIVER */ /**************************************************************************** * Public Functions ****************************************************************************/ +#ifdef USE_SERIALDRIVER + /**************************************************************************** * Name: up_earlyserialinit * @@ -2734,8 +2735,6 @@ void stm32_serial_dma_poll(void) * ****************************************************************************/ -#ifdef USE_SERIALDRIVER - int up_putc(int ch) { #if CONSOLE_UART > 0 diff --git a/configs/stm32f4discovery/kernel/up_userspace.c b/configs/stm32f4discovery/kernel/up_userspace.c index 047fd7647a..19fda356d3 100644 --- a/configs/stm32f4discovery/kernel/up_userspace.c +++ b/configs/stm32f4discovery/kernel/up_userspace.c @@ -41,9 +41,10 @@ #include -#include -#include +#include #include +#include +#include #if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) @@ -69,7 +70,7 @@ * following way: * * - The linker script defines, for example, the symbol_sdata. - * - The declareion extern uint32_t _sdata; makes C happy. C will believe + * - The declaration extern uint32_t _sdata; makes C happy. C will believe * that the value _sdata is the address of a uint32_t variable _data (it is * not!). * - We can recoved the linker value then by simply taking the address of diff --git a/configs/stm32f4discovery/kostest/defconfig b/configs/stm32f4discovery/kostest/defconfig index 7435859187..59f682fd34 100644 --- a/configs/stm32f4discovery/kostest/defconfig +++ b/configs/stm32f4discovery/kostest/defconfig @@ -21,11 +21,12 @@ CONFIG_WINDOWS_CYGWIN=y # Build Configuration # # CONFIG_APPS_DIR="../apps" +# CONFIG_BUILD_FLAT is not set +CONFIG_BUILD_PROTECTED=y CONFIG_BUILD_2PASS=y CONFIG_PASS1_TARGET="all" CONFIG_PASS1_BUILDIR="configs/stm32f4discovery/kernel" CONFIG_PASS1_OBJECT="" -CONFIG_BUILD_PROTECTED=y CONFIG_NUTTX_USERSPACE=0x08020000 # @@ -35,6 +36,7 @@ CONFIG_NUTTX_USERSPACE=0x08020000 CONFIG_INTELHEX_BINARY=y # CONFIG_MOTOROLA_SREC is not set CONFIG_RAW_BINARY=y +# CONFIG_UBOOT_UIMAGE is not set # # Customize Header Files @@ -84,6 +86,7 @@ CONFIG_ARCH="arm" # CONFIG_ARCH_CHIP_KINETIS is not set # CONFIG_ARCH_CHIP_KL is not set # CONFIG_ARCH_CHIP_LM is not set +# CONFIG_ARCH_CHIP_TIVA is not set # CONFIG_ARCH_CHIP_LPC17XX is not set # CONFIG_ARCH_CHIP_LPC214X is not set # CONFIG_ARCH_CHIP_LPC2378 is not set @@ -110,8 +113,6 @@ CONFIG_ARCH_HAVE_CMNVECTOR=y # CONFIG_ARMV7M_CMNVECTOR is not set CONFIG_ARCH_HAVE_FPU=y # CONFIG_ARCH_FPU is not set -CONFIG_ARCH_HAVE_MPU=y -CONFIG_ARCH_USE_MPU=y CONFIG_ARMV7M_MPU=y CONFIG_ARMV7M_MPU_NREGIONS=8 @@ -149,6 +150,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y # CONFIG_ARCH_CHIP_STM32L152V6 is not set # CONFIG_ARCH_CHIP_STM32L152V8 is not set # CONFIG_ARCH_CHIP_STM32L152VB is not set +# CONFIG_ARCH_CHIP_STM32L162ZD is not set # CONFIG_ARCH_CHIP_STM32F100C8 is not set # CONFIG_ARCH_CHIP_STM32F100CB is not set # CONFIG_ARCH_CHIP_STM32F100R8 is not set @@ -161,16 +163,18 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y # CONFIG_ARCH_CHIP_STM32F100VC is not set # CONFIG_ARCH_CHIP_STM32F100VD is not set # CONFIG_ARCH_CHIP_STM32F100VE is not set -# CONFIG_ARCH_CHIP_STM32F103C4 is not set -# CONFIG_ARCH_CHIP_STM32F103C8 is not set # CONFIG_ARCH_CHIP_STM32F103T8 is not set # CONFIG_ARCH_CHIP_STM32F103TB is not set +# CONFIG_ARCH_CHIP_STM32F103C4 is not set +# CONFIG_ARCH_CHIP_STM32F103C8 is not set # CONFIG_ARCH_CHIP_STM32F103CB is not set # CONFIG_ARCH_CHIP_STM32F103R8 is not set # CONFIG_ARCH_CHIP_STM32F103RB is not set +# CONFIG_ARCH_CHIP_STM32F103RC is not set +# CONFIG_ARCH_CHIP_STM32F103RD is not set +# CONFIG_ARCH_CHIP_STM32F103RE is not set # CONFIG_ARCH_CHIP_STM32F103V8 is not set # CONFIG_ARCH_CHIP_STM32F103VB is not set -# CONFIG_ARCH_CHIP_STM32F103RE is not set # CONFIG_ARCH_CHIP_STM32F103VC is not set # CONFIG_ARCH_CHIP_STM32F103VE is not set # CONFIG_ARCH_CHIP_STM32F103ZE is not set @@ -190,6 +194,7 @@ CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYW=y # CONFIG_ARCH_CHIP_STM32F303RC is not set # CONFIG_ARCH_CHIP_STM32F303VB is not set # CONFIG_ARCH_CHIP_STM32F303VC is not set +# CONFIG_ARCH_CHIP_STM32F401RE is not set # CONFIG_ARCH_CHIP_STM32F405RG is not set # CONFIG_ARCH_CHIP_STM32F405VG is not set # CONFIG_ARCH_CHIP_STM32F405ZG is not set @@ -217,15 +222,50 @@ CONFIG_ARCH_CHIP_STM32F407VG=y # CONFIG_STM32_MEDIUMDENSITY is not set # CONFIG_STM32_LOWDENSITY is not set # CONFIG_STM32_STM32F20XX is not set +# CONFIG_STM32_STM32F207 is not set # CONFIG_STM32_STM32F30XX is not set CONFIG_STM32_STM32F40XX=y +# CONFIG_STM32_STM32F401 is not set +# CONFIG_STM32_STM32F405 is not set +CONFIG_STM32_STM32F407=y +# CONFIG_STM32_STM32F427 is not set +# CONFIG_STM32_STM32F429 is not set # CONFIG_STM32_DFU is not set # # STM32 Peripheral Support # +CONFIG_STM32_HAVE_CCM=y # CONFIG_STM32_HAVE_USBDEV is not set CONFIG_STM32_HAVE_OTGFS=y +CONFIG_STM32_HAVE_FSMC=y +CONFIG_STM32_HAVE_USART3=y +CONFIG_STM32_HAVE_USART4=y +CONFIG_STM32_HAVE_USART5=y +CONFIG_STM32_HAVE_USART6=y +# CONFIG_STM32_HAVE_USART7 is not set +# CONFIG_STM32_HAVE_USART8 is not set +CONFIG_STM32_HAVE_TIM1=y +CONFIG_STM32_HAVE_TIM5=y +CONFIG_STM32_HAVE_TIM6=y +CONFIG_STM32_HAVE_TIM7=y +CONFIG_STM32_HAVE_TIM8=y +CONFIG_STM32_HAVE_TIM9=y +CONFIG_STM32_HAVE_TIM10=y +CONFIG_STM32_HAVE_TIM11=y +CONFIG_STM32_HAVE_TIM12=y +CONFIG_STM32_HAVE_TIM13=y +CONFIG_STM32_HAVE_TIM14=y +# CONFIG_STM32_HAVE_TIM15 is not set +# CONFIG_STM32_HAVE_TIM16 is not set +# CONFIG_STM32_HAVE_TIM17 is not set +CONFIG_STM32_HAVE_ADC2=y +CONFIG_STM32_HAVE_ADC3=y +# CONFIG_STM32_HAVE_ADC4 is not set +CONFIG_STM32_HAVE_CAN1=y +CONFIG_STM32_HAVE_CAN2=y +CONFIG_STM32_HAVE_RNG=y +CONFIG_STM32_HAVE_ETHMAC=y # CONFIG_STM32_ADC1 is not set # CONFIG_STM32_ADC2 is not set # CONFIG_STM32_ADC3 is not set @@ -314,11 +354,17 @@ CONFIG_STM32_USART=y # CONFIG_ARCH_VECNOTIRQ is not set # CONFIG_ARCH_DMA is not set CONFIG_ARCH_HAVE_IRQPRIO=y +# CONFIG_ARCH_L2CACHE is not set +# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set # CONFIG_CUSTOM_STACK is not set -# CONFIG_ARCH_ADDRENV is not set +# CONFIG_ARCH_HAVE_ADDRENV is not set +# CONFIG_ARCH_NEED_ADDRENV_MAPPING is not set CONFIG_ARCH_HAVE_VFORK=y # CONFIG_ARCH_HAVE_MMU is not set +CONFIG_ARCH_HAVE_MPU=y # CONFIG_ARCH_NAND_HWECC is not set +# CONFIG_ARCH_HAVE_EXTCLK is not set +CONFIG_ARCH_USE_MPU=y # CONFIG_ARCH_IRQPRIO is not set CONFIG_ARCH_STACKDUMP=y # CONFIG_ENDIAN_BIG is not set @@ -381,29 +427,6 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y # # RTOS Features # -CONFIG_BOARD_INITIALIZE=y -CONFIG_USEC_PER_TICK=10000 -# CONFIG_SYSTEM_TIME64 is not set -CONFIG_RR_INTERVAL=200 -# CONFIG_SCHED_CPULOAD is not set -# CONFIG_SCHED_INSTRUMENTATION is not set -CONFIG_TASK_NAME_SIZE=0 -# CONFIG_SCHED_HAVE_PARENT is not set -# CONFIG_JULIAN_TIME is not set -CONFIG_START_YEAR=2013 -CONFIG_START_MONTH=3 -CONFIG_START_DAY=22 -CONFIG_DEV_CONSOLE=y -# CONFIG_MUTEX_TYPES is not set -# CONFIG_PRIORITY_INHERITANCE is not set -# CONFIG_FDCLONE_DISABLE is not set -# CONFIG_FDCLONE_STDIO is not set -CONFIG_SDCLONE_DISABLE=y -# CONFIG_SCHED_WAITPID is not set -# CONFIG_SCHED_STARTHOOK is not set -# CONFIG_SCHED_ATEXIT is not set -# CONFIG_SCHED_ONEXIT is not set -CONFIG_USER_ENTRYPOINT="ostest_main" CONFIG_DISABLE_OS_API=y # CONFIG_DISABLE_POSIX_TIMERS is not set # CONFIG_DISABLE_PTHREAD is not set @@ -411,6 +434,64 @@ CONFIG_DISABLE_OS_API=y # CONFIG_DISABLE_MQUEUE is not set CONFIG_DISABLE_ENVIRON=y +# +# Clocks and Timers +# +CONFIG_USEC_PER_TICK=10000 +# CONFIG_SYSTEM_TIME64 is not set +# CONFIG_CLOCK_MONOTONIC is not set +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2013 +CONFIG_START_MONTH=3 +CONFIG_START_DAY=22 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=8 +CONFIG_WDOG_INTRESERVE=2 +CONFIG_PREALLOC_TIMERS=4 + +# +# Tasks and Scheduling +# +CONFIG_USER_ENTRYPOINT="ostest_main" +CONFIG_RR_INTERVAL=200 +CONFIG_TASK_NAME_SIZE=0 +CONFIG_MAX_TASK_ARGS=4 +CONFIG_MAX_TASKS=16 +# CONFIG_SCHED_HAVE_PARENT is not set +# CONFIG_SCHED_WAITPID is not set + +# +# Pthread Options +# +# CONFIG_MUTEX_TYPES is not set +CONFIG_NPTHREAD_KEYS=4 + +# +# Performance Monitoring +# +# CONFIG_SCHED_CPULOAD is not set +# CONFIG_SCHED_INSTRUMENTATION is not set + +# +# Files and I/O +# +CONFIG_DEV_CONSOLE=y +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +# CONFIG_PRIORITY_INHERITANCE is not set + +# +# RTOS hooks +# +CONFIG_BOARD_INITIALIZE=y +# CONFIG_SCHED_STARTHOOK is not set +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set + # # Signal Numbers # @@ -420,19 +501,10 @@ CONFIG_SIG_SIGALARM=3 CONFIG_SIG_SIGCONDTIMEDOUT=16 # -# Sizes of configurable things (0 disables) +# POSIX Message Queue Options # -CONFIG_MAX_TASKS=16 -CONFIG_MAX_TASK_ARGS=4 -CONFIG_NPTHREAD_KEYS=4 -CONFIG_NFILE_DESCRIPTORS=8 -CONFIG_NFILE_STREAMS=8 -CONFIG_NAME_MAX=32 CONFIG_PREALLOC_MQ_MSGS=4 CONFIG_MQ_MAXMSGSIZE=32 -CONFIG_MAX_WDOGPARMS=2 -CONFIG_PREALLOC_WDOGS=4 -CONFIG_PREALLOC_TIMERS=4 # # Stack and heap information @@ -441,10 +513,7 @@ CONFIG_IDLETHREAD_STACKSIZE=1024 CONFIG_USERMAIN_STACKSIZE=2048 CONFIG_PTHREAD_STACK_MIN=256 CONFIG_PTHREAD_STACK_DEFAULT=2048 - -# -# System call configuration -# +CONFIG_LIB_SYSCALL=y CONFIG_SYS_RESERVED=8 CONFIG_SYS_NNEST=2 @@ -455,6 +524,12 @@ CONFIG_DISABLE_POLL=y CONFIG_DEV_NULL=y # CONFIG_DEV_ZERO is not set # CONFIG_LOOP is not set + +# +# Buffering +# +# CONFIG_DRVR_WRITEBUFFER is not set +# CONFIG_DRVR_READAHEAD is not set # CONFIG_RAMDISK is not set # CONFIG_CAN is not set # CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set @@ -465,6 +540,7 @@ CONFIG_ARCH_HAVE_I2CRESET=y # CONFIG_I2S is not set # CONFIG_RTC is not set # CONFIG_WATCHDOG is not set +# CONFIG_TIMER is not set # CONFIG_ANALOG is not set # CONFIG_AUDIO_DEVICES is not set # CONFIG_VIDEO_DEVICES is not set @@ -544,6 +620,11 @@ CONFIG_USART2_2STOP=0 # CONFIG_ARCH_HAVE_PHY is not set # CONFIG_NET is not set +# +# Crypto API +# +# CONFIG_CRYPTO is not set + # # File Systems # @@ -591,7 +672,6 @@ CONFIG_MM_REGIONS=2 # CONFIG_BINFMT_DISABLE is not set # CONFIG_NXFLAT is not set # CONFIG_ELF is not set -# CONFIG_BUILTIN is not set # CONFIG_PIC is not set CONFIG_SYMTAB_ORDEREDBYNAME=y @@ -650,6 +730,7 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # CONFIG_EXAMPLES_BUTTONS is not set # CONFIG_EXAMPLES_CAN is not set # CONFIG_EXAMPLES_CONFIGDATA is not set +# CONFIG_EXAMPLES_CPUHOG is not set # CONFIG_EXAMPLES_DHCPD is not set # CONFIG_EXAMPLES_ELF is not set # CONFIG_EXAMPLES_FTPC is not set @@ -660,7 +741,6 @@ CONFIG_LIB_SENDFILE_BUFSIZE=512 # CONFIG_EXAMPLES_HIDKBD is not set # CONFIG_EXAMPLES_KEYPADTEST is not set # CONFIG_EXAMPLES_IGMP is not set -# CONFIG_EXAMPLES_LCDRW is not set # CONFIG_EXAMPLES_MM is not set # CONFIG_EXAMPLES_MODBUS is not set # CONFIG_EXAMPLES_MOUNT is not set @@ -681,7 +761,6 @@ CONFIG_EXAMPLES_OSTEST_STACKSIZE=2048 CONFIG_EXAMPLES_OSTEST_NBARRIER_THREADS=3 CONFIG_EXAMPLES_OSTEST_RR_RANGE=10000 CONFIG_EXAMPLES_OSTEST_RR_RUNS=10 -# CONFIG_EXAMPLES_PASHELLO is not set # CONFIG_EXAMPLES_PIPE is not set # CONFIG_EXAMPLES_POLL is not set # CONFIG_EXAMPLES_POSIXSPAWN is not set @@ -689,6 +768,8 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10 # CONFIG_EXAMPLES_RGMP is not set # CONFIG_EXAMPLES_ROMFS is not set # CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERIALBLASTER is not set +# CONFIG_EXAMPLES_SERIALRX is not set # CONFIG_EXAMPLES_SERLOOP is not set # CONFIG_EXAMPLES_SLCD is not set # CONFIG_EXAMPLES_SMART is not set @@ -755,27 +836,15 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10 # System Libraries and NSH Add-Ons # -# -# USB CDC/ACM Device Commands -# - -# -# USB Composite Device Commands -# - # # Custom Free Memory Command # # CONFIG_SYSTEM_FREE is not set # -# I2C tool +# EMACS-like Command Line Editor # - -# -# INI File Parser -# -# CONFIG_SYSTEM_INIFILE is not set +# CONFIG_SYSTEM_CLE is not set # # FLASH Program Installation @@ -786,6 +855,20 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10 # FLASH Erase-all Command # +# +# Intel HEX to binary conversion +# +# CONFIG_SYSTEM_HEX2BIN is not set + +# +# I2C tool +# + +# +# INI File Parser +# +# CONFIG_SYSTEM_INIFILE is not set + # # NxPlayer media player library / command Line # @@ -801,6 +884,14 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10 # # CONFIG_SYSTEM_READLINE is not set +# +# P-Code Support +# + +# +# PHY Tool +# + # # Power Off # @@ -816,20 +907,16 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10 # # CONFIG_SYSTEM_SDCARD is not set +# +# Sudoku +# +# CONFIG_SYSTEM_SUDOKU is not set + # # Sysinfo # # CONFIG_SYSTEM_SYSINFO is not set -# -# USB Monitor -# - -# -# EMACS-like Command Line Editor -# -# CONFIG_SYSTEM_CLE is not set - # # VI Work-Alike Editor # @@ -839,10 +926,22 @@ CONFIG_EXAMPLES_OSTEST_RR_RUNS=10 # Stack Monitor # +# +# USB CDC/ACM Device Commands +# + +# +# USB Composite Device Commands +# + # # USB Mass Storage Device Commands # +# +# USB Monitor +# + # # Zmodem Commands # diff --git a/include/errno.h b/include/errno.h index dc90b4d051..e61a752aa6 100644 --- a/include/errno.h +++ b/include/errno.h @@ -43,8 +43,31 @@ #include /************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************/ +/* How can we access the errno variable? */ + +#undef __DIRECT_ERRNO_ACCESS +#if !defined(CONFIG_LIB_SYSCALL) + /* No system calls? Then there can only be direct access */ + +# define __DIRECT_ERRNO_ACCESS 1 + +#elif !defined(CONFIG_BUILD_PROTECTED) && !defined(CONFIG_BUILD_KERNEL) + /* Flat build... complete access */ + +# define __DIRECT_ERRNO_ACCESS 1 + +#elif defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__) + /* Kernel portion of protected build. The Kernel has access */ + +# define __DIRECT_ERRNO_ACCESS 1 + +#elif defined(CONFIG_BUILD_KERNEL) + /* Kernel only build. The kernel has access */ + +# define __DIRECT_ERRNO_ACCESS 1 +#endif /* Convenience/compatibility definition. * @@ -52,7 +75,7 @@ * from all code using a simple pointer. */ -#ifndef CONFIG_LIB_SYSCALL +#ifdef __DIRECT_ERRNO_ACCESS # define errno *get_errno_ptr() # define set_errno(e) do { errno = (int)(e); } while (0) @@ -64,16 +87,8 @@ * a little differently. In kernel-mode, the TCB errno value can still be * read and written using a pointer from code executing within the * kernel. - */ - -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) -# define errno *get_errno_ptr() -# define set_errno(e) do { errno = (int)(e); } while (0) -# define get_errno(e) errno -#else - -/* But in user-mode, the errno can only be read using the name 'errno'. + * + * But in user-mode, the errno can only be read using the name 'errno'. * The non-standard API set_errno() must explicitly be used from user- * mode code in order to set the errno value. * @@ -84,8 +99,7 @@ # define errno get_errno() -#endif /* __KERNEL__ */ -#endif /* CONFIG_LIB_SYSCALL */ +#endif /* __DIRECT_ERRNO_ACCESS */ /* Definitions of error numbers and the string that would be * returned by strerror(). @@ -365,7 +379,7 @@ extern "C" FAR int *get_errno_ptr(void); -#ifdef CONFIG_LIB_SYSCALL +#ifndef __DIRECT_ERRNO_ACCESS void set_errno(int errcode); int get_errno(void); #endif diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index 3070f02910..a9290d8a33 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -617,8 +617,8 @@ void up_signal_dispatch(_sa_sigaction_t sighand, int signo, * ****************************************************************************/ -#if (defined(CONFIG_BUILD_PROTECTED) && defined(__KERNEL__)) || \ - defined(CONFIG_BUILD_KERNEL) && !defined(CONFIG_DISABLE_SIGNALS) +#if (defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__)) && \ + !defined(CONFIG_DISABLE_SIGNALS) void up_signal_handler(_sa_sigaction_t sighand, int signo, FAR siginfo_t *info, FAR void *ucontext) noreturn_function; diff --git a/syscall/syscall_funclookup.c b/syscall/syscall_funclookup.c index 6f38634ac2..43e411fc38 100644 --- a/syscall/syscall_funclookup.c +++ b/syscall/syscall_funclookup.c @@ -90,9 +90,24 @@ uint32_t syscall_clock_systimer(void); /**************************************************************************** - * Pre-processor definitions + * Pre-processor Definitions ****************************************************************************/ +/* Errno access is awkward. We need to generate get_errno() and set_errno() + * interfaces to support the system calls, even though we don't use them + * ourself. + * + * The "normal" protoypes for these functions is in errno.h. The following + * must agree exactly. + */ + +#ifdef __DIRECT_ERRNO_ACCESS +# undef set_errno +# undef get_errno +void set_errno(int errcode); +int get_errno(void); +#endif + /**************************************************************************** * Public Data ****************************************************************************/