2012-02-05 18:36:13 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* apps/nshlib/nsh_init.c
|
|
|
|
*
|
2015-07-28 15:17:50 +02:00
|
|
|
* Copyright (C) 2007-2012, 2014-2015 Gregory Nutt. All rights reserved.
|
2012-02-05 18:36:13 +01:00
|
|
|
* 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>
|
|
|
|
|
2015-03-31 20:14:16 +02:00
|
|
|
#include <sys/boardctl.h>
|
2015-07-30 20:11:58 +02:00
|
|
|
|
2016-07-11 18:11:18 +02:00
|
|
|
#include "system/readline.h"
|
2019-04-29 18:22:56 +02:00
|
|
|
#include "netutils/netinit.h"
|
2016-07-11 18:11:18 +02:00
|
|
|
#include "nshlib/nshlib.h"
|
2014-01-14 20:30:22 +01:00
|
|
|
|
2012-02-05 18:36:13 +01:00
|
|
|
#include "nsh.h"
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-07-30 20:11:58 +02:00
|
|
|
#if defined(CONFIG_NSH_READLINE) && defined(CONFIG_READLINE_TABCOMPLETION) && \
|
|
|
|
defined(CONFIG_READLINE_HAVE_EXTMATCH)
|
|
|
|
static const struct extmatch_vtable_s g_nsh_extmatch =
|
|
|
|
{
|
|
|
|
nsh_extmatch_count, /* count_matches */
|
|
|
|
nsh_extmatch_getname /* getname */
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2012-02-05 18:36:13 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: nsh_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* This nterfaces is used to initialize the NuttShell (NSH).
|
|
|
|
* nsh_initialize() should be called one during application start-up prior
|
|
|
|
* to executing either nsh_consolemain() or nsh_telnetstart().
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2015-04-07 20:18:08 +02:00
|
|
|
|
2012-02-05 18:36:13 +01:00
|
|
|
void nsh_initialize(void)
|
|
|
|
{
|
2015-11-01 09:41:01 +01:00
|
|
|
#if defined(CONFIG_NSH_READLINE) && defined(CONFIG_READLINE_TABCOMPLETION)
|
|
|
|
/* Configure the NSH prompt */
|
|
|
|
|
2020-01-02 13:09:50 +01:00
|
|
|
readline_prompt(g_nshprompt);
|
2015-11-01 09:41:01 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_READLINE_HAVE_EXTMATCH
|
|
|
|
/* Set up for tab completion on NSH commands */
|
|
|
|
|
2020-01-02 13:09:50 +01:00
|
|
|
readline_extmatch(&g_nsh_extmatch);
|
2015-11-01 09:41:01 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2012-02-05 18:36:13 +01:00
|
|
|
/* Mount the /etc filesystem */
|
|
|
|
|
|
|
|
(void)nsh_romfsetc();
|
|
|
|
|
2015-03-31 20:14:16 +02:00
|
|
|
#ifdef CONFIG_NSH_ARCHINIT
|
|
|
|
/* Perform architecture-specific initialization (if configured) */
|
2012-02-05 18:36:13 +01:00
|
|
|
|
2020-01-02 13:09:50 +01:00
|
|
|
boardctl(BOARDIOC_INIT, 0);
|
2015-03-31 20:14:16 +02:00
|
|
|
#endif
|
2012-02-05 18:36:13 +01:00
|
|
|
|
2019-04-29 18:22:56 +02:00
|
|
|
#ifdef CONFIG_NSH_NETINIT
|
2012-02-05 18:36:13 +01:00
|
|
|
/* Bring up the network */
|
|
|
|
|
2020-01-02 13:09:50 +01:00
|
|
|
netinit_bringup();
|
2019-04-29 18:22:56 +02:00
|
|
|
#endif
|
2012-02-05 18:36:13 +01:00
|
|
|
}
|