startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWN
PATCH v2 1/3 startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWN
If we export the autoboot state variable for customization, having unknown as default is not so helpful. Rename it to what actually happens (abortable countdown).
---
v1 -> v2:
* New commit
--- common/startup.c | 4 ++-- include/common.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
common/startup.c +2 -2
@@ -195,7 +195,7 @@ static bool test_abort(void)#define INITFILE "/env/bin/init"#define MENUFILE "/env/menu/mainmenu" -static enum autoboot_state autoboot_state =AUTOBOOT_UNKNOWN ; +static enum autoboot_state autoboot_state =AUTOBOOT_COUNTDOWN ;/** * set_autoboot_state - set the autoboot state
@@ -229,7 +229,7 @@ enum autoboot_state do_autoboot_countdown(void)char *abortkeys =NULL ;unsigned char outkey; -if (autoboot_state !=AUTOBOOT_UNKNOWN ) +if (autoboot_state !=AUTOBOOT_COUNTDOWN )return autoboot_state; menu_exists =stat (MENUFILE , &s) ==0 ;
include/common.h +1 -1
@@ -87,7 +87,7 @@ unsigned long long strtoull_suffix(const char *str, char **endp, int base);extern int (*barebox_main)(void );enum autoboot_state { -AUTOBOOT_UNKNOWN , +AUTOBOOT_COUNTDOWN ,AUTOBOOT_ABORT ,AUTOBOOT_MENU ,AUTOBOOT_BOOT ,
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 2/3 startup: don't clobber original autoboot state
do_autoboot_countdown changes autoboot state if the user presses m for menu or ctrl+c to abort during count down. This is an internal detail and doesn't need to be reflected in the state of the global variable.
This will improve UX when exporting the variable in the follow-up commit, because on a regular boot it $autoboot will expand to countdown instead of abort/boot/menu dependent on prior user input.
---
v1 -> v2:
* New commit
--- common/startup.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
common/startup.c +5 -4
@@ -195,7 +195,7 @@ static bool test_abort(void)#define INITFILE "/env/bin/init"#define MENUFILE "/env/menu/mainmenu" -static enum autoboot_state autoboot_state =AUTOBOOT_COUNTDOWN ; +static enum autoboot_state global_autoboot_state =AUTOBOOT_COUNTDOWN ;/** * set_autoboot_state - set the autoboot state
@@ -206,7 +206,7 @@ static enum autoboot_state autoboot_state = AUTOBOOT_COUNTDOWN;*/ void set_autoboot_state (enum autoboot_state autoboot) { - autoboot_state = autoboot; + global_autoboot_state = autoboot; }/**
@@ -222,6 +222,7 @@ void set_autoboot_state(enum autoboot_state autoboot)*/ enum autoboot_state do_autoboot_countdown (void ) { +enum autoboot_state autoboot_state;unsigned flags =CONSOLE_COUNTDOWN_EXTERN ;int ret;struct stat s;
@@ -229,8 +230,8 @@ enum autoboot_state do_autoboot_countdown(void)char *abortkeys =NULL ;unsigned char outkey; -if (autoboot_state !=AUTOBOOT_COUNTDOWN ) -return autoboot_state; +if (global_autoboot_state !=AUTOBOOT_COUNTDOWN ) +return global_autoboot_state; menu_exists =stat (MENUFILE , &s) ==0 ;
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH v2 3/3 startup: add $global.autoboot to make behavior configurable
In reply to Ahmad FatoumWe already have a global_autoboot_state variable that controls barebox init behavior on startup:
* ABORT abort and fall into shell * MENU display boot menu * BOOT boot immediately, only abortable via ctrl+c
during init
* COUNTDOWN regular boot after count down
Exporting this as a device parameter allows us to support some different boot scenarios:
* COUNTDOWN is the default
* ABORT boot always while debugging
* display MENU by default (e.g. for graphical boots)
* BOOT while ignoring external code calling console_countdown_abort()
---
v1 -> v2:
* Add magic var description (Sascha)
* Rebased on the other patches as well as Sascha magicvar commit
* Reworded commit message to address aborting on autoboot=boot
--- common/startup.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
common/startup.c +15 -2
@@ -164,6 +164,14 @@ static const char * const global_autoboot_abort_keys[] = { };static int global_autoboot_timeout =3 ; +static const char *const global_autoboot_states[] = { + [AUTOBOOT_COUNTDOWN ] ="countdown" , + [AUTOBOOT_ABORT ] ="abort" , + [AUTOBOOT_MENU ] ="menu" , + [AUTOBOOT_BOOT ] ="boot" , +}; +static int global_autoboot_state =AUTOBOOT_COUNTDOWN ; +static bool test_abort (void ) {bool do_abort = false;
@@ -195,8 +203,6 @@ static bool test_abort(void)#define INITFILE "/env/bin/init"#define MENUFILE "/env/menu/mainmenu" -static enum autoboot_state global_autoboot_state =AUTOBOOT_COUNTDOWN ; -/** * set_autoboot_state - set the autoboot state * @autoboot: the state to set
@@ -287,6 +293,10 @@ static int run_init(void) ARRAY_SIZE(global_autoboot_abort_keys));globalvar_add_simple_int ("autoboot_timeout" , &global_autoboot_timeout,"%u" ); +globalvar_add_simple_enum ("autoboot" , + &global_autoboot_state, + global_autoboot_states, +ARRAY_SIZE (global_autoboot_states));setenv ("PATH" ,"/env/bin" );
@@ -394,6 +404,9 @@ void shutdown_barebox(void) } } +BAREBOX_MAGICVAR_NAMED (autoboot_state, + global.autoboot, +"Autoboot state. Possible values: countdown (default), abort, menu, boot" );BAREBOX_MAGICVAR_NAMED (global_autoboot_abort_key, global.autoboot_abort_key,"Which key allows to interrupt autoboot. Possible values: any, ctrl-c" );
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 4 lines · Ahmad Fatoum
If we export the autoboot state variable for customization, having unknown as default is not so helpful. Rename it to what actually happens (abortable countdown).
Quoted 8 lines
Signed-off-by Ahmad Fatoum <[email protected]>---
v1 -> v2:
* New commit--- common/startup.c | 4 ++-- include/common.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
Applied, thanks
Sascha
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox