[PATCH v2 12/27] Move bootmenu_conv_key() into its own file
Simon Glass
sjg at chromium.org
Sun Oct 8 01:12:31 CEST 2023
This conversion function is used by expo which does not require CMDLINE.
The menu feature does require CMDLINE.
Move the function into a separate file so that it can be used even when
CMDLINE is not enabled.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
(no changes since v1)
common/Makefile | 2 +-
common/cli_getch.c | 1 +
common/menu.c | 40 -------------------------------------
common/menu_key.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 51 insertions(+), 41 deletions(-)
create mode 100644 common/menu_key.c
diff --git a/common/Makefile b/common/Makefile
index b21916f15340..637066ae6682 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -8,7 +8,7 @@ ifndef CONFIG_SPL_BUILD
obj-y += init/
obj-y += main.o
obj-y += exports.o
-obj-y += cli_getch.o
+obj-y += cli_getch.o menu_key.o
obj-$(CONFIG_HUSH_PARSER) += cli_hush.o
obj-$(CONFIG_AUTOBOOT) += autoboot.o
diff --git a/common/cli_getch.c b/common/cli_getch.c
index 61d4cb261b81..c3332dc27fae 100644
--- a/common/cli_getch.c
+++ b/common/cli_getch.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <cli.h>
+#include <menu.h>
/**
* enum cli_esc_state_t - indicates what to do with an escape character
diff --git a/common/menu.c b/common/menu.c
index b55cf7b99967..844d0ec52af3 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -483,46 +483,6 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
return key;
}
-enum bootmenu_key bootmenu_conv_key(int ichar)
-{
- enum bootmenu_key key;
-
- switch (ichar) {
- case '\n':
- /* enter key was pressed */
- key = BKEY_SELECT;
- break;
- case CTL_CH('c'):
- case '\e':
- /* ^C was pressed */
- key = BKEY_QUIT;
- break;
- case CTL_CH('p'):
- key = BKEY_UP;
- break;
- case CTL_CH('n'):
- key = BKEY_DOWN;
- break;
- case CTL_CH('s'):
- key = BKEY_SAVE;
- break;
- case '+':
- key = BKEY_PLUS;
- break;
- case '-':
- key = BKEY_MINUS;
- break;
- case ' ':
- key = BKEY_SPACE;
- break;
- default:
- key = BKEY_NONE;
- break;
- }
-
- return key;
-}
-
enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
struct cli_ch_state *cch)
{
diff --git a/common/menu_key.c b/common/menu_key.c
new file mode 100644
index 000000000000..4e9c3b426b0c
--- /dev/null
+++ b/common/menu_key.c
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright 2010-2011 Calxeda, Inc.
+ * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
+ */
+
+#include <common.h>
+#include <cli.h>
+#include <menu.h>
+
+enum bootmenu_key bootmenu_conv_key(int ichar)
+{
+ enum bootmenu_key key;
+
+ switch (ichar) {
+ case '\n':
+ /* enter key was pressed */
+ key = BKEY_SELECT;
+ break;
+ case CTL_CH('c'):
+ case '\e':
+ /* ^C was pressed */
+ key = BKEY_QUIT;
+ break;
+ case CTL_CH('p'):
+ key = BKEY_UP;
+ break;
+ case CTL_CH('n'):
+ key = BKEY_DOWN;
+ break;
+ case CTL_CH('s'):
+ key = BKEY_SAVE;
+ break;
+ case '+':
+ key = BKEY_PLUS;
+ break;
+ case '-':
+ key = BKEY_MINUS;
+ break;
+ case ' ':
+ key = BKEY_SPACE;
+ break;
+ default:
+ key = BKEY_NONE;
+ break;
+ }
+
+ return key;
+}
--
2.42.0.609.gbb76f46606-goog
More information about the U-Boot
mailing list