mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
boards/boardctl.c and libs/libc/builtin: The BINFS file system uses the same builtin library and builtin arrays as does NSH. The builtin arrays are simple name-value pairs that map builtin function names with the user-space entry point. In the FLAT build, the builtin arrays are available everywhere via the backdoor left open by the FLAT address space. In the PROTECTED build, however, the kernel must maintain its own reference to the user-space builtin array. This commits adds those kernel globals and a new boardctl(BOARDIOC_BUILTINS) that can be used by applications to the provide the builtin list reference to the kernel.
This commit is contained in:
@@ -38,6 +38,7 @@ ifeq ($(CONFIG_BUILTIN),y)
|
||||
# Builtin library files
|
||||
|
||||
CSRCS += lib_builtin_getname.c lib_builtin_isavail.c lib_builtin_forindex.c
|
||||
CSRCS += lib_builtin_setlist.c
|
||||
|
||||
# Hook the builtin subdirectory into the build
|
||||
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/builtin/libbuiltin_getname.c
|
||||
*
|
||||
* Originally by:
|
||||
*
|
||||
* Copyright (C) 2011 Uros Platise. All rights reserved.
|
||||
* Author: Uros Platise <uros.platise@isotel.eu>
|
||||
*
|
||||
* With subsequent updates, modifications, and general maintenance by:
|
||||
*
|
||||
* 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
|
||||
* 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>
|
||||
|
||||
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_FS_BINFS) && \
|
||||
defined(__KERNEL__)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct builtin_s * const *g_builtins;
|
||||
int g_builtin_count;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: builtin_setlist
|
||||
*
|
||||
* Description:
|
||||
* Saves the user-space list of built-in applications for use by BINFS in
|
||||
* protected mode. Normally this is small set of globals provided by
|
||||
* user-space logic. It provides name-value pairs for associating
|
||||
* built-in application names with user-space entry point addresses.
|
||||
* These globals are only needed for use by BINFS which executes built-in
|
||||
* applications from kernel-space in PROTECTED mode. In the FLAT build,
|
||||
* the user space globals are readily available. (BINFS is not
|
||||
* supportable in KERNEL mode since user-space address have no general
|
||||
* meaning that configuration).
|
||||
*
|
||||
* Input Parameters:
|
||||
* builtins - The list of built-in functions. Each entry is a name-value
|
||||
* pair that maps a builtin function name to its user-space
|
||||
* entry point address.
|
||||
* count - The number of name-value pairs in the builtin list.
|
||||
*
|
||||
* Returned Value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void builtin_setlist(FAR struct builtin_s * const *builtins, int count)
|
||||
{
|
||||
g_builtins = builtins;
|
||||
g_builtin_count = builtins;
|
||||
}
|
||||
|
||||
#endif /* CONFIG_BUILD_PROTECTED && CONFIG_FS_BINFS && __KERNEL__ */
|
||||
Reference in New Issue
Block a user