rename console input/output functions to more distinguishable names.
This commit is contained in:
parent
fa003769c5
commit
1b9e348ef6
6 changed files with 145 additions and 11 deletions
31
ChangeLog
31
ChangeLog
|
@ -1,3 +1,34 @@
|
|||
2000-07-12 OKUJI Yoshinori <okuji@gnu.org>
|
||||
|
||||
Just to start implementing serial console support...
|
||||
|
||||
* stage2/asm.S (grub_putchar): Renamed to ...
|
||||
(console_putchar): ... this.
|
||||
[!STAGE1_5] (getkey): Renamed to ...
|
||||
[!STAGE1_5] (console_getkey): ... this.
|
||||
[!STAGE1_5] (checkkey): Renamed to ...
|
||||
[!STAGE1_5] (console_checkkey): ... this.
|
||||
* stage2/char_io.c [!STAGE1_5] (getkey): New function.
|
||||
[!STAGE1_5] (checkkey): Likewise.
|
||||
(grub_putchar): Likewise.
|
||||
* stage2/shared.h [!STAGE1_5] (terminal): Declared.
|
||||
[!STAGE1_5] (TERMINAL_CONSOLE): New macro.
|
||||
[!STAGE1_5] (TERMINAL_SERIAL): Likewise.
|
||||
(console_putchar): Declared.
|
||||
(serial_putchar): Likewise.
|
||||
(console_getkey): Likewise.
|
||||
(serial_getkey): Likewise.
|
||||
(console_checkkey): Likewise.
|
||||
(serial_checkkey): Likewise.
|
||||
* stage2/builtins.c (terminal): New global variable. The default
|
||||
is TERMINAL_CONSOLE.
|
||||
* grub/asmstub.c (grub_putchar): Renamed to ...
|
||||
(console_putchar): ... this.
|
||||
(getkey): Renamed to ...
|
||||
(console_getkey): ... this.
|
||||
(checkkey): Renamed to ...
|
||||
(console_checkkey): ... this.
|
||||
|
||||
2000-07-12 OKUJI Yoshinori <okuji@gnu.org>
|
||||
|
||||
* stage2/Makefile.am (libgrub_a_CFLAGS): Added
|
||||
|
|
|
@ -460,7 +460,7 @@ grub_longjmp (grub_jmp_buf env, int val)
|
|||
/* displays an ASCII character. IBM displays will translate some
|
||||
characters to special graphical ones */
|
||||
void
|
||||
grub_putchar (int c)
|
||||
console_putchar (int c)
|
||||
{
|
||||
#ifdef HAVE_LIBCURSES
|
||||
if (use_curses)
|
||||
|
@ -480,7 +480,7 @@ static int save_char = ERR;
|
|||
|
||||
/* returns packed BIOS/ASCII code */
|
||||
int
|
||||
getkey (void)
|
||||
console_getkey (void)
|
||||
{
|
||||
int c;
|
||||
|
||||
|
@ -512,7 +512,7 @@ getkey (void)
|
|||
|
||||
/* like 'getkey', but doesn't wait, returns -1 if nothing available */
|
||||
int
|
||||
checkkey (void)
|
||||
console_checkkey (void)
|
||||
{
|
||||
#ifdef HAVE_LIBCURSES
|
||||
if (use_curses)
|
||||
|
|
17
stage2/asm.S
17
stage2/asm.S
|
@ -1386,8 +1386,9 @@ ENTRY(grub_longjmp)
|
|||
|
||||
|
||||
/*
|
||||
* putchar(c) : Puts character on the screen, interpreting '\n' as in the
|
||||
* UNIX fashion.
|
||||
* console_putchar(c)
|
||||
*
|
||||
* Puts character on the screen, interpreting '\n' as in the UNIX fashion.
|
||||
*
|
||||
* BIOS call "INT 10H Function 0Eh" to write character to console
|
||||
* Call with %ah = 0x0e
|
||||
|
@ -1397,7 +1398,7 @@ ENTRY(grub_longjmp)
|
|||
*/
|
||||
|
||||
|
||||
ENTRY(grub_putchar)
|
||||
ENTRY(console_putchar)
|
||||
push %ebp
|
||||
push %eax
|
||||
push %ebx
|
||||
|
@ -1410,7 +1411,7 @@ ENTRY(grub_putchar)
|
|||
|
||||
/* if newline, print CR as well */
|
||||
pushl $0xd
|
||||
call EXT_C(grub_putchar)
|
||||
call EXT_C(console_putchar)
|
||||
popl %eax
|
||||
|
||||
pc_notnewline:
|
||||
|
@ -2063,14 +2064,14 @@ ENTRY(ascii_key_map)
|
|||
|
||||
|
||||
/*
|
||||
* getkey()
|
||||
* console_getkey()
|
||||
* BIOS call "INT 16H Function 00H" to read character from keyboard
|
||||
* Call with %ah = 0x0
|
||||
* Return: %ah = keyboard scan code
|
||||
* %al = ASCII character
|
||||
*/
|
||||
|
||||
ENTRY(getkey)
|
||||
ENTRY(console_getkey)
|
||||
push %ebp
|
||||
push %ebx /* save %ebx */
|
||||
|
||||
|
@ -2093,7 +2094,7 @@ ENTRY(getkey)
|
|||
|
||||
|
||||
/*
|
||||
* checkkey()
|
||||
* console_checkkey()
|
||||
* if there is a character pending, return it; otherwise return -1
|
||||
* BIOS call "INT 16H Function 01H" to check whether a character is pending
|
||||
* Call with %ah = 0x1
|
||||
|
@ -2105,7 +2106,7 @@ ENTRY(getkey)
|
|||
* else
|
||||
* Zero flag = set
|
||||
*/
|
||||
ENTRY(checkkey)
|
||||
ENTRY(console_checkkey)
|
||||
push %ebp
|
||||
push %ebx
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
# include <smp-imps.h>
|
||||
#endif /* ! GRUB_UTIL */
|
||||
|
||||
/* Terminal types. */
|
||||
int terminal = TERMINAL_CONSOLE;
|
||||
/* The type of kernel loaded. */
|
||||
kernel_t kernel_type;
|
||||
/* The boot device. */
|
||||
|
|
|
@ -170,6 +170,7 @@ grub_sprintf (char *buffer, const char *format, ...)
|
|||
return bp - buffer;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
init_page (void)
|
||||
{
|
||||
|
@ -739,8 +740,83 @@ grub_strcmp (const char *s1, const char *s2)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Wait for a keypress and return its code. */
|
||||
int
|
||||
getkey (void)
|
||||
{
|
||||
int c = -1;
|
||||
|
||||
if (terminal == TERMINAL_CONSOLE)
|
||||
c = console_getkey ();
|
||||
#ifdef serial_console_is_not_implemented_yet
|
||||
else if (terminal == TERMINAL_SERIAL)
|
||||
c = serial_getkey ();
|
||||
else
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
c = console_checkkey ();
|
||||
if (c != -1)
|
||||
{
|
||||
c = console_getkey ();
|
||||
break;
|
||||
}
|
||||
|
||||
c = serial_checkkey ();
|
||||
if (c != -1)
|
||||
{
|
||||
c = serial_getkey ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Check if a key code is available. */
|
||||
int
|
||||
checkkey (void)
|
||||
{
|
||||
int c = -1;
|
||||
|
||||
if (terminal & TERMINAL_CONSOLE)
|
||||
c = console_checkkey ();
|
||||
|
||||
#ifdef serial_console_is_not_implemented_yet
|
||||
if (c == -1 && (terminal & TERMINAL_SERIAL))
|
||||
c = serial_checkkey ();
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif /* ! STAGE1_5 */
|
||||
|
||||
/* Display an ASCII character. */
|
||||
void
|
||||
grub_putchar (int c)
|
||||
{
|
||||
#ifdef STAGE1_5
|
||||
|
||||
/* In Stage 1.5, only the normal console is supported. */
|
||||
console_putchar (c);
|
||||
|
||||
#else /* ! STAGE1_5 */
|
||||
|
||||
if (terminal & TERMINAL_CONSOLE)
|
||||
console_putchar (c);
|
||||
|
||||
#ifdef serial_console_is_not_implemented_yet
|
||||
if (terminal & TERMINAL_SERIAL)
|
||||
serial_putchar (c);
|
||||
#endif
|
||||
|
||||
#endif /* ! STAGE1_5 */
|
||||
}
|
||||
|
||||
int
|
||||
substring (char *s1, char *s2)
|
||||
{
|
||||
|
|
|
@ -625,14 +625,32 @@ void gotoxy (int x, int y);
|
|||
characters to special graphical ones (see the DISP_* constants). */
|
||||
void grub_putchar (int c);
|
||||
|
||||
/* The console part of grub_putchar. */
|
||||
void console_putchar (int c);
|
||||
|
||||
/* The serial part of grub_putchar. */
|
||||
void serial_putchar (int c);
|
||||
|
||||
/* Wait for a keypress, and return its packed BIOS/ASCII key code.
|
||||
Use ASCII_CHAR(ret) to extract the ASCII code. */
|
||||
int getkey (void);
|
||||
|
||||
/* The console part of getkey. */
|
||||
int console_getkey (void);
|
||||
|
||||
/* The serial part of getkey. */
|
||||
int serial_getkey (void);
|
||||
|
||||
/* Like GETKEY, but doesn't block, and returns -1 if no keystroke is
|
||||
available. */
|
||||
int checkkey (void);
|
||||
|
||||
/* The console part of checkkey. */
|
||||
int console_checkkey (void);
|
||||
|
||||
/* The serial part of checkkey. */
|
||||
int serial_checkkey (void);
|
||||
|
||||
/* Sets text mode character attribute at the cursor position. See A_*
|
||||
constants defined above. */
|
||||
void set_attrib (int attr);
|
||||
|
@ -686,6 +704,12 @@ extern kernel_t kernel_type;
|
|||
extern int show_menu;
|
||||
extern int grub_timeout;
|
||||
|
||||
/* This variable specifies which console should be used. */
|
||||
extern int terminal;
|
||||
|
||||
#define TERMINAL_CONSOLE (1 << 0) /* keyboard and screen */
|
||||
#define TERMINAL_SERIAL (1 << 1) /* serial console */
|
||||
|
||||
void init_builtins (void);
|
||||
void init_config (void);
|
||||
char *skip_to (int after_equal, char *cmdline);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue