add two new options, --dumb and --timeout, into the command terminal.
This commit is contained in:
parent
7f6d84c46f
commit
fa8456816f
3 changed files with 71 additions and 22 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2000-08-31 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
|
* stage2/builtins.c (terminal_func): Added two new options,
|
||||||
|
--dumb and --timeout=SECS.
|
||||||
|
* stage2/char_io.c [!STAGE1_5] (getkey): Use logical AND
|
||||||
|
operations, when checking if the terminal is a console or a
|
||||||
|
serial terminal.
|
||||||
|
[!STAGE1_5] (getkey) [SUPPORT_SERIAL]: Don't check if both
|
||||||
|
TERMINAL_CONSOLE and TERMINAL_SERIAL are set in TERMINAL.
|
||||||
|
|
||||||
2000-08-31 OKUJI Yoshinori <okuji@gnu.org>
|
2000-08-31 OKUJI Yoshinori <okuji@gnu.org>
|
||||||
|
|
||||||
* stage1/stage1.S (MOV_MEM_TO_AL): New macro.
|
* stage1/stage1.S (MOV_MEM_TO_AL): New macro.
|
||||||
|
|
|
@ -3283,31 +3283,68 @@ static struct builtin builtin_setup =
|
||||||
static int
|
static int
|
||||||
terminal_func (char *arg, int flags)
|
terminal_func (char *arg, int flags)
|
||||||
{
|
{
|
||||||
|
int default_terminal = 0;
|
||||||
|
int timeout = -1;
|
||||||
|
int dumb = 0;
|
||||||
|
int saved_terminal = terminal;
|
||||||
|
|
||||||
|
/* Get GNU-style long options. */
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (grub_memcmp (arg, "--dumb", sizeof ("--dumb") - 1) == 0)
|
||||||
|
dumb = 1;
|
||||||
|
else if (grub_memcmp (arg, "--timeout=", sizeof ("--timeout=") - 1) == 0)
|
||||||
|
{
|
||||||
|
char *val = arg + sizeof ("--timeout=") - 1;
|
||||||
|
|
||||||
|
if (! safe_parse_maxint (&val, &timeout))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
|
||||||
|
arg = skip_to (0, arg);
|
||||||
|
}
|
||||||
|
|
||||||
/* If no argument is specified, show current setting. */
|
/* If no argument is specified, show current setting. */
|
||||||
if (! *arg)
|
if (! *arg)
|
||||||
{
|
{
|
||||||
if (terminal & TERMINAL_CONSOLE)
|
if (terminal & TERMINAL_CONSOLE)
|
||||||
grub_printf ("console\n");
|
grub_printf ("console%s\n",
|
||||||
|
terminal & TERMINAL_DUMB ? " (dumb)" : "");
|
||||||
#ifdef SUPPORT_SERIAL
|
#ifdef SUPPORT_SERIAL
|
||||||
else if (terminal & TERMINAL_SERIAL)
|
else if (terminal & TERMINAL_SERIAL)
|
||||||
grub_printf ("serial\n");
|
grub_printf ("serial%s\n",
|
||||||
|
terminal & TERMINAL_DUMB ? " (dumb)" : " (vt100)");
|
||||||
#endif /* SUPPORT_SERIAL */
|
#endif /* SUPPORT_SERIAL */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear current setting. */
|
/* Clear current setting. */
|
||||||
terminal = 0;
|
terminal = dumb ? TERMINAL_DUMB : 0;
|
||||||
|
|
||||||
while (1)
|
while (*arg)
|
||||||
{
|
{
|
||||||
if (grub_memcmp (arg, "console", sizeof ("console") - 1) == 0)
|
if (grub_memcmp (arg, "console", sizeof ("console") - 1) == 0)
|
||||||
|
{
|
||||||
terminal |= TERMINAL_CONSOLE;
|
terminal |= TERMINAL_CONSOLE;
|
||||||
|
if (! default_terminal)
|
||||||
|
default_terminal = TERMINAL_CONSOLE;
|
||||||
|
}
|
||||||
#ifdef SUPPORT_SERIAL
|
#ifdef SUPPORT_SERIAL
|
||||||
else if (grub_memcmp (arg, "serial", sizeof ("serial") - 1) == 0)
|
else if (grub_memcmp (arg, "serial", sizeof ("serial") - 1) == 0)
|
||||||
|
{
|
||||||
terminal |= TERMINAL_SERIAL;
|
terminal |= TERMINAL_SERIAL;
|
||||||
|
if (! default_terminal)
|
||||||
|
default_terminal = TERMINAL_SERIAL;
|
||||||
|
}
|
||||||
#endif /* SUPPORT_SERIAL */
|
#endif /* SUPPORT_SERIAL */
|
||||||
else
|
else
|
||||||
break;
|
{
|
||||||
|
terminal = saved_terminal;
|
||||||
|
errnum = ERR_BAD_ARGUMENT;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
arg = skip_to (0, arg);
|
arg = skip_to (0, arg);
|
||||||
}
|
}
|
||||||
|
@ -3323,13 +3360,13 @@ terminal_func (char *arg, int flags)
|
||||||
;
|
;
|
||||||
|
|
||||||
/* Wait for a key input. */
|
/* Wait for a key input. */
|
||||||
while (1)
|
while (timeout)
|
||||||
{
|
{
|
||||||
if ((terminal & TERMINAL_CONSOLE) && console_checkkey () != -1)
|
if ((terminal & TERMINAL_CONSOLE) && console_checkkey () != -1)
|
||||||
{
|
{
|
||||||
terminal = TERMINAL_CONSOLE;
|
terminal = TERMINAL_CONSOLE;
|
||||||
(void) getkey ();
|
(void) getkey ();
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
else if ((terminal & TERMINAL_SERIAL) && serial_checkkey () != -1)
|
else if ((terminal & TERMINAL_SERIAL) && serial_checkkey () != -1)
|
||||||
{
|
{
|
||||||
|
@ -3340,7 +3377,8 @@ terminal_func (char *arg, int flags)
|
||||||
it to repaint the screen. */
|
it to repaint the screen. */
|
||||||
if (flags & BUILTIN_CMDLINE)
|
if (flags & BUILTIN_CMDLINE)
|
||||||
grub_longjmp (restart_cmdline_env, 0);
|
grub_longjmp (restart_cmdline_env, 0);
|
||||||
break;
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prompt the user, once per sec. */
|
/* Prompt the user, once per sec. */
|
||||||
|
@ -3348,8 +3386,14 @@ terminal_func (char *arg, int flags)
|
||||||
{
|
{
|
||||||
grub_printf ("Press any key to continue.\n");
|
grub_printf ("Press any key to continue.\n");
|
||||||
time2 = time1;
|
time2 = time1;
|
||||||
|
if (timeout > 0)
|
||||||
|
timeout--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Expired. */
|
||||||
|
terminal &= TERMINAL_DUMB;
|
||||||
|
terminal |= default_terminal;
|
||||||
}
|
}
|
||||||
#endif /* SUPPORT_SERIAL */
|
#endif /* SUPPORT_SERIAL */
|
||||||
|
|
||||||
|
@ -3361,11 +3405,14 @@ static struct builtin builtin_terminal =
|
||||||
"terminal",
|
"terminal",
|
||||||
terminal_func,
|
terminal_func,
|
||||||
BUILTIN_MENU | BUILTIN_CMDLINE,
|
BUILTIN_MENU | BUILTIN_CMDLINE,
|
||||||
"terminal [console] [serial]",
|
"terminal [--dumb] [--timeout=SECS] [console] [serial]",
|
||||||
"Select a terminal. When serial is specified, wait until you push any key"
|
"Select a terminal. When serial is specified, wait until you push any key"
|
||||||
" to continue. If both console and serial are specified, the terminal"
|
" to continue. If both console and serial are specified, the terminal"
|
||||||
" to which you input a key first will be selected. If no argument is"
|
" to which you input a key first will be selected. If no argument is"
|
||||||
" specified, print current setting."
|
" specified, print current setting. The option --dumb speicifies that"
|
||||||
|
" your terminal is dumb, otherwise, vt100-compatibility is assumed."
|
||||||
|
" If --timeout is present, this command will wait at most for SECS"
|
||||||
|
" seconds."
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1023,19 +1023,11 @@ getkey (void)
|
||||||
{
|
{
|
||||||
int c = -1;
|
int c = -1;
|
||||||
|
|
||||||
if (terminal == TERMINAL_CONSOLE)
|
if (terminal & TERMINAL_CONSOLE)
|
||||||
c = console_getkey ();
|
c = console_getkey ();
|
||||||
#ifdef SUPPORT_SERIAL
|
#ifdef SUPPORT_SERIAL
|
||||||
else if (terminal == TERMINAL_SERIAL)
|
else if (terminal & TERMINAL_SERIAL)
|
||||||
c = serial_getkey ();
|
c = serial_getkey ();
|
||||||
else
|
|
||||||
{
|
|
||||||
grub_printf ("\
|
|
||||||
Warning: Both the console and serial terminals are enabled in getkey!
|
|
||||||
The serial terminal will be disabled.\n");
|
|
||||||
terminal = TERMINAL_CONSOLE;
|
|
||||||
c = console_getkey ();
|
|
||||||
}
|
|
||||||
#endif /* SUPPORT_SERIAL */
|
#endif /* SUPPORT_SERIAL */
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue