2002-12-27 08:53:07 +00:00
|
|
|
/*
|
2004-04-04 13:46:03 +00:00
|
|
|
* GRUB -- GRand Unified Bootloader
|
2009-08-28 13:20:34 +00:00
|
|
|
* Copyright (C) 2002,2003,2005,2007,2008,2009 Free Software Foundation, Inc.
|
2002-12-27 08:53:07 +00:00
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
2002-12-27 08:53:07 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-21 23:32:33 +00:00
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2002-12-27 08:53:07 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
2002-12-27 08:53:07 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-07-21 23:32:33 +00:00
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
2002-12-27 08:53:07 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-28 13:20:34 +00:00
|
|
|
#include <grub/machine/memory.h>
|
2004-04-04 13:46:03 +00:00
|
|
|
#include <grub/machine/console.h>
|
|
|
|
#include <grub/term.h>
|
|
|
|
#include <grub/types.h>
|
2011-11-12 15:29:04 +00:00
|
|
|
#include <grub/machine/int.h>
|
|
|
|
|
2012-06-28 13:27:54 +00:00
|
|
|
static grub_uint8_t grub_console_cur_color = 0x7;
|
|
|
|
|
2011-11-12 15:29:04 +00:00
|
|
|
static void
|
|
|
|
int10_9 (grub_uint8_t ch, grub_uint16_t n)
|
|
|
|
{
|
|
|
|
struct grub_bios_int_registers regs;
|
|
|
|
|
|
|
|
regs.eax = ch | 0x0900;
|
|
|
|
regs.ebx = grub_console_cur_color & 0xff;
|
|
|
|
regs.ecx = n;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x10, ®s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BIOS call "INT 10H Function 03h" to get cursor position
|
|
|
|
* Call with %ah = 0x03
|
|
|
|
* %bh = page
|
|
|
|
* Returns %ch = starting scan line
|
|
|
|
* %cl = ending scan line
|
|
|
|
* %dh = row (0 is top)
|
|
|
|
* %dl = column (0 is left)
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
static grub_uint16_t
|
|
|
|
grub_console_getxy (struct grub_term_output *term __attribute__ ((unused)))
|
|
|
|
{
|
|
|
|
struct grub_bios_int_registers regs;
|
|
|
|
|
|
|
|
regs.eax = 0x0300;
|
|
|
|
regs.ebx = 0;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x10, ®s);
|
|
|
|
|
|
|
|
return ((regs.edx & 0xff) << 8) | ((regs.edx & 0xff00) >> 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BIOS call "INT 10H Function 02h" to set cursor position
|
|
|
|
* Call with %ah = 0x02
|
|
|
|
* %bh = page
|
|
|
|
* %dh = row (0 is top)
|
|
|
|
* %dl = column (0 is left)
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
grub_console_gotoxy (struct grub_term_output *term __attribute__ ((unused)),
|
|
|
|
grub_uint8_t x, grub_uint8_t y)
|
|
|
|
{
|
|
|
|
struct grub_bios_int_registers regs;
|
|
|
|
|
|
|
|
/* set page to 0 */
|
|
|
|
regs.ebx = 0;
|
|
|
|
regs.eax = 0x0200;
|
|
|
|
regs.edx = (y << 8) | x;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x10, ®s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Put the character C on the console. Because GRUB wants to write a
|
|
|
|
* character with an attribute, this implementation is a bit tricky.
|
|
|
|
* If C is a control character (CR, LF, BEL, BS), use INT 10, AH = 0Eh
|
2013-04-08 17:51:33 +00:00
|
|
|
* (TELETYPE OUTPUT). Otherwise, use INT 10, AH = 9 to write character
|
|
|
|
* with attributes and advance cursor. If we are on the last column,
|
|
|
|
* let BIOS to wrap line correctly.
|
2011-11-12 15:29:04 +00:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
grub_console_putchar_real (grub_uint8_t c)
|
|
|
|
{
|
|
|
|
struct grub_bios_int_registers regs;
|
|
|
|
grub_uint16_t pos;
|
|
|
|
|
|
|
|
if (c == 7 || c == 8 || c == 0xa || c == 0xd)
|
|
|
|
{
|
|
|
|
regs.eax = c | 0x0e00;
|
|
|
|
regs.ebx = 0x0001;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x10, ®s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get the current position */
|
|
|
|
pos = grub_console_getxy (NULL);
|
|
|
|
|
2013-04-08 17:51:33 +00:00
|
|
|
/* write the character with the attribute */
|
|
|
|
int10_9 (c, 1);
|
|
|
|
|
2011-11-12 15:29:04 +00:00
|
|
|
/* check the column with the width */
|
|
|
|
if ((pos & 0xff00) >= (79 << 8))
|
|
|
|
{
|
|
|
|
grub_console_putchar_real (0x0d);
|
|
|
|
grub_console_putchar_real (0x0a);
|
|
|
|
}
|
2013-04-08 17:51:33 +00:00
|
|
|
else
|
|
|
|
grub_console_gotoxy (NULL, ((pos & 0xff00) >> 8) + 1, (pos & 0xff));
|
2011-11-12 15:29:04 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
grub_console_putchar (struct grub_term_output *term __attribute__ ((unused)),
|
|
|
|
const struct grub_unicode_glyph *c)
|
|
|
|
{
|
|
|
|
grub_console_putchar_real (c->base);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* BIOS call "INT 10H Function 09h" to write character and attribute
|
|
|
|
* Call with %ah = 0x09
|
|
|
|
* %al = (character)
|
|
|
|
* %bh = (page number)
|
|
|
|
* %bl = (attribute)
|
|
|
|
* %cx = (number of times)
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
grub_console_cls (struct grub_term_output *term)
|
|
|
|
{
|
|
|
|
/* move the cursor to the beginning */
|
|
|
|
grub_console_gotoxy (term, 0, 0);
|
|
|
|
|
|
|
|
/* write spaces to the entire screen */
|
|
|
|
int10_9 (' ', 80 * 25);
|
|
|
|
|
|
|
|
/* move back the cursor */
|
|
|
|
grub_console_gotoxy (term, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* void grub_console_setcursor (int on)
|
|
|
|
* BIOS call "INT 10H Function 01h" to set cursor type
|
|
|
|
* Call with %ah = 0x01
|
|
|
|
* %ch = cursor starting scanline
|
|
|
|
* %cl = cursor ending scanline
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)),
|
|
|
|
int on)
|
|
|
|
{
|
|
|
|
static grub_uint16_t console_cursor_shape = 0;
|
|
|
|
struct grub_bios_int_registers regs;
|
|
|
|
|
|
|
|
/* check if the standard cursor shape has already been saved */
|
|
|
|
if (!console_cursor_shape)
|
|
|
|
{
|
|
|
|
regs.eax = 0x0300;
|
|
|
|
regs.ebx = 0;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x10, ®s);
|
|
|
|
console_cursor_shape = regs.ecx;
|
|
|
|
if ((console_cursor_shape >> 8) >= (console_cursor_shape & 0xff))
|
|
|
|
console_cursor_shape = 0x0d0e;
|
|
|
|
}
|
|
|
|
/* set %cx to the designated cursor shape */
|
|
|
|
regs.ecx = on ? console_cursor_shape : 0x2000;
|
|
|
|
regs.eax = 0x0100;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x10, ®s);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* Return:
|
|
|
|
* If key waiting to be input:
|
|
|
|
* %ah = keyboard scan code
|
|
|
|
* %al = ASCII character
|
|
|
|
* Zero flag = clear
|
|
|
|
* else
|
|
|
|
* Zero flag = set
|
|
|
|
* BIOS call "INT 16H Function 00H" to read character from keyboard
|
|
|
|
* Call with %ah = 0x0
|
|
|
|
* Return: %ah = keyboard scan code
|
|
|
|
* %al = ASCII character
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
grub_console_getkey (struct grub_term_input *term __attribute__ ((unused)))
|
|
|
|
{
|
|
|
|
const grub_uint16_t bypass_table[] = {
|
|
|
|
0x0100 | '\e', 0x0f00 | '\t', 0x0e00 | '\b', 0x1c00 | '\r', 0x1c00 | '\n'
|
|
|
|
};
|
|
|
|
struct grub_bios_int_registers regs;
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Due to a bug in apple's bootcamp implementation, INT 16/AH = 0 would
|
|
|
|
* cause the machine to hang at the second keystroke. However, we can
|
|
|
|
* work around this problem by ensuring the presence of keystroke with
|
|
|
|
* INT 16/AH = 1 before calling INT 16/AH = 0.
|
|
|
|
*/
|
|
|
|
|
|
|
|
regs.eax = 0x0100;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x16, ®s);
|
|
|
|
if (regs.flags & GRUB_CPU_INT_FLAGS_ZERO)
|
|
|
|
return GRUB_TERM_NO_KEY;
|
|
|
|
|
|
|
|
regs.eax = 0x0000;
|
|
|
|
regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
|
|
|
|
grub_bios_interrupt (0x16, ®s);
|
|
|
|
if (!(regs.eax & 0xff))
|
|
|
|
return ((regs.eax >> 8) & 0xff) | GRUB_TERM_EXTENDED;
|
|
|
|
|
|
|
|
if ((regs.eax & 0xff) >= ' ')
|
|
|
|
return regs.eax & 0xff;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE (bypass_table); i++)
|
|
|
|
if (bypass_table[i] == (regs.eax & 0xffff))
|
|
|
|
return regs.eax & 0xff;
|
|
|
|
|
|
|
|
return (regs.eax & 0xff) + (('a' - 1) | GRUB_TERM_CTRL);
|
|
|
|
}
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2009-08-28 14:10:02 +00:00
|
|
|
static const struct grub_machine_bios_data_area *bios_data_area =
|
|
|
|
(struct grub_machine_bios_data_area *) GRUB_MEMORY_MACHINE_BIOS_DATA_AREA_ADDR;
|
2009-08-28 13:20:34 +00:00
|
|
|
|
|
|
|
static int
|
2010-05-07 00:30:44 +00:00
|
|
|
grub_console_getkeystatus (struct grub_term_input *term __attribute__ ((unused)))
|
2009-08-28 13:20:34 +00:00
|
|
|
{
|
2010-08-19 13:00:31 +00:00
|
|
|
/* conveniently GRUB keystatus is modelled after BIOS one. */
|
|
|
|
return bios_data_area->keyboard_flag_lower & ~0x80;
|
2009-08-28 13:20:34 +00:00
|
|
|
}
|
|
|
|
|
2012-06-28 13:27:54 +00:00
|
|
|
static grub_uint16_t
|
|
|
|
grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
|
|
|
|
{
|
2013-04-08 17:51:33 +00:00
|
|
|
return (80 << 8) | 25;
|
2012-06-28 13:27:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2013-01-21 16:53:41 +00:00
|
|
|
grub_console_setcolorstate (struct grub_term_output *term
|
|
|
|
__attribute__ ((unused)),
|
2012-06-28 13:27:54 +00:00
|
|
|
grub_term_color_state state)
|
|
|
|
{
|
|
|
|
switch (state) {
|
|
|
|
case GRUB_TERM_COLOR_STANDARD:
|
|
|
|
grub_console_cur_color = GRUB_TERM_DEFAULT_STANDARD_COLOR & 0x7f;
|
|
|
|
break;
|
|
|
|
case GRUB_TERM_COLOR_NORMAL:
|
2013-01-21 16:53:41 +00:00
|
|
|
grub_console_cur_color = grub_term_normal_color & 0x7f;
|
2012-06-28 13:27:54 +00:00
|
|
|
break;
|
|
|
|
case GRUB_TERM_COLOR_HIGHLIGHT:
|
2013-01-21 16:53:41 +00:00
|
|
|
grub_console_cur_color = grub_term_highlight_color & 0x7f;
|
2012-06-28 13:27:54 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-07 Robert Millan <rmh@aybabtu.com>
Modularize at_keyboard.mod:
* conf/i386.rmk (pkglib_MODULES): Add `at_keyboard.mod'.
(at_keyboard_mod_SOURCES, at_keyboard_mod_CFLAGS)
(at_keyboard_mod_LDFLAGS): New variables.
Actual terminal split:
* include/grub/term.h (struct grub_term): Split in ...
(struct grub_term_input): ... this, and ...
(struct grub_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/term.c (grub_term_list): Split in ...
(grub_term_list_input): ... this, and ...
(grub_term_list_output): ... this. Update all users.
(grub_cur_term): Split in ...
(grub_cur_term_input): ... this, and ...
(grub_cur_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/misc.c (grub_abort): Split use of grub_term_get_current() into
a check for input and one for output (and only attempt to get keys
from user when input works).
* util/grub-probe.c (grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
* util/grub-fstest.c: Likewise.
* util/i386/pc/grub-setup.c: Likewise.
* util/grub-editenv.c: Likewise.
Portability adjustments:
* conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Remove
`term/i386/pc/at_keyboard.c'.
* kern/ieee1275/init.c [__i386__] (grub_machine_init): Remove call to
grub_keyboard_controller_init() (now handled by terminal .init).
* kern/i386/coreboot/init.c (grub_machine_init): Add call to
grub_at_keyboard_init().
* include/grub/i386/ieee1275/console.h (grub_keyboard_controller_init)
(grub_console_checkkey, grub_console_getkey): Remove (now provided by
at_keyboard.mod via input terminal interface).
* include/grub/i386/coreboot/console.h: Convert into a stub for
`<grub/i386/pc/console.h>'.
Migrate full terminals to new API:
* term/efi/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
* term/ieee1275/ofconsole.c: Remove __i386__ hack.
(grub_ofconsole_init): Split into ...
(grub_ofconsole_init_input): ... this, and ...
(grub_ofconsole_init_output): ... this.
(grub_ofconsole_term): Split into ...
(grub_ofconsole_term_input): ... this, and ...
(grub_ofconsole_term_output): ... this. Update all users.
* term/i386/pc/serial.c (grub_serial_term): Split into ...
(grub_serial_term_input): ... this, and ...
(grub_serial_term_output): ... this. Update all users.
* term/i386/pc/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
(grub_console_term_input): Only enable it on PC/BIOS platform.
(grub_console_init): Remove grub_keyboard_controller_init() call.
Migrate input terminals to new API:
* term/i386/pc/at_keyboard.c: Replace `cpu' and `machine' with
`i386' and `i386/pc' to enable build on x86_64 (this driver is
i386-specific anyway).
(grub_console_checkkey): Rename to ...
(grub_at_keyboard_checkkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_orig): New variable.
(grub_console_getkey): Rename to ...
(grub_at_keyboard_getkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_init): Static-ize. Save original
controller value so that it can be restored ...
(grub_keyboard_controller_fini): ... here (new function).
(grub_at_keyboard_term): New structure.
(GRUB_MOD_INIT(at_keyboard), GRUB_MOD_FINI(at_keyboard)): New
functions.
Migrate output terminals to new API:
* term/i386/pc/vga.c (grub_vga_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* term/gfxterm.c (grub_video_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* include/grub/i386/pc/console.h (grub_console_checkkey)
(grub_console_getkey): Do not export (no longer needed by gfxterm,
etc).
Migrate `terminal' command and userland tools to new API:
* commands/terminal.c (grub_cmd_terminal): Split into ...
(grub_cmd_terminal_input): ... this, and ...
(grub_cmd_terminal_output): ... this.
(GRUB_MOD_INIT(terminal)): Split `terminal' command in two commands:
`terminal_input' and `terminal_output'.
* util/grub.d/00_header.in: Adjust `terminal' calls to new
`terminal_input' / `terminal_output' API.
* util/grub-mkconfig.in: Export ${GRUB_TERMINAL_INPUT} and
${GRUB_TERMINAL_OUTPUT} instead of ${GRUB_TERMINAL} (and if user
provided ${GRUB_TERMINAL}, convert it).
2008-11-07 19:11:39 +00:00
|
|
|
static struct grub_term_input grub_console_term_input =
|
2002-12-27 08:53:07 +00:00
|
|
|
{
|
|
|
|
.name = "console",
|
2004-04-04 13:46:03 +00:00
|
|
|
.getkey = grub_console_getkey,
|
2010-08-19 11:32:36 +00:00
|
|
|
.getkeystatus = grub_console_getkeystatus
|
2008-11-07 Robert Millan <rmh@aybabtu.com>
Modularize at_keyboard.mod:
* conf/i386.rmk (pkglib_MODULES): Add `at_keyboard.mod'.
(at_keyboard_mod_SOURCES, at_keyboard_mod_CFLAGS)
(at_keyboard_mod_LDFLAGS): New variables.
Actual terminal split:
* include/grub/term.h (struct grub_term): Split in ...
(struct grub_term_input): ... this, and ...
(struct grub_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/term.c (grub_term_list): Split in ...
(grub_term_list_input): ... this, and ...
(grub_term_list_output): ... this. Update all users.
(grub_cur_term): Split in ...
(grub_cur_term_input): ... this, and ...
(grub_cur_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/misc.c (grub_abort): Split use of grub_term_get_current() into
a check for input and one for output (and only attempt to get keys
from user when input works).
* util/grub-probe.c (grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
* util/grub-fstest.c: Likewise.
* util/i386/pc/grub-setup.c: Likewise.
* util/grub-editenv.c: Likewise.
Portability adjustments:
* conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Remove
`term/i386/pc/at_keyboard.c'.
* kern/ieee1275/init.c [__i386__] (grub_machine_init): Remove call to
grub_keyboard_controller_init() (now handled by terminal .init).
* kern/i386/coreboot/init.c (grub_machine_init): Add call to
grub_at_keyboard_init().
* include/grub/i386/ieee1275/console.h (grub_keyboard_controller_init)
(grub_console_checkkey, grub_console_getkey): Remove (now provided by
at_keyboard.mod via input terminal interface).
* include/grub/i386/coreboot/console.h: Convert into a stub for
`<grub/i386/pc/console.h>'.
Migrate full terminals to new API:
* term/efi/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
* term/ieee1275/ofconsole.c: Remove __i386__ hack.
(grub_ofconsole_init): Split into ...
(grub_ofconsole_init_input): ... this, and ...
(grub_ofconsole_init_output): ... this.
(grub_ofconsole_term): Split into ...
(grub_ofconsole_term_input): ... this, and ...
(grub_ofconsole_term_output): ... this. Update all users.
* term/i386/pc/serial.c (grub_serial_term): Split into ...
(grub_serial_term_input): ... this, and ...
(grub_serial_term_output): ... this. Update all users.
* term/i386/pc/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
(grub_console_term_input): Only enable it on PC/BIOS platform.
(grub_console_init): Remove grub_keyboard_controller_init() call.
Migrate input terminals to new API:
* term/i386/pc/at_keyboard.c: Replace `cpu' and `machine' with
`i386' and `i386/pc' to enable build on x86_64 (this driver is
i386-specific anyway).
(grub_console_checkkey): Rename to ...
(grub_at_keyboard_checkkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_orig): New variable.
(grub_console_getkey): Rename to ...
(grub_at_keyboard_getkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_init): Static-ize. Save original
controller value so that it can be restored ...
(grub_keyboard_controller_fini): ... here (new function).
(grub_at_keyboard_term): New structure.
(GRUB_MOD_INIT(at_keyboard), GRUB_MOD_FINI(at_keyboard)): New
functions.
Migrate output terminals to new API:
* term/i386/pc/vga.c (grub_vga_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* term/gfxterm.c (grub_video_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* include/grub/i386/pc/console.h (grub_console_checkkey)
(grub_console_getkey): Do not export (no longer needed by gfxterm,
etc).
Migrate `terminal' command and userland tools to new API:
* commands/terminal.c (grub_cmd_terminal): Split into ...
(grub_cmd_terminal_input): ... this, and ...
(grub_cmd_terminal_output): ... this.
(GRUB_MOD_INIT(terminal)): Split `terminal' command in two commands:
`terminal_input' and `terminal_output'.
* util/grub.d/00_header.in: Adjust `terminal' calls to new
`terminal_input' / `terminal_output' API.
* util/grub-mkconfig.in: Export ${GRUB_TERMINAL_INPUT} and
${GRUB_TERMINAL_OUTPUT} instead of ${GRUB_TERMINAL} (and if user
provided ${GRUB_TERMINAL}, convert it).
2008-11-07 19:11:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct grub_term_output grub_console_term_output =
|
|
|
|
{
|
|
|
|
.name = "console",
|
|
|
|
.putchar = grub_console_putchar,
|
2005-08-04 18:10:51 +00:00
|
|
|
.getwh = grub_console_getwh,
|
2004-04-04 13:46:03 +00:00
|
|
|
.getxy = grub_console_getxy,
|
|
|
|
.gotoxy = grub_console_gotoxy,
|
|
|
|
.cls = grub_console_cls,
|
|
|
|
.setcolorstate = grub_console_setcolorstate,
|
2010-03-15 20:14:11 +00:00
|
|
|
.setcursor = grub_console_setcursor,
|
2010-05-09 11:26:52 +00:00
|
|
|
.flags = GRUB_TERM_CODE_TYPE_CP437,
|
2002-12-27 08:53:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_console_init (void)
|
2002-12-27 08:53:07 +00:00
|
|
|
{
|
2010-01-09 22:42:17 +00:00
|
|
|
grub_term_register_output ("console", &grub_console_term_output);
|
|
|
|
grub_term_register_input ("console", &grub_console_term_input);
|
2002-12-27 08:53:07 +00:00
|
|
|
}
|
2005-02-15 00:07:01 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
grub_console_fini (void)
|
|
|
|
{
|
2008-11-07 Robert Millan <rmh@aybabtu.com>
Modularize at_keyboard.mod:
* conf/i386.rmk (pkglib_MODULES): Add `at_keyboard.mod'.
(at_keyboard_mod_SOURCES, at_keyboard_mod_CFLAGS)
(at_keyboard_mod_LDFLAGS): New variables.
Actual terminal split:
* include/grub/term.h (struct grub_term): Split in ...
(struct grub_term_input): ... this, and ...
(struct grub_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/term.c (grub_term_list): Split in ...
(grub_term_list_input): ... this, and ...
(grub_term_list_output): ... this. Update all users.
(grub_cur_term): Split in ...
(grub_cur_term_input): ... this, and ...
(grub_cur_term_output): ... this. Update all users.
(grub_term_set_current): Split in ...
(grub_term_set_current_input): ... this, and ...
(grub_term_set_current_output): ... this.
(grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
(grub_term_register): Split in ...
(grub_term_register_input): ... this, and ...
(grub_term_register_output): ... this.
(grub_term_unregister): Split in ...
(grub_term_unregister_input): ... this, and ...
(grub_term_unregister_output): ... this.
(grub_term_iterate): Split in ...
(grub_term_iterate_input): ... this, and ...
(grub_term_iterate_output): ... this.
* kern/misc.c (grub_abort): Split use of grub_term_get_current() into
a check for input and one for output (and only attempt to get keys
from user when input works).
* util/grub-probe.c (grub_term_get_current): Split in ...
(grub_term_get_current_input): ... this, and ...
(grub_term_get_current_output): ... this.
* util/grub-fstest.c: Likewise.
* util/i386/pc/grub-setup.c: Likewise.
* util/grub-editenv.c: Likewise.
Portability adjustments:
* conf/i386-ieee1275.rmk (kernel_elf_SOURCES): Remove
`term/i386/pc/at_keyboard.c'.
* kern/ieee1275/init.c [__i386__] (grub_machine_init): Remove call to
grub_keyboard_controller_init() (now handled by terminal .init).
* kern/i386/coreboot/init.c (grub_machine_init): Add call to
grub_at_keyboard_init().
* include/grub/i386/ieee1275/console.h (grub_keyboard_controller_init)
(grub_console_checkkey, grub_console_getkey): Remove (now provided by
at_keyboard.mod via input terminal interface).
* include/grub/i386/coreboot/console.h: Convert into a stub for
`<grub/i386/pc/console.h>'.
Migrate full terminals to new API:
* term/efi/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
* term/ieee1275/ofconsole.c: Remove __i386__ hack.
(grub_ofconsole_init): Split into ...
(grub_ofconsole_init_input): ... this, and ...
(grub_ofconsole_init_output): ... this.
(grub_ofconsole_term): Split into ...
(grub_ofconsole_term_input): ... this, and ...
(grub_ofconsole_term_output): ... this. Update all users.
* term/i386/pc/serial.c (grub_serial_term): Split into ...
(grub_serial_term_input): ... this, and ...
(grub_serial_term_output): ... this. Update all users.
* term/i386/pc/console.c (grub_console_term): Split into ...
(grub_console_term_input): ... this, and ...
(grub_console_term_output): ... this. Update all users.
(grub_console_term_input): Only enable it on PC/BIOS platform.
(grub_console_init): Remove grub_keyboard_controller_init() call.
Migrate input terminals to new API:
* term/i386/pc/at_keyboard.c: Replace `cpu' and `machine' with
`i386' and `i386/pc' to enable build on x86_64 (this driver is
i386-specific anyway).
(grub_console_checkkey): Rename to ...
(grub_at_keyboard_checkkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_orig): New variable.
(grub_console_getkey): Rename to ...
(grub_at_keyboard_getkey): ... this. Static-ize. Update all
users.
(grub_keyboard_controller_init): Static-ize. Save original
controller value so that it can be restored ...
(grub_keyboard_controller_fini): ... here (new function).
(grub_at_keyboard_term): New structure.
(GRUB_MOD_INIT(at_keyboard), GRUB_MOD_FINI(at_keyboard)): New
functions.
Migrate output terminals to new API:
* term/i386/pc/vga.c (grub_vga_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* term/gfxterm.c (grub_video_term): Change type to
`struct grub_term_output'. Remove `.checkkey' and `.getkey'
members. Update all users.
* include/grub/i386/pc/console.h (grub_console_checkkey)
(grub_console_getkey): Do not export (no longer needed by gfxterm,
etc).
Migrate `terminal' command and userland tools to new API:
* commands/terminal.c (grub_cmd_terminal): Split into ...
(grub_cmd_terminal_input): ... this, and ...
(grub_cmd_terminal_output): ... this.
(GRUB_MOD_INIT(terminal)): Split `terminal' command in two commands:
`terminal_input' and `terminal_output'.
* util/grub.d/00_header.in: Adjust `terminal' calls to new
`terminal_input' / `terminal_output' API.
* util/grub-mkconfig.in: Export ${GRUB_TERMINAL_INPUT} and
${GRUB_TERMINAL_OUTPUT} instead of ${GRUB_TERMINAL} (and if user
provided ${GRUB_TERMINAL}, convert it).
2008-11-07 19:11:39 +00:00
|
|
|
grub_term_unregister_input (&grub_console_term_input);
|
|
|
|
grub_term_unregister_output (&grub_console_term_output);
|
2005-02-15 00:07:01 +00:00
|
|
|
}
|