summaryrefslogtreecommitdiffstats
path: root/common/startup.c
diff options
context:
space:
mode:
authorAhmad Fatoum <ahmad@a3f.at>2020-04-22 09:35:17 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2020-04-27 21:16:05 +0200
commit10062129e708a23b354424d0134a9ccd3e56b4bc (patch)
tree2898b9c7229a7ecfede1fbe89e9bc68ce90f4d68 /common/startup.c
parent19738925331a98244f7f774001e4964e9891d3b6 (diff)
downloadbarebox-10062129e708a23b354424d0134a9ccd3e56b4bc.tar.gz
barebox-10062129e708a23b354424d0134a9ccd3e56b4bc.tar.xz
startup: add $global.autoboot to make behavior configurable
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> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/startup.c')
-rw-r--r--common/startup.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/common/startup.c b/common/startup.c
index bda7823176..796cd6cc7e 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");