Rename namedapp as simply builtin

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5454 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-12-23 20:22:41 +00:00
parent ee7d4f64c1
commit 88d3058222
17 changed files with 100 additions and 100 deletions

View File

@ -439,4 +439,5 @@
* Makefiles: Removed dependency of distclean on clean in most top-level
files. It makes sense for 'leaf' Makefiles to have this dependency,
but it does not make sense for upper-level Makefiles.
* namedapp/: Renamed to builtins in preparation for another change.

View File

@ -3,8 +3,8 @@
# see misc/tools/kconfig-language.txt.
#
menu "Named Applications"
source "$APPSDIR/namedapp/Kconfig"
menu "Built-In Applications"
source "$APPSDIR/builtin/Kconfig"
endmenu
menu "Examples"

View File

@ -36,6 +36,6 @@
define REGISTER
@echo "Register: $1"
@echo "{ \"$1\", $2, $3, $4 }," >> "$(APPDIR)/namedapp/namedapp_list.h"
@echo "EXTERN int $4(int argc, char *argv[]);" >> "$(APPDIR)/namedapp/namedapp_proto.h"
@echo "{ \"$1\", $2, $3, $4 }," >> "$(APPDIR)/builtin/builtin_list.h"
@echo "EXTERN int $4(int argc, char *argv[]);" >> "$(APPDIR)/builtin/builtin_proto.h"
endef

View File

@ -44,11 +44,11 @@ APPDIR = ${shell pwd}
# action. It is created by the configured appconfig file (a copy of which
# appears in this directory as .config)
# SUBDIRS is the list of all directories containing Makefiles. It is used
# only for cleaning. namedapp must always be the first in the list. This
# only for cleaning. builtin must always be the first in the list. This
# list can be extended by the .config file as well.
CONFIGURED_APPS =
SUBDIRS = examples graphics interpreters modbus namedapp nshlib netutils system
SUBDIRS = examples graphics interpreters modbus builtin nshlib netutils system
# There are two different mechanisms for obtaining the list of configured
# directories:
@ -69,9 +69,9 @@ SUBDIRS = examples graphics interpreters modbus namedapp nshlib netutils system
ifeq ($(CONFIG_NUTTX_NEWCONFIG),y)
# namedapp/Make.defs must be included first
# builtin/Make.defs must be included first
include namedapp/Make.defs
include builtin/Make.defs
include examples/Make.defs
include graphics/Make.defs
include interpreters/Make.defs
@ -82,7 +82,7 @@ include system/Make.defs
# INSTALLED_APPS is the list of currently available application directories. It
# is the same as CONFIGURED_APPS, but filtered to exclude any non-existent
# application directory. namedapp is always in the list of applications to be
# application directory. builtin is always in the list of applications to be
# built.
INSTALLED_APPS =
@ -94,10 +94,10 @@ else
# INSTALLED_APPS is the list of currently available application directories. It
# is the same as CONFIGURED_APPS, but filtered to exclude any non-existent
# application directory. namedapp is always in the list of applications to be
# application directory. builtin is always in the list of applications to be
# built.
INSTALLED_APPS = namedapp
INSTALLED_APPS = builtin
endif
# Create the list of available applications (INSTALLED_APPS)

View File

@ -6,12 +6,12 @@ Contents
General
Directory Location
Named Applications
Named Startup main() function
Built-In Applications
Built-In Startup main() function
NuttShell (NSH) Built-In Commands
Synchronous Built-In Commands
Application Configuration File
Example Named Application
Example Built-In Application
Building NuttX with Board-Specific Pieces Outside the Source Tree
General
@ -47,14 +47,14 @@ ways to do that:
path to the application directory on the configuration command line
like: ./configure.sh -a <app-dir> <board-name>/<config-name>
Named Applications
------------------
Built-In Applications
---------------------
NuttX also supports applications that can be started using a name string.
In this case, application entry points with their requirements are gathered
together in two files:
- namedapp/namedapp_proto.h Entry points, prototype function
- namedapp/namedapp_list.h Application specific information and requirements
- builtin/builtin_proto.h Entry points, prototype function
- builtin/builtin_list.h Application specific information and requirements
The build occurs in several phases as different build targets are executed:
(1) context, (2) depend, and (3) default (all). Application information is
@ -62,18 +62,18 @@ collected during the make context build phase.
To execute an application function:
exec_namedapp() is defined in the nuttx/include/apps/apps.h
exec_builtin() is defined in the nuttx/include/apps/apps.h
NuttShell (NSH) Built-In Commands
---------------------------------
One use of named applications is to provide a way of invoking your custom
One use of builtin applications is to provide a way of invoking your custom
application through the NuttShell (NSH) command line. NSH will support
a seamless method invoking the applications, when the following option is
enabled in the NuttX configuration file:
CONFIG_NSH_BUILTIN_APPS=y
Applications registered in the apps/namedapp/namedapp_list.h file will then
Applications registered in the apps/builtin/builtin_list.h file will then
be accessible from the NSH command line. If you type 'help' at the NSH
prompt, you will see a list of the registered commands.
@ -109,9 +109,9 @@ CONFIGURED_APPS list like:
CONFIGURED_APPS += examples/hello system/poweroff
Named Start-Up main() function
Built-In Start-Up main() function
------------------------------
A named application can even be used as the main, start-up entry point
A builtin application can even be used as the main, start-up entry point
into your embedded software. When the user defines this option in
the NuttX configuration file:
@ -124,10 +124,10 @@ will call:
int hello_main(int argc, char *argv[])
Example Named Application
-------------------------
Example Built-In Application
----------------------------
An example application skeleton can be found under the examples/hello
sub-directory. This example shows how a named application can be added
sub-directory. This example shows how a builtin application can be added
to the project. One must define:
1. create sub-directory as: appname

View File

@ -3,13 +3,13 @@
# see misc/tools/kconfig-language.txt.
#
config NAMEDAPP
bool "Support named applications"
config BUILTIN
bool "Support Builtin Applications"
default n
---help---
Enable support for named applications. This features assigns a string
Enable support for builtin applications. This features assigns a string
name to an application. This feature is also the underlying requirement
to support built-in applications in the NuttShell (NSH).
if NAMEDAPP
if BUILTIN
endif

View File

@ -1,5 +1,5 @@
############################################################################
# apps/namedapps/Make.defs
# apps/builtin/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 2012 Gregory Nutt. All rights reserved.
@ -34,7 +34,7 @@
#
############################################################################
ifeq ($(CONFIG_NAMEDAPP),y)
CONFIGURED_APPS += namedapp
ifeq ($(CONFIG_BUILTIN),y)
CONFIGURED_APPS += builtin
endif

View File

