[coreboot] Patch set updated for filo: 3fa954b Add non-interactive mode for FILO
Patrick Georgi (patrick@georgi-clan.de)
gerrit at coreboot.org
Fri Sep 9 10:01:19 CEST 2011
Patrick Georgi (patrick at georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/195
-gerrit
commit 3fa954bd32a3b990ce7a6dda83890cd481422273
Author: Mathias Krause <mathias.krause at secunet.com>
Date: Mon Mar 8 13:14:24 2010 +0100
Add non-interactive mode for FILO
It forbids modifications of the configuration loaded and prevents
entering the command line mode.
Change-Id: I8c13d64832b6f8659927ec1e5fe3b527ef8cbdc4
Signed-off-by: Mathias Krause <mathias.krause at secunet.com>
Signed-off-by: Patrick Georgi <patrick.georgi at secunet.com>
---
Config.in | 7 +++++++
main/filo.c | 17 +++++++++++++++++
main/grub/cmdline.c | 4 ++++
main/grub/grub.c | 40 +++++++++++++++++++++++++++++++++++++++-
4 files changed, 67 insertions(+), 1 deletions(-)
diff --git a/Config.in b/Config.in
index a8cbfbb..251bd2a 100644
--- a/Config.in
+++ b/Config.in
@@ -24,6 +24,13 @@ config USE_GRUB
help
Use GRUB legacy like interface instead of autoboot?
+config NON_INTERACTIVE
+ bool "non-interactive interface"
+ default n
+ help
+ Build a non-interactive interface to disallow modifications of
+ the boot options, e.g. the kernel to load or the command line.
+
config PROMPT
string "Command line prompt"
default "filo"
diff --git a/main/filo.c b/main/filo.c
index a8bf372..e37559b 100644
--- a/main/filo.c
+++ b/main/filo.c
@@ -156,6 +156,10 @@ int main(void)
#ifdef CONFIG_AUTOBOOT_FILE
#ifdef CONFIG_AUTOBOOT_DELAY
+#ifdef CONFIG_NON_INTERACTIVE
+#error "autoboot delay is not supported for non-interactive builds"
+#define autoboot_delay() 0 /* success */
+#else
static inline int autoboot_delay(void)
{
u64 timeout;
@@ -189,13 +193,16 @@ static inline int autoboot_delay(void)
return 0; /* default accepted */
}
}
+#endif /* CONFIG_NON_INTERACTIVE */
#endif /* CONFIG_AUTOBOOT_DELAY */
static void autoboot(void)
{
+#ifndef CONFIG_NON_INTERACTIVE
/* If Escape key is pressed already, skip autoboot */
if (havechar() && getchar()==ESCAPE)
return;
+#endif /* CONFIG_NON_INTERACTIVE */
if (autoboot_delay()==0) {
printf("boot: %s\n", CONFIG_AUTOBOOT_FILE);
@@ -215,6 +222,7 @@ int main(void)
/* Try default image */
autoboot();
+#ifndef CONFIG_NON_INTERACTIVE
/* The above didn't work, ask user */
while (havechar())
getchar();
@@ -233,6 +241,15 @@ int main(void)
if (line[0])
boot(line);
}
+#else /* ! CONFIG_NON_INTERACTIVE */
+ for (;;) {
+ printf("\nAutoboot failed! Press any key to reboot.\n");
+ getchar();
+ if (reset_handler) {
+ reset_handler();
+ }
+ }
+#endif /* CONFIG_NON_INTERACTIVE */
return 0;
}
diff --git a/main/grub/cmdline.c b/main/grub/cmdline.c
index 1f56ac6..2ace871 100644
--- a/main/grub/cmdline.c
+++ b/main/grub/cmdline.c
@@ -40,6 +40,7 @@ char *skip_to(int after_equal, char *cmdline)
return cmdline;
}
+#ifndef CONFIG_NON_INTERACTIVE
/* Print a helpful message for the command-line interface. */
void print_cmdline_message(int type)
{
@@ -67,6 +68,7 @@ void print_cmdline_message(int type)
grub_printf("\n");
#endif
}
+#endif /* CONFIG_NON_INTERACTIVE */
/* Find the builtin whose command name is COMMAND and return the
* pointer. If not found, return 0.
@@ -118,6 +120,7 @@ static void init_cmdline(void)
init_builtins();
}
+#ifndef CONFIG_NON_INTERACTIVE
/* Enter the command-line interface. HEAP is used for the command-line
* buffer. Return only if FOREVER is nonzero and get_cmdline returns
* nonzero (ESC is pushed).
@@ -179,6 +182,7 @@ void enter_cmdline(char *heap, int forever)
count_lines = -1;
}
}
+#endif /* CONFIG_NON_INTERACTIVE */
/* Run an entry from the script SCRIPT. HEAP is used for the
command-line buffer. If an error occurs, return non-zero, otherwise
diff --git a/main/grub/grub.c b/main/grub/grub.c
index 7881a98..b1fcdd1 100644
--- a/main/grub/grub.c
+++ b/main/grub/grub.c
@@ -191,6 +191,16 @@ old:
}
+static void reboot(void) {
+ for (;;) {
+ grub_printf("Press any key to reboot.\n");
+ getchar();
+ if (reset_handler) {
+ reset_handler();
+ }
+ }
+}
+
/* Define if there is user specified preset menu string */
/* #undef PRESET_MENU_STRING */
@@ -409,16 +419,27 @@ static void run_menu(char *menu_entries, char *config_entries, int num_entries,
password to unlock the next set of features.");
} else {
if (config_entries)
+#ifndef CONFIG_NON_INTERACTIVE
grub_printf("\
Press enter to boot the selected OS, \'e\' to edit the\n\
commands before booting, \'a\' to modify the kernel arguments\n\
before booting, or \'c\' for a command-line.");
+#else /* ! CONFIG_NON_INTERACTIVE */
+ grub_printf("\
+ Press enter to boot the selected OS, \'e\' to see the\n\
+ commands before booting.");
+#endif /* CONFIG_NON_INTERACTIVE */
else
+#ifndef CONFIG_NON_INTERACTIVE
grub_printf("\
Press \'b\' to boot, \'e\' to edit the selected command in the\n\
boot sequence, \'c\' for a command-line, \'o\' to open a new line\n\
after (\'O\' for before) the selected line, \'d\' to remove the\n\
selected line, or escape to go back to the main menu.");
+#else /* ! CONFIG_NON_INTERACTIVE */
+ grub_printf("\
+ Press \'b\' to boot or escape to go back to the main menu.");
+#endif /* CONFIG_NON_INTERACTIVE */
}
print_entries(3, 12, first_entry, entryno, menu_entries);
@@ -520,6 +541,7 @@ static void run_menu(char *menu_entries, char *config_entries, int num_entries,
if ((c == '\n') || (c == '\r') || (c == 6))
break;
} else {
+#ifndef CONFIG_NON_INTERACTIVE
if ((c == 'd') || (c == 'o') || (c == 'O')) {
print_entry(4 + entryno, 0,
get_entry(menu_entries, first_entry + entryno, 0));
@@ -565,6 +587,7 @@ static void run_menu(char *menu_entries, char *config_entries, int num_entries,
print_entries(3, 12, first_entry, entryno, menu_entries);
}
+#endif /* CONFIG_NON_INTERACTIVE */
cur_entry = menu_entries;
if (c == 27)
@@ -645,6 +668,7 @@ static void run_menu(char *menu_entries, char *config_entries, int num_entries,
if (config_entries)
run_menu(heap, NULL, new_num_entries, new_heap, 0);
+#ifndef CONFIG_NON_INTERACTIVE
else {
/* flush color map */
grub_printf(" ");
@@ -677,9 +701,11 @@ static void run_menu(char *menu_entries, char *config_entries, int num_entries,
heap += (j - i);
}
}
+#endif /* CONFIG_NON_INTERACTIVE */
goto restart;
}
+#ifndef CONFIG_NON_INTERACTIVE
if (c == 'c') {
extern int keep_cmdline_running;
enter_cmdline(heap, 0);
@@ -778,6 +804,7 @@ static void run_menu(char *menu_entries, char *config_entries, int num_entries,
break;
}
+#endif /* CONFIG_NON_INTERACTIVE */
}
}
}
@@ -1077,7 +1104,11 @@ restart:
}
if (!is_opened) {
- grub_printf("Could not open menu.lst file '%s'. Entering command line.\n", config_file);
+#ifndef CONFIG_NON_INTERACTIVE
+ grub_printf("Could not open configuration file '%s'. Entering command line.\n", config_file);
+#else /* ! CONFIG_NON_INTERACTIVE */
+ grub_printf("Could not open configuration file '%s'.\n", config_file);
+#endif /* CONFIG_NON_INTERACTIVE */
// memset(myheap, 0, 256);
// run_script("terminal console\n\0", myheap);
break;
@@ -1205,10 +1236,17 @@ restart:
} while (is_preset);
if (!num_entries) {
+#ifndef CONFIG_NON_INTERACTIVE
/* If no acceptable config file, goto command-line, starting
heap from where the config entries would have been stored
if there were any. */
enter_cmdline(config_entries, 1);
+#else /* ! CONFIG_NON_INTERACTIVE */
+ for (;;) {
+ grub_printf("\nNo menu entries found. Giving up.\n");
+ reboot();
+ }
+#endif /* CONFIG_NON_INTERACTIVE */
} else {
/* Run menu interface. */
run_menu(menu_entries, config_entries, num_entries, menu_entries + menu_len, default_entry);
More information about the coreboot
mailing list