* [patch] Fix for vga terminal
@ 2007-11-10 14:04 Vesa Jääskeläinen
2007-11-10 18:25 ` Marco Gerards
0 siblings, 1 reply; 3+ messages in thread
From: Vesa Jääskeläinen @ 2007-11-10 14:04 UTC (permalink / raw)
To: The development of GRUB 2
[-- Attachment #1: Type: text/plain, Size: 409 bytes --]
Hi All,
Here is patch for fixing vga terminal. At least it worked fine on qemu.
Now it uses only font system to get fonts so you need to load font
module and use fonts. See gfxterm section on the wiki on how to do that.
I had to edit patch by hand as 64bit patch is still pending and I need
that to compile my codes. But it should still apply nicely to current CVS.
Thanks,
Vesa Jääskeläinen
[-- Attachment #2: vgaterm-fix.diff --]
[-- Type: text/plain, Size: 8531 bytes --]
Index: ChangeLog
===================================================================
RCS file: /sources/grub/grub2/ChangeLog,v
retrieving revision 1.438
diff -u -r1.438 ChangeLog
--- ChangeLog 6 Nov 2007 21:23:59 -0000 1.438
+++ ChangeLog 10 Nov 2007 13:57:07 -0000
@@ -1,3 +1,23 @@
+2007-11-10 Vesa Jaaskelainen <chaac@nic.fi>
+
+ * conf/i386-pc.rmk (pkgdata_MODULES): Added vga.mod.
+ (vga_mod_SOURCES): Added.
+ (vga_mod_CFLAGS): Likewise.
+ (vga_mod_LDFLAGS): Likewise.
+
+ * term/i386/pc/vga.c (get_map_mask): Switch order of arguments in
+ grub_outb() calls.
+ (set_map_mask): Likewise.
+ (set_read_map): Likewise.
+ (set_read_address): Likewise.
+ (vga_font): Removed variable.
+ (get_vga_glyph): Removed function.
+ (invalidate_char): Likewise.
+ (write_char): Changed to use grub_font_get_glyph() for font
+ information.
+ (grub_vga_putchar): Likewise.
+ (grub_vga_getcharwidth): Likewise.
+
2007-11-06 Robert Millan <rmh@aybabtu.com>
* term/i386/pc/serial.c (serial_hw_put): Switch order of arguments
Index: conf/i386-pc.rmk
===================================================================
RCS file: /sources/grub/grub2/conf/i386-pc.rmk,v
retrieving revision 1.91
diff -u -r1.91 i386-pc.rmk
--- conf/i386-pc.rmk 31 Oct 2007 22:29:20 -0000 1.91
+++ conf/i386-pc.rmk 10 Nov 2007 13:57:13 -0000
@@ -129,7 +129,8 @@
pkgdata_MODULES = biosdisk.mod _chain.mod _linux.mod linux.mod normal.mod \
_multiboot.mod chain.mod multiboot.mod reboot.mod halt.mod \
vbe.mod vbetest.mod vbeinfo.mod video.mod gfxterm.mod \
- videotest.mod play.mod bitmap.mod tga.mod cpuid.mod serial.mod ata.mod
+ videotest.mod play.mod bitmap.mod tga.mod cpuid.mod serial.mod ata.mod \
+ vga.mod
# For biosdisk.mod.
biosdisk_mod_SOURCES = disk/i386/pc/biosdisk.c
@@ -251,4 +252,9 @@
ata_mod_CFLAGS = $(COMMON_CFLAGS)
ata_mod_LDFLAGS = $(COMMON_LDFLAGS)
+# For vga.mod.
+vga_mod_SOURCES = term/i386/pc/vga.c
+vga_mod_CFLAGS = $(COMMON_CFLAGS)
+vga_mod_LDFLAGS = $(COMMON_LDFLAGS)
+
include $(srcdir)/conf/common.mk
Index: term/i386/pc/vga.c
===================================================================
RCS file: /sources/grub/grub2/term/i386/pc/vga.c,v
retrieving revision 1.12
diff -u -r1.12 vga.c
--- term/i386/pc/vga.c 3 Oct 2007 20:13:21 -0000 1.12
+++ term/i386/pc/vga.c 10 Nov 2007 13:57:15 -0000
@@ -18,6 +18,7 @@
#include <grub/machine/vga.h>
#include <grub/machine/console.h>
+#include <grub/cpu/io.h>
#include <grub/term.h>
#include <grub/types.h>
#include <grub/dl.h>
@@ -62,7 +63,6 @@
static int cursor_state;
static unsigned char fg_color, bg_color;
static struct colored_char text_buf[TEXT_WIDTH * TEXT_HEIGHT];
-static unsigned char *vga_font;
static unsigned char saved_map_mask;
static int page = 0;
@@ -97,11 +97,11 @@
unsigned char old_data;
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
- grub_outb (SEQUENCER_ADDR_PORT, MAP_MASK_REGISTER);
+ grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
old_data = grub_inb (SEQUENCER_DATA_PORT);
- grub_outb (SEQUENCER_ADDR_PORT, old_addr);
+ grub_outb (old_addr, SEQUENCER_ADDR_PORT);
return old_data;
}
@@ -113,11 +113,11 @@
unsigned char old_addr;
old_addr = grub_inb (SEQUENCER_ADDR_PORT);
- grub_outb (SEQUENCER_ADDR_PORT, MAP_MASK_REGISTER);
+ grub_outb (MAP_MASK_REGISTER, SEQUENCER_ADDR_PORT);
- grub_outb (SEQUENCER_DATA_PORT, mask);
+ grub_outb (mask, SEQUENCER_DATA_PORT);
- grub_outb (SEQUENCER_ADDR_PORT, old_addr);
+ grub_outb (old_addr, SEQUENCER_ADDR_PORT);
}
/* Set Read Map Register. */
@@ -128,10 +128,10 @@
old_addr = grub_inb (GRAPHICS_ADDR_PORT);
- grub_outb (GRAPHICS_ADDR_PORT, READ_MAP_REGISTER);
- grub_outb (GRAPHICS_DATA_PORT, map);
+ grub_outb (READ_MAP_REGISTER, GRAPHICS_ADDR_PORT);
+ grub_outb (map, GRAPHICS_DATA_PORT);
- grub_outb (GRAPHICS_ADDR_PORT, old_addr);
+ grub_outb (old_addr, GRAPHICS_ADDR_PORT);
}
/* Set start address. */
@@ -142,19 +142,18 @@
old_addr = grub_inb (CRTC_ADDR_PORT);
- grub_outb (CRTC_ADDR_PORT, START_ADDR_LOW_REGISTER);
- grub_outb (CRTC_DATA_PORT, start & 0xFF);
+ grub_outb (START_ADDR_LOW_REGISTER, CRTC_ADDR_PORT);
+ grub_outb (start & 0xFF, CRTC_DATA_PORT);
- grub_outb (CRTC_ADDR_PORT, START_ADDR_HIGH_REGISTER);
- grub_outb (CRTC_DATA_PORT, start >> 8);
+ grub_outb (START_ADDR_HIGH_REGISTER, CRTC_ADDR_PORT);
+ grub_outb (start >> 8, CRTC_DATA_PORT);
- grub_outb (CRTC_ADDR_PORT, old_addr);
+ grub_outb (old_addr, CRTC_ADDR_PORT);
}
static grub_err_t
grub_vga_mod_init (void)
{
- vga_font = grub_vga_get_font ();
text_mode = grub_vga_set_mode (0x10);
cursor_state = 1;
fg_color = DEFAULT_FG_COLOR;
@@ -175,77 +174,6 @@
}
static int
-get_vga_glyph (grub_uint32_t code, unsigned char bitmap[32], unsigned *width)
-{
- if (code > 0x7f)
- {
- /* Map some unicode characters to the VGA font, if possible. */
- switch (code)
- {
- case 0x2190: /* left arrow */
- code = 0x1b;
- break;
- case 0x2191: /* up arrow */
- code = 0x18;
- break;
- case 0x2192: /* right arrow */
- code = 0x1a;
- break;
- case 0x2193: /* down arrow */
- code = 0x19;
- break;
- case 0x2501: /* horizontal line */
- code = 0xc4;
- break;
- case 0x2503: /* vertical line */
- code = 0xb3;
- break;
- case 0x250F: /* upper-left corner */
- code = 0xda;
- break;
- case 0x2513: /* upper-right corner */
- code = 0xbf;
- break;
- case 0x2517: /* lower-left corner */
- code = 0xc0;
- break;
- case 0x251B: /* lower-right corner */
- code = 0xd9;
- break;
-
- default:
- return grub_font_get_glyph (code, bitmap, width);
- }
- }
-
- if (bitmap)
- grub_memcpy (bitmap, vga_font + code * CHAR_HEIGHT, CHAR_HEIGHT);
-
- *width = 1;
- return 1;
-}
-
-static void
-invalidate_char (struct colored_char *p)
-{
- p->code = 0xFFFF;
-
- if (p->width)
- {
- struct colored_char *q;
-
- for (q = p + 1; q <= p + p->width; q++)
- {
- q->code = 0xFFFF;
- q->width = 0;
- q->index = 0;
- }
- }
-
- p->width = 0;
-}
-
-static int
check_vga_mem (void *p)
{
return (p >= (void *) (VGA_MEM + PAGE_OFFSET (page))
@@ -257,8 +185,7 @@
write_char (void)
{
struct colored_char *p = text_buf + xpos + ypos * TEXT_WIDTH;
- unsigned char bitmap[32];
- unsigned width;
+ struct grub_font_glyph glyph;
unsigned char *mem_base;
unsigned plane;
@@ -266,8 +193,8 @@
ypos * CHAR_HEIGHT * TEXT_WIDTH + PAGE_OFFSET (page)) - p->index;
p -= p->index;
- if (! get_vga_glyph (p->code, bitmap, &width))
- invalidate_char (p);
+ /* Get glyph for character. */
+ grub_font_get_glyph (p->code, &glyph);
for (plane = 0x01; plane <= 0x08; plane <<= 1)
{
@@ -283,12 +210,12 @@
{
unsigned i;
- for (i = 0; i < width && offset < 32; i++)
+ for (i = 0; i < glyph.char_width && offset < 32; i++)
{
unsigned char fg_mask, bg_mask;
- fg_mask = (p->fg_color & plane) ? bitmap[offset] : 0;
- bg_mask = (p->bg_color & plane) ? ~(bitmap[offset]) : 0;
+ fg_mask = (p->fg_color & plane) ? glyph.bitmap[offset] : 0;
+ bg_mask = (p->bg_color & plane) ? ~(glyph.bitmap[offset]) : 0;
offset++;
if (check_vga_mem (mem + i))
@@ -393,36 +320,36 @@
}
else
{
- unsigned width;
+ struct grub_font_glyph glyph;
struct colored_char *p;
- get_vga_glyph (c, 0, &width);
+ grub_font_get_glyph(c, &glyph);
- if (xpos + width > TEXT_WIDTH)
+ if (xpos + glyph.char_width > TEXT_WIDTH)
grub_putchar ('\n');
p = text_buf + xpos + ypos * TEXT_WIDTH;
p->code = c;
p->fg_color = fg_color;
p->bg_color = bg_color;
- p->width = width - 1;
+ p->width = glyph.char_width - 1;
p->index = 0;
- if (width > 1)
+ if (glyph.char_width > 1)
{
unsigned i;
- for (i = 1; i < width; i++)
+ for (i = 1; i < glyph.char_width; i++)
{
p[i].code = ' ';
- p[i].width = width - 1;
+ p[i].width = glyph.char_width - 1;
p[i].index = i;
}
}
write_char ();
- xpos += width;
+ xpos += glyph.char_width;
if (xpos >= TEXT_WIDTH)
{
xpos = 0;
@@ -454,12 +381,11 @@
static grub_ssize_t
grub_vga_getcharwidth (grub_uint32_t c)
{
- unsigned width;
+ struct grub_font_glyph glyph;
- if (! get_vga_glyph (c, 0, &width))
- return 0;
-
- return width;
+ grub_font_get_glyph (c, &glyph);
+
+ return glyph.char_width;
}
static grub_uint16_t
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Fix for vga terminal
2007-11-10 14:04 [patch] Fix for vga terminal Vesa Jääskeläinen
@ 2007-11-10 18:25 ` Marco Gerards
2007-11-10 18:55 ` Vesa Jääskeläinen
0 siblings, 1 reply; 3+ messages in thread
From: Marco Gerards @ 2007-11-10 18:25 UTC (permalink / raw)
To: The development of GRUB 2
Vesa Jääskeläinen <chaac@nic.fi> writes:
Hi Vesa,
> Here is patch for fixing vga terminal. At least it worked fine on qemu.
> Now it uses only font system to get fonts so you need to load font
> module and use fonts. See gfxterm section on the wiki on how to do that.
>
> I had to edit patch by hand as 64bit patch is still pending and I need
> that to compile my codes. But it should still apply nicely to current CVS.
Great! Thanks for fixing this!
[...]
> +2007-11-10 Vesa Jaaskelainen <chaac@nic.fi>
> +
> + * conf/i386-pc.rmk (pkgdata_MODULES): Added vga.mod.
> + (vga_mod_SOURCES): Added.
> + (vga_mod_CFLAGS): Likewise.
> + (vga_mod_LDFLAGS): Likewise.
> +
> + * term/i386/pc/vga.c (get_map_mask): Switch order of arguments in
> + grub_outb() calls.
> + (set_map_mask): Likewise.
> + (set_read_map): Likewise.
> + (set_read_address): Likewise.
> + (vga_font): Removed variable.
> + (get_vga_glyph): Removed function.
> + (invalidate_char): Likewise.
> + (write_char): Changed to use grub_font_get_glyph() for font
> + information.
> + (grub_vga_putchar): Likewise.
> + (grub_vga_getcharwidth): Likewise.
This looks good to me. Feel free to commit this! :-)
--
Marco
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Fix for vga terminal
2007-11-10 18:25 ` Marco Gerards
@ 2007-11-10 18:55 ` Vesa Jääskeläinen
0 siblings, 0 replies; 3+ messages in thread
From: Vesa Jääskeläinen @ 2007-11-10 18:55 UTC (permalink / raw)
To: The development of GRUB 2
Marco Gerards wrote:
> Vesa Jääskeläinen <chaac@nic.fi> writes:
>
> Hi Vesa,
>
>> Here is patch for fixing vga terminal. At least it worked fine on qemu.
>> Now it uses only font system to get fonts so you need to load font
>> module and use fonts. See gfxterm section on the wiki on how to do that.
>>
>> I had to edit patch by hand as 64bit patch is still pending and I need
>> that to compile my codes. But it should still apply nicely to current CVS.
>
> This looks good to me. Feel free to commit this! :-)
Done.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-11-10 18:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-10 14:04 [patch] Fix for vga terminal Vesa Jääskeläinen
2007-11-10 18:25 ` Marco Gerards
2007-11-10 18:55 ` Vesa Jääskeläinen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.