diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-08-28 12:09:49 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-08-28 12:09:49 -0600 |
commit | 397298da8d61a5887b15fc9c53206e11821a92d8 (patch) | |
tree | 90d6802a2b459c69323a95f3e4a392d5b1b90562 | |
parent | d6c088a4acc3cb6fddc40740c2da8c5b27adc244 (diff) | |
download | nuttx-397298da8d61a5887b15fc9c53206e11821a92d8.tar.gz nuttx-397298da8d61a5887b15fc9c53206e11821a92d8.tar.bz2 nuttx-397298da8d61a5887b15fc9c53206e11821a92d8.zip |
The system call library can now be built with CONFIG_NUTTX_KERNEL. New select: CONFIG_LIB_SYSCALL
-rw-r--r-- | nuttx/Kconfig | 3 | ||||
-rw-r--r-- | nuttx/Makefile.unix | 14 | ||||
-rw-r--r-- | nuttx/Makefile.win | 14 | ||||
-rw-r--r-- | nuttx/arch/arm/src/armv6-m/svcall.h | 22 | ||||
-rw-r--r-- | nuttx/arch/arm/src/armv6-m/up_svcall.c | 8 | ||||
-rw-r--r-- | nuttx/arch/arm/src/armv7-m/svcall.h | 22 | ||||
-rw-r--r-- | nuttx/arch/arm/src/armv7-m/up_svcall.c | 8 | ||||
-rw-r--r-- | nuttx/syscall/Kconfig | 28 |
8 files changed, 84 insertions, 35 deletions
diff --git a/nuttx/Kconfig b/nuttx/Kconfig index 7a5f41cba..4a84866cf 100644 --- a/nuttx/Kconfig +++ b/nuttx/Kconfig @@ -186,6 +186,7 @@ config PASS1_OBJECT config NUTTX_KERNEL bool "NuttX kernel build" default n + select LIB_SYSCALL ---help--- Builds NuttX as a separately compiled kernel. @@ -681,9 +682,7 @@ endmenu menu "RTOS Features" source sched/Kconfig -if NUTTX_KERNEL source syscall/Kconfig -endif endmenu menu "Device Drivers" diff --git a/nuttx/Makefile.unix b/nuttx/Makefile.unix index b0e7cca7b..ec662a694 100644 --- a/nuttx/Makefile.unix +++ b/nuttx/Makefile.unix @@ -119,9 +119,7 @@ OTHERDIRS = lib ifeq ($(CONFIG_NUTTX_KERNEL),y) -NONFSDIRS += syscall -CONTEXTDIRS += syscall -USERDIRS += syscall libc mm $(USER_ADDONS) +USERDIRS += libc mm $(USER_ADDONS) ifeq ($(CONFIG_HAVE_CXX),y) USERDIRS += libxx endif @@ -129,7 +127,7 @@ endif else NONFSDIRS += libc mm -OTHERDIRS += syscall $(USER_ADDONS) +OTHERDIRS += $(USER_ADDONS) ifeq ($(CONFIG_HAVE_CXX),y) NONFSDIRS += libxx else @@ -138,6 +136,14 @@ endif endif +ifeq ($(CONFIG_LIB_SYSCALL),y) +NONFSDIRS += syscall +CONTEXTDIRS += syscall +USERDIRS += syscall +else +OTHERDIRS += syscall +endif + ifeq ($(CONFIG_NX),y) NONFSDIRS += graphics libnx CONTEXTDIRS += graphics libnx diff --git a/nuttx/Makefile.win b/nuttx/Makefile.win index 91aec195e..bc9cfcf58 100644 --- a/nuttx/Makefile.win +++ b/nuttx/Makefile.win @@ -112,9 +112,7 @@ OTHERDIRS = lib ifeq ($(CONFIG_NUTTX_KERNEL),y) -NONFSDIRS += syscall -CONTEXTDIRS += syscall -USERDIRS += syscall libc mm $(USER_ADDONS) +USERDIRS += libc mm $(USER_ADDONS) ifeq ($(CONFIG_HAVE_CXX),y) USERDIRS += libxx endif @@ -122,7 +120,7 @@ endif else NONFSDIRS += libc mm -OTHERDIRS += syscall $(USER_ADDONS) +OTHERDIRS += $(USER_ADDONS) ifeq ($(CONFIG_HAVE_CXX),y) NONFSDIRS += libxx else @@ -131,6 +129,14 @@ endif endif +ifeq ($(CONFIG_LIB_SYSCALL),y) +NONFSDIRS += syscall +CONTEXTDIRS += syscall +USERDIRS += syscall +else +OTHERDIRS += syscall +endif + ifeq ($(CONFIG_NX),y) NONFSDIRS += graphics libnx CONTEXTDIRS += graphics libnx diff --git a/nuttx/arch/arm/src/armv6-m/svcall.h b/nuttx/arch/arm/src/armv6-m/svcall.h index daa70a0c0..f5511c525 100644 --- a/nuttx/arch/arm/src/armv6-m/svcall.h +++ b/nuttx/arch/arm/src/armv6-m/svcall.h @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/armv6-m/svcall.h * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,7 @@ #include <nuttx/config.h> -#ifdef CONFIG_NUTTX_KERNEL +#ifdef CONFIG_LIB_SYSCALL # include <syscall.h> #endif @@ -55,11 +55,19 @@ * syscall return. The first four syscall values must be reserved. */ -#ifdef CONFIG_NUTTX_KERNEL -# ifndef CONFIG_SYS_RESERVED -# error "CONFIG_SYS_RESERVED must be defined to have the value 8" -# elif CONFIG_SYS_RESERVED != 8 -# error "CONFIG_SYS_RESERVED must have the value 8" +#ifdef CONFIG_LIB_SYSCALL +# ifdef CONFIG_NUTTX_KERNEL +# ifndef CONFIG_SYS_RESERVED +# error "CONFIG_SYS_RESERVED must be defined to have the value 8" +# elif CONFIG_SYS_RESERVED != 8 +# error "CONFIG_SYS_RESERVED must have the value 8" +# endif +# else +# ifndef CONFIG_SYS_RESERVED +# error "CONFIG_SYS_RESERVED must be defined to have the value 3" +# elif CONFIG_SYS_RESERVED != 3 +# error "CONFIG_SYS_RESERVED must have the value 3" +# endif # endif #endif diff --git a/nuttx/arch/arm/src/armv6-m/up_svcall.c b/nuttx/arch/arm/src/armv6-m/up_svcall.c index 1b367259b..ad9da62d4 100644 --- a/nuttx/arch/arm/src/armv6-m/up_svcall.c +++ b/nuttx/arch/arm/src/armv6-m/up_svcall.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv6-m/up_svcall.c * - * Copyright (C) 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ #include <arch/irq.h> #include <nuttx/sched.h> -#ifdef CONFIG_NUTTX_KERNEL +#ifdef CONFIG_LIB_SYSCALL # include <syscall.h> #endif @@ -119,7 +119,7 @@ * ****************************************************************************/ -#ifdef CONFIG_NUTTX_KERNEL +#ifdef CONFIG_LIB_SYSCALL static void dispatch_syscall(void) naked_function; static void dispatch_syscall(void) { @@ -444,7 +444,7 @@ int up_svcall(int irq, FAR void *context) default: { -#ifdef CONFIG_NUTTX_KERNEL +#ifdef CONFIG_LIB_SYSCALL FAR struct tcb_s *rtcb = sched_self(); int index = rtcb->xcp.nsyscalls; diff --git a/nuttx/arch/arm/src/armv7-m/svcall.h b/nuttx/arch/arm/src/armv7-m/svcall.h index 2c4735335..64c4bdfe8 100644 --- a/nuttx/arch/arm/src/armv7-m/svcall.h +++ b/nuttx/arch/arm/src/armv7-m/svcall.h @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/armv7-m/svcall.h * - * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013-2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -42,7 +42,7 @@ #include <nuttx/config.h> -#ifdef CONFIG_NUTTX_KERNEL +#ifdef CONFIG_LIB_SYSCALL # include <syscall.h> #endif @@ -55,11 +55,19 @@ * syscall return. The first four syscall values must be reserved. */ -#ifdef CONFIG_NUTTX_KERNEL -# ifndef CONFIG_SYS_RESERVED -# error "CONFIG_SYS_RESERVED must be defined to have the value 8" -# elif CONFIG_SYS_RESERVED != 8 -# error "CONFIG_SYS_RESERVED must have the value 8" +#ifdef CONFIG_LIB_SYSCALL +# ifdef CONFIG_NUTTX_KERNEL +# ifndef CONFIG_SYS_RESERVED +# error "CONFIG_SYS_RESERVED must be defined to have the value 8" +# elif CONFIG_SYS_RESERVED != 8 +# error "CONFIG_SYS_RESERVED must have the value 8" +# endif +# else +# ifndef CONFIG_SYS_RESERVED +# error "CONFIG_SYS_RESERVED must be defined to have the value 3" +# elif CONFIG_SYS_RESERVED != 3 +# error "CONFIG_SYS_RESERVED must have the value 3" +# endif # endif #endif diff --git a/nuttx/arch/arm/src/armv7-m/up_svcall.c b/nuttx/arch/arm/src/armv7-m/up_svcall.c index be33b675d..9909057d3 100644 --- a/nuttx/arch/arm/src/armv7-m/up_svcall.c +++ b/nuttx/arch/arm/src/armv7-m/up_svcall.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-m/up_svcall.c * - * Copyright (C) 2009, 2011-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011-2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ #include <arch/irq.h> #include <nuttx/sched.h> -#ifdef CONFIG_NUTTX_KERNEL +#ifdef CONFIG_LIB_SYSCALL # include <syscall.h> #endif @@ -116,7 +116,7 @@ * ****************************************************************************/ -#ifdef CONFIG_NUTTX_KERNEL +#ifdef CONFIG_LIB_SYSCALL static void dispatch_syscall(void) naked_function; static void dispatch_syscall(void) { @@ -443,7 +443,7 @@ int up_svcall(int irq, FAR void *context) default: { -#ifdef CONFIG_NUTTX_KERNEL +#ifdef CONFIG_LIB_SYSCALL FAR struct tcb_s *rtcb = sched_self(); int index = rtcb->xcp.nsyscalls; diff --git a/nuttx/syscall/Kconfig b/nuttx/syscall/Kconfig index 0c5b74ab1..f1138611a 100644 --- a/nuttx/syscall/Kconfig +++ b/nuttx/syscall/Kconfig @@ -3,9 +3,31 @@ # see misc/tools/kconfig-language.txt. # -if NUTTX_KERNEL +menuconfig LIB_SYSCALL + bool "System call support" + default n + ---help--- + Build in support for "system calls". System calls are used to + implement a call gate mechanism that can be be used to call from + user code into the kernel. This is only useful for user code that + likes outside of the kernel such as when the NUTTX_KERNEL build is + selected. + + This permits calls from user-mode code into kernel mode; the call + gate will change the mode of operation from user to supervisor mode, + then call into the OS code on behalf of the user-mode application. + + If if there are no privilege issues preventing the call, system + calls may also be of value because it can eliminate the need for + symbol tables when linking external modules to the NuttX base code. + The selection will build libsyscall. External modules can then link + with libsyscall when they are built and they can call into the OS + with no knowledge of the actual address in the OS. In this case, + they call into a proxy that is link with the external code; that + proxy then marshals the call parameter and invokes the system call + to accomplish the interface. -comment "System call configuration" +if LIB_SYSCALL config SYS_RESERVED int "Number of reserved system calls" @@ -34,4 +56,4 @@ config SYS_NNEST space memory. So it is expected that the maximum nesting level will be only 2. -endif +endif # LIB_SYSCALL |