2002-12-27 08:53:07 +00:00
|
|
|
/*
|
2004-04-04 13:46:03 +00:00
|
|
|
* GRUB -- GRand Unified Bootloader
|
2008-02-05 Robert Millan <rmh@aybabtu.com>
* include/grub/term.h (GRUB_TERM_LEFT, GRUB_TERM_RIGHT)
(GRUB_TERM_UP, GRUB_TERM_DOWN, GRUB_TERM_HOME, GRUB_TERM_END)
(GRUB_TERM_DC, GRUB_TERM_PPAGE, GRUB_TERM_NPAGE, GRUB_TERM_ESC)
(GRUB_TERM_TAB, GRUB_TERM_BACKSPACE): New macros.
* kern/i386/pc/startup.S: Include `<grub/term.h>'.
(translation_table): Replace hardcoded values with macros
provided by `<grub/term.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/term.h>'.
(keyboard_map): Correct/add a few values, with macros provided
by `<grub/term.h>'.
(keyboard_map_shift): Zero values that don't differ from their
`keyboard_map' equivalents.
(grub_console_checkkey): Optimize KEYBOARD_STATUS_CAPS_LOCK toggling.
Discard the second scan code that is always sent by Caps lock.
Only use `keyboard_map_shift' when it provides a non-zero value,
otherwise fallback to `keyboard_map'.
2008-02-05 10:23:24 +00:00
|
|
|
* Copyright (C) 2002,2003,2005,2007,2008 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
|
|
|
*/
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
#ifndef GRUB_TERM_HEADER
|
|
|
|
#define GRUB_TERM_HEADER 1
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2008-02-05 Robert Millan <rmh@aybabtu.com>
* include/grub/term.h (GRUB_TERM_LEFT, GRUB_TERM_RIGHT)
(GRUB_TERM_UP, GRUB_TERM_DOWN, GRUB_TERM_HOME, GRUB_TERM_END)
(GRUB_TERM_DC, GRUB_TERM_PPAGE, GRUB_TERM_NPAGE, GRUB_TERM_ESC)
(GRUB_TERM_TAB, GRUB_TERM_BACKSPACE): New macros.
* kern/i386/pc/startup.S: Include `<grub/term.h>'.
(translation_table): Replace hardcoded values with macros
provided by `<grub/term.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/term.h>'.
(keyboard_map): Correct/add a few values, with macros provided
by `<grub/term.h>'.
(keyboard_map_shift): Zero values that don't differ from their
`keyboard_map' equivalents.
(grub_console_checkkey): Optimize KEYBOARD_STATUS_CAPS_LOCK toggling.
Discard the second scan code that is always sent by Caps lock.
Only use `keyboard_map_shift' when it provides a non-zero value,
otherwise fallback to `keyboard_map'.
2008-02-05 10:23:24 +00:00
|
|
|
/* Internal codes used by GRUB to represent terminal input. */
|
|
|
|
#define GRUB_TERM_LEFT 2
|
|
|
|
#define GRUB_TERM_RIGHT 6
|
|
|
|
#define GRUB_TERM_UP 16
|
|
|
|
#define GRUB_TERM_DOWN 14
|
|
|
|
#define GRUB_TERM_HOME 1
|
|
|
|
#define GRUB_TERM_END 5
|
|
|
|
#define GRUB_TERM_DC 4
|
|
|
|
#define GRUB_TERM_PPAGE 7
|
|
|
|
#define GRUB_TERM_NPAGE 3
|
|
|
|
#define GRUB_TERM_ESC '\e'
|
|
|
|
#define GRUB_TERM_TAB '\t'
|
|
|
|
#define GRUB_TERM_BACKSPACE '\b'
|
|
|
|
|
|
|
|
#ifndef ASM_FILE
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
#include <grub/err.h>
|
|
|
|
#include <grub/symbol.h>
|
|
|
|
#include <grub/types.h>
|
2009-03-01 17:51:44 +00:00
|
|
|
#include <grub/handler.h>
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
/* These are used to represent the various color states we use. */
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
/* The color used to display all text that does not use the
|
|
|
|
user defined colors below. */
|
2004-04-04 13:46:03 +00:00
|
|
|
GRUB_TERM_COLOR_STANDARD,
|
2002-12-27 08:53:07 +00:00
|
|
|
/* The user defined colors for normal text. */
|
2004-04-04 13:46:03 +00:00
|
|
|
GRUB_TERM_COLOR_NORMAL,
|
2002-12-27 08:53:07 +00:00
|
|
|
/* The user defined colors for highlighted text. */
|
2004-04-04 13:46:03 +00:00
|
|
|
GRUB_TERM_COLOR_HIGHLIGHT
|
2002-12-27 08:53:07 +00:00
|
|
|
}
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_term_color_state;
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
/* Flags for representing the capabilities of a terminal. */
|
|
|
|
/* Some notes about the flags:
|
|
|
|
- These flags are used by higher-level functions but not terminals
|
|
|
|
themselves.
|
|
|
|
- If a terminal is dumb, you may assume that only putchar, getkey and
|
|
|
|
checkkey are called.
|
|
|
|
- Some fancy features (setcolorstate, setcolor and setcursor) can be set
|
|
|
|
to NULL. */
|
|
|
|
|
|
|
|
/* Set when input characters shouldn't be echoed back. */
|
2004-04-04 13:46:03 +00:00
|
|
|
#define GRUB_TERM_NO_ECHO (1 << 0)
|
2002-12-27 08:53:07 +00:00
|
|
|
/* Set when the editing feature should be disabled. */
|
2004-04-04 13:46:03 +00:00
|
|
|
#define GRUB_TERM_NO_EDIT (1 << 1)
|
2002-12-27 08:53:07 +00:00
|
|
|
/* Set when the terminal cannot do fancy things. */
|
2004-04-04 13:46:03 +00:00
|
|
|
#define GRUB_TERM_DUMB (1 << 2)
|
2002-12-27 08:53:07 +00:00
|
|
|
/* Set when the terminal needs to be initialized. */
|
2004-04-04 13:46:03 +00:00
|
|
|
#define GRUB_TERM_NEED_INIT (1 << 16)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
|
|
|
|
/* Unicode characters for fancy graphics. */
|
|
|
|
#define GRUB_TERM_DISP_LEFT 0x2190
|
|
|
|
#define GRUB_TERM_DISP_UP 0x2191
|
|
|
|
#define GRUB_TERM_DISP_RIGHT 0x2192
|
|
|
|
#define GRUB_TERM_DISP_DOWN 0x2193
|
|
|
|
#define GRUB_TERM_DISP_HLINE 0x2501
|
|
|
|
#define GRUB_TERM_DISP_VLINE 0x2503
|
|
|
|
#define GRUB_TERM_DISP_UL 0x250F
|
|
|
|
#define GRUB_TERM_DISP_UR 0x2513
|
|
|
|
#define GRUB_TERM_DISP_LL 0x2517
|
|
|
|
#define GRUB_TERM_DISP_LR 0x251B
|
|
|
|
|
|
|
|
|
|
|
|
/* Menu-related geometrical constants. */
|
|
|
|
|
2005-08-04 18:10:51 +00:00
|
|
|
/* FIXME: Ugly way to get them form terminal. */
|
|
|
|
#define GRUB_TERM_WIDTH ((grub_getwh()&0xFF00)>>8)
|
|
|
|
#define GRUB_TERM_HEIGHT (grub_getwh()&0xFF)
|
2005-02-19 20:56:07 +00:00
|
|
|
|
|
|
|
/* The number of lines of "GRUB version..." at the top. */
|
|
|
|
#define GRUB_TERM_INFO_HEIGHT 1
|
|
|
|
|
|
|
|
/* The number of columns/lines between messages/borders/etc. */
|
|
|
|
#define GRUB_TERM_MARGIN 1
|
|
|
|
|
|
|
|
/* The number of columns of scroll information. */
|
|
|
|
#define GRUB_TERM_SCROLL_WIDTH 1
|
|
|
|
|
|
|
|
/* The Y position of the top border. */
|
|
|
|
#define GRUB_TERM_TOP_BORDER_Y (GRUB_TERM_MARGIN + GRUB_TERM_INFO_HEIGHT \
|
|
|
|
+ GRUB_TERM_MARGIN)
|
|
|
|
|
|
|
|
/* The X position of the left border. */
|
|
|
|
#define GRUB_TERM_LEFT_BORDER_X GRUB_TERM_MARGIN
|
|
|
|
|
|
|
|
/* The width of the border. */
|
|
|
|
#define GRUB_TERM_BORDER_WIDTH (GRUB_TERM_WIDTH \
|
|
|
|
- GRUB_TERM_MARGIN * 3 \
|
|
|
|
- GRUB_TERM_SCROLL_WIDTH)
|
|
|
|
|
|
|
|
/* The number of lines of messages at the bottom. */
|
|
|
|
#define GRUB_TERM_MESSAGE_HEIGHT 8
|
|
|
|
|
|
|
|
/* The height of the border. */
|
|
|
|
#define GRUB_TERM_BORDER_HEIGHT (GRUB_TERM_HEIGHT \
|
|
|
|
- GRUB_TERM_TOP_BORDER_Y \
|
|
|
|
- GRUB_TERM_MESSAGE_HEIGHT)
|
|
|
|
|
|
|
|
/* The number of entries shown at a time. */
|
|
|
|
#define GRUB_TERM_NUM_ENTRIES (GRUB_TERM_BORDER_HEIGHT - 2)
|
|
|
|
|
|
|
|
/* The Y position of the first entry. */
|
|
|
|
#define GRUB_TERM_FIRST_ENTRY_Y (GRUB_TERM_TOP_BORDER_Y + 1)
|
|
|
|
|
|
|
|
/* The max column number of an entry. The last "-1" is for a
|
|
|
|
continuation marker. */
|
|
|
|
#define GRUB_TERM_ENTRY_WIDTH (GRUB_TERM_BORDER_WIDTH - 2 \
|
|
|
|
- GRUB_TERM_MARGIN * 2 - 1)
|
|
|
|
|
|
|
|
/* The standard X position of the cursor. */
|
|
|
|
#define GRUB_TERM_CURSOR_X (GRUB_TERM_LEFT_BORDER_X \
|
|
|
|
+ GRUB_TERM_BORDER_WIDTH \
|
|
|
|
- GRUB_TERM_MARGIN \
|
|
|
|
- 1)
|
|
|
|
|
|
|
|
|
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
|
|
|
struct grub_term_input
|
|
|
|
{
|
2009-03-01 17:51:44 +00:00
|
|
|
/* The next terminal. */
|
|
|
|
struct grub_term_input *next;
|
|
|
|
|
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
|
|
|
/* The terminal name. */
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/* Initialize the terminal. */
|
|
|
|
grub_err_t (*init) (void);
|
|
|
|
|
|
|
|
/* Clean up the terminal. */
|
|
|
|
grub_err_t (*fini) (void);
|
|
|
|
|
|
|
|
/* Check if any input character is available. */
|
|
|
|
int (*checkkey) (void);
|
|
|
|
|
|
|
|
/* Get a character. */
|
|
|
|
int (*getkey) (void);
|
|
|
|
};
|
|
|
|
typedef struct grub_term_input *grub_term_input_t;
|
|
|
|
|
|
|
|
struct grub_term_output
|
2002-12-27 08:53:07 +00:00
|
|
|
{
|
2009-03-01 17:51:44 +00:00
|
|
|
/* The next terminal. */
|
|
|
|
struct grub_term_output *next;
|
|
|
|
|
2002-12-27 08:53:07 +00:00
|
|
|
/* The terminal name. */
|
|
|
|
const char *name;
|
2003-09-25 20:15:53 +00:00
|
|
|
|
|
|
|
/* Initialize the terminal. */
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_err_t (*init) (void);
|
2003-09-25 20:15:53 +00:00
|
|
|
|
|
|
|
/* Clean up the terminal. */
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_err_t (*fini) (void);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2003-09-25 20:15:53 +00:00
|
|
|
/* Put a character. C is encoded in Unicode. */
|
2004-04-04 13:46:03 +00:00
|
|
|
void (*putchar) (grub_uint32_t c);
|
2005-08-20 05:26:51 +00:00
|
|
|
|
|
|
|
/* Get the number of columns occupied by a given character C. C is
|
|
|
|
encoded in Unicode. */
|
|
|
|
grub_ssize_t (*getcharwidth) (grub_uint32_t c);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2005-08-04 18:10:51 +00:00
|
|
|
/* Get the screen size. The return value is ((Width << 8) | Height). */
|
|
|
|
grub_uint16_t (*getwh) (void);
|
|
|
|
|
2002-12-27 08:53:07 +00:00
|
|
|
/* Get the cursor position. The return value is ((X << 8) | Y). */
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_uint16_t (*getxy) (void);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
/* Go to the position (X, Y). */
|
2004-04-04 13:46:03 +00:00
|
|
|
void (*gotoxy) (grub_uint8_t x, grub_uint8_t y);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
/* Clear the screen. */
|
|
|
|
void (*cls) (void);
|
|
|
|
|
|
|
|
/* Set the current color to be used */
|
2004-04-04 13:46:03 +00:00
|
|
|
void (*setcolorstate) (grub_term_color_state state);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
/* Set the normal color and the highlight color. The format of each
|
|
|
|
color is VGA's. */
|
2004-04-04 13:46:03 +00:00
|
|
|
void (*setcolor) (grub_uint8_t normal_color, grub_uint8_t highlight_color);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2007-12-25 11:10:47 +00:00
|
|
|
/* Get the normal color and the highlight color. The format of each
|
|
|
|
color is VGA's. */
|
|
|
|
void (*getcolor) (grub_uint8_t *normal_color, grub_uint8_t *highlight_color);
|
|
|
|
|
2002-12-27 08:53:07 +00:00
|
|
|
/* Turn on/off the cursor. */
|
|
|
|
void (*setcursor) (int on);
|
|
|
|
|
2003-11-17 18:07:09 +00:00
|
|
|
/* Update the screen. */
|
|
|
|
void (*refresh) (void);
|
|
|
|
|
2002-12-27 08:53:07 +00:00
|
|
|
/* The feature flags defined above. */
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_uint32_t flags;
|
2002-12-27 08:53:07 +00:00
|
|
|
};
|
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
|
|
|
typedef struct grub_term_output *grub_term_output_t;
|
|
|
|
|
2009-03-01 17:51:44 +00:00
|
|
|
extern struct grub_handler_class EXPORT_VAR(grub_term_input_class);
|
|
|
|
extern struct grub_handler_class EXPORT_VAR(grub_term_output_class);
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
grub_term_register_input (grub_term_input_t term)
|
|
|
|
{
|
|
|
|
grub_handler_register (&grub_term_input_class, GRUB_AS_HANDLER (term));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
grub_term_register_output (grub_term_output_t term)
|
|
|
|
{
|
|
|
|
grub_handler_register (&grub_term_output_class, GRUB_AS_HANDLER (term));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
grub_term_unregister_input (grub_term_input_t term)
|
|
|
|
{
|
|
|
|
grub_handler_unregister (&grub_term_input_class, GRUB_AS_HANDLER (term));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
grub_term_unregister_output (grub_term_output_t term)
|
|
|
|
{
|
|
|
|
grub_handler_unregister (&grub_term_output_class, GRUB_AS_HANDLER (term));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline grub_err_t
|
|
|
|
grub_term_set_current_input (grub_term_input_t term)
|
|
|
|
{
|
|
|
|
return grub_handler_set_current (&grub_term_input_class,
|
|
|
|
GRUB_AS_HANDLER (term));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline grub_err_t
|
|
|
|
grub_term_set_current_output (grub_term_output_t term)
|
|
|
|
{
|
|
|
|
return grub_handler_set_current (&grub_term_output_class,
|
|
|
|
GRUB_AS_HANDLER (term));
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline grub_term_input_t
|
|
|
|
grub_term_get_current_input (void)
|
|
|
|
{
|
|
|
|
return (grub_term_input_t) grub_term_input_class.cur_handler;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline grub_term_output_t
|
|
|
|
grub_term_get_current_output (void)
|
|
|
|
{
|
|
|
|
return (grub_term_output_t) grub_term_output_class.cur_handler;
|
|
|
|
}
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
void EXPORT_FUNC(grub_putchar) (int c);
|
|
|
|
void EXPORT_FUNC(grub_putcode) (grub_uint32_t code);
|
2005-08-20 05:26:51 +00:00
|
|
|
grub_ssize_t EXPORT_FUNC(grub_getcharwidth) (grub_uint32_t code);
|
2004-04-04 13:46:03 +00:00
|
|
|
int EXPORT_FUNC(grub_getkey) (void);
|
|
|
|
int EXPORT_FUNC(grub_checkkey) (void);
|
2005-08-04 18:10:51 +00:00
|
|
|
grub_uint16_t EXPORT_FUNC(grub_getwh) (void);
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_uint16_t EXPORT_FUNC(grub_getxy) (void);
|
|
|
|
void EXPORT_FUNC(grub_gotoxy) (grub_uint8_t x, grub_uint8_t y);
|
|
|
|
void EXPORT_FUNC(grub_cls) (void);
|
|
|
|
void EXPORT_FUNC(grub_setcolorstate) (grub_term_color_state state);
|
|
|
|
void EXPORT_FUNC(grub_setcolor) (grub_uint8_t normal_color,
|
|
|
|
grub_uint8_t highlight_color);
|
2007-12-25 11:10:47 +00:00
|
|
|
void EXPORT_FUNC(grub_getcolor) (grub_uint8_t *normal_color,
|
|
|
|
grub_uint8_t *highlight_color);
|
2004-04-04 13:46:03 +00:00
|
|
|
int EXPORT_FUNC(grub_setcursor) (int on);
|
2005-10-15 09:22:32 +00:00
|
|
|
int EXPORT_FUNC(grub_getcursor) (void);
|
2004-04-04 13:46:03 +00:00
|
|
|
void EXPORT_FUNC(grub_refresh) (void);
|
|
|
|
void EXPORT_FUNC(grub_set_more) (int onoff);
|
2002-12-27 08:53:07 +00:00
|
|
|
|
|
|
|
/* For convenience. */
|
2004-04-04 13:46:03 +00:00
|
|
|
#define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff)
|
2002-12-27 08:53:07 +00:00
|
|
|
|
2008-02-05 Robert Millan <rmh@aybabtu.com>
* include/grub/term.h (GRUB_TERM_LEFT, GRUB_TERM_RIGHT)
(GRUB_TERM_UP, GRUB_TERM_DOWN, GRUB_TERM_HOME, GRUB_TERM_END)
(GRUB_TERM_DC, GRUB_TERM_PPAGE, GRUB_TERM_NPAGE, GRUB_TERM_ESC)
(GRUB_TERM_TAB, GRUB_TERM_BACKSPACE): New macros.
* kern/i386/pc/startup.S: Include `<grub/term.h>'.
(translation_table): Replace hardcoded values with macros
provided by `<grub/term.h>'.
* term/i386/pc/at_keyboard.c: Include `<grub/term.h>'.
(keyboard_map): Correct/add a few values, with macros provided
by `<grub/term.h>'.
(keyboard_map_shift): Zero values that don't differ from their
`keyboard_map' equivalents.
(grub_console_checkkey): Optimize KEYBOARD_STATUS_CAPS_LOCK toggling.
Discard the second scan code that is always sent by Caps lock.
Only use `keyboard_map_shift' when it provides a non-zero value,
otherwise fallback to `keyboard_map'.
2008-02-05 10:23:24 +00:00
|
|
|
#endif /* ! ASM_FILE */
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
#endif /* ! GRUB_TERM_HEADER */
|