Blame SOURCES/0001-Add-monochrome-text-support-mda_text-aka-hercules-in.patch

f96e0b
From 8c5886df17cdfb148d4e17bddf38143ed65fe674 Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Thu, 28 Jun 2012 15:27:54 +0200
f96e0b
Subject: [PATCH 001/482] 	Add monochrome text support (mda_text, aka
f96e0b
 `hercules' in grub-legacy).
f96e0b
f96e0b
	* grub-core/Makefile.core.def (mda_text): New module.
f96e0b
	* grub-core/lib/legacy_parse.c (grub_legacy_parse): Support `hercules'.
f96e0b
	* grub-core/term/i386/vga_common.c (grub_console_cur_color): Moved to ..
f96e0b
	* grub-core/term/i386/pc/vga_text.c (cur_color): ... here
f96e0b
	* grub-core/term/i386/pc/console.c (grub_console_cur_color): ... and
f96e0b
	here.
f96e0b
	* grub-core/term/i386/vga_common.c (grub_console_getwh): Moved to ..
f96e0b
	* grub-core/term/i386/pc/vga_text.c (grub_console_getwh): ... here
f96e0b
	* grub-core/term/i386/pc/console.c (grub_console_getwh): ... and
f96e0b
	here.
f96e0b
	* grub-core/term/i386/vga_common.c (grub_console_setcolorstate): Moved
f96e0b
	to ..
f96e0b
	* grub-core/term/i386/pc/vga_text.c (grub_console_setcolorstate):
f96e0b
	... here
f96e0b
	* grub-core/term/i386/pc/console.c (grub_console_setcolorstate): ... and
f96e0b
	here.
f96e0b
	* grub-core/term/i386/vga_common.c: Removed.
f96e0b
	* include/grub/i386/vga_common.h: Likewise.
f96e0b
	* include/grub/vga.h (grub_vga_cr_bw_write): New function.
f96e0b
	(grub_vga_cr_bw_read): Likewise.
f96e0b
	* include/grub/vgaregs.h (GRUB_VGA_IO_CR_BW_INDEX): New enum value.
f96e0b
	(GRUB_VGA_IO_CR_BW_DATA): Likewise.
f96e0b
	* grub-core/term/i386/pc/vga_text.c [MODE_MDA]: Call
f96e0b
	grub_vga_cr_bw_read/grub_vga_cr_bw_write instead of
f96e0b
	grub_vga_cr_read/grub_vga_cr_write.
f96e0b
	(grub_vga_text_setcolorstate) [MODE_MDA]: Ignore color.
f96e0b
---
f96e0b
 ChangeLog                         |  31 +++++++++
f96e0b
 grub-core/Makefile.core.def       |  12 ++--
f96e0b
 grub-core/lib/legacy_parse.c      |  15 ++--
f96e0b
 grub-core/term/i386/pc/console.c  |  27 ++++++++
f96e0b
 grub-core/term/i386/pc/vga_text.c | 141 +++++++++++++++++++++++++++++++++-----
f96e0b
 grub-core/term/i386/vga_common.c  |  48 -------------
f96e0b
 include/grub/i386/pc/console.h    |   1 -
f96e0b
 include/grub/i386/vga_common.h    |  32 ---------
f96e0b
 include/grub/vga.h                |  14 ++++
f96e0b
 include/grub/vgaregs.h            |   2 +
f96e0b
 10 files changed, 213 insertions(+), 110 deletions(-)
f96e0b
 delete mode 100644 grub-core/term/i386/vga_common.c
f96e0b
 delete mode 100644 include/grub/i386/vga_common.h
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 81bdae9..f6e864a 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,3 +1,34 @@
f96e0b
+2012-06-28  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
+
f96e0b
+	Add monochrome text support (mda_text, aka `hercules' in grub-legacy).
f96e0b
+
f96e0b
+	* grub-core/Makefile.core.def (mda_text): New module.
f96e0b
+	* grub-core/lib/legacy_parse.c (grub_legacy_parse): Support `hercules'.
f96e0b
+	* grub-core/term/i386/vga_common.c (grub_console_cur_color): Moved to ..
f96e0b
+	* grub-core/term/i386/pc/vga_text.c (cur_color): ... here
f96e0b
+	* grub-core/term/i386/pc/console.c (grub_console_cur_color): ... and
f96e0b
+	here.
f96e0b
+	* grub-core/term/i386/vga_common.c (grub_console_getwh): Moved to ..
f96e0b
+	* grub-core/term/i386/pc/vga_text.c (grub_console_getwh): ... here
f96e0b
+	* grub-core/term/i386/pc/console.c (grub_console_getwh): ... and
f96e0b
+	here.
f96e0b
+	* grub-core/term/i386/vga_common.c (grub_console_setcolorstate): Moved
f96e0b
+	to ..
f96e0b
+	* grub-core/term/i386/pc/vga_text.c (grub_console_setcolorstate):
f96e0b
+	... here
f96e0b
+	* grub-core/term/i386/pc/console.c (grub_console_setcolorstate): ... and
f96e0b
+	here.
f96e0b
+	* grub-core/term/i386/vga_common.c: Removed.
f96e0b
+	* include/grub/i386/vga_common.h: Likewise.
f96e0b
+	* include/grub/vga.h (grub_vga_cr_bw_write): New function.
f96e0b
+	(grub_vga_cr_bw_read): Likewise.
f96e0b
+	* include/grub/vgaregs.h (GRUB_VGA_IO_CR_BW_INDEX): New enum value.
f96e0b
+	(GRUB_VGA_IO_CR_BW_DATA): Likewise.
f96e0b
+	* grub-core/term/i386/pc/vga_text.c [MODE_MDA]: Call
f96e0b
+	grub_vga_cr_bw_read/grub_vga_cr_bw_write instead of
f96e0b
+	grub_vga_cr_read/grub_vga_cr_write.
f96e0b
+	(grub_vga_text_setcolorstate) [MODE_MDA]: Ignore color.
f96e0b
+
f96e0b
 2012-06-27  Vladimir Serbinenko  <phcoder@gmail.com>
f96e0b
 
f96e0b
 	* configure.ac: Bump version to 2.00.
f96e0b
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
f96e0b
index 39e77a4..5c2fcc2 100644
f96e0b
--- a/grub-core/Makefile.core.def
f96e0b
+++ b/grub-core/Makefile.core.def
f96e0b
@@ -123,9 +123,6 @@ kernel = {
f96e0b
   i386_coreboot_multiboot_qemu = kern/i386/coreboot/init.c;
f96e0b
   i386_coreboot_multiboot_qemu = term/i386/pc/vga_text.c;
f96e0b
 
f96e0b
-  i386_coreboot_multiboot_qemu = term/i386/vga_common.c;
f96e0b
-  i386_pc = term/i386/vga_common.c;
f96e0b
-
f96e0b
   x86 = kern/i386/pit.c;
f96e0b
 
f96e0b
   efi = disk/efi/efidisk.c;
f96e0b
@@ -175,7 +172,6 @@ kernel = {
f96e0b
   mips_qemu_mips = term/at_keyboard.c;
f96e0b
   mips_qemu_mips = commands/keylayouts.c;
f96e0b
   mips_qemu_mips = term/i386/pc/vga_text.c;
f96e0b
-  mips_qemu_mips = term/i386/vga_common.c;
f96e0b
   mips_qemu_mips = kern/vga_init.c;
f96e0b
 
f96e0b
   mips_arc = kern/mips/arc/init.c;
f96e0b
@@ -1591,11 +1587,17 @@ module = {
f96e0b
 module = {
f96e0b
   name = vga_text;
f96e0b
   common = term/i386/pc/vga_text.c;
f96e0b
-  common = term/i386/vga_common.c;
f96e0b
   enable = i386_pc;
f96e0b
 };
f96e0b
 
f96e0b
 module = {
f96e0b
+  name = mda_text;
f96e0b
+  common = term/i386/pc/mda_text.c;
f96e0b
+  enable = i386_pc;
f96e0b
+  enable = i386_coreboot_multiboot_qemu;
f96e0b
+};
f96e0b
+
f96e0b
+module = {
f96e0b
   name = video_cirrus;
f96e0b
   x86 = video/cirrus.c;
f96e0b
   enable = x86;
f96e0b
diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c
f96e0b
index 775eaad..14768b8 100644
f96e0b
--- a/grub-core/lib/legacy_parse.c
f96e0b
+++ b/grub-core/lib/legacy_parse.c
f96e0b
@@ -1,6 +1,6 @@
f96e0b
 /*
f96e0b
  *  GRUB  --  GRand Unified Bootloader
f96e0b
- *  Copyright (C) 1999,2000,2001,2002,2003,2004,2010  Free Software Foundation, Inc.
f96e0b
+ *  Copyright (C) 1999,2000,2001,2002,2003,2004,2010,2012  Free Software Foundation, Inc.
f96e0b
  *
f96e0b
  *  GRUB is free software: you can redistribute it and/or modify
f96e0b
  *  it under the terms of the GNU General Public License as published by
f96e0b
@@ -290,7 +290,7 @@ static struct legacy_command legacy_commands[] =
f96e0b
      " default values are COM1, 9600, 8N1."},
f96e0b
     /* FIXME: setkey unsupported.  */    /* NUL_TERMINATE */
f96e0b
     /* NOTE: setup unsupported.  */
f96e0b
-    /* FIXME: --no-echo, --no-edit, hercules unsupported.  */
f96e0b
+    /* FIXME: --no-echo, --no-edit unsupported.  */
f96e0b
     /* NOTE: both terminals are activated so --silent and --timeout
f96e0b
        are useless.  */
f96e0b
     {"terminal", NULL, NULL, 0, 0, {}, FLAG_TERMINAL | FLAG_IGNORE_REST,
f96e0b
@@ -507,8 +507,8 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
f96e0b
       int dumb = 0, lines = 24;
f96e0b
 #ifdef TODO
f96e0b
       int no_echo = 0, no_edit = 0;
f96e0b
-      int hercules = 0;
f96e0b
 #endif
f96e0b
+      int hercules = 0;
f96e0b
       int console = 0, serial = 0;
f96e0b
       /* Big enough for any possible resulting command. */
f96e0b
       char outbuf[256] = "";
f96e0b
@@ -541,10 +541,8 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
f96e0b
 
f96e0b
 	  if (grub_memcmp (ptr, "serial", sizeof ("serial") - 1) == 0)
f96e0b
 	    serial = 1;
f96e0b
-#ifdef TODO
f96e0b
 	  if (grub_memcmp (ptr, "hercules", sizeof ("hercules") - 1) == 0)
f96e0b
 	    hercules = 1;
f96e0b
-#endif
f96e0b
 	  while (*ptr && !grub_isspace (*ptr))
f96e0b
 	    ptr++;
f96e0b
 	  while (*ptr && grub_isspace (*ptr))
f96e0b
@@ -561,7 +559,7 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
f96e0b
 	  grub_strcpy (outptr, "serial ");
f96e0b
 	  outptr += grub_strlen (outptr);
f96e0b
 	}
f96e0b
-      if (console)
f96e0b
+      if (console || hercules)
f96e0b
 	{
f96e0b
 	  grub_strcpy (outptr, "console ");
f96e0b
 	  outptr += grub_strlen (outptr);
f96e0b
@@ -578,6 +576,11 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix)
f96e0b
 	  grub_strcpy (outptr, "console ");
f96e0b
 	  outptr += grub_strlen (outptr);
f96e0b
 	}
f96e0b
+      if (hercules)
f96e0b
+	{
f96e0b
+	  grub_strcpy (outptr, "mda_text ");
f96e0b
+	  outptr += grub_strlen (outptr);
f96e0b
+	}
f96e0b
       grub_strcpy (outptr, "; ");
f96e0b
       outptr += grub_strlen (outptr);
f96e0b
       if (serial)
f96e0b
diff --git a/grub-core/term/i386/pc/console.c b/grub-core/term/i386/pc/console.c
f96e0b
index 7cf5ffc..a681435 100644
f96e0b
--- a/grub-core/term/i386/pc/console.c
f96e0b
+++ b/grub-core/term/i386/pc/console.c
f96e0b
@@ -22,6 +22,8 @@
f96e0b
 #include <grub/types.h>
f96e0b
 #include <grub/machine/int.h>
f96e0b
 
f96e0b
+static grub_uint8_t grub_console_cur_color = 0x7;
f96e0b
+
f96e0b
 static void
f96e0b
 int10_9 (grub_uint8_t ch, grub_uint16_t n)
f96e0b
 {
f96e0b
@@ -250,6 +252,31 @@ grub_console_getkeystatus (struct grub_term_input *term __attribute__ ((unused))
f96e0b
   return bios_data_area->keyboard_flag_lower & ~0x80;
f96e0b
 }
f96e0b
 
f96e0b
+static grub_uint16_t
f96e0b
+grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
f96e0b
+{
f96e0b
+  return (80 << 8) | 25;
f96e0b
+}
f96e0b
+
f96e0b
+static void
f96e0b
+grub_console_setcolorstate (struct grub_term_output *term,
f96e0b
+			    grub_term_color_state state)
f96e0b
+{
f96e0b
+  switch (state) {
f96e0b
+    case GRUB_TERM_COLOR_STANDARD:
f96e0b
+      grub_console_cur_color = GRUB_TERM_DEFAULT_STANDARD_COLOR & 0x7f;
f96e0b
+      break;
f96e0b
+    case GRUB_TERM_COLOR_NORMAL:
f96e0b
+      grub_console_cur_color = term->normal_color & 0x7f;
f96e0b
+      break;
f96e0b
+    case GRUB_TERM_COLOR_HIGHLIGHT:
f96e0b
+      grub_console_cur_color = term->highlight_color & 0x7f;
f96e0b
+      break;
f96e0b
+    default:
f96e0b
+      break;
f96e0b
+  }
f96e0b
+}
f96e0b
+
f96e0b
 static struct grub_term_input grub_console_term_input =
f96e0b
   {
f96e0b
     .name = "console",
f96e0b
diff --git a/grub-core/term/i386/pc/vga_text.c b/grub-core/term/i386/pc/vga_text.c
f96e0b
index c934c68..d1e4ef9 100644
f96e0b
--- a/grub-core/term/i386/pc/vga_text.c
f96e0b
+++ b/grub-core/term/i386/pc/vga_text.c
f96e0b
@@ -17,10 +17,17 @@
f96e0b
  */
f96e0b
 
f96e0b
 #include <grub/dl.h>
f96e0b
-#include <grub/i386/vga_common.h>
f96e0b
 #include <grub/cpu/io.h>
f96e0b
 #include <grub/types.h>
f96e0b
 #include <grub/vga.h>
f96e0b
+#include <grub/term.h>
f96e0b
+
f96e0b
+/* MODESET is used for testing to force monochrome or colour mode.
f96e0b
+   You shouldn't use mda_text on vga.
f96e0b
+ */
f96e0b
+#ifdef MODESET
f96e0b
+#include <grub/machine/int.h>
f96e0b
+#endif
f96e0b
 
f96e0b
 #if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_MULTIBOOT)
f96e0b
 #include <grub/machine/console.h>
f96e0b
@@ -35,10 +42,21 @@ static int grub_curr_x, grub_curr_y;
f96e0b
 
f96e0b
 #ifdef __mips__
f96e0b
 #define VGA_TEXT_SCREEN		((grub_uint16_t *) 0xb00b8000)
f96e0b
+#define cr_read grub_vga_cr_read
f96e0b
+#define cr_write grub_vga_cr_write
f96e0b
+#elif defined (MODE_MDA)
f96e0b
+#define VGA_TEXT_SCREEN		((grub_uint16_t *) 0xb0000)
f96e0b
+#define cr_read grub_vga_cr_bw_read
f96e0b
+#define cr_write grub_vga_cr_bw_write
f96e0b
+static grub_uint8_t cur_color;
f96e0b
 #else
f96e0b
 #define VGA_TEXT_SCREEN		((grub_uint16_t *) 0xb8000)
f96e0b
+#define cr_read grub_vga_cr_read
f96e0b
+#define cr_write grub_vga_cr_write
f96e0b
 #endif
f96e0b
 
f96e0b
+static grub_uint8_t cur_color = 0x7;
f96e0b
+
f96e0b
 static void
f96e0b
 screen_write_char (int x, int y, short c)
f96e0b
 {
f96e0b
@@ -55,8 +73,8 @@ static void
f96e0b
 update_cursor (void)
f96e0b
 {
f96e0b
   unsigned int pos = grub_curr_y * COLS + grub_curr_x;
f96e0b
-  grub_vga_cr_write (pos >> 8, GRUB_VGA_CR_CURSOR_ADDR_HIGH);
f96e0b
-  grub_vga_cr_write (pos & 0xFF, GRUB_VGA_CR_CURSOR_ADDR_LOW);
f96e0b
+  cr_write (pos >> 8, GRUB_VGA_CR_CURSOR_ADDR_HIGH);
f96e0b
+  cr_write (pos & 0xFF, GRUB_VGA_CR_CURSOR_ADDR_LOW);
f96e0b
 }
f96e0b
 
f96e0b
 static void
f96e0b
@@ -72,7 +90,7 @@ inc_y (void)
f96e0b
         for (x = 0; x < COLS; x++)
f96e0b
           screen_write_char (x, y, screen_read_char (x, y + 1));
f96e0b
       for (x = 0; x < COLS; x++)
f96e0b
-	screen_write_char (x, ROWS - 1, ' ' | (grub_console_cur_color << 8));
f96e0b
+	screen_write_char (x, ROWS - 1, ' ' | (cur_color << 8));
f96e0b
     }
f96e0b
 }
f96e0b
 
f96e0b
@@ -103,7 +121,7 @@ grub_vga_text_putchar (struct grub_term_output *term __attribute__ ((unused)),
f96e0b
 	break;
f96e0b
       default:
f96e0b
 	screen_write_char (grub_curr_x, grub_curr_y,
f96e0b
-			   c->base | (grub_console_cur_color << 8));
f96e0b
+			   c->base | (cur_color << 8));
f96e0b
 	inc_x ();
f96e0b
     }
f96e0b
 
f96e0b
@@ -130,7 +148,7 @@ grub_vga_text_cls (struct grub_term_output *term)
f96e0b
 {
f96e0b
   int i;
f96e0b
   for (i = 0; i < ROWS * COLS; i++)
f96e0b
-    VGA_TEXT_SCREEN[i] = grub_cpu_to_le16 (' ' | (grub_console_cur_color << 8));
f96e0b
+    VGA_TEXT_SCREEN[i] = grub_cpu_to_le16 (' ' | (cur_color << 8));
f96e0b
   grub_vga_text_gotoxy (term, 0, 0);
f96e0b
 }
f96e0b
 
f96e0b
@@ -139,49 +157,136 @@ grub_vga_text_setcursor (struct grub_term_output *term __attribute__ ((unused)),
f96e0b
 			 int on)
f96e0b
 {
f96e0b
   grub_uint8_t old;
f96e0b
-  old = grub_vga_cr_read (GRUB_VGA_CR_CURSOR_START);
f96e0b
+  old = cr_read (GRUB_VGA_CR_CURSOR_START);
f96e0b
   if (on)
f96e0b
-    grub_vga_cr_write (old & ~GRUB_VGA_CR_CURSOR_START_DISABLE,
f96e0b
-		       GRUB_VGA_CR_CURSOR_START);
f96e0b
+    cr_write (old & ~GRUB_VGA_CR_CURSOR_START_DISABLE,
f96e0b
+	      GRUB_VGA_CR_CURSOR_START);
f96e0b
   else
f96e0b
-    grub_vga_cr_write (old | GRUB_VGA_CR_CURSOR_START_DISABLE,
f96e0b
-		       GRUB_VGA_CR_CURSOR_START);
f96e0b
+    cr_write (old | GRUB_VGA_CR_CURSOR_START_DISABLE,
f96e0b
+	      GRUB_VGA_CR_CURSOR_START);
f96e0b
 }
f96e0b
 
f96e0b
 static grub_err_t
f96e0b
-grub_vga_text_init_fini (struct grub_term_output *term)
f96e0b
+grub_vga_text_init (struct grub_term_output *term)
f96e0b
 {
f96e0b
+#ifdef MODESET
f96e0b
+  struct grub_bios_int_registers regs;
f96e0b
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
f96e0b
+
f96e0b
+#ifdef MODE_MDA
f96e0b
+  regs.eax = 7;
f96e0b
+#else
f96e0b
+  regs.eax = 3;
f96e0b
+#endif
f96e0b
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
f96e0b
+  grub_bios_interrupt (0x10, ®s;;
f96e0b
+#endif
f96e0b
   grub_vga_text_cls (term);
f96e0b
   return 0;
f96e0b
 }
f96e0b
 
f96e0b
+static grub_err_t
f96e0b
+grub_vga_text_fini (struct grub_term_output *term)
f96e0b
+{
f96e0b
+#ifdef MODESET
f96e0b
+  struct grub_bios_int_registers regs;
f96e0b
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
f96e0b
+
f96e0b
+  regs.eax = 3;
f96e0b
+  regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT;
f96e0b
+  grub_bios_interrupt (0x10, ®s;;
f96e0b
+#endif
f96e0b
+  grub_vga_text_cls (term);
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
+static grub_uint16_t
f96e0b
+grub_vga_text_getwh (struct grub_term_output *term __attribute__ ((unused)))
f96e0b
+{
f96e0b
+  return (80 << 8) | 25;
f96e0b
+}
f96e0b
+
f96e0b
+#ifndef MODE_MDA
f96e0b
+
f96e0b
+static void
f96e0b
+grub_vga_text_setcolorstate (struct grub_term_output *term,
f96e0b
+			    grub_term_color_state state)
f96e0b
+{
f96e0b
+  switch (state) {
f96e0b
+    case GRUB_TERM_COLOR_STANDARD:
f96e0b
+      cur_color = GRUB_TERM_DEFAULT_STANDARD_COLOR & 0x7f;
f96e0b
+      break;
f96e0b
+    case GRUB_TERM_COLOR_NORMAL:
f96e0b
+      cur_color = term->normal_color & 0x7f;
f96e0b
+      break;
f96e0b
+    case GRUB_TERM_COLOR_HIGHLIGHT:
f96e0b
+      cur_color = term->highlight_color & 0x7f;
f96e0b
+      break;
f96e0b
+    default:
f96e0b
+      break;
f96e0b
+  }
f96e0b
+}
f96e0b
+
f96e0b
+#else
f96e0b
+static void
f96e0b
+grub_vga_text_setcolorstate (struct grub_term_output *term __attribute__ ((unused)),
f96e0b
+			     grub_term_color_state state)
f96e0b
+{
f96e0b
+  switch (state) {
f96e0b
+    case GRUB_TERM_COLOR_STANDARD:
f96e0b
+      cur_color = 0x07;
f96e0b
+      break;
f96e0b
+    case GRUB_TERM_COLOR_NORMAL:
f96e0b
+      cur_color = 0x07;
f96e0b
+      break;
f96e0b
+    case GRUB_TERM_COLOR_HIGHLIGHT:
f96e0b
+      cur_color = 0x70;
f96e0b
+      break;
f96e0b
+    default:
f96e0b
+      break;
f96e0b
+  }
f96e0b
+}
f96e0b
+#endif
f96e0b
+
f96e0b
 static struct grub_term_output grub_vga_text_term =
f96e0b
   {
f96e0b
+#ifdef MODE_MDA
f96e0b
+    .name = "mda_text",
f96e0b
+#else
f96e0b
     .name = "vga_text",
f96e0b
-    .init = grub_vga_text_init_fini,
f96e0b
-    .fini = grub_vga_text_init_fini,
f96e0b
+#endif
f96e0b
+    .init = grub_vga_text_init,
f96e0b
+    .fini = grub_vga_text_fini,
f96e0b
     .putchar = grub_vga_text_putchar,
f96e0b
-    .getwh = grub_console_getwh,
f96e0b
+    .getwh = grub_vga_text_getwh,
f96e0b
     .getxy = grub_vga_text_getxy,
f96e0b
     .gotoxy = grub_vga_text_gotoxy,
f96e0b
     .cls = grub_vga_text_cls,
f96e0b
-    .setcolorstate = grub_console_setcolorstate,
f96e0b
+    .setcolorstate = grub_vga_text_setcolorstate,
f96e0b
     .setcursor = grub_vga_text_setcursor,
f96e0b
     .flags = GRUB_TERM_CODE_TYPE_CP437,
f96e0b
     .normal_color = GRUB_TERM_DEFAULT_NORMAL_COLOR,
f96e0b
     .highlight_color = GRUB_TERM_DEFAULT_HIGHLIGHT_COLOR,
f96e0b
   };
f96e0b
 
f96e0b
-#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_MULTIBOOT)
f96e0b
+#ifdef MODE_MDA
f96e0b
+GRUB_MOD_INIT(mda_text)
f96e0b
+#elif defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_MULTIBOOT)
f96e0b
 void grub_vga_text_init (void)
f96e0b
 #else
f96e0b
 GRUB_MOD_INIT(vga_text)
f96e0b
 #endif
f96e0b
 {
f96e0b
+#ifdef MODE_MDA
f96e0b
+  grub_term_register_output ("mda_text", &grub_vga_text_term);
f96e0b
+#else
f96e0b
   grub_term_register_output ("vga_text", &grub_vga_text_term);
f96e0b
+#endif
f96e0b
 }
f96e0b
 
f96e0b
-#if defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_MULTIBOOT)
f96e0b
+#ifdef MODE_MDA
f96e0b
+GRUB_MOD_FINI(mda_text)
f96e0b
+#elif defined (GRUB_MACHINE_COREBOOT) || defined (GRUB_MACHINE_QEMU) || defined (GRUB_MACHINE_MIPS_QEMU_MIPS) || defined (GRUB_MACHINE_MULTIBOOT)
f96e0b
 void grub_vga_text_fini (void)
f96e0b
 #else
f96e0b
 GRUB_MOD_FINI(vga_text)
f96e0b
diff --git a/grub-core/term/i386/vga_common.c b/grub-core/term/i386/vga_common.c
f96e0b
deleted file mode 100644
f96e0b
index 0c21769..0000000
f96e0b
--- a/grub-core/term/i386/vga_common.c
f96e0b
+++ /dev/null
f96e0b
@@ -1,48 +0,0 @@
f96e0b
-/*
f96e0b
- *  GRUB  --  GRand Unified Bootloader
f96e0b
- *  Copyright (C) 2002,2003,2005,2007,2008  Free Software Foundation, Inc.
f96e0b
- *
f96e0b
- *  GRUB is free software: you can redistribute it and/or modify
f96e0b
- *  it under the terms of the GNU General Public License as published by
f96e0b
- *  the Free Software Foundation, either version 3 of the License, or
f96e0b
- *  (at your option) any later version.
f96e0b
- *
f96e0b
- *  GRUB is distributed in the hope that it will be useful,
f96e0b
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
f96e0b
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f96e0b
- *  GNU General Public License for more details.
f96e0b
- *
f96e0b
- *  You should have received a copy of the GNU General Public License
f96e0b
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
f96e0b
- */
f96e0b
-
f96e0b
-#include <grub/i386/vga_common.h>
f96e0b
-#include <grub/term.h>
f96e0b
-#include <grub/types.h>
f96e0b
-
f96e0b
-grub_uint8_t grub_console_cur_color = 0x7;
f96e0b
-
f96e0b
-grub_uint16_t
f96e0b
-grub_console_getwh (struct grub_term_output *term __attribute__ ((unused)))
f96e0b
-{
f96e0b
-  return (80 << 8) | 25;
f96e0b
-}
f96e0b
-
f96e0b
-void
f96e0b
-grub_console_setcolorstate (struct grub_term_output *term,
f96e0b
-			    grub_term_color_state state)
f96e0b
-{
f96e0b
-  switch (state) {
f96e0b
-    case GRUB_TERM_COLOR_STANDARD:
f96e0b
-      grub_console_cur_color = GRUB_TERM_DEFAULT_STANDARD_COLOR & 0x7f;
f96e0b
-      break;
f96e0b
-    case GRUB_TERM_COLOR_NORMAL:
f96e0b
-      grub_console_cur_color = term->normal_color & 0x7f;
f96e0b
-      break;
f96e0b
-    case GRUB_TERM_COLOR_HIGHLIGHT:
f96e0b
-      grub_console_cur_color = term->highlight_color & 0x7f;
f96e0b
-      break;
f96e0b
-    default:
f96e0b
-      break;
f96e0b
-  }
f96e0b
-}
f96e0b
diff --git a/include/grub/i386/pc/console.h b/include/grub/i386/pc/console.h
f96e0b
index f752b9a..191964f 100644
f96e0b
--- a/include/grub/i386/pc/console.h
f96e0b
+++ b/include/grub/i386/pc/console.h
f96e0b
@@ -24,7 +24,6 @@
f96e0b
 #include <grub/types.h>
f96e0b
 #include <grub/symbol.h>
f96e0b
 #include <grub/term.h>
f96e0b
-#include <grub/i386/vga_common.h>
f96e0b
 
f96e0b
 /* Initialize the console system.  */
f96e0b
 void grub_console_init (void);
f96e0b
diff --git a/include/grub/i386/vga_common.h b/include/grub/i386/vga_common.h
f96e0b
deleted file mode 100644
f96e0b
index 8727903..0000000
f96e0b
--- a/include/grub/i386/vga_common.h
f96e0b
+++ /dev/null
f96e0b
@@ -1,32 +0,0 @@
f96e0b
-/*
f96e0b
- *  GRUB  --  GRand Unified Bootloader
f96e0b
- *  Copyright (C) 2002,2005,2007,2008  Free Software Foundation, Inc.
f96e0b
- *
f96e0b
- *  GRUB is free software: you can redistribute it and/or modify
f96e0b
- *  it under the terms of the GNU General Public License as published by
f96e0b
- *  the Free Software Foundation, either version 3 of the License, or
f96e0b
- *  (at your option) any later version.
f96e0b
- *
f96e0b
- *  GRUB is distributed in the hope that it will be useful,
f96e0b
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
f96e0b
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f96e0b
- *  GNU General Public License for more details.
f96e0b
- *
f96e0b
- *  You should have received a copy of the GNU General Public License
f96e0b
- *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
f96e0b
- */
f96e0b
-
f96e0b
-#ifndef GRUB_VGA_COMMON_CPU_HEADER
f96e0b
-#define GRUB_VGA_COMMON_CPU_HEADER	1
f96e0b
-
f96e0b
-#include <grub/types.h>
f96e0b
-#include <grub/symbol.h>
f96e0b
-#include <grub/term.h>
f96e0b
-
f96e0b
-extern grub_uint8_t grub_console_cur_color;
f96e0b
-
f96e0b
-grub_uint16_t grub_console_getwh (struct grub_term_output *term);
f96e0b
-void grub_console_setcolorstate (struct grub_term_output *term,
f96e0b
-				 grub_term_color_state state);
f96e0b
-
f96e0b
-#endif /* ! GRUB_VGA_COMMON_CPU_HEADER */
f96e0b
diff --git a/include/grub/vga.h b/include/grub/vga.h
f96e0b
index 81d40a1..1d8449c 100644
f96e0b
--- a/include/grub/vga.h
f96e0b
+++ b/include/grub/vga.h
f96e0b
@@ -57,6 +57,20 @@ grub_vga_cr_read (grub_uint8_t addr)
f96e0b
 }
f96e0b
 
f96e0b
 static inline void
f96e0b
+grub_vga_cr_bw_write (grub_uint8_t val, grub_uint8_t addr)
f96e0b
+{
f96e0b
+  grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_BW_INDEX);
f96e0b
+  grub_outb (val, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_BW_DATA);
f96e0b
+}
f96e0b
+
f96e0b
+static inline grub_uint8_t
f96e0b
+grub_vga_cr_bw_read (grub_uint8_t addr)
f96e0b
+{
f96e0b
+  grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_BW_INDEX);
f96e0b
+  return grub_inb (GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_CR_BW_DATA);
f96e0b
+}
f96e0b
+
f96e0b
+static inline void
f96e0b
 grub_vga_sr_write (grub_uint8_t val, grub_uint8_t addr)
f96e0b
 {
f96e0b
   grub_outb (addr, GRUB_MACHINE_PCI_IO_BASE + GRUB_VGA_IO_SR_INDEX);
f96e0b
diff --git a/include/grub/vgaregs.h b/include/grub/vgaregs.h
f96e0b
index a7b13ee..1a666a1 100644
f96e0b
--- a/include/grub/vgaregs.h
f96e0b
+++ b/include/grub/vgaregs.h
f96e0b
@@ -26,6 +26,8 @@
f96e0b
 
f96e0b
 enum
f96e0b
   {
f96e0b
+    GRUB_VGA_IO_CR_BW_INDEX = 0x3b4,
f96e0b
+    GRUB_VGA_IO_CR_BW_DATA = 0x3b5,
f96e0b
     GRUB_VGA_IO_ARX = 0x3c0,
f96e0b
     GRUB_VGA_IO_ARX_READ = 0x3c1,
f96e0b
     GRUB_VGA_IO_MISC_WRITE = 0x3c2,
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b