* [PATCH v2 2/3] startup: don't clobber original autoboot state
2020-04-22 7:35 [PATCH v2 1/3] startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWN Ahmad Fatoum
@ 2020-04-22 7:35 ` Ahmad Fatoum
2020-04-22 7:35 ` [PATCH v2 3/3] startup: add $global.autoboot to make behavior configurable Ahmad Fatoum
2020-04-23 6:30 ` [PATCH v2 1/3] startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWN Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2020-04-22 7:35 UTC (permalink / raw)
To: barebox
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.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
v1 -> v2:
* New commit
---
common/startup.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/common/startup.c b/common/startup.c
index 7373ba7d0cd3..bda782317697 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -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;
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 3/3] startup: add $global.autoboot to make behavior configurable
2020-04-22 7:35 [PATCH v2 1/3] startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWN Ahmad Fatoum
2020-04-22 7:35 ` [PATCH v2 2/3] startup: don't clobber original autoboot state Ahmad Fatoum
@ 2020-04-22 7:35 ` Ahmad Fatoum
2020-04-23 6:30 ` [PATCH v2 1/3] startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWN Sascha Hauer
2 siblings, 0 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2020-04-22 7:35 UTC (permalink / raw)
To: barebox
We 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()
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
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(-)
diff --git a/common/startup.c b/common/startup.c
index bda782317697..796cd6cc7e3b 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -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");
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 4+ messages in thread