@ -1,5 +1,5 @@
############################################################################
# apps/nshlib/Makefile
# apps/builtin/Makefile
#
# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
@ -42,7 +42,7 @@ include $(APPDIR)/Make.defs
# Source and object files
ASRCS =
CSRCS = namedapp.c exec_namedapp.c
CSRCS = builtin.c exec_builtin.c
ifeq ($(CONFIG_APPS_BINDIR),y)
CSRCS += binfs.c
@ -83,8 +83,8 @@ $(COBJS): %$(OBJEXT): %.c
$(Q) touch .built
.context:
@echo "/* List of application requirements, generated during make context. */" > namedapp_list.h
@echo "/* List of application entry points, generated during make context. */" > namedapp_proto.h
@echo "/* List of application requirements, generated during make context. */" > builtin_list.h
@echo "/* List of application entry points, generated during make context. */" > builtin_proto.h
$(Q) touch $@
context: .context
@ -103,8 +103,8 @@ distclean: clean
$(call DELFILE, .context)
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
$(call DELFILE, namedapp_list.h)
$(call DELFILE, namedapp_proto.h)
$(call DELFILE, builtin_list.h)
$(call DELFILE, builtin_proto.h)
-include Make.dep

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/namedapps/binfs.c
* apps/builtin/binfs.c
*
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -55,7 +55,7 @@
#include <nuttx/fs/fs.h>
#include <nuttx/fs/dirent.h>
#include "namedapp.h"
#include "builtin.h"
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_APPS_BINDIR)
@ -362,7 +362,7 @@ static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
/* Have we reached the end of the directory */
index = dir->u.binfs.fb_index;
if (namedapps[index].name == NULL)
if (builtins[index].name == NULL)
{
/* We signal the end of the directory by returning the
* special error -ENOENT
@ -375,9 +375,9 @@ static int binfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
{
/* Save the filename and file type */
fvdbg("Entry %d: \"%s\"\n", index, namedapps[index].name);
fvdbg("Entry %d: \"%s\"\n", index, builtins[index].name);
dir->fd_dir.d_type = DTYPE_FILE;
strncpy(dir->fd_dir.d_name, namedapps[index].name, NAME_MAX+1);
strncpy(dir->fd_dir.d_name, builtins[index].name, NAME_MAX+1);
/* The application list is terminated by an entry with a NULL name.
* Therefore, there is at least one more entry in the list.
@ -559,7 +559,7 @@ static int binfs_stat(struct inode *mountpt, const char *relpath, struct stat *b
{
/* Check if there is a file with this name. */
if (namedapp_isavail(relpath) < 0)
if (builtin_isavail(relpath) < 0)
{
ret = -ENOENT;
goto errout_with_semaphore;

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/namedaps/namedapp.c
* apps/builtin/builtin.c
*
* Copyright (C) 2011 Uros Platise. All rights reserved.
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
@ -62,11 +62,11 @@ extern "C" {
#define EXTERN extern
#endif
#include "namedapp_proto.h"
#include "builtin_proto.h"
const struct namedapp_s namedapps[] =
const struct builtin_s builtins[] =
{
# include "namedapp_list.h"
# include "builtin_list.h"
{ NULL, 0, 0, 0 }
};
@ -88,9 +88,9 @@ const struct namedapp_s namedapps[] =
* Public Functions
****************************************************************************/
int number_namedapps(void)
int number_builtins(void)
{
return sizeof(namedapps)/sizeof(struct namedapp_s) - 1;
return sizeof(builtins)/sizeof(struct builtin_s) - 1;
}

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/namedaps/namedapp.h
* apps/builtin/builtin.h
*
* Copyright (C) 2011 Uros Platise. All rights reserved.
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
@ -35,8 +35,8 @@
*
****************************************************************************/
#ifndef __APPS_NAMEDAPP_NAMEDAPP_H
#define __APPS_NAMEDAPP_NAMEDAPP_H
#ifndef __APPS_BUILTIN_BUILTIN_H
#define __APPS_BUILTIN_BUILTIN_H
/****************************************************************************
* Included Files
@ -53,7 +53,6 @@
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C" {
@ -61,18 +60,18 @@ extern "C" {
#define EXTERN extern
#endif
EXTERN const struct namedapp_s namedapps[];
EXTERN const struct builtin_s builtins[];
/****************************************************************************
* Public Functions
****************************************************************************/
EXTERN int number_namedapps(void);
EXTERN int number_builtins(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __APPS_NAMEDAPP_NAMEDAPP_H */
#endif /* __APPS_BUILTIN_BUILTIN_H */

View File

@ -1,5 +1,5 @@
/****************************************************************************
* apps/namedaps/exec_namedapp.c
* apps/builtin/exec_builtin.c
*
* Copyright (C) 2011 Uros Platise. All rights reserved.
* Author: Uros Platise <uros.platise@isotel.eu>
@ -49,7 +49,7 @@
#include <string.h>
#include <errno.h>
#include "namedapp.h"
#include "builtin.h"
/****************************************************************************
* Private Types
@ -72,26 +72,26 @@
****************************************************************************/
/****************************************************************************
* Name: namedapp_getname
* Name: builtin_getname
*
* Description:
* Return the name of the application at index in the table of named
* Return the name of the application at index in the table of builtin
* applications.
*
****************************************************************************/
const char *namedapp_getname(int index)
const char *builtin_getname(int index)
{
if (index < 0 || index >= number_namedapps())
if (index < 0 || index >= number_builtins())
{
return NULL;
}
return namedapps[index].name;
return builtins[index].name;
}
/****************************************************************************
* Name: namedapp_isavail
* Name: builtin_isavail
*
* Description:
* Return the index into the table of applications for the applicaiton with
@ -99,13 +99,13 @@ const char *namedapp_getname(int index)
*
****************************************************************************/
int namedapp_isavail(FAR const char *appname)
int builtin_isavail(FAR const char *appname)
{
int i;
for (i = 0; namedapps[i].name; i++)
for (i = 0; builtins[i].name; i++)
{
if (!strcmp(namedapps[i].name, appname))
if (!strcmp(builtins[i].name, appname))
{
return i;
}
@ -116,39 +116,39 @@ int namedapp_isavail(FAR const char *appname)
}
/****************************************************************************
* Name: namedapp_isavail
* Name: builtin_isavail
*
* Description:
* Execute the application with name 'appname', providing the arguments
* in the argv[] array.
*
* Returned Value:
* On success, the task ID of the named application is returned. On
* On success, the task ID of the builtin application is returned. On
* failure, -1 (ERROR) is returned an the errno value is set appropriately.
*
****************************************************************************/
int exec_namedapp(FAR const char *appname, FAR const char **argv)
int exec_builtin(FAR const char *appname, FAR const char **argv)
{
pid_t pid;
int index;
/* Verify that an application with this name exists */
index = namedapp_isavail(appname);
index = builtin_isavail(appname);
if (index >= 0)
{
/* Disable pre-emption. This means that although we start the named
/* Disable pre-emption. This means that although we start the builtin
* application here, it will not actually run until pre-emption is
* re-enabled below.
*/
sched_lock();
/* Start the named application task */
/* Start the builtin application task */
pid = TASK_CREATE(namedapps[index].name, namedapps[index].priority,
namedapps[index].stacksize, namedapps[index].main,
pid = TASK_CREATE(builtins[index].name, builtins[index].priority,
builtins[index].stacksize, builtins[index].main,
(argv) ? &argv[1] : (const char **)NULL);
/* If robin robin scheduling is enabled, then set the scheduling policy
@ -165,11 +165,11 @@ int exec_namedapp(FAR const char *appname, FAR const char **argv)
* new task cannot yet have changed from its initial value.
*/
param.sched_priority = namedapps[index].priority;
param.sched_priority = builtins[index].priority;
sched_setscheduler(pid, SCHED_RR, &param);
}
#endif
/* Now let the named application run */
/* Now let the builtin application run */
sched_unlock();

View File

@ -52,7 +52,7 @@
* Public Types
****************************************************************************/
struct namedapp_s
struct builtin_s
{
const char *name; /* Invocation name and as seen under /sbin/ */
int priority; /* Use: SCHED_PRIORITY_DEFAULT */
@ -64,7 +64,7 @@ struct namedapp_s
* Public Data
****************************************************************************/
/* The "bindir" is file system that supports access to the named applications.
/* The "bindir" is file system that supports access to the builtin applications.
* It is typically mounted under /bin.
*/
@ -86,7 +86,7 @@ extern "C" {
#endif
/****************************************************************************
* Name: namedapp_isavail
* Name: builtin_isavail
*
* Description:
* Checks for availabiliy of application registerred during compile time.
@ -101,10 +101,10 @@ extern "C" {
*
****************************************************************************/
EXTERN int namedapp_isavail(FAR const char *appname);
EXTERN int builtin_isavail(FAR const char *appname);
/****************************************************************************
* Name: namedapp_getname
* Name: builtin_getname
*
* Description:
* Returns pointer to a name of built-in application pointed by the
@ -119,13 +119,13 @@ EXTERN int namedapp_isavail(FAR const char *appname);
*
****************************************************************************/
EXTERN const char *namedapp_getname(int index);
EXTERN const char *builtin_getname(int index);
/****************************************************************************
* Name: exec_namedapp
* Name: exec_builtin
*
* Description:
* Executes builtin named application registered during compile time.
* Executes builtin applications registered during 'make context' time.
* New application is run in a separate task context (and thread).
*
* Input Parameter:
@ -139,7 +139,7 @@ EXTERN const char *namedapp_getname(int index);
*
****************************************************************************/
EXTERN int exec_namedapp(FAR const char *appname, FAR const char **argv);
EXTERN int exec_builtin(FAR const char *appname, FAR const char **argv);
#undef EXTERN
#if defined(__cplusplus)

View File

@ -15,12 +15,12 @@ if NSH_LIBRARY
config NSH_BUILTIN_APPS
bool "Enable built-in applications"
default y
depends on NAMEDAPP
depends on BUILTIN
---help---
Support external registered, "named" applications that can be
Support external registered, "built-in" applications that can be
executed from the NSH command line (see apps/README.txt for
more information). This options requires support for named applications
(NAMEDAPP).
more information). This options requires support for builtin
applications (BUILTIN).
menu "Disable Individual commands"

View File

@ -945,7 +945,7 @@ NSH-Specific Configuration Settings
the configs/<board-name>/defconfig file:
* CONFIG_NSH_BUILTIN_APPS
Support external registered, "named" applications that can be
Support external registered, "builtin" applications that can be
executed from the NSH command line (see apps/README.txt for
more information).

View File

@ -90,7 +90,7 @@
* Attempt to execute the application task whose name is 'cmd'
*
* Returned Value:
* <0 If exec_namedapp() fails, then the negated errno value
* <0 If exec_builtin() fails, then the negated errno value
* is returned.
* -1 (ERROR) if the application task corresponding to 'cmd' could not
* be started (possibly because it doesn not exist).
@ -119,7 +119,7 @@ int nsh_execapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
* applications.
*/
ret = exec_namedapp(cmd, (FAR const char **)argv);
ret = exec_builtin(cmd, (FAR const char **)argv);
if (ret >= 0)
{
/* The application was successfully started (but still blocked because
@ -205,7 +205,7 @@ int nsh_execapp(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
sched_unlock();
/* If exec_namedapp() or waitpid() failed, then return the negated errno
/* If exec_builtin() or waitpid() failed, then return the negated errno
* value.
*/

View File

@ -605,7 +605,7 @@ static inline void help_builtins(FAR struct nsh_vtbl_s *vtbl)
/* List the set of available built-in commands */
nsh_output(vtbl, "\nBuiltin Apps:\n");
for (i = 0; (name = namedapp_getname(i)) != NULL; i++)
for (i = 0; (name = builtin_getname(i)) != NULL; i++)
{
nsh_output(vtbl, " %s\n", name);
}
@ -726,7 +726,7 @@ static int cmd_exit(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
* Exectue the command in argv[0]
*
* Returned Value:
* <0 If exec_namedapp() fails, then the negated errno value
* <0 If exec_builtin() fails, then the negated errno value
* is returned.
* -1 (ERRROR) if the command was unsuccessful
* 0 (OK) if the command was successful
@ -1439,13 +1439,13 @@ int nsh_parse(FAR struct nsh_vtbl_s *vtbl, char *cmdline)
}
/* Handle the case where the command is executed in background.
* However is app is to be started as namedapp new process will
* However is app is to be started as builtin new process will
* be created anyway, so skip this step. */
#ifndef CONFIG_NSH_DISABLEBG
if (vtbl->np.np_bg
#ifdef CONFIG_NSH_BUILTIN_APPS
&& namedapp_isavail(argv[0]) < 0
&& builtin_isavail(argv[0]) < 0
#endif
)
{