* [PATCH] startup: add $global.autoboot to make behavior configurable
@ 2020-04-15 9:36 Ahmad Fatoum
2020-04-20 14:08 ` Sascha Hauer
0 siblings, 1 reply; 3+ messages in thread
From: Ahmad Fatoum @ 2020-04-15 9:36 UTC (permalink / raw)
To: barebox
We already have a autoboot_state variable that controls barebox init
behavior on startup:
* ABORT: abort and fall into shell
* MENU: display boot menu
* BOOT: boot directly without delay
* UNKNOWN: default; count down and then boot
Exporting this as a device parameter allows us to support some
different boot scenarios:
* ABORT boot always while debugging
* display MENU by default (e.g. for graphical boots)
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
common/startup.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/common/startup.c b/common/startup.c
index c417a4d0781a..ff890fa744ab 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -163,6 +163,13 @@ static const char * const global_autoboot_abort_keys[] = {
};
static int global_autoboot_timeout = 3;
+static const char * const autoboot_states[] = {
+ [AUTOBOOT_UNKNOWN] = "unknown",
+ [AUTOBOOT_ABORT] = "abort",
+ [AUTOBOOT_MENU] = "menu",
+ [AUTOBOOT_BOOT] = "boot",
+};
+
static bool test_abort(void)
{
bool do_abort = false;
@@ -194,7 +201,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 int autoboot_state = AUTOBOOT_UNKNOWN;
/**
* set_autoboot_state - set the autoboot state
@@ -285,6 +292,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",
+ &autoboot_state,
+ autoboot_states,
+ ARRAY_SIZE(autoboot_states));
setenv("PATH", "/env/bin");
--
2.20.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] startup: add $global.autoboot to make behavior configurable
2020-04-15 9:36 [PATCH] startup: add $global.autoboot to make behavior configurable Ahmad Fatoum
@ 2020-04-20 14:08 ` Sascha Hauer
2020-04-22 7:29 ` Ahmad Fatoum
0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2020-04-20 14:08 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Wed, Apr 15, 2020 at 11:36:00AM +0200, Ahmad Fatoum wrote:
> We already have a autoboot_state variable that controls barebox init
> behavior on startup:
>
> * ABORT: abort and fall into shell
> * MENU: display boot menu
> * BOOT: boot directly without delay
> * UNKNOWN: default; count down and then boot
>
> Exporting this as a device parameter allows us to support some
> different boot scenarios:
>
> * ABORT boot always while debugging
> * display MENU by default (e.g. for graphical boots)
>
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
> common/startup.c | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/common/startup.c b/common/startup.c
> index c417a4d0781a..ff890fa744ab 100644
> --- a/common/startup.c
> +++ b/common/startup.c
> @@ -163,6 +163,13 @@ static const char * const global_autoboot_abort_keys[] = {
> };
> static int global_autoboot_timeout = 3;
>
> +static const char * const autoboot_states[] = {
> + [AUTOBOOT_UNKNOWN] = "unknown",
> + [AUTOBOOT_ABORT] = "abort",
> + [AUTOBOOT_MENU] = "menu",
> + [AUTOBOOT_BOOT] = "boot",
> +};
> +
> static bool test_abort(void)
> {
> bool do_abort = false;
> @@ -194,7 +201,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 int autoboot_state = AUTOBOOT_UNKNOWN;
>
> /**
> * set_autoboot_state - set the autoboot state
> @@ -285,6 +292,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",
> + &autoboot_state,
> + autoboot_states,
> + ARRAY_SIZE(autoboot_states));
Please add a MAGICVAR description for this.
Setting it to AUTOBOOT_BOOT seems a bit dangerous, there's no way back
if booting goes wrong.
Sascha
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] startup: add $global.autoboot to make behavior configurable
2020-04-20 14:08 ` Sascha Hauer
@ 2020-04-22 7:29 ` Ahmad Fatoum
0 siblings, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2020-04-22 7:29 UTC (permalink / raw)
To: Sascha Hauer, Ahmad Fatoum; +Cc: barebox
Hi,
On 4/20/20 4:08 PM, Sascha Hauer wrote:
>> + globalvar_add_simple_enum("autoboot",
>> + &autoboot_state,
>> + autoboot_states,
>> + ARRAY_SIZE(autoboot_states));
>
> Please add a MAGICVAR description for this.
Will do.
> Setting it to AUTOBOOT_BOOT seems a bit dangerous, there's no way back
> if booting goes wrong.
You can still abort init itself with ctrl+c, not much different than when
using normal countdown.
>
> Sascha
>
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-22 7:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15 9:36 [PATCH] startup: add $global.autoboot to make behavior configurable Ahmad Fatoum
2020-04-20 14:08 ` Sascha Hauer
2020-04-22 7:29 ` Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox