Hi,
This patch splits terminal handling in input and output. While at it, it
resolves/removes some of the kludges we had to work around this limitation.
For example, gfxterm/vga no longer need to assume the input is bios console,
at_keyboard can be used in combination with any output terminal, etc.
It will also be possible to turn vga_text.c into a standalone output term,
but this needs more work since it is currently sharing much code with the
bios console in console.c.
--
Robert Millan
The DRM opt-in fallacy: Your data belongs to us. We will decide when (and
how) you may access your data; but nobody's threatening your freedom: we
still allow you to remove your data and not access it at all.
Index: conf/i386.rmk
===
--- conf/i386.rmk (revision 1891)
+++ conf/i386.rmk (working copy)
@@ -1,8 +1,11 @@
# -*- makefile -*-
pkglib_MODULES += cpuid.mod
-
-# For cpuid.mod.
cpuid_mod_SOURCES = commands/i386/cpuid.c
cpuid_mod_CFLAGS = $(COMMON_CFLAGS)
cpuid_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
+pkglib_MODULES += at_keyboard.mod
+at_keyboard_mod_SOURCES = term/i386/pc/at_keyboard.c
+at_keyboard_mod_CFLAGS = $(COMMON_CFLAGS)
+at_keyboard_mod_LDFLAGS = $(COMMON_LDFLAGS)
Index: conf/i386-ieee1275.rmk
===
--- conf/i386-ieee1275.rmk (revision 1891)
+++ conf/i386-ieee1275.rmk (working copy)
@@ -22,7 +22,7 @@
kern/time.c \
kern/generic/millisleep.c \
kern/ieee1275/ieee1275.c \
- term/ieee1275/ofconsole.c term/i386/pc/at_keyboard.c \
+ term/ieee1275/ofconsole.c \
disk/ieee1275/ofdisk.c \
symlist.c
kernel_elf_HEADERS = arg.h cache.h device.h disk.h dl.h elf.h elfload.h \
Index: kern/ieee1275/init.c
===
--- kern/ieee1275/init.c (revision 1891)
+++ kern/ieee1275/init.c (working copy)
@@ -217,7 +217,6 @@
grub_console_init ();
#ifdef __i386__
grub_get_extended_memory ();
- grub_keyboard_controller_init ();
#endif
grub_claim_heap ();
grub_ofdisk_init ();
Index: kern/term.c
===
--- kern/term.c (revision 1891)
+++ kern/term.c (working copy)
@@ -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 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,45 +67,87 @@
}
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)
+