From 21236a85569c2a3d66084dddcae4d3cb2aa7d814 Mon Sep 17 00:00:00 2001 From: okuji Date: Wed, 21 Jun 2000 07:35:37 +0000 Subject: [PATCH] add a new command hiddenmenu. --- ChangeLog | 17 +++++++++++++++++ NEWS | 2 ++ stage2/builtins.c | 23 +++++++++++++++++++++++ stage2/shared.h | 1 + stage2/stage2.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 5 files changed, 85 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 23df32a75..370d8a45c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2000-06-21 OKUJI Yoshinori + + * stage2/stage2.c (run_menu): Initialize CUR_ENTRY at the + definition. + If SHOW_MENU is zero, don't display the menu interface. Instead, + wait until the timeout is expired and then boot the default + entry. If the user presses `ESC' during the timeout, set + SHOW_MENU to one and break the loop. + Display the menu if SHOW_MENU is true, instead of if + GRUB_TIMEOUT is non-zero. + Set SHOW_MENU to one before go to the label `restart'. + * stage2/builtins.c (show_menu): New global variable. + (hiddenmenu_func): New function. + (builtin_hiddenmenu): New variable. + (builtin_table): Added a pointer to BUILTIN_HIDDENMENU. + * stage2/shared.h (show_menu): Declared. + 2000-06-19 OKUJI Yoshinori * docs/mdate-sh: Moved to ... diff --git a/NEWS b/NEWS index b2ed2ae57..55da3e982 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ NEWS - list of user-visible changes between releases of GRUB New in 0.5.96 - XXXX-XX-XX: * New commands, "reboot" and "halt". +* New command, "hiddenmenu". You can hide the menu interface by default + with this command. New in 0.5.95 - XXXX-XX-XX: * NetBSD ELF kernel support is added. You have to specify the new option diff --git a/stage2/builtins.c b/stage2/builtins.c index b0c4c717e..f4e8f7957 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -52,6 +52,8 @@ int normal_color; int highlight_color; /* The timeout. */ int grub_timeout = -1; +/* Whether to show the menu or not. */ +int show_menu = 1; /* The BIOS drive map. */ static unsigned short bios_drive_map[DRIVE_MAP_SIZE + 1]; @@ -1329,6 +1331,26 @@ static struct builtin builtin_help = "Display helpful information about builtin commands." }; + +/* hiddenmenu */ +static int +hiddenmenu_func (char *arg, int flags) +{ + show_menu = 0; + return 0; +} + +static struct builtin builtin_hiddenmenu = +{ + "hiddenmenu", + hiddenmenu_func, + BUILTIN_MENU, +#if 0 + "hiddenmenu", + "Hide the menu." +#endif +}; + /* hide */ static int @@ -3133,6 +3155,7 @@ struct builtin *builtin_table[] = &builtin_geometry, &builtin_halt, &builtin_help, + &builtin_hiddenmenu, &builtin_hide, &builtin_impsprobe, &builtin_initrd, diff --git a/stage2/shared.h b/stage2/shared.h index 6da7ca0a2..0945c34e0 100644 --- a/stage2/shared.h +++ b/stage2/shared.h @@ -688,6 +688,7 @@ typedef enum kernel_t; extern kernel_t kernel_type; +extern int show_menu; extern int grub_timeout; void init_builtins (void); diff --git a/stage2/stage2.c b/stage2/stage2.c index 27675c844..2a4d847bd 100644 --- a/stage2/stage2.c +++ b/stage2/stage2.c @@ -173,7 +173,7 @@ run_menu (char *menu_entries, char *config_entries, int num_entries, char *heap, int entryno) { int c, time1, time2 = -1, first_entry = 0; - char *cur_entry; + char *cur_entry = 0; /* * Main loop for menu UI. @@ -186,8 +186,45 @@ restart: entryno --; } - /* Only display the menu if we're not out of time. */ - if (grub_timeout != 0) + /* If SHOW_MENU is false, don't display the menu until ESC is pressed. */ + if (! show_menu) + { + /* Print a message. */ + grub_printf ("Press `ESC' to enter the menu...\n"); + + /* Get current time. */ + while ((time1 = getrtsecs ()) == 0xFF) + ; + + while (1) + { + /* Check if ESC is pressed. */ + if (checkkey () != -1 && getkey () == 27) + { + grub_timeout = -1; + show_menu = 1; + break; + } + + /* If GRUB_TIMEOUT is expired, boot the default entry. */ + if (grub_timeout >=0 + && (time1 = getrtsecs ()) != time2 + && time1 != 0xFF) + { + if (grub_timeout <= 0) + { + grub_timeout = -1; + goto boot_entry; + } + + time2 = time1; + grub_timeout--; + } + } + } + + /* Only display the menu if the user wants to see it. */ + if (show_menu) { init_page (); #ifndef GRUB_UTIL @@ -519,7 +556,7 @@ restart: /* * Attempt to boot an entry. */ - + boot_entry: while (1) { cls (); @@ -549,6 +586,7 @@ restart: break; } + show_menu = 1; goto restart; }