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 <xiaoxiang@xiaomi.com>
Change-Id: I684e9c76b9eac54404d0e4e63ab78e51e039c9a8
This commit is contained in:
Xiang Xiao 2020-08-17 02:05:58 +08:00 committed by patacongo
parent 7ce2b3fa74
commit d43bf7717e
3 changed files with 47 additions and 50 deletions

View File

@ -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

View File

@ -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
*

View File

@ -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 */