diff --git a/sched/Kconfig b/sched/Kconfig index 437451a3ad..dcb3911e70 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 e7fcdec5c6..63f703b1a8 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); -#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); + USERSPACE->us_entrypoint, argv); +#else + ret = nxtask_create("init", CONFIG_USERMAIN_PRIORITY, + CONFIG_USERMAIN_STACKSIZE, + (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 e8a1cb15c3..9e2d56f35f 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 */