You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/08/17 18:52:37 UTC
[incubator-nuttx] branch master updated: sched: Support config the
argument passed to init
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new d43bf77 sched: Support config the argument passed to init
d43bf77 is described below
commit d43bf7717e9d2ec3feaa7e7b5c24dd6ed09ca9b4
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Mon Aug 17 02:05:58 2020 +0800
sched: Support config the argument passed to init
it is useful to pass the nonempty argument to change the init task behaviour
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
Change-Id: I684e9c76b9eac54404d0e4e63ab78e51e039c9a8
---
sched/Kconfig | 21 ++++++++++++-------
sched/init/nx_bringup.c | 55 ++++++++++++++++++++-----------------------------
tools/cfgdefine.c | 19 +++++++++--------
3 files changed, 46 insertions(+), 49 deletions(-)
diff --git a/sched/Kconfig b/sched/Kconfig
index 437451a..dcb3911 100644
--- a/sched/Kconfig
+++ b/sched/Kconfig
@@ -329,6 +329,13 @@ config INIT_FILEPATH
endchoice # Initialization task
+config INIT_ARGS
+ string "Application argument list"
+ depends on !INIT_NONE
+ ---help---
+ The argument list for user applications. e.g.:
+ "\"arg1\",\"arg2\",\"arg3\""
+
if INIT_ENTRYPOINT
config USER_ENTRYPOINT
string "Application entry point"
@@ -338,6 +345,13 @@ config USER_ENTRYPOINT
applications this is of the form 'app_main' where 'app' is the application
name. If not defined, USER_ENTRYPOINT defaults to "main".
+config USERMAIN_STACKSIZE
+ int "Main thread stack size"
+ default DEFAULT_TASK_STACKSIZE
+ ---help---
+ The size of the stack to allocate for the user initialization thread
+ that is started as soon as the OS completes its initialization.
+
config USERMAIN_PRIORITY
int "init thread priority"
default 100
@@ -1741,13 +1755,6 @@ config IDLETHREAD_STACKSIZE
point where start-up application is spawned, and (2) there after is the
IDLE thread that executes only when there is no other thread ready to run.
-config USERMAIN_STACKSIZE
- int "Main thread stack size"
- default DEFAULT_TASK_STACKSIZE
- ---help---
- The size of the stack to allocate for the user initialization thread
- that is started as soon as the OS completes its initialization.
-
config PTHREAD_STACK_MIN
int "Minimum pthread stack size"
default 256
diff --git a/sched/init/nx_bringup.c b/sched/init/nx_bringup.c
index e7fcdec..63f703b 100644
--- a/sched/init/nx_bringup.c
+++ b/sched/init/nx_bringup.c
@@ -221,10 +221,18 @@ static inline void nx_workqueues(void)
*
****************************************************************************/
-#if defined(CONFIG_INIT_ENTRYPOINT)
static inline void nx_start_application(void)
{
- int pid;
+#ifdef CONFIG_INIT_ARGS
+ FAR char *const argv[] =
+ {
+ CONFIG_INIT_ARGS,
+ NULL,
+ };
+#else
+ FAR char *const *argv = NULL;
+#endif
+ int ret;
#ifdef CONFIG_BOARD_LATE_INITIALIZE
/* Perform any last-minute, board-specific initialization, if so
@@ -234,6 +242,8 @@ static inline void nx_start_application(void)
board_late_initialize();
#endif
+#if defined(CONFIG_INIT_ENTRYPOINT)
+
/* Start the application initialization task. In a flat build, this is
* entrypoint is given by the definitions, CONFIG_USER_ENTRYPOINT. In
* the protected build, however, we must get the address of the
@@ -244,31 +254,17 @@ static inline void nx_start_application(void)
#ifdef CONFIG_BUILD_PROTECTED
DEBUGASSERT(USERSPACE->us_entrypoint != NULL);
- pid = nxtask_create("init", CONFIG_USERMAIN_PRIORITY,
- CONFIG_USERMAIN_STACKSIZE, USERSPACE->us_entrypoint,
- (FAR char * const *)NULL);
+ ret = nxtask_create("init", CONFIG_USERMAIN_PRIORITY,
+ CONFIG_USERMAIN_STACKSIZE,
+ USERSPACE->us_entrypoint, argv);
#else
- pid = nxtask_create("init", CONFIG_USERMAIN_PRIORITY,
+ ret = nxtask_create("init", CONFIG_USERMAIN_PRIORITY,
CONFIG_USERMAIN_STACKSIZE,
- (main_t)CONFIG_USER_ENTRYPOINT,
- (FAR char * const *)NULL);
+ (main_t)CONFIG_USER_ENTRYPOINT, argv);
#endif
- DEBUGASSERT(pid > 0);
- UNUSED(pid);
-}
+ DEBUGASSERT(ret > 0);
#elif defined(CONFIG_INIT_FILEPATH)
-static inline void nx_start_application(void)
-{
- int ret;
-
-#ifdef CONFIG_BOARD_LATE_INITIALIZE
- /* Perform any last-minute, board-specific initialization, if so
- * configured.
- */
-
- board_late_initialize();
-#endif
#ifdef CONFIG_INIT_MOUNT
/* Mount the file system containing the init program. */
@@ -277,7 +273,6 @@ static inline void nx_start_application(void)
CONFIG_INIT_MOUNT_FSTYPE, CONFIG_INIT_MOUNT_FLAGS,
CONFIG_INIT_MOUNT_DATA);
DEBUGASSERT(ret >= 0);
- UNUSED(ret);
#endif
/* Start the application initialization program from a program in a
@@ -287,20 +282,14 @@ static inline void nx_start_application(void)
sinfo("Starting init task: %s\n", CONFIG_USER_INITPATH);
- ret = exec(CONFIG_USER_INITPATH, NULL, CONFIG_INIT_SYMTAB,
- CONFIG_INIT_NEXPORTS);
+ ret = exec(CONFIG_USER_INITPATH, argv,
+ CONFIG_INIT_SYMTAB, CONFIG_INIT_NEXPORTS);
DEBUGASSERT(ret >= 0);
+#endif
+
UNUSED(ret);
}
-#elif defined(CONFIG_INIT_NONE)
-# define nx_start_application()
-
-#else
-# error "Cannot start initialization thread"
-
-#endif
-
/****************************************************************************
* Name: nx_start_task
*
diff --git a/tools/cfgdefine.c b/tools/cfgdefine.c
index e8a1cb1..9e2d56f 100644
--- a/tools/cfgdefine.c
+++ b/tools/cfgdefine.c
@@ -63,27 +63,28 @@ static const char *dequote_list[] =
{
/* NuttX */
- "CONFIG_USER_ENTRYPOINT", /* Name of entry point function */
- "CONFIG_EXECFUNCS_SYMTAB_ARRAY", /* Symbol table array used by exec[l|v] */
+ "CONFIG_DEBUG_OPTLEVEL", /* Custom debug level */
"CONFIG_EXECFUNCS_NSYMBOLS_VAR", /* Variable holding number of symbols in the table */
+ "CONFIG_EXECFUNCS_SYMTAB_ARRAY", /* Symbol table array used by exec[l|v] */
+ "CONFIG_INIT_ARGS", /* Argument list of entry point */
+ "CONFIG_INIT_SYMTAB", /* Global symbol table */
+ "CONFIG_INIT_NEXPORTS", /* Global symbol table size */
"CONFIG_MODLIB_SYMTAB_ARRAY", /* Symbol table array used by modlib functions */
"CONFIG_MODLIB_NSYMBOLS_VAR", /* Variable holding number of symbols in the table */
"CONFIG_PASS1_BUILDIR", /* Pass1 build directory */
"CONFIG_PASS1_TARGET", /* Pass1 build target */
"CONFIG_PASS1_OBJECT", /* Pass1 build object */
- "CONFIG_DEBUG_OPTLEVEL", /* Custom debug level */
- "CONFIG_INIT_SYMTAB", /* Global symbol table */
- "CONFIG_INIT_NEXPORTS", /* Global symbol table size */
+ "CONFIG_USER_ENTRYPOINT", /* Name of entry point function */
/* NxWidgets/NxWM */
"CONFIG_NXWM_BACKGROUND_IMAGE", /* Name of bitmap image class */
- "CONFIG_NXWM_STOP_BITMAP", /* Name of bitmap image class */
- "CONFIG_NXWM_MINIMIZE_BITMAP", /* Name of bitmap image class */
- "CONFIG_NXWM_STARTWINDOW_ICON", /* Name of bitmap image class */
- "CONFIG_NXWM_NXTERM_ICON", /* Name of bitmap image class */
"CONFIG_NXWM_CALIBRATION_ICON", /* Name of bitmap image class */
"CONFIG_NXWM_HEXCALCULATOR_ICON", /* Name of bitmap image class */
+ "CONFIG_NXWM_MINIMIZE_BITMAP", /* Name of bitmap image class */
+ "CONFIG_NXWM_NXTERM_ICON", /* Name of bitmap image class */
+ "CONFIG_NXWM_STARTWINDOW_ICON", /* Name of bitmap image class */
+ "CONFIG_NXWM_STOP_BITMAP", /* Name of bitmap image class */
/* apps/ definitions */