mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Johannes Schneider <johannes.schneider@leica-geosystems.com>
To: barebox@lists.infradead.org
Cc: Johannes Schneider <johannes.schneider@leica-geosystems.com>
Subject: [PATCH] common: add custom autoboot_abort_key
Date: Mon, 16 Sep 2024 15:53:00 +0200	[thread overview]
Message-ID: <20240916135300.3996776-1-johannes.schneider@leica-geosystems.com> (raw)

Add the Kconfig options to select a compile-time custom key(s) that
can be used to enter the console when barebox prompts for:
"Hit <custom_key> to stop autoboot."

This commit also adds the option to set the global autoboot_abort_key's default
value to any of the available ones: 'any', 'ctrl-c' or the new 'custom'.

Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
---
 common/Kconfig   | 34 ++++++++++++++++++++++++++++++++++
 common/startup.c |  8 +++++++-
 2 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/common/Kconfig b/common/Kconfig
index 4af0225..db9585c 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -408,6 +408,39 @@ config CBSIZE
 	prompt "Buffer size for input from the Console"
 	default 1024
 
+choice
+	prompt "autoboot_abort_key default"
+	help
+		Set the compile time default of global.autoboot_abort_key. Note that it
+		still possible to set the global to a different value during runtime.
+
+	config AUTOBOOT_ABORT_KEY_DEFAULT_ANY
+		bool "any"
+
+	config AUTOBOOT_ABORT_KEY_DEFAULT_CTRL_C
+		bool "ctrl-c"
+
+	config AUTOBOOT_ABORT_KEY_DEFAULT_CUSTOM
+		bool "custom"
+		select AUTOBOOT_ABORT_KEY_CUSTOM
+
+endchoice
+
+config AUTOBOOT_ABORT_KEY_DEFAULT
+	int
+	default 0 if AUTOBOOT_ABORT_KEY_DEFAULT_ANY
+	default 1 if AUTOBOOT_ABORT_KEY_DEFAULT_CTRL_C
+	default 2 if AUTOBOOT_ABORT_KEY_DEFAULT_CUSTOM
+
+config AUTOBOOT_ABORT_KEY_CUSTOM_KEY
+	depends on AUTOBOOT_ABORT_KEY_DEFAULT_CUSTOM
+	prompt "select a custom autoboot_abort_key"
+	string
+	default "c"
+	help
+		Set key to use as autoboot_abort_key.
+		If set to a string, any of the characters can be pressed to abort autoboot.
+
 config FIRMWARE
 	bool
 
diff --git a/common/startup.c b/common/startup.c
index 47b70a7..6b068a8 100644
--- a/common/startup.c
+++ b/common/startup.c
@@ -93,10 +93,13 @@ static int load_environment(void)
 }
 environment_initcall(load_environment);
 
-static int global_autoboot_abort_key;
+static int global_autoboot_abort_key = CONFIG_AUTOBOOT_ABORT_KEY_DEFAULT;
 static const char * const global_autoboot_abort_keys[] = {
 	"any",
 	"ctrl-c",
+#if defined CONFIG_AUTOBOOT_ABORT_KEY_CUSTOM_KEY
+	CONFIG_AUTOBOOT_ABORT_KEY_CUSTOM_KEY
+#endif
 };
 static int global_autoboot_timeout = 3;
 
@@ -202,6 +205,11 @@ enum autoboot_state do_autoboot_countdown(void)
 	case 1:
 		flags |= CONSOLE_COUNTDOWN_CTRLC;
 		break;
+#if defined CONFIG_AUTOBOOT_ABORT_KEY_CUSTOM_KEY
+	case 2:
+		abortkeys = xasprintf("%s%s", (abortkeys)?abortkeys:"", CONFIG_AUTOBOOT_ABORT_KEY_CUSTOM_KEY);
+		break;
+#endif
 	default:
 		break;
 	}
-- 
2.43.0




                 reply	other threads:[~2024-09-16 13:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240916135300.3996776-1-johannes.schneider@leica-geosystems.com \
    --to=johannes.schneider@leica-geosystems.com \
    --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