mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-24 08:09:22 +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).
This commit is contained in:
1 parent
96e5d876a4
commit
651c29b79e
26 files changed
+555
-190
No files matched your search
@@ -138,6 +138,7 @@ grub_machine_init (void)
|
||||
grub_upper_mem -= GRUB_MEMORY_MACHINE_UPPER_START;
|
||||
|
||||
grub_tsc_init ();
|
||||
grub_at_keyboard_init ();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -217,7 +217,6 @@ grub_machine_init (void)
|
||||
grub_console_init ();
|
||||
#ifdef __i386__
|
||||
grub_get_extended_memory ();
|
||||
grub_keyboard_controller_init ();
|
||||
#endif
|
||||
grub_claim_heap ();
|
||||
grub_ofdisk_init ();
|
||||
|
||||
+8
-3
@@ -1026,10 +1026,15 @@ grub_utf8_to_ucs4 (grub_uint32_t *dest, const grub_uint8_t *src,
|
||||
void
|
||||
grub_abort (void)
|
||||
{
|
||||
if (grub_term_get_current ())
|
||||
if (grub_term_get_current_output ())
|
||||
{
|
||||
grub_printf ("\nAborted. Press any key to exit.");
|
||||
grub_getkey ();
|
||||
grub_printf ("\nAborted.");
|
||||
|
||||
if (grub_term_get_current_input ())
|
||||
{
|
||||
grub_printf (" Press any key to exit.");
|
||||
grub_getkey ();
|
||||
}
|
||||
}
|
||||
|
||||
grub_exit ();
|
||||
|
||||
+91
-40
@@ -23,10 +23,12 @@
|
||||
#include <grub/env.h>
|
||||
|
||||
/* The list of terminals. */
|
||||
static grub_term_t grub_term_list;
|
||||
static grub_term_input_t grub_term_list_input;
|
||||
static grub_term_output_t grub_term_list_output;
|
||||
|
||||
/* The current terminal. */
|
||||
static grub_term_t grub_cur_term;
|
||||
static grub_term_input_t grub_cur_term_input;
|
||||
static grub_term_output_t grub_cur_term_output;
|
||||
|
||||
/* The amount of lines counted by the pager. */
|
||||
static int grub_more_lines;
|
||||
@@ -38,18 +40,25 @@ static int grub_more;
|
||||
static int cursor_state = 1;
|
||||
|
||||
void
|
||||
grub_term_register (grub_term_t term)
|
||||
grub_term_register_input (grub_term_input_t term)
|
||||
{
|
||||
term->next = grub_term_list;
|
||||
grub_term_list = term;
|
||||
term->next = grub_term_list_input;
|
||||
grub_term_list_input = term;
|
||||
}
|
||||
|
||||
void
|
||||
grub_term_unregister (grub_term_t term)
|
||||
grub_term_register_output (grub_term_output_t term)
|
||||
{
|
||||
grub_term_t *p, q;
|
||||
term->next = grub_term_list_output;
|
||||
grub_term_list_output = term;
|
||||
}
|
||||
|
||||
void
|
||||
grub_term_unregister_input (grub_term_input_t term)
|
||||
{
|
||||
grub_term_input_t *p, q;
|
||||
|
||||
for (p = &grub_term_list, q = *p; q; p = &(q->next), q = q->next)
|
||||
for (p = &grub_term_list_input, q = *p; q; p = &(q->next), q = q->next)
|
||||
if (q == term)
|
||||
{
|
||||
*p = q->next;
|
||||
@@ -58,36 +67,78 @@ grub_term_unregister (grub_term_t term)
|
||||
}
|
||||
|
||||
void
|
||||
grub_term_iterate (int (*hook) (grub_term_t term))
|
||||
grub_term_unregister_output (grub_term_output_t term)
|
||||
{
|
||||
grub_term_t p;
|
||||
grub_term_output_t *p, q;
|
||||
|
||||
for (p = grub_term_list; p; p = p->next)
|
||||
for (p = &grub_term_list_output, q = *p; q; p = &(q->next), q = q->next)
|
||||
if (q == term)
|
||||
{
|
||||
*p = q->next;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
grub_term_iterate_input (int (*hook) (grub_term_input_t term))
|
||||
{
|
||||
grub_term_input_t p;
|
||||
|
||||
for (p = grub_term_list_input; p; p = p->next)
|
||||
if (hook (p))
|
||||
break;
|
||||
}
|
||||
|
||||
void
|
||||
grub_term_iterate_output (int (*hook) (grub_term_output_t term))
|
||||
{
|
||||
grub_term_output_t p;
|
||||
|
||||
for (p = grub_term_list_output; p; p = p->next)
|
||||
if (hook (p))
|
||||
break;
|
||||
}
|
||||
|
||||
grub_err_t
|
||||
grub_term_set_current (grub_term_t term)
|
||||
grub_term_set_current_input (grub_term_input_t term)
|
||||
{
|
||||
if (grub_cur_term && grub_cur_term->fini)
|
||||
if ((grub_cur_term->fini) () != GRUB_ERR_NONE)
|
||||
if (grub_cur_term_input && grub_cur_term_input->fini)
|
||||
if ((grub_cur_term_input->fini) () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
if (term->init)
|
||||
if ((term->init) () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_cur_term = term;
|
||||
grub_cls ();
|
||||
grub_setcursor (grub_getcursor ());
|
||||
grub_cur_term_input = term;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_term_t
|
||||
grub_term_get_current (void)
|
||||
grub_err_t
|
||||
grub_term_set_current_output (grub_term_output_t term)
|
||||
{
|
||||
return grub_cur_term;
|
||||
if (grub_cur_term_output && grub_cur_term_output->fini)
|
||||
if ((grub_cur_term_output->fini) () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
if (term->init)
|
||||
if ((term->init) () != GRUB_ERR_NONE)
|
||||
return grub_errno;
|
||||
|
||||
grub_cur_term_output = term;
|
||||
return GRUB_ERR_NONE;
|
||||
}
|
||||
|
||||
grub_term_input_t
|
||||
grub_term_get_current_input (void)
|
||||
{
|
||||
return grub_cur_term_input;
|
||||
}
|
||||
|
||||
grub_term_output_t
|
||||
grub_term_get_current_output (void)
|
||||
{
|
||||
return grub_cur_term_output;
|
||||
}
|
||||
|
||||
/* Put a Unicode character. */
|
||||
@@ -96,7 +147,7 @@ grub_putcode (grub_uint32_t code)
|
||||
{
|
||||
int height = grub_getwh () & 255;
|
||||
|
||||
if (code == '\t' && grub_cur_term->getxy)
|
||||
if (code == '\t' && grub_cur_term_output->getxy)
|
||||
{
|
||||
int n;
|
||||
|
||||
@@ -107,7 +158,7 @@ grub_putcode (grub_uint32_t code)
|
||||
return;
|
||||
}
|
||||
|
||||
(grub_cur_term->putchar) (code);
|
||||
(grub_cur_term_output->putchar) (code);
|
||||
|
||||
if (code == '\n')
|
||||
{
|
||||
@@ -171,70 +222,70 @@ grub_putchar (int c)
|
||||
grub_ssize_t
|
||||
grub_getcharwidth (grub_uint32_t code)
|
||||
{
|
||||
return (grub_cur_term->getcharwidth) (code);
|
||||
return (grub_cur_term_output->getcharwidth) (code);
|
||||
}
|
||||
|
||||
int
|
||||
grub_getkey (void)
|
||||
{
|
||||
return (grub_cur_term->getkey) ();
|
||||
return (grub_cur_term_input->getkey) ();
|
||||
}
|
||||
|
||||
int
|
||||
grub_checkkey (void)
|
||||
{
|
||||
return (grub_cur_term->checkkey) ();
|
||||
return (grub_cur_term_input->checkkey) ();
|
||||
}
|
||||
|
||||
grub_uint16_t
|
||||
grub_getxy (void)
|
||||
{
|
||||
return (grub_cur_term->getxy) ();
|
||||
return (grub_cur_term_output->getxy) ();
|
||||
}
|
||||
|
||||
grub_uint16_t
|
||||
grub_getwh (void)
|
||||
{
|
||||
return (grub_cur_term->getwh) ();
|
||||
return (grub_cur_term_output->getwh) ();
|
||||
}
|
||||
|
||||
void
|
||||
grub_gotoxy (grub_uint8_t x, grub_uint8_t y)
|
||||
{
|
||||
(grub_cur_term->gotoxy) (x, y);
|
||||
(grub_cur_term_output->gotoxy) (x, y);
|
||||
}
|
||||
|
||||
void
|
||||
grub_cls (void)
|
||||
{
|
||||
if ((grub_cur_term->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug")))
|
||||
if ((grub_cur_term_output->flags & GRUB_TERM_DUMB) || (grub_env_get ("debug")))
|
||||
{
|
||||
grub_putchar ('\n');
|
||||
grub_refresh ();
|
||||
}
|
||||
else
|
||||
(grub_cur_term->cls) ();
|
||||
(grub_cur_term_output->cls) ();
|
||||
}
|
||||
|
||||
void
|
||||
grub_setcolorstate (grub_term_color_state state)
|
||||
{
|
||||
if (grub_cur_term->setcolorstate)
|
||||
(grub_cur_term->setcolorstate) (state);
|
||||
if (grub_cur_term_output->setcolorstate)
|
||||
(grub_cur_term_output->setcolorstate) (state);
|
||||
}
|
||||
|
||||
void
|
||||
grub_setcolor (grub_uint8_t normal_color, grub_uint8_t highlight_color)
|
||||
{
|
||||
if (grub_cur_term->setcolor)
|
||||
(grub_cur_term->setcolor) (normal_color, highlight_color);
|
||||
if (grub_cur_term_output->setcolor)
|
||||
(grub_cur_term_output->setcolor) (normal_color, highlight_color);
|
||||
}
|
||||
|
||||
void
|
||||
grub_getcolor (grub_uint8_t *normal_color, grub_uint8_t *highlight_color)
|
||||
{
|
||||
if (grub_cur_term->getcolor)
|
||||
(grub_cur_term->getcolor) (normal_color, highlight_color);
|
||||
if (grub_cur_term_output->getcolor)
|
||||
(grub_cur_term_output->getcolor) (normal_color, highlight_color);
|
||||
}
|
||||
|
||||
int
|
||||
@@ -242,9 +293,9 @@ grub_setcursor (int on)
|
||||
{
|
||||
int ret = cursor_state;
|
||||
|
||||
if (grub_cur_term->setcursor)
|
||||
if (grub_cur_term_output->setcursor)
|
||||
{
|
||||
(grub_cur_term->setcursor) (on);
|
||||
(grub_cur_term_output->setcursor) (on);
|
||||
cursor_state = on;
|
||||
}
|
||||
|
||||
@@ -260,8 +311,8 @@ grub_getcursor (void)
|
||||
void
|
||||
grub_refresh (void)
|
||||
{
|
||||
if (grub_cur_term->refresh)
|
||||
(grub_cur_term->refresh) ();
|
||||
if (grub_cur_term_output->refresh)
|
||||
(grub_cur_term_output->refresh) ();
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in new issue
Block a user