nshlib: Move symbol table initialization from nsh_main to nsh_initialize
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
0d210c3227
commit
8e460e7e19
@ -25,6 +25,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <sys/boardctl.h>
|
#include <sys/boardctl.h>
|
||||||
|
#include <nuttx/symtab.h>
|
||||||
|
|
||||||
#include "system/readline.h"
|
#include "system/readline.h"
|
||||||
#include "netutils/netinit.h"
|
#include "netutils/netinit.h"
|
||||||
@ -33,6 +34,32 @@
|
|||||||
#include "nsh.h"
|
#include "nsh.h"
|
||||||
#include "nsh_console.h"
|
#include "nsh_console.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Pre-processor Definitions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Symbol table is not needed if loadable binary modules are not supported */
|
||||||
|
|
||||||
|
#if !defined(CONFIG_LIBC_EXECFUNCS)
|
||||||
|
# undef CONFIG_SYSTEM_NSH_SYMTAB
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* boardctl() support is also required for application-space symbol table
|
||||||
|
* support.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if !defined(CONFIG_BOARDCTL) || !defined(CONFIG_BOARDCTL_APP_SYMTAB)
|
||||||
|
# undef CONFIG_SYSTEM_NSH_SYMTAB
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* If a symbol table is provided by board-specific logic, then we do not
|
||||||
|
* need to do anything from the application space.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
|
||||||
|
# undef CONFIG_SYSTEM_NSH_SYMTAB
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -46,6 +73,11 @@ static const struct extmatch_vtable_s g_nsh_extmatch =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSTEM_NSH_SYMTAB)
|
||||||
|
extern const struct symtab_s CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME[];
|
||||||
|
extern const int CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME;
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -68,6 +100,9 @@ static const struct extmatch_vtable_s g_nsh_extmatch =
|
|||||||
|
|
||||||
void nsh_initialize(void)
|
void nsh_initialize(void)
|
||||||
{
|
{
|
||||||
|
#if defined (CONFIG_SYSTEM_NSH_SYMTAB)
|
||||||
|
struct boardioc_symtab_s symdesc;
|
||||||
|
#endif
|
||||||
#if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
#if defined(CONFIG_NSH_ROMFSETC) && !defined(CONFIG_NSH_DISABLESCRIPT)
|
||||||
FAR struct console_stdio_s *pstate;
|
FAR struct console_stdio_s *pstate;
|
||||||
#endif
|
#endif
|
||||||
@ -94,6 +129,15 @@ void nsh_initialize(void)
|
|||||||
usbtrace_enable(TRACE_BITSET);
|
usbtrace_enable(TRACE_BITSET);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(CONFIG_SYSTEM_NSH_SYMTAB)
|
||||||
|
/* Make sure that we are using our symbol table */
|
||||||
|
|
||||||
|
symdesc.symtab = (FAR struct symtab_s *)CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME; /* Discard 'const' */
|
||||||
|
symdesc.nsymbols = CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME;
|
||||||
|
|
||||||
|
boardctl(BOARDIOC_APP_SYMTAB, (uintptr_t)&symdesc);
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_ARCHINIT
|
#ifdef CONFIG_NSH_ARCHINIT
|
||||||
/* Perform architecture-specific initialization (if configured) */
|
/* Perform architecture-specific initialization (if configured) */
|
||||||
|
|
||||||
|
@ -31,55 +31,18 @@
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#if defined(CONFIG_LIBC_EXECFUNCS)
|
|
||||||
# include <nuttx/symtab.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "nshlib/nshlib.h"
|
#include "nshlib/nshlib.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Symbol table is not needed if loadable binary modules are not supported */
|
|
||||||
|
|
||||||
#if !defined(CONFIG_LIBC_EXECFUNCS)
|
|
||||||
# undef CONFIG_SYSTEM_NSH_SYMTAB
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* boardctl() support is also required for application-space symbol table
|
|
||||||
* support.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if !defined(CONFIG_BOARDCTL) || !defined(CONFIG_BOARDCTL_APP_SYMTAB)
|
|
||||||
# undef CONFIG_SYSTEM_NSH_SYMTAB
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* If a symbol table is provided by board-specific logic, then we do not
|
|
||||||
* need to do anything from the application space.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef CONFIG_EXECFUNCS_HAVE_SYMTAB
|
|
||||||
# undef CONFIG_SYSTEM_NSH_SYMTAB
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The NSH telnet console requires networking support (and TCP/IP) */
|
/* The NSH telnet console requires networking support (and TCP/IP) */
|
||||||
|
|
||||||
#ifndef CONFIG_NET
|
#ifndef CONFIG_NET
|
||||||
# undef CONFIG_NSH_TELNET
|
# undef CONFIG_NSH_TELNET
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#if defined(CONFIG_SYSTEM_NSH_SYMTAB)
|
|
||||||
|
|
||||||
extern const struct symtab_s CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME[];
|
|
||||||
extern const int CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -96,9 +59,6 @@ extern const int CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME;
|
|||||||
|
|
||||||
int main(int argc, FAR char *argv[])
|
int main(int argc, FAR char *argv[])
|
||||||
{
|
{
|
||||||
#if defined (CONFIG_SYSTEM_NSH_SYMTAB)
|
|
||||||
struct boardioc_symtab_s symdesc;
|
|
||||||
#endif
|
|
||||||
struct sched_param param;
|
struct sched_param param;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
@ -113,15 +73,6 @@ int main(int argc, FAR char *argv[])
|
|||||||
sched_setparam(0, ¶m);
|
sched_setparam(0, ¶m);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_SYSTEM_NSH_SYMTAB)
|
|
||||||
/* Make sure that we are using our symbol table */
|
|
||||||
|
|
||||||
symdesc.symtab = (FAR struct symtab_s *)CONFIG_SYSTEM_NSH_SYMTAB_ARRAYNAME; /* Discard 'const' */
|
|
||||||
symdesc.nsymbols = CONFIG_SYSTEM_NSH_SYMTAB_COUNTNAME;
|
|
||||||
|
|
||||||
boardctl(BOARDIOC_APP_SYMTAB, (uintptr_t)&symdesc);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Initialize the NSH library */
|
/* Initialize the NSH library */
|
||||||
|
|
||||||
nsh_initialize();
|
nsh_initialize();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user