diff options
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/Documentation/NuttxPortingGuide.html | 13 | ||||
-rw-r--r-- | nuttx/TODO | 12 | ||||
-rw-r--r-- | nuttx/arch/arm/include/arm/syscall.h | 10 | ||||
-rw-r--r-- | nuttx/arch/arm/include/cortexm3/syscall.h | 12 | ||||
-rw-r--r-- | nuttx/arch/arm/src/cortexm3/svcall.h | 94 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/cortexm3/up_fullcontextrestore.S | 22 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/cortexm3/up_saveusercontext.S | 30 | ||||
-rw-r--r-- | nuttx/arch/arm/src/cortexm3/up_svcall.c | 200 | ||||
-rwxr-xr-x | nuttx/arch/arm/src/cortexm3/up_switchcontext.S | 24 | ||||
-rw-r--r-- | nuttx/configs/README.txt | 55 | ||||
-rwxr-xr-x | nuttx/configs/sam3u-ek/knsh/defconfig | 9 | ||||
-rw-r--r-- | nuttx/include/sys/syscall.h | 48 | ||||
-rw-r--r-- | nuttx/syscall/stub_lookup.c | 6 |
13 files changed, 409 insertions, 126 deletions
diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index 1f27a5565..5efc76e6c 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -12,7 +12,7 @@ <h1><big><font color="#3c34ec"> <i>NuttX RTOS Porting Guide</i> </font></big></h1> - <p>Last Updated: April 5, 2011</p> + <p>Last Updated: April 6, 2011</p> </td> </tr> </table> @@ -3001,6 +3001,17 @@ build </ul> <p> + Kernel build options: +</p> +<ul> + <li> + <code>CONFIG_NUTTX_KERNEL</code>: Builds NuttX as a separately compiled kernel. + </li> + <code>CONFIG_SYS_RESERVED</code>: Reserved system call values for use by architecture-specific logic. + </li> +</ul> + +<p> OS setup related to on-demand paging: </p> <ul> diff --git a/nuttx/TODO b/nuttx/TODO index d9b2491b0..25a40dc1a 100644 --- a/nuttx/TODO +++ b/nuttx/TODO @@ -10,7 +10,7 @@ nuttx/ (1) pthreads (sched/) (1) C++ Support (5) Binary loaders (binfmt/) - (15) Network (net/, drivers/net) + (15) Network (net/, drivers/net) (2) USB (drivers/usbdev, drivers/usbhost) (5) Libraries (lib/) (13) File system/Generic drivers (fs/, drivers/) @@ -514,7 +514,15 @@ o Build system Status: Open. This may not be a real issue. I have not seen this happen lately so it may have nothing to do with GCC. Priority: High if you are using NX and a newer compiler. - + + Description: It has been reported to me that in some environments, the int8_t + type is unsigned (0-255). The uint8_t type is based on type char + and char may or may not be treated as a signed value by your compiler. + Two options: (1) in arch/<cpu>/include/<cpu>/types.h, try typedef'ing + int8_t as 'signed char', (2) for GCC, you should be able to add the + compiler option -fsigned-char to your CFLAGS in Make.defs. + Status: Open + Priority: Medium o Linux/Cywgin simulation (arch/sim) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/nuttx/arch/arm/include/arm/syscall.h b/nuttx/arch/arm/include/arm/syscall.h index c81ad7aec..e06de1a3c 100644 --- a/nuttx/arch/arm/include/arm/syscall.h +++ b/nuttx/arch/arm/include/arm/syscall.h @@ -45,7 +45,10 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <stdint.h> + +#ifndef __ASSEMBLY__ +# include <stdint.h> +#endif /**************************************************************************** * Pre-Processor Definitions @@ -61,6 +64,8 @@ * Inline functions ****************************************************************************/ +#ifndef __ASSEMBLY__ + /* SWI with SYS_ call number and no parameters */ static inline uintptr_t sys_call0(unsigned int nbr) @@ -221,7 +226,6 @@ static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1, * Public Function Prototypes ****************************************************************************/ -#ifndef __ASSEMBLY__ #ifdef __cplusplus #define EXTERN extern "C" extern "C" { @@ -233,7 +237,7 @@ extern "C" { #ifdef __cplusplus } #endif -#endif +#endif /* __ASSEMBLY__ */ #endif /* __ARCH_ARM_INCLUDE_ARM_SYSCALL_H */ diff --git a/nuttx/arch/arm/include/cortexm3/syscall.h b/nuttx/arch/arm/include/cortexm3/syscall.h index 4c5eb6556..bf61d7ee8 100644 --- a/nuttx/arch/arm/include/cortexm3/syscall.h +++ b/nuttx/arch/arm/include/cortexm3/syscall.h @@ -44,8 +44,11 @@ * Included Files ****************************************************************************/ - #include <nuttx/config.h> -#include <stdint.h> +#include <nuttx/config.h> + +#ifndef __ASSEMBLY__ +# include <stdint.h> +#endif /**************************************************************************** * Pro-processor Definitions @@ -61,6 +64,8 @@ * Inline functions ****************************************************************************/ +#ifndef __ASSEMBLY__ + /* SVC call with SYS_ call number and no parameters */ static inline uintptr_t sys_call0(unsigned int nbr) @@ -221,7 +226,6 @@ static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1, * Public Function Prototypes ****************************************************************************/ -#ifndef __ASSEMBLY__ #ifdef __cplusplus #define EXTERN extern "C" extern "C" { @@ -233,7 +237,7 @@ extern "C" { #ifdef __cplusplus } #endif -#endif +#endif /* __ASSEMBLY__ */ #endif /* __ARCH_ARM_INCLUDE_CORTEXM3_SYSCALL_H */ diff --git a/nuttx/arch/arm/src/cortexm3/svcall.h b/nuttx/arch/arm/src/cortexm3/svcall.h new file mode 100644 index 000000000..bca3e0799 --- /dev/null +++ b/nuttx/arch/arm/src/cortexm3/svcall.h @@ -0,0 +1,94 @@ +/************************************************************************************ + * arch/arm/src/cortexm3/svcall.h + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt <spudmonkey@racsa.co.cr> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +#ifndef __ARCH_ARM_SRC_COMMON_CORTEXM_SVCALL_H +#define __ARCH_ARM_SRC_COMMON_CORTEXM_SVCALL_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include <nuttx/config.h> + +#ifdef CONFIG_NUTTX_KERNEL +# include <syscall.h> +#endif + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +/* Configuration ********************************************************************/ +/* This logic uses three system calls {0,1,2} for context switching. The first three + * syscall values must be reserved. + */ + +#ifdef CONFIG_NUTTX_KERNEL +# ifndef CONFIG_SYS_RESERVED +# error "CONFIG_SYS_RESERVED must be defined to the value 3" +# elif CONFIG_SYS_RESERVED != 3 +# error "CONFIG_SYS_RESERVED must have the value 3" +# endif +#endif + +/* Cortex M3 system calls ***********************************************************/ + +/* SYS call 0: + * + * int up_saveusercontext(uint32_t *saveregs); + */ + +#define SYS_save_context (0) + +/* SYS call 1: + * + * void up_fullcontextrestore(uint32_t *restoreregs) __attribute__ ((noreturn)); + */ + +#define SYS_restore_context (1) + +/* SYS call 1: + * + * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); + */ + +#define SYS_switch_context (2) + +/************************************************************************************ + * Inline Functions + ************************************************************************************/ + +#endif /* __ARCH_ARM_SRC_COMMON_CORTEXM_SVCALL_H */ + diff --git a/nuttx/arch/arm/src/cortexm3/up_fullcontextrestore.S b/nuttx/arch/arm/src/cortexm3/up_fullcontextrestore.S index aab30b309..1194510b9 100755 --- a/nuttx/arch/arm/src/cortexm3/up_fullcontextrestore.S +++ b/nuttx/arch/arm/src/cortexm3/up_fullcontextrestore.S @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/cortexm3/up_fullcontextrestore.S * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,9 @@ #include <nuttx/config.h> #include <arch/irq.h> + #include "nvic.h" +#include "svcall.h" /************************************************************************************ * Preprocessor Definitions @@ -49,9 +51,9 @@ * Global Symbols ************************************************************************************/ - .syntax unified + .syntax unified .thumb - .file "up_fullcontextrestore.S" + .file "up_fullcontextrestore.S" /************************************************************************************ * Macros @@ -75,19 +77,19 @@ **************************************************************************/ .thumb_func - .globl up_fullcontextrestore - .type up_fullcontextrestore, function + .globl up_fullcontextrestore + .type up_fullcontextrestore, function up_fullcontextrestore: /* Perform the System call with R0=1 and R1=regs */ - mov r1, r0 /* R1: regs */ - mov r0, #1 /* R0: 1 means restore context */ - svc 0 /* Force synchronous SVCall (or Hard Fault) */ + mov r1, r0 /* R1: regs */ + mov r0, #SYS_restore_context /* R0: restore context */ + svc 0 /* Force synchronous SVCall (or Hard Fault) */ /* This call should not return */ - bx lr /* Unnecessary ... will not return */ - .size up_fullcontextrestore, .-up_fullcontextrestore + bx lr /* Unnecessary ... will not return */ + .size up_fullcontextrestore, .-up_fullcontextrestore .end diff --git a/nuttx/arch/arm/src/cortexm3/up_saveusercontext.S b/nuttx/arch/arm/src/cortexm3/up_saveusercontext.S index dee841959..2ca11aa28 100755 --- a/nuttx/arch/arm/src/cortexm3/up_saveusercontext.S +++ b/nuttx/arch/arm/src/cortexm3/up_saveusercontext.S @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/cortexm3/up_saveusercontext.S * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,9 @@ #include <nuttx/config.h> #include <arch/irq.h> + #include "nvic.h" +#include "svcall.h" /************************************************************************************ * Pre-processor Definitions @@ -49,9 +51,9 @@ * Global Symbols ************************************************************************************/ - .syntax unified + .syntax unified .thumb - .file "up_saveusercontext.S" + .file "up_saveusercontext.S" /************************************************************************************ * Macros @@ -77,26 +79,26 @@ .text .thumb_func - .globl up_saveusercontext - .type up_saveusercontext, function + .globl up_saveusercontext + .type up_saveusercontext, function up_saveusercontext: /* Perform the System call with R0=0 and R1=regs */ - mov r1, r0 /* R1: regs */ - mov r0, #0 /* R0: 0 means save context (also return value) */ - svc 0 /* Force synchronous SVCall (or Hard Fault) */ + mov r1, r0 /* R1: regs */ + mov r0, #SYS_save_context /* R0: save context (also return value) */ + svc 0 /* Force synchronous SVCall (or Hard Fault) */ /* There are two return conditions. On the first return, R0 (the * return value will be zero. On the second return we need to * force R0 to be 1. */ - add r2, r1, #(4*REG_R0) - mov r3, #1 - str r3, [r2, #0] - bx lr /* "normal" return with r0=0 or - * context switch with r0=1 */ - .size up_saveusercontext, .-up_saveusercontext + add r2, r1, #(4*REG_R0) + mov r3, #1 + str r3, [r2, #0] + bx lr /* "normal" return with r0=0 or + * context switch with r0=1 */ + .size up_saveusercontext, .-up_saveusercontext .end diff --git a/nuttx/arch/arm/src/cortexm3/up_svcall.c b/nuttx/arch/arm/src/cortexm3/up_svcall.c index 0fc96df42..ec67617a7 100644 --- a/nuttx/arch/arm/src/cortexm3/up_svcall.c +++ b/nuttx/arch/arm/src/cortexm3/up_svcall.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/cortexm3/up_svcall.c * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -45,19 +45,30 @@ #include <debug.h> #include <arch/irq.h> +#include <nuttx/sched.h> -#include "os_internal.h" +#ifdef CONFIG_NUTTX_KERNEL +# include <syscall.h> +#endif + +#include "svcall.h" #include "up_internal.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ -/* Debug output from this file may interfere with context switching! */ +/* Debug output from this file may interfere with context switching! To get + * debug output you must enabled the following in your NuttX configuration: + * + * CONFIG_DEBUG and CONFIG_DEBUG_SCHED + * + * And you must explicitly define DEBUG_SVCALL below: + */ #undef DEBUG_SVCALL /* Define to debug SVCall */ #ifdef DEBUG_HARDFAULTS -# define svcdbg(format, arg...) lldbg(format, ##arg) +# define svcdbg(format, arg...) slldbg(format, ##arg) #else # define svcdbg(x...) #endif @@ -75,6 +86,118 @@ ****************************************************************************/ /**************************************************************************** + * Name: up_svcall + * + * Description: + * This is SVCall exception handler that performs context switching + * + ****************************************************************************/ + +#ifdef CONFIG_NUTTX_KERNEL +static inline void dispatch_syscall(uint32_t *regs) +{ + uint32_t cmd = regs[REG_R0]; + FAR _TCB *rtcb = sched_self(); + uintptr_t ret = (uintptr_t)ERROR; + + /* Verify the the SYS call number is within range */ + + if (cmd < SYS_maxsyscall) + { + /* Report error and return ERROR */ + + slldbg("ERROR: Bad SYS call: %d\n", cmd); + } + else + { + /* The index into the syscall table is offset by the number of architecture- + * specific reserved entries at the beginning of the SYS call number space. + */ + + int index = cmd - CONFIG_SYS_RESERVED; + + /* Call the correct stub for each SYS call, based on the number of parameters */ + + svcdbg("Calling stub%d at %p\n", index, g_stubloopkup[index].stub0); + + switch (g_stubnparms[index]) + { + /* No parameters */ + + case 0: + ret = g_stublookup[index].stub0(); + break; + + /* Number of parameters: 1 */ + + case 1: + ret = g_stublookup[index].stub1(regs[REG_R1]); + break; + + /* Number of parameters: 2 */ + + case 2: + ret = g_stublookup[index].stub2(regs[REG_R1], regs[REG_R2]); + break; + + /* Number of parameters: 3 */ + + case 3: + ret = g_stublookup[index].stub3(regs[REG_R1], regs[REG_R2], + regs[REG_R3]); + break; + + /* Number of parameters: 4 */ + + case 4: + ret = g_stublookup[index].stub4(regs[REG_R1], regs[REG_R2], + regs[REG_R3], regs[REG_R4]); + break; + + /* Number of parameters: 5 */ + + case 5: + ret = g_stublookup[index].stub5(regs[REG_R1], regs[REG_R2], + regs[REG_R3], regs[REG_R4], + regs[REG_R5]); + break; + + /* Number of parameters: 6 */ + + case 6: + ret = g_stublookup[index].stub6(regs[REG_R1], regs[REG_R2], + regs[REG_R3], regs[REG_R4], + regs[REG_R5], regs[REG_R6]); + break; + + /* Unsupported number of paramters. Report error and return ERROR */ + + default: + slldbg("ERROR: Bad SYS call %d number parameters %d\n", + cmd, g_stubnparms[index]); + break; + } + } + + /* Set up the return vaue. First, check if a context switch occurred. + * In this case, regs will no longer be the same as current_regs. In + * the case of a context switch, we will have to save the return value + * in the TCB where it can be returned later when the task is restarted. + */ + + if (regs != current_regs) + { + regs = rtcb->xcp.regs; + } + + /* Then return the result in R0 */ + + svcdbg("Return value regs: %p value: %d\n", regs, ret); + regs[REG_R0] = (uint32_t)ret; +} +#endif + +/**************************************************************************** * Public Functions ****************************************************************************/ @@ -91,16 +214,12 @@ int up_svcall(int irq, FAR void *context) uint32_t *regs = (uint32_t*)context; DEBUGASSERT(regs && regs == current_regs); - DEBUGASSERT(regs[REG_R1] != 0); - /* The SVCall software interrupt is called with R0 = SVC command and R1 = - * the TCB register save area. + /* The SVCall software interrupt is called with R0 = system call command + * and R1..R7 = variable number of arguments depending on the system call. */ - svcdbg("Command: %d regs: %p R1: %08x R2: %08x\n", - regs[REG_R0], regs, regs[REG_R1], regs[REG_R2]); - - svcdbg("SVCall Entry:\n"); + svcdbg("SVCALL Entry: regs: %p cmd: %d\n", regs, regs[REG_R0]); svcdbg(" R0: %08x %08x %08x %08x %08x %08x %08x %08x\n", regs[REG_R0], regs[REG_R1], regs[REG_R2], regs[REG_R3], regs[REG_R4], regs[REG_R5], regs[REG_R6], regs[REG_R7]); @@ -113,32 +232,33 @@ int up_svcall(int irq, FAR void *context) switch (regs[REG_R0]) { - /* R0=0: This is a save context command: + /* R0=SYS_save_context: This is a save context command: * * int up_saveusercontext(uint32_t *saveregs); * * At this point, the following values are saved in context: * - * R0 = 0 + * R0 = SYS_save_context * R1 = saveregs * * In this case, we simply need to copy the current regsters to the * save regiser space references in the saved R1 and return. */ - case 0: + case SYS_save_context: { + DEBUGASSERT(regs[REG_R1] != 0); memcpy((uint32_t*)regs[REG_R1], regs, XCPTCONTEXT_SIZE); } break; - /* R0=1: This a restore context command: + /* R0=SYS_restore_context: This a restore context command: * * void up_fullcontextrestore(uint32_t *restoreregs) __attribute__ ((noreturn)); * * At this point, the following values are saved in context: * - * R0 = 1 + * R0 = SYS_restore_context * R1 = restoreregs * * In this case, we simply need to set current_regs to restore register @@ -147,13 +267,14 @@ int up_svcall(int irq, FAR void *context) * the return to the saved context referenced in R1. */ - case 1: + case SYS_restore_context: { + DEBUGASSERT(regs[REG_R1] != 0); current_regs = (uint32_t*)regs[REG_R1]; } break; - /* R0=2: This a switch context command: + /* R0=SYS_switch_context: This a switch context command: * * void up_switchcontext(uint32_t *saveregs, uint32_t *restoreregs); * @@ -169,28 +290,45 @@ int up_svcall(int irq, FAR void *context) * contents of R2. */ - case 2: + case SYS_switch_context: { - DEBUGASSERT(regs[REG_R2] != 0); + DEBUGASSERT(regs[REG_R1] != 0 && regs[REG_R2] != 0); memcpy((uint32_t*)regs[REG_R1], regs, XCPTCONTEXT_SIZE); current_regs = (uint32_t*)regs[REG_R2]; } break; - + /* This is not an architecture-specify system call. If NuttX is built + * as a standalone kernel with a system call interface, then all of the + * additional system calls must be handled as in the default case. + */ + default: - PANIC(OSERR_INTERNAL); +#ifdef CONFIG_NUTTX_KERNEL + dispatch_syscall(regs); +#else + slldbg("ERROR: Bad SYS call: %d\n", regs[REG_R0]); +#endif break; } - - svcdbg("SVCall Return:\n"); - svcdbg(" R0: %08x %08x %08x %08x %08x %08x %08x %08x\n", - current_regs[REG_R0], current_regs[REG_R1], current_regs[REG_R2], current_regs[REG_R3], - current_regs[REG_R4], current_regs[REG_R5], current_regs[REG_R6], current_regs[REG_R7]); - svcdbg(" R8: %08x %08x %08x %08x %08x %08x %08x %08x\n", - current_regs[REG_R8], current_regs[REG_R9], current_regs[REG_R10], current_regs[REG_R11], - current_regs[REG_R12], current_regs[REG_R13], current_regs[REG_R14], current_regs[REG_R15]); - svcdbg(" PSR=%08x\n", current_regs[REG_XPSR]); + + /* Report what happened. That might difficult in the case of a context switch */ + + if (regs != current_regs) + { + svcdbg("SVCall Return: Context switch!\n"); + svcdbg(" R0: %08x %08x %08x %08x %08x %08x %08x %08x\n", + current_regs[REG_R0], current_regs[REG_R1], current_regs[REG_R2], current_regs[REG_R3], + current_regs[REG_R4], current_regs[REG_R5], current_regs[REG_R6], current_regs[REG_R7]); + svcdbg(" R8: %08x %08x %08x %08x %08x %08x %08x %08x\n", + current_regs[REG_R8], current_regs[REG_R9], current_regs[REG_R10], current_regs[REG_R11], + current_regs[REG_R12], current_regs[REG_R13], current_regs[REG_R14], current_regs[REG_R15]); + svcdbg(" PSR=%08x\n", current_regs[REG_XPSR]); + } + else + { + svcdbg("SVCall Return: %d\n", regs[REG_R0]); + } return OK; } diff --git a/nuttx/arch/arm/src/cortexm3/up_switchcontext.S b/nuttx/arch/arm/src/cortexm3/up_switchcontext.S index 2823d325a..1b91e0938 100755 --- a/nuttx/arch/arm/src/cortexm3/up_switchcontext.S +++ b/nuttx/arch/arm/src/cortexm3/up_switchcontext.S @@ -1,7 +1,7 @@ /************************************************************************************ * arch/arm/src/cortexm3/up_switchcontext.S * - * Copyright (C) 2009-2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> * * Redistribution and use in source and binary forms, with or without @@ -39,7 +39,9 @@ #include <nuttx/config.h> #include <arch/irq.h> + #include "nvic.h" +#include "svcall.h" /************************************************************************************ * Pre-processor Definitions @@ -49,9 +51,9 @@ * Global Symbols ************************************************************************************/ - .syntax unified + .syntax unified .thumb - .file "up_switchcontext.S" + .file "up_switchcontext.S" /************************************************************************************ * Macros @@ -76,20 +78,20 @@ **************************************************************************/ .thumb_func - .globl up_switchcontext - .type up_switchcontext, function + .globl up_switchcontext + .type up_switchcontext, function up_switchcontext: /* Perform the System call with R0=1, R1=saveregs, R2=restoreregs */ - mov r2, r1 /* R2: restoreregs */ - mov r1, r0 /* R1: saveregs */ - mov r0, #2 /* R0: 2 means context switch */ - svc 0 /* Force synchronous SVCall (or Hard Fault) */ + mov r2, r1 /* R2: restoreregs */ + mov r1, r0 /* R1: saveregs */ + mov r0, #SYS_switch_context /* R0: context switch */ + svc 0 /* Force synchronous SVCall (or Hard Fault) */ /* This call should not return */ - bx lr /* Unnecessary ... will not return */ - .size up_switchcontext, .-up_switchcontext + bx lr /* Unnecessary ... will not return */ + .size up_switchcontext, .-up_switchcontext .end diff --git a/nuttx/configs/README.txt b/nuttx/configs/README.txt index ed3462b28..5986f9c60 100644 --- a/nuttx/configs/README.txt +++ b/nuttx/configs/README.txt @@ -49,18 +49,18 @@ following characteristics: <board-name> - |-- README.txt + |-- README.txt |-- include/ | `-- (board-specific header files) |-- src/ | |-- Makefile | `-- (board-specific source files) - |-- <config1-dir> + |-- <config1-dir> | |-- Make.defs | |-- defconfig | |-- appconfig* | `-- setenv.sh - |-- <config2-dir> + |-- <config2-dir> | |-- Make.defs | |-- defconfig | |-- appconfig* @@ -119,7 +119,7 @@ defconfig -- This is a configuration file similar to the Linux (1) as a makefile fragment included in other makefiles, and (2) to generate include/nuttx/config.h which is included by - most C files in the system. + most C files in the system. The following variables are recognized by the build (you may also include architecture/board-specific settings). @@ -172,7 +172,7 @@ defconfig -- This is a configuration file similar to the Linux application to link with NuttX. Default: ../apps This symbol must be assigned to the path to the application build directory *relative* to the NuttX top build direcory. If you had an application - directory and the NuttX directory each in separate directory + directory and the NuttX directory each in separate directory trees like this: build @@ -336,6 +336,11 @@ defconfig -- This is a configuration file similar to the Linux CONFIG_SIG_SIGWORK - The signal number that will be used to wake-up the worker thread. Default: 4 + Kernel build options: + CONFIG_NUTTX_KERNEL - Builds NuttX as a separately compiled kernel. + CONFIG_SYS_RESERVED - Reserved system call values for use + by architecture-specific logic. + OS setup related to on-demand paging: CONFIG_PAGING - If set =y in your configation file, this setting will @@ -755,43 +760,43 @@ defconfig -- This is a configuration file similar to the Linux USB host controller driver CONFIG_USBHOST - Enables USB host support + Enables USB host support CONFIG_USBHOST_NPREALLOC - Number of pre-allocated class instances + Number of pre-allocated class instances CONFIG_USBHOST_BULK_DISABLE - On some architectures, selecting this setting will reduce driver size - by disabling bulk endpoint support + On some architectures, selecting this setting will reduce driver size + by disabling bulk endpoint support CONFIG_USBHOST_INT_DISABLE - On some architectures, selecting this setting will reduce driver size - by disabling interrupt endpoint support + On some architectures, selecting this setting will reduce driver size + by disabling interrupt endpoint support CONFIG_USBHOST_ISOC_DISABLE - On some architectures, selecting this setting will reduce driver size - by disabling isochronous endpoint support + On some architectures, selecting this setting will reduce driver size + by disabling isochronous endpoint support USB host HID class driver. Requires CONFIG_USBHOST=y, CONFIG_USBHOST_INT_DISABLE=n, CONFIG_NFILE_DESCRIPTORS > 0, CONFIG_SCHED_WORKQUEUE=y, and CONFIG_DISABLE_SIGNALS=n. CONFIG_HIDKBD_POLLUSEC - Device poll rate in microseconds. Default: 100 milliseconds. + Device poll rate in microseconds. Default: 100 milliseconds. CONFIG_HIDKBD_DEFPRIO - Priority of the polling thread. Default: 50. + Priority of the polling thread. Default: 50. CONFIG_HIDKBD_STACKSIZE - Stack size for polling thread. Default: 1024 + Stack size for polling thread. Default: 1024 CONFIG_HIDKBD_BUFSIZE - Scancode buffer size. Default: 64. + Scancode buffer size. Default: 64. CONFIG_HIDKBD_NPOLLWAITERS - If the poll() method is enabled, this defines the maximum number - of threads that can be waiting for keyboard events. Default: 2. + If the poll() method is enabled, this defines the maximum number + of threads that can be waiting for keyboard events. Default: 2. CONFIG_HIDKBD_RAWSCANCODES - If set to y no conversion will be made on the raw keyboard scan - codes. Default: ASCII conversion. + If set to y no conversion will be made on the raw keyboard scan + codes. Default: ASCII conversion. CONFIG_HIDKBD_ALLSCANCODES' - If set to y all 231 possible scancodes will be converted to - something. Default: 104 key US keyboard. + If set to y all 231 possible scancodes will be converted to + something. Default: 104 key US keyboard. CONFIG_HIDKBD_NODEBOUNCE - If set to y normal debouncing is disabled. Default: - Debounce enabled (No repeat keys). + If set to y normal debouncing is disabled. Default: + Debounce enabled (No repeat keys). USB host mass storage class driver. Requires CONFIG_USBHOST=y, CONFIG_USBHOST_BULK_DISABLE=n, CONFIG_NFILE_DESCRIPTORS > 0, diff --git a/nuttx/configs/sam3u-ek/knsh/defconfig b/nuttx/configs/sam3u-ek/knsh/defconfig index b2bed075a..551817c56 100755 --- a/nuttx/configs/sam3u-ek/knsh/defconfig +++ b/nuttx/configs/sam3u-ek/knsh/defconfig @@ -225,6 +225,8 @@ CONFIG_PASS1_OBJECT= # CONFIG_DEBUG_SYMBOLS - build without optimization and with # debug symbols (needed for use with a debugger). # CONFIG_NUTTX_KERNEL - Builds NuttX as a separately compiled kernel. +# CONFIG_SYS_RESERVED - Reserved system call values for use +# by archtecture specific ligc. # CONFIG_MM_REGIONS - If the architecture includes multiple # regions of memory to allocate from, this specifies the # number of memory regions that the memory manager must @@ -313,14 +315,15 @@ CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n CONFIG_DEBUG_SYMBOLS=n CONFIG_NUTTX_KERNEL=y +CONFIG_SYS_RESERVED=3 CONFIG_MM_REGIONS=3 CONFIG_ARCH_LOWPUTC=y CONFIG_RR_INTERVAL=200 CONFIG_SCHED_INSTRUMENTATION=n CONFIG_TASK_NAME_SIZE=0 -CONFIG_START_YEAR=2009 -CONFIG_START_MONTH=9 -CONFIG_START_DAY=21 +CONFIG_START_YEAR=2011 +CONFIG_START_MONTH=4 +CONFIG_START_DAY=6 CONFIG_GREGORIAN_TIME=n CONFIG_JULIAN_TIME=n CONFIG_DEV_CONSOLE=y diff --git a/nuttx/include/sys/syscall.h b/nuttx/include/sys/syscall.h index 09e4a632f..0e2ed01c7 100644 --- a/nuttx/include/sys/syscall.h +++ b/nuttx/include/sys/syscall.h @@ -42,7 +42,10 @@ ****************************************************************************/ #include <nuttx/config.h> -#include <stdint.h> + +#ifndef __ASSEMBLY__ +# include <stdint.h> +#endif /**************************************************************************** * Pre-processor Definitions @@ -52,7 +55,7 @@ * configured. */ -#ifndef CONFIG_CONFIG_SYS_RESERVED +#ifndef CONFIG_SYS_RESERVED # define CONFIG_SYS_RESERVED (0) #endif @@ -308,32 +311,38 @@ # define SYS_sendto (__SYS_network+8) # define SYS_setsockopt (__SYS_network+9) # define SYS_socket (__SYS_network+10) -# define SYS_nsyscalls (__SYS_network+11) +# define SYS_maxsyscall (__SYS_network+11) #else -# define SYS_nsyscalls __SYS_network +# define SYS_maxsyscall __SYS_network #endif +/* Note that the reported number of system calls does *NOT* include the + * architecture-specific system calls. If the "real" total is required, + * use SYS_maxsyscall. + */ + +#define SYS_nsyscalls (SYS_maxsyscall-CONFIG_SYS_RESERVED) + /**************************************************************************** * Public Type Definitions ****************************************************************************/ +#ifndef __ASSEMBLY__ + /* This is the union of all possible stub function types */ union syscall_stubfunc_u { - uintptr_t (*stub0)(unsigned int nbr); - uintptr_t (*stub1)(unsigned int nbr, uintptr_t parm1); - uintptr_t (*stub2)(unsigned int nbr, uintptr_t parm1, uintptr_t parm2); - uintptr_t (*stub3)(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, - uintptr_t parm3); - uintptr_t (*stub4)(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, - uintptr_t parm3, uintptr_t parm4); - uintptr_t (*stub5)(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, - uintptr_t parm3, uintptr_t parm4, - uintptr_t parm5); - uintptr_t (*stub6)(unsigned int nbr, uintptr_t parm1, uintptr_t parm2, - uintptr_t parm3, uintptr_t parm4, - uintptr_t parm5, uintptr_t parm6); + uintptr_t (*stub0)(void); + uintptr_t (*stub1)(uintptr_t parm1); + uintptr_t (*stub2)(uintptr_t parm1, uintptr_t parm2); + uintptr_t (*stub3)(uintptr_t parm1, uintptr_t parm2, uintptr_t parm3); + uintptr_t (*stub4)(uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, + uintptr_t parm4); + uintptr_t (*stub5)(uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, + uintptr_t parm4, uintptr_t parm5); + uintptr_t (*stub6)(uintptr_t parm1, uintptr_t parm2, uintptr_t parm3, + uintptr_t parm4, uintptr_t parm5, uintptr_t parm6); }; /**************************************************************************** @@ -352,8 +361,8 @@ extern "C" { * these tables describes how to call the stub dispatch function. */ -EXTERN const union syscall_stubfunc_u *g_stublookup[SYS_nsyscalls]; -EXTERN const uint8_t g_stubnparms[SYS_nsyscalls]; +EXTERN const union syscall_stubfunc_u g_stublookup[SYS_nsyscalls]; +EXTERN const uint8_t g_stubnparms[SYS_nsyscalls]; /**************************************************************************** * Public Functions @@ -364,5 +373,6 @@ EXTERN const uint8_t g_stubnparms[SYS_nsyscalls]; } #endif +#endif /* __ASSEMBLY__ */ #endif /* __INCLUDE_SYS_SYSCALL_H */ diff --git a/nuttx/syscall/stub_lookup.c b/nuttx/syscall/stub_lookup.c index 108019b34..5ed67fd0a 100644 --- a/nuttx/syscall/stub_lookup.c +++ b/nuttx/syscall/stub_lookup.c @@ -239,12 +239,12 @@ extern uintptr_t STUB_socket(uintptr_t parm1, uintptr_t parm2, uintptr_t parm3); * these tables describes how to call the stub dispatch function. */ -const union syscall_stubfunc_u *g_stublookup[SYS_nsyscalls] = +const union syscall_stubfunc_u g_stublookup[SYS_nsyscalls] = { # undef STUB_LOOKUP1 -# define STUB_LOOKUP1(n,p) (union syscall_stubfunc_u *)p +# define STUB_LOOKUP1(n,p) (union syscall_stubfunc_u)p # undef STUB_LOOKUP -# define STUB_LOOKUP(n,p) , (union syscall_stubfunc_u *)p +# define STUB_LOOKUP(n,p) , (union syscall_stubfunc_u)p # include "stub_lookup.h" }; |