mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH v2 1/3] startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWN
@ 2020-04-22  7:35 Ahmad Fatoum
  2020-04-22  7:35 ` [PATCH v2 2/3] startup: don't clobber original autoboot state Ahmad Fatoum
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ahmad Fatoum @ 2020-04-22  7:35 UTC (permalink / raw)
  To: barebox

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).

Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
v1 -> v2:
  * New commit
---
 common/startup.c | 4 ++--
 include/common.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/startup.c b/common/startup.c
index e251142fca9e..7373ba7d0cd3 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_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;
diff --git a/include/common.h b/include/common.h
index ef2e4e5c31dd..b2533f4176bc 100644
--- a/include/common.h
+++ b/include/common.h
@@ -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,
-- 
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 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

* Re: [PATCH v2 1/3] startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWN
  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 ` [PATCH v2 3/3] startup: add $global.autoboot to make behavior configurable Ahmad Fatoum
@ 2020-04-23  6:30 ` Sascha Hauer
  2 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2020-04-23  6:30 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Wed, Apr 22, 2020 at 09:35:15AM +0200, Ahmad Fatoum wrote:
> 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).
> 
> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
> ---
> v1 -> v2:
>   * New commit
> ---
>  common/startup.c | 4 ++--
>  include/common.h | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)

Applied, thanks

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] 4+ messages in thread

end of thread, other threads:[~2020-04-23  6:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox