This commit moves shared builtin information out of binfmt/libbuiltin and into libs/libc/builtin where it can be shared. This should permit builtin application in the PROTECTED build where binfmt/libbuiltin is not available in user space.
Squashed commit of the following: Correct some additional compile-related issues. Move include/nuttx/binfmt/builtin.h to include/nuttx/lib/builtin.h. Move apps/builtin/lib_builtin_forindex.c to libs/libc/builtin/lib_builtin_forindex.c. Move binfmt/libbuiltin to libs/libc/builtin. There are calls made directly from apps/nshlib into this logic and hence, must be part of a library that can be shared between the OS and applications.
This commit is contained in:
parent
b3d609959c
commit
dd97fb991b
@ -4946,7 +4946,7 @@ Builtin Apps:
|
||||
|
||||
<p>
|
||||
<b>Built-In Application Utility Functions</b>.
|
||||
The utility functions exported by the builtin application logic are prototyped in <code>nuttx/include/nuttx/binfmt/builtin.h</code> and <code>apps/include/builtin.h</code>.
|
||||
The utility functions exported by the builtin application logic are prototyped in <code>nuttx/include/nuttx/lib/builtin.h</code> and <code>apps/include/builtin.h</code>.
|
||||
These utility functions include:
|
||||
</p>
|
||||
|
||||
|
@ -57,26 +57,6 @@ if ELF
|
||||
source binfmt/libelf/Kconfig
|
||||
endif
|
||||
|
||||
config BUILTIN
|
||||
bool "Support Builtin Applications"
|
||||
default n
|
||||
depends on (!BUILD_PROTECTED && !BUILD_KERNEL) || EXPERIMENTAL
|
||||
---help---
|
||||
Enable support for builtin applications. This features assigns a string
|
||||
name to an application and in addition if FS_BINFS is defined, retaining
|
||||
those names in a file system from which they can be executed. This feature
|
||||
is also the underlying requirement to support built-in applications in the
|
||||
NuttShell (NSH).
|
||||
|
||||
ISSUES: This feature is highly coupled with logic in the apps/
|
||||
sub-directory and, as a consequence, cannot be used in environments
|
||||
that do not include the standard NuttX apps/ nor in build
|
||||
configurations using BUILD_PROTECTED or BUILD_KERNEL.
|
||||
|
||||
if BUILTIN
|
||||
source binfmt/libbuiltin/Kconfig
|
||||
endif
|
||||
|
||||
config BINFMT_PCODE
|
||||
bool "Support P-Code Applications"
|
||||
default n
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# binfmt/Makefile
|
||||
#
|
||||
# Copyright (C) 2007-2009, 2012-2016, 2018 Gregory Nutt. All rights
|
||||
# Copyright (C) 2007-2009, 2012-2016, 2018-2019 Gregory Nutt. All rights
|
||||
# reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
@ -57,6 +57,12 @@ ifeq ($(CONFIG_LIBC_EXECFUNCS),y)
|
||||
BINFMT_CSRCS += binfmt_execsymtab.c
|
||||
endif
|
||||
|
||||
# Builtin application interfaces
|
||||
|
||||
ifeq ($(CONFIG_BUILTIN),y)
|
||||
CSRCS += builtin.c
|
||||
endif
|
||||
|
||||
# Add configured binary modules
|
||||
|
||||
VPATH =
|
||||
@ -65,7 +71,6 @@ DEPPATH = --dep-path .
|
||||
|
||||
include libnxflat$(DELIM)Make.defs
|
||||
include libelf$(DELIM)Make.defs
|
||||
include libbuiltin$(DELIM)Make.defs
|
||||
include libpcode$(DELIM)Make.defs
|
||||
|
||||
BINFMT_AOBJS = $(BINFMT_ASRCS:.S=$(OBJEXT))
|
||||
|
@ -132,6 +132,39 @@ void binfmt_freeargv(FAR struct binary_s *bin);
|
||||
# define binfmt_freeargv(bin)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: builtin_initialize
|
||||
*
|
||||
* Description:
|
||||
* In order to use the builtin binary format, this function must be called
|
||||
* during system initialize to register the builtin binary format.
|
||||
*
|
||||
* Returned Value:
|
||||
* This is a NuttX internal function so it follows the convention that
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_FS_BINFS) && defined(HAVE_BUILTIN_CONTEXT)
|
||||
int builtin_initialize(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: builtin_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* Unregister the builtin binary loader
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_FS_BINFS) && defined(HAVE_BUILTIN_CONTEXT)
|
||||
void builtin_uninitialize(void);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
@ -40,10 +40,10 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
#include <nuttx/binfmt/builtin.h>
|
||||
#include <nuttx/binfmt/elf.h>
|
||||
#include <nuttx/binfmt/pcode.h>
|
||||
#include <nuttx/binfmt/nxflat.h>
|
||||
#include <nuttx/lib/builtin.h>
|
||||
|
||||
#ifndef CONFIG_BINFMT_DISABLE
|
||||
|
||||
@ -63,7 +63,7 @@ void binfmt_initialize(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef CONFIG_FS_BINFS
|
||||
#if defined(CONFIG_FS_BINFS) && defined(HAVE_BUILTIN_CONTEXT)
|
||||
ret = builtin_initialize();
|
||||
if (ret < 0)
|
||||
{
|
||||
|
@ -51,13 +51,9 @@
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/binfmt/binfmt.h>
|
||||
#include <nuttx/binfmt/builtin.h>
|
||||
#include <nuttx/lib/builtin.h>
|
||||
|
||||
#ifdef CONFIG_BUILTIN
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
#ifdef HAVE_BUILTIN_CONTEXT
|
||||
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
@ -197,5 +193,5 @@ void builtin_uninitialize(void)
|
||||
(void)unregister_binfmt(&g_builtin_binfmt);
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BUILTIN */
|
||||
#endif /* HAVE_BUILTIN_CONTEXT */
|
||||
|
||||
|
@ -56,7 +56,7 @@
|
||||
#include <nuttx/fs/binfs.h>
|
||||
#include <nuttx/fs/dirent.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/binfmt/builtin.h>
|
||||
#include <nuttx/lib/builtin.h>
|
||||
|
||||
#if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_BINFS)
|
||||
|
||||
|
@ -56,7 +56,6 @@
|
||||
#include <nuttx/fs/fs.h>
|
||||
#include <nuttx/fs/dirent.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/binfmt/builtin.h>
|
||||
|
||||
#include "cromfs.h"
|
||||
|
||||
|
@ -60,7 +60,6 @@
|
||||
#include <nuttx/fs/unionfs.h>
|
||||
#include <nuttx/fs/dirent.h>
|
||||
#include <nuttx/fs/ioctl.h>
|
||||
#include <nuttx/binfmt/builtin.h>
|
||||
|
||||
#include "inode/inode.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/binfmt/builtin.h
|
||||
* include/nuttx/lib/builtin.h
|
||||
*
|
||||
* Originally by:
|
||||
*
|
||||
@ -8,7 +8,7 @@
|
||||
*
|
||||
* With subsequent updates, modifications, and general maintenance by:
|
||||
*
|
||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012-2013, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -40,8 +40,8 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_BINFMT_BUILTIN_H
|
||||
#define __INCLUDE_NUTTX_BINFMT_BUILTIN_H
|
||||
#ifndef __INCLUDE_NUTTX_LIB_BUILTIN_H
|
||||
#define __INCLUDE_NUTTX_LIB_BUILTIN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
@ -50,6 +50,21 @@
|
||||
#include <nuttx/config.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef CONFIG_BUILTIN
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* This logic is not usable in the KERNEL build and, furthermore, it has no
|
||||
* meaning in __KERNEL__ blob of a protected build.
|
||||
*/
|
||||
|
||||
#if (defined(CONFIG_BUILD_FLAT) || \
|
||||
(defined(CONFIG_BUILD_PROTECTED )&& !__KERNEL__))
|
||||
# define HAVE_BUILTIN_CONTEXT
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@ -74,39 +89,15 @@ extern "C"
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* These must be provided the application layer */
|
||||
|
||||
EXTERN const struct builtin_s g_builtins[];
|
||||
EXTERN const int g_builtin_count;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: builtin_initialize
|
||||
*
|
||||
* Description:
|
||||
* In order to use the builtin binary format, this function must be called
|
||||
* during system initialize to register the builtin binary format.
|
||||
*
|
||||
* Returned Value:
|
||||
* This is a NuttX internal function so it follows the convention that
|
||||
* 0 (OK) is returned on success and a negated errno is returned on
|
||||
* failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int builtin_initialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: builtin_uninitialize
|
||||
*
|
||||
* Description:
|
||||
* Unregister the builtin binary loader
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void builtin_uninitialize(void);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: builtin_isavail
|
||||
*
|
||||
@ -168,4 +159,5 @@ FAR const struct builtin_s *builtin_for_index(int index);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_BINFMT_BUILTIN_H */
|
||||
#endif /* CONFIG_BUILTIN */
|
||||
#endif /* __INCLUDE_NUTTX_LIB_BUILTIN_H */
|
@ -27,3 +27,4 @@ source libs/libc/misc/Kconfig
|
||||
source libs/libc/wqueue/Kconfig
|
||||
source libs/libc/hex2bin/Kconfig
|
||||
source libs/libc/userfs/Kconfig
|
||||
source libs/libc/builtins/Kconfig
|
||||
|
@ -1,7 +1,7 @@
|
||||
############################################################################
|
||||
# libs/libc/Makefile
|
||||
#
|
||||
# Copyright (C) 2007-2014, 2016-2017 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2007-2014, 2016-2017, 2019 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -55,6 +55,7 @@ VPATH := .
|
||||
|
||||
include aio/Make.defs
|
||||
include audio/Make.defs
|
||||
include builtin/Make.defs
|
||||
include dirent/Make.defs
|
||||
include dlfcn/Make.defs
|
||||
include endian/Make.defs
|
||||
|
@ -29,6 +29,7 @@ in the include/ directory provides the prototype for library functions. So
|
||||
we have:
|
||||
|
||||
audio - This part of the audio system: nuttx/audio/audio.h
|
||||
builtin - Support for builtin applications. Used by nuttx/binfmt and NSH.
|
||||
dlfcn - dlfcn.h
|
||||
endian - endian.h
|
||||
hex2bin - hex2bin.h
|
||||
|
15
libs/libc/builtin/Kconfig
Normal file
15
libs/libc/builtin/Kconfig
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||
#
|
||||
|
||||
config BUILTIN
|
||||
bool "Support Builtin Applications"
|
||||
default n
|
||||
depends on !BUILD_KERNEL || EXPERIMENTAL
|
||||
---help---
|
||||
Enable support for builtin applications. This features assigns a string
|
||||
name to an application and in addition if FS_BINFS is defined, retaining
|
||||
those names in a file system from which they can be executed. This feature
|
||||
is also the underlying requirement to support built-in applications in the
|
||||
NuttShell (NSH).
|
@ -35,18 +35,13 @@
|
||||
|
||||
ifeq ($(CONFIG_BUILTIN),y)
|
||||
|
||||
# Builtin application interfaces
|
||||
# Builtin library files
|
||||
|
||||
BINFMT_CSRCS += builtin.c
|
||||
CSRCS += lib_builtin_getname.c lib_builtin_isavail.c lib_builtin_forindex.c
|
||||
|
||||
# Builtin library interfaces
|
||||
# Hook the builtin subdirectory into the build
|
||||
|
||||
BINFMT_CSRCS += libbuiltin_getname.c libbuiltin_isavail.c
|
||||
|
||||
# Hook the libbuiltin subdirectory into the build
|
||||
|
||||
VPATH += libbuiltin
|
||||
SUBDIRS += libbuiltin
|
||||
DEPPATH += --dep-path libbuiltin
|
||||
DEPPATH += --dep-path builtin
|
||||
VPATH += builtin
|
||||
|
||||
endif
|
62
libs/libc/builtin/lib_builtin_forindex.c
Normal file
62
libs/libc/builtin/lib_builtin_forindex.c
Normal file
@ -0,0 +1,62 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/builtin/lib_builtin_forindex.c
|
||||
*
|
||||
* Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||
* Copyright (C) 2011, 2016, 2019 Gregory Nutt. All rights reserved.
|
||||
* Authors: Uros Platise <uros.platise@isotel.eu>
|
||||
* Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <nuttx/lib/builtin.h>
|
||||
|
||||
#ifdef HAVE_BUILTIN_CONTEXT
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
FAR const struct builtin_s *builtin_for_index(int index)
|
||||
{
|
||||
if (index < g_builtin_count)
|
||||
{
|
||||
return &g_builtins[index];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* HAVE_BUILTIN_CONTEXT */
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libbuiltin/libbuiltin_getname.c
|
||||
* libs/libc/builtin/libbuiltin_getname.c
|
||||
*
|
||||
* Originally by:
|
||||
*
|
||||
@ -8,7 +8,7 @@
|
||||
*
|
||||
* With subsequent updates, modifications, and general maintenance by:
|
||||
*
|
||||
* Copyright (C) 2012-2013 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2012-2013, 2019 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -46,7 +46,9 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <nuttx/binfmt/builtin.h>
|
||||
#include <nuttx/lib/builtin.h>
|
||||
|
||||
#ifdef HAVE_BUILTIN_CONTEXT
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -74,3 +76,5 @@ FAR const char *builtin_getname(int index)
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif /* HAVE_BUILTIN_CONTEXT */
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* binfmt/libbuiltin/libbuiltin_isavail.c
|
||||
* libs/libc/builtin/lib_builtin_isavail.c
|
||||
*
|
||||
* Originally by:
|
||||
*
|
||||
@ -50,7 +50,9 @@
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/binfmt/builtin.h>
|
||||
#include <nuttx/lib/builtin.h>
|
||||
|
||||
#ifdef HAVE_BUILTIN_CONTEXT
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
@ -81,3 +83,5 @@ int builtin_isavail(FAR const char *appname)
|
||||
set_errno(ENOENT);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
#endif /* HAVE_BUILTIN_CONTEXT */
|
Loading…
Reference in New Issue
Block a user