From 506452c6fa4b7d408da0d332100f43a3102168ab Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 10 Mar 2011 14:42:28 +0000 Subject: add apps/ dir git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3360 42af7a65-404d-4744-a932-0658087f49c3 --- apps/Makefile | 122 +++++++++++++++++++++++++++++++++++++++ apps/README | 62 ++++++++++++++++++++ apps/exec_nuttapp.c | 117 ++++++++++++++++++++++++++++++++++++++ apps/exec_nuttapp_list.h | 2 + apps/exec_nuttapp_proto.h | 2 + apps/hello/Makefile | 103 +++++++++++++++++++++++++++++++++ apps/hello/hello.c | 47 +++++++++++++++ nuttx/Makefile | 22 ++++++- nuttx/configs/vsn/nsh/defconfig | 36 +++++++++++- nuttx/examples/nsh/nsh_main.c | 33 +++++++++++ nuttx/include/nuttx/nuttapp.h | 123 ++++++++++++++++++++++++++++++++++++++++ nuttx/sched/sched_waitpid.c | 8 +-- 12 files changed, 668 insertions(+), 9 deletions(-) create mode 100644 apps/Makefile create mode 100644 apps/README create mode 100644 apps/exec_nuttapp.c create mode 100644 apps/exec_nuttapp_list.h create mode 100644 apps/exec_nuttapp_proto.h create mode 100644 apps/hello/Makefile create mode 100644 apps/hello/hello.c create mode 100644 nuttx/include/nuttx/nuttapp.h diff --git a/apps/Makefile b/apps/Makefile new file mode 100644 index 000000000..4bc1f90bc --- /dev/null +++ b/apps/Makefile @@ -0,0 +1,122 @@ +############################################################################ +# apps/Makefile +# +# Copyright (C) 2011 Uros Platise. All rights reserved. +# Author: Uros Platise +# Gregory Nutt +# +# 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. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +ifeq ($(WINTOOL),y) +INCDIROPT = -w +endif + +# Application Directories + +BUILTIN_APPS_DIR = +BUILTIN_APPS_BUILT = + +ifeq ($(CONFIG_BUILTIN_APPS_NUTTX),y) + + +# Individual application: HELLO + +ifeq ($(CONFIG_BUILTIN_APPS_HELLO),y) + +BUILTIN_APPS_DIR += hello + +# we use a non-existing .built_always to guarantee that Makefile +# always walks into the sub-directories and asks for build +BUILTIN_APPS_BUILT += hello/.built_always + +hello/libhello$(LIBEXT): + @$(MAKE) -C hello TOPDIR="$(TOPDIR)" libhello$(LIBEXT) + +endif + +# end of application list + +endif + + +ROOTDEPPATH = --dep-path . +ASRCS = +CSRCS = exec_nuttapp.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +BIN = libapps$(LIBEXT) + +VPATH = + +all: $(BIN) + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +$(BUILTIN_APPS_BUILT): + @for dir in $(BUILTIN_APPS_DIR) ; do \ + $(MAKE) -C $$dir TOPDIR="$(TOPDIR)" ; \ + done + +$(BIN): $(OBJS) $(BUILTIN_APPS_BUILT) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $@, $${obj}); \ + done ; ) + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) \ + $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + echo "/* List of application requirements, generated during make depend. */" > exec_nuttapp_list.h + echo "/* List of application entry points, generated during make depend. */" > exec_nuttapp_proto.h + @for dir in $(BUILTIN_APPS_DIR) ; do \ + $(MAKE) -C $$dir TOPDIR="$(TOPDIR)" depend ; \ + done + +depend: .depend + +clean: + @rm -f $(BIN) *~ .*.swp *.o libapps.a + $(call CLEAN) + +distclean: clean + @rm -f Make.dep .depend + +-include Make.dep diff --git a/apps/README b/apps/README new file mode 100644 index 000000000..61129e7d6 --- /dev/null +++ b/apps/README @@ -0,0 +1,62 @@ + +Application Folder +================== + +This folder provides various applications that can be enabled in the .config +file and further provides frame-work to include external user applications +from the ../apps directory. + +Application entry points with their requirements are gathered together in +this folder, in two files: + - exec_nuttapp_proto.h Entry points, prototype function + - exec_nuttapp_list.h Application specific information and requirements + +Application information is collected during the make .depend process. + +To execute an application function: + exec_nuttapp() is defined in the include/nuttx/nuttapp.h + +Further, builtin applications may be accessed via pseudo file-system found +under the nuttx/drivers/sbin directory. + +NuttShell provides transparent method of invoking the command, when the +following option is enabled (regardless of sbin pseudo file system): + CONFIG_EXAMPLES_NSH_BUILTIN_APPS=y + +To select which application to be included in the build process set your +preferences the .config file as: + +To include applications under the nuttx apps directory: + CONFIG_BUILTIN_APPS_NUTTX=y/n + +where each application can be controlled as: + CONFIG_BUILTIN_APPS_=y/n + +To include applications under the user ../apps directory: + CONFIG_BUILTIN_APPS_USER=y/n + +When the user defines an option: + CONFIG_BUILTIN_APP_START= + +then after initialization of the NuttX OS it starts this application +using the exec_nuttapp() method. + +Application skeleton can be found under the hello sub-directory, +which shows how an application can be added to the project. One must +define: + 1. create sub-directory as: appname + 2. provide entry point: appname_main() + 3. set the requirements in the file: Makefile, specially the lines: + APPNAME = appname + PRIORITY = SCHED_PRIORITY_DEFAULT + STACKSIZE = 768 + ASRCS = asm source file list as a.asm b.asm ... + CSRCS = C source file list as foo1.c foo2.c .. + + 4. add enable/disable option in the top file in this directory as: + ifeq CONFIG_BUILTIN_APPS_ + ... + +To include user (external) application create an application under +../apps directory and steps 1. - 3. The last 4. step is not needed, as, +all applications under ../apps becomes a part of the build process. diff --git a/apps/exec_nuttapp.c b/apps/exec_nuttapp.c new file mode 100644 index 000000000..658cbf07f --- /dev/null +++ b/apps/exec_nuttapp.c @@ -0,0 +1,117 @@ +/**************************************************************************** + * drivers/sbin/exec_nuttapp.c + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * 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. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +#include +#include + + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +/* Load builtin function prototypes */ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +#include "exec_nuttapp_proto.h" + +static const struct nuttapp_s nuttapps[] = { +# include "exec_nuttapp_list.h" + {.name=NULL} +}; + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + + +/**************************************************************************** + * Private Data + ****************************************************************************/ + + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int exec_nuttapp(FAR const char *appname, FAR const char *argv[]) +{ + int i, ret = ERROR; + + // Not sure what to do with exports and nexports ... as found in exec + // FAR const struct symtab_s *exports, int nexports + // so they are ommited in the args list. + + for (i=0; nuttapps[i].name; i++) + { + if ( !strcmp(nuttapps[i].name, appname) ) + { +#ifndef CONFIG_CUSTOM_STACK + ret = task_create(nuttapps[i].name, nuttapps[i].priority, + nuttapps[i].stacksize, nuttapps[i].main, &argv[1]); +#else + ret = task_create(nuttapps[i].name, nuttapps[i].priority, nuttapps[i].main, &argv[1]); +#endif + return ret; + } + } + errno = ENOENT; + return ret; +} diff --git a/apps/exec_nuttapp_list.h b/apps/exec_nuttapp_list.h new file mode 100644 index 000000000..e8e4424ad --- /dev/null +++ b/apps/exec_nuttapp_list.h @@ -0,0 +1,2 @@ +/* List of application requirements, generated during make depend. */ +{ .name = "hello", .priority = SCHED_PRIORITY_DEFAULT, .stacksize = 768, .main = hello_main }, diff --git a/apps/exec_nuttapp_proto.h b/apps/exec_nuttapp_proto.h new file mode 100644 index 000000000..2c9c65ec9 --- /dev/null +++ b/apps/exec_nuttapp_proto.h @@ -0,0 +1,2 @@ +/* List of application entry points, generated during make depend. */ +EXTERN int hello_main(int argc, char *argv[]); diff --git a/apps/hello/Makefile b/apps/hello/Makefile new file mode 100644 index 000000000..f4267cd4d --- /dev/null +++ b/apps/hello/Makefile @@ -0,0 +1,103 @@ +############################################################################ +# Makefile +# +# Copyright (C) 2011 Uros Platise. All rights reserved. +# Author: Uros Platise +# Gregory Nutt +# +# 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. +# +############################################################################ + +# TODO, this makefile should run make under the app dirs, instead of +# sourcing the Make.defs! + +-include $(TOPDIR)/Make.defs + +ifeq ($(WINTOOL),y) +INCDIROPT = -w +endif + +# Hello Application +# TODO: appname can be automatically extracted from the directory name + +APPNAME = hello +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 768 + +ASRCS = +CSRCS = hello.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +BIN = ../libapps$(LIBEXT) + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +$(BIN): $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $@, $${obj}); \ + done ; ) + @touch .built + +.built: $(BIN) + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) \ + $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + echo "{ .name = \""$(APPNAME)"\", .priority = "$(PRIORITY)", .stacksize = "$(STACKSIZE)", .main = "$(APPNAME)"_main }," >> ../exec_nuttapp_list.h + echo "EXTERN int "$(APPNAME)"_main(int argc, char *argv[]);" >> ../exec_nuttapp_proto.h + +# Register application +depend: .depend + +clean: + @rm -f $(BIN) *.o *~ .*.swp .built + $(call CLEAN) + +distclean: clean + @rm -f Make.dep .depend + +-include Make.dep diff --git a/apps/hello/hello.c b/apps/hello/hello.c new file mode 100644 index 000000000..d7818d351 --- /dev/null +++ b/apps/hello/hello.c @@ -0,0 +1,47 @@ +/**************************************************************************** + * hello/hello.c + * + * Copyright (C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * 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. + * + ****************************************************************************/ + +#include + + +/** Example of a standalone application + */ +int hello_main(int argc, char *argv[]) +{ + int i; + printf("Hello Builtin Application\nFound argc=%d arguments and are as follows:\n", argc); + for (i=0; i argument. Otherwise argv[0] +# will be noname. +# +# Include builtin NuttX application (disabling this option will +# exclude all of the apps found under the nuttx/apps directory, but +# not the apps found under the ../apps directory unless _APPS_USER=n. +CONFIG_BUILTIN_APPS_NUTTX=y + +# Individual selection of built-in applications: +CONFIG_BUILTIN_APPS_HELLO=y + +# Include user (external) applications located under ../apps directory? +CONFIG_BUILTIN_APPS_USER=y + +# Invoke the following application after NuttX starts +# (enter app name, as: hello) +CONFIG_BUILTIN_APP_START= + +# CONFIG_EXAMPLES_NSH_BUILTIN_APPS - Support for running the builtin +# apps from command line. See apps/README for more information. +# +CONFIG_EXAMPLES_NSH_BUILTIN_APPS=y + +# +######################################################################## diff --git a/nuttx/examples/nsh/nsh_main.c b/nuttx/examples/nsh/nsh_main.c index 9981ad073..a13c6dae0 100644 --- a/nuttx/examples/nsh/nsh_main.c +++ b/nuttx/examples/nsh/nsh_main.c @@ -55,6 +55,10 @@ # include #endif +#ifdef CONFIG_EXAMPLES_NSH_BUILTIN_APPS +# include +#endif + #include "nsh.h" /**************************************************************************** @@ -487,6 +491,35 @@ static int nsh_execute(FAR struct nsh_vtbl_s *vtbl, int argc, char *argv[]) } } +#ifdef CONFIG_EXAMPLES_NSH_BUILTIN_APPS + if (handler == cmd_unrecognized) + { + /* Try to find command within pre-built application list. */ + + if ((ret = exec_nuttapp(cmd, argv)) < 0) + { + if (errno != ENOENT) + { + return -errno; + } + } + else + { + /* Is the background mode or foreground mode desired? */ +#if 0 + if (argc > 1 && strcmp(argv[argc-1], "&") == 0) + { + } + else + { + waitpid(ret, ); + } +#endif + return ret; + } + } +#endif + ret = handler(vtbl, argc, argv); return ret; } diff --git a/nuttx/include/nuttx/nuttapp.h b/nuttx/include/nuttx/nuttapp.h new file mode 100644 index 000000000..a8b6e8397 --- /dev/null +++ b/nuttx/include/nuttx/nuttapp.h @@ -0,0 +1,123 @@ +/**************************************************************************** + * include/nuttx/nuttapp.h + * + * Copyright(C) 2011 Uros Platise. All rights reserved. + * Author: Uros Platise + * + * 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 __NUTTX_NUTTAPP_H +#define __NUTTX_NUTTAPP_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct nuttapp_s +{ + const char *name; /* Invocation name and as seen under /sbin/ */ + int priority; /* Use: SCHED_PRIORITY_DEFAULT */ + int stacksize; /* Desired stack size */ + main_t main; /* Entry point: main(int argc, char *argv[]) */ +}; + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: execute builtin NuttX application + * + * Description: + * Executes builtin application registerred during compile time. + * New application is run in a separate task context (and thread). + * + * Input Parameter: + * filename - Name of the linked-in binary to be started. + * argv - Argument list + * + * Returned Value: + * This is an end-user function, so it follows the normal convention: + * Returns the PID of the exec'ed module. On failure, it.returns + * -1 (ERROR) and sets errno appropriately. + * + * Implementation within drivers/bchsbin + ****************************************************************************/ + +EXTERN int exec_nuttapp(FAR const char *appname, FAR const char *argv[]); + +/**************************************************************************** + * Name: execute a nutt shell command + * + * Description: + * Invokes an application that is either: + * - invokes a nsh script or directly invoke: + * - system application list, registerred via XXXX + * - resides in a file system compiled/linked in NXFLAT model + * - resides in a non-executable file-system, which is loaded + * into the memory first and then executed. + * + * Input Parameter: + * Sheel command. + * + * Returned Value: + * Zero on success or -1 on error with errno set. + * + * TODO: move this command to the stdlib.h (?) and + * merge implementation with the nuttshell sh command + ****************************************************************************/ + +EXTERN FAR int system(const char *command); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif +#endif /* __NUTTX_NUTAPP_H */ diff --git a/nuttx/sched/sched_waitpid.c b/nuttx/sched/sched_waitpid.c index 6e544f2eb..a1af343e1 100644 --- a/nuttx/sched/sched_waitpid.c +++ b/nuttx/sched/sched_waitpid.c @@ -195,12 +195,6 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) /* None of the options are supported */ #ifdef CONFIG_DEBUG - if (stat_loc == NULL) - { - err = EINVAL; - goto errout_with_errno; - } - if (options != 0) { err = ENOSYS; @@ -214,7 +208,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options) * others? */ - if (tcb->stat_loc == NULL) + if (stat_loc != NULL && tcb->stat_loc == NULL) { tcb->stat_loc = stat_loc; mystat = true; -- cgit v1.2.3