From 724d3c4c0dd93354fb02cc64972448e4ea7e00a0 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 29 Nov 2012 13:58:53 +0000 Subject: [PATCH] Patches for NSH disable background, and ARMv7M assembly from Freddie Chopin git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5398 42af7a65-404d-4744-a932-0658087f49c3 --- apps/nshlib/nsh_apps.c | 41 +++++++++++++++++-- nuttx/arch/arm/src/armv7-m/up_exception.S | 4 +- .../configs/z8encore000zco/scripts/setenv.bat | 2 +- .../configs/z8f64200100kit/scripts/setenv.bat | 2 +- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/apps/nshlib/nsh_apps.c b/apps/nshlib/nsh_apps.c index e335c2e2c2..7dbaf9ba8d 100644 --- a/apps/nshlib/nsh_apps.c +++ b/apps/nshlib/nsh_apps.c @@ -122,13 +122,28 @@ int nsh_execapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, ret = exec_namedapp(cmd, (FAR const char **)argv); if (ret >= 0) { - /* The application was successfully started (but still blocked because the - * scheduler is locked). If the application was not backgrounded, then we - * need to wait here for the application to exit. + /* The application was successfully started (but still blocked because + * the scheduler is locked). If the application was not backgrounded, + * then we need to wait here for the application to exit. These really + * only works works with the following options: + * + * - CONFIG_NSH_DISABLEBG - Do not run commands in background + * - CONFIG_SCHED_WAITPID - Required to run external commands in + * foreground + * + * These concepts do not apply cleanly to the external applications. */ #ifdef CONFIG_SCHED_WAITPID + + /* CONFIG_SCHED_WAITPID is selected, so we may run the command in + * foreground unless we were specifically requested to run the command + * in background (and running commands in background is enabled). + */ + +# ifndef CONFIG_NSH_DISABLEBG if (vtbl->np.np_bg == false) +# endif /* CONFIG_NSH_DISABLEBG */ { int rc = 0; @@ -155,8 +170,25 @@ int nsh_execapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, */ } } +# ifndef CONFIG_NSH_DISABLEBG else -#endif +# endif /* CONFIG_NSH_DISABLEBG */ +#endif /* CONFIG_SCHED_WAITPID */ + + /* We get here if either: + * + * - CONFIG_SCHED_WAITPID is not selected meaning that all commands + * have to be run in background, or + * - CONFIG_SCHED_WAITPID and CONFIG_NSH_DISABLEBG are both selected, but the + * user requested to run the command in background. + * + * NOTE that the case of a) CONFIG_SCHED_WAITPID is not selected and + * b) CONFIG_NSH_DISABLEBG selected cannot be supported. In that event, all + * commands will have to run in background. The waitpid() API must be + * available to support running the command in foreground. + */ + +#if !defined(CONFIG_SCHED_WAITPID) || !defined(CONFIG_NSH_DISABLEBG) { struct sched_param param; sched_getparam(0, ¶m); @@ -168,6 +200,7 @@ int nsh_execapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, ret = OK; } +#endif /* !CONFIG_SCHED_WAITPID || !CONFIG_NSH_DISABLEBG */ } sched_unlock(); diff --git a/nuttx/arch/arm/src/armv7-m/up_exception.S b/nuttx/arch/arm/src/armv7-m/up_exception.S index 31d8dbb0cc..c9f2160274 100644 --- a/nuttx/arch/arm/src/armv7-m/up_exception.S +++ b/nuttx/arch/arm/src/armv7-m/up_exception.S @@ -134,9 +134,9 @@ exception_common: #if CONFIG_ARCH_INTERRUPTSTACK > 3 ldr sp, =g_intstackbase - push r1 /* Save the MSP on the interrupt stack */ + push {r1} /* Save the MSP on the interrupt stack */ bl up_doirq /* R0=IRQ, R1=register save area on stack */ - pop r1 /* Recover R1=main stack pointer */ + pop {r1} /* Recover R1=main stack pointer */ #else msr msp, r1 /* We are using the main stack pointer */ bl up_doirq /* R0=IRQ, R1=register save area on stack */ diff --git a/nuttx/configs/z8encore000zco/scripts/setenv.bat b/nuttx/configs/z8encore000zco/scripts/setenv.bat index f208a6e8bb..407cca97fe 100644 --- a/nuttx/configs/z8encore000zco/scripts/setenv.bat +++ b/nuttx/configs/z8encore000zco/scripts/setenv.bat @@ -41,7 +41,7 @@ set PATH=C:\MinGW\bin;%PATH% rem This is the location where I installed the ZDS-II toolchain. -set PATH=C:\Program Files (x86)\ZiLOG\ZZDSII_Z8Encore!_5.0.0\bin;%PATH% +set PATH=C:\Program Files (x86)\ZiLOG\ZDSII_Z8Encore!_5.0.0\bin;%PATH% rem This is the location where I installed the GNUWin32 tools. See rem http://gnuwin32.sourceforge.net/. diff --git a/nuttx/configs/z8f64200100kit/scripts/setenv.bat b/nuttx/configs/z8f64200100kit/scripts/setenv.bat index 4281d5b117..e0526d988a 100644 --- a/nuttx/configs/z8f64200100kit/scripts/setenv.bat +++ b/nuttx/configs/z8f64200100kit/scripts/setenv.bat @@ -41,7 +41,7 @@ set PATH=C:\MinGW\bin;%PATH% rem This is the location where I installed the ZDS-II toolchain. -set PATH=C:\Program Files (x86)\ZiLOG\ZZDSII_Z8Encore!_5.0.0\bin;%PATH% +set PATH=C:\Program Files (x86)\ZiLOG\ZDSII_Z8Encore!_5.0.0\bin;%PATH% rem This is the location where I installed the GNUWin32 tools. See rem http://gnuwin32.sourceforge.net/.