From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 1/3] startup: implement get_autoboot_state() helper
Date: Mon, 15 Dec 2025 09:24:37 +0100 [thread overview]
Message-ID: <20251215082442.1977789-1-a.fatoum@pengutronix.de> (raw)
This helper returns the last autoboot state used and can thus be used to
detect if boot was aborted manually.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/startup.c | 24 ++++++++++++++++++------
include/barebox.h | 1 +
2 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/common/startup.c b/common/startup.c
index 73cf4a495b9c..81a3ae1513c2 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -274,11 +274,22 @@ static int register_autoboot_vars(void)
}
postcore_initcall(register_autoboot_vars);
+static enum autoboot_state current_autoboot = AUTOBOOT_UNKNOWN;
+
+/**
+ * get_autoboot_state - get the autoboot state
+ *
+ * This functions returns the autoboot state last used.
+ */
+enum autoboot_state get_autoboot_state(void)
+{
+ return current_autoboot;
+}
+
static int run_init(void)
{
const char *bmode, *cmdline;
bool env_bin_init_exists;
- enum autoboot_state autoboot;
struct stat s;
glob_t g;
int i, ret;
@@ -355,19 +366,20 @@ static int run_init(void)
free(scr);
}
- autoboot = do_autoboot_countdown();
+ current_autoboot = do_autoboot_countdown();
console_ctrlc_allow();
- if (autoboot == AUTOBOOT_BOOT)
+ if (current_autoboot == AUTOBOOT_BOOT)
run_command("boot");
if (IS_ENABLED(CONFIG_NET) && !IS_ENABLED(CONFIG_CONSOLE_DISABLE_INPUT) &&
- autoboot != AUTOBOOT_HALT)
+ current_autoboot != AUTOBOOT_HALT)
eth_open_all();
- if (autoboot != AUTOBOOT_MENU) {
- if (autoboot == AUTOBOOT_ABORT && autoboot == global_autoboot_state)
+ if (current_autoboot != AUTOBOOT_MENU) {
+ if (current_autoboot == AUTOBOOT_ABORT &&
+ current_autoboot == global_autoboot_state)
watchdog_inhibit_all();
run_shell();
diff --git a/include/barebox.h b/include/barebox.h
index 6f3179d4bd62..4e694e0db9a6 100644
--- a/include/barebox.h
+++ b/include/barebox.h
@@ -40,6 +40,7 @@ enum autoboot_state {
AUTOBOOT_UNKNOWN,
};
+enum autoboot_state get_autoboot_state(void);
void set_autoboot_state(enum autoboot_state autoboot);
enum autoboot_state do_autoboot_countdown(void);
--
2.47.3
next reply other threads:[~2025-12-15 8:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-15 8:24 Ahmad Fatoum [this message]
2025-12-15 8:24 ` [PATCH 2/3] of: implement of_get_machine_vendor() Ahmad Fatoum
2025-12-15 8:24 ` [PATCH 3/3] lib: smbios: add support for populating SMBIOS table Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251215082442.1977789-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox