From: Robert Millan <rmh@aybabtu.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] Fixed ieee1275 console
Date: Mon, 1 Oct 2007 14:31:02 +0200 [thread overview]
Message-ID: <20071001123102.GA20428@thorin> (raw)
In-Reply-To: <8a2a06bb0710010357u142f6ba4gb053afde829f0f39@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2138 bytes --]
On Mon, Oct 01, 2007 at 12:57:35PM +0200, Marcin Kurek wrote:
> 2) menu looks ugly like hell as it contains some random characters in
> place of borders.
I have a few concerns about this part:
> static void
> grub_ofconsole_putchar (grub_uint32_t c)
> {
> - char chr = c;
> - if (c == '\n')
> - {
> + char chr;
> +
> + switch (c)
> + {
> + case GRUB_TERM_DISP_LEFT:
> + c = '<';
> + break;
> + case GRUB_TERM_DISP_UP:
> + c = '^';
> + break;
> + case GRUB_TERM_DISP_RIGHT:
> + c = '>';
> + break;
> + case GRUB_TERM_DISP_DOWN:
> + c = 'v';
> + break;
> + case GRUB_TERM_DISP_HLINE:
> + c = '-';
> + break;
> + case GRUB_TERM_DISP_VLINE:
> + c = '|';
> + break;
> + case GRUB_TERM_DISP_UL:
> + case GRUB_TERM_DISP_UR:
> + case GRUB_TERM_DISP_LL:
> + case GRUB_TERM_DISP_LR:
> + c = '+';
> + break;
> + case '\t':
> + c = ' ';
> + break;
> +
> + default:
> + /* of does not support Unicode. */
> + if (c > 0x7f)
> + c = '?';
> + break;
> + }
1- First, you're duplicating code from term/i386/pc/serial.c. I think it should
be shared.
2- Do we _always_ want to map to ascii? Of course, mapping to ascii is the best
choice when we don't have anything better, but if we can distinguish physical
screen (cp437 charset, on PCs and on efika as well) from serial cable (must
be ascii?), we could still draw pretty lines instead of -|+ stuff.
3- The cp437 charset in efika is buggy (I don't know about pegasos), as some
chars are replaced with portions of the bplan logo (sigh). I gave it a try
before, and the only sane way to draw a pretty rectangle seems to
be:
(warning, utf-8 follows. if you can't read this get a decent MUA ;-))
╒═╕
│ │
╘═╛
I had this pending patch liing around. I never got the time to sort out all
these problems, but perhaps you can obtain something useful from it.
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
[-- Attachment #2: charset.diff --]
[-- Type: text/x-diff, Size: 7314 bytes --]
Tested on Efika *only*
Get rid of the FIXME
diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/conf/i386-pc.rmk grub2/conf/i386-pc.rmk
--- grub2.old/conf/i386-pc.rmk 2007-06-23 16:40:12.000000000 +0200
+++ grub2/conf/i386-pc.rmk 2007-07-10 21:32:52.000000000 +0200
@@ -28,7 +28,7 @@
kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \
kern/i386/dl.c kern/i386/pc/init.c kern/parser.c kern/partition.c \
kern/env.c disk/i386/pc/biosdisk.c \
- term/i386/pc/console.c \
+ term/i386/pc/console.c term/cp437.c \
symlist.c
kernel_img_HEADERS = arg.h boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/conf/powerpc-ieee1275.rmk grub2/conf/powerpc-ieee1275.rmk
--- grub2.old/conf/powerpc-ieee1275.rmk 2007-07-10 20:40:07.000000000 +0200
+++ grub2/conf/powerpc-ieee1275.rmk 2007-07-10 21:33:19.000000000 +0200
@@ -80,7 +80,8 @@
kern/ieee1275/ieee1275.c kern/main.c kern/device.c \
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
kern/misc.c kern/mm.c kern/loader.c kern/rescue.c kern/term.c \
- kern/powerpc/ieee1275/init.c term/ieee1275/ofconsole.c \
+ kern/powerpc/ieee1275/init.c term/ieee1275/ofconsole.c \
+ term/cp437.c \
kern/powerpc/ieee1275/openfw.c disk/ieee1275/ofdisk.c \
kern/parser.c kern/partition.c kern/env.c kern/powerpc/dl.c \
kernel_elf_symlist.c kern/powerpc/cache.S
diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/include/grub/ieee1275/ieee1275.h grub2/include/grub/ieee1275/ieee1275.h
--- grub2.old/include/grub/ieee1275/ieee1275.h 2007-07-09 17:12:15.000000000 +0200
+++ grub2/include/grub/ieee1275/ieee1275.h 2007-07-10 23:29:37.000000000 +0200
@@ -83,6 +83,14 @@
/* CodeGen firmware does not correctly implement "output-device output" */
GRUB_IEEE1275_FLAG_BROKEN_OUTPUT,
+
+ /* On CodeGen firmware (maybe others?), extended chars are assumed to be
+ cp437-encoded */
+ GRUB_IEEE1275_FLAG_CP437_DISPLAY,
+
+ /* On CodeGen firmware, cp437 characters 0xc0 to 0xcb are reserved for the
+ bplan logo */
+ GRUB_IEEE1275_FLAG_BPLAN_LOGO,
};
extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag flag);
diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/include/grub/term.h grub2/include/grub/term.h
--- grub2.old/include/grub/term.h 2005-10-15 11:22:31.000000000 +0200
+++ grub2/include/grub/term.h 2007-07-10 23:31:02.000000000 +0200
@@ -202,6 +202,7 @@
int EXPORT_FUNC(grub_getcursor) (void);
void EXPORT_FUNC(grub_refresh) (void);
void EXPORT_FUNC(grub_set_more) (int onoff);
+grub_uint32_t EXPORT_FUNC(grub_utf8_to_cp437) (grub_uint32_t c);
/* For convenience. */
#define GRUB_TERM_ASCII_CHAR(c) ((c) & 0xff)
diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/kern/powerpc/ieee1275/cmain.c grub2/kern/powerpc/ieee1275/cmain.c
--- grub2.old/kern/powerpc/ieee1275/cmain.c 2007-07-09 17:12:15.000000000 +0200
+++ grub2/kern/powerpc/ieee1275/cmain.c 2007-07-10 23:30:34.000000000 +0200
@@ -66,6 +66,8 @@
{
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS);
grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_CP437_DISPLAY);
+ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO);
}
}
diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/term/i386/pc/console.c grub2/term/i386/pc/console.c
--- grub2.old/term/i386/pc/console.c 2007-05-05 00:28:31.000000000 +0200
+++ grub2/term/i386/pc/console.c 2007-07-10 21:30:06.000000000 +0200
@@ -26,58 +26,10 @@
static grub_uint8_t grub_console_normal_color = 0x7;
static grub_uint8_t grub_console_highlight_color = 0x70;
-static grub_uint32_t
-map_char (grub_uint32_t c)
-{
- if (c > 0x7f)
- {
- /* Map some unicode characters to the VGA font, if possible. */
- switch (c)
- {
- case 0x2190: /* left arrow */
- c = 0x1b;
- break;
- case 0x2191: /* up arrow */
- c = 0x18;
- break;
- case 0x2192: /* right arrow */
- c = 0x1a;
- break;
- case 0x2193: /* down arrow */
- c = 0x19;
- break;
- case 0x2501: /* horizontal line */
- c = 0xc4;
- break;
- case 0x2503: /* vertical line */
- c = 0xb3;
- break;
- case 0x250F: /* upper-left corner */
- c = 0xda;
- break;
- case 0x2513: /* upper-right corner */
- c = 0xbf;
- break;
- case 0x2517: /* lower-left corner */
- c = 0xc0;
- break;
- case 0x251B: /* lower-right corner */
- c = 0xd9;
- break;
-
- default:
- c = '?';
- break;
- }
- }
-
- return c;
-}
-
static void
grub_console_putchar (grub_uint32_t c)
{
- grub_console_real_putchar (map_char (c));
+ grub_console_real_putchar (grub_utf8_to_cp437 (c));
}
static grub_ssize_t
diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/term/i386/pc/serial.c grub2/term/i386/pc/serial.c
--- grub2.old/term/i386/pc/serial.c 2005-11-13 16:47:09.000000000 +0100
+++ grub2/term/i386/pc/serial.c 2007-07-10 23:18:53.000000000 +0200
@@ -328,44 +328,7 @@
/* The serial terminal does not have VGA fonts. */
if (c > 0x7F)
{
- /* Better than nothing. */
- switch (c)
- {
- case GRUB_TERM_DISP_LEFT:
- c = '<';
- break;
-
- case GRUB_TERM_DISP_UP:
- c = '^';
- break;
-
- case GRUB_TERM_DISP_RIGHT:
- c = '>';
- break;
-
- case GRUB_TERM_DISP_DOWN:
- c = 'v';
- break;
-
- case GRUB_TERM_DISP_HLINE:
- c = '-';
- break;
-
- case GRUB_TERM_DISP_VLINE:
- c = '|';
- break;
-
- case GRUB_TERM_DISP_UL:
- case GRUB_TERM_DISP_UR:
- case GRUB_TERM_DISP_LL:
- case GRUB_TERM_DISP_LR:
- c = '+';
- break;
-
- default:
- c = '?';
- break;
- }
+ / * FIXME */
}
switch (c)
diff -ur -x i386-pc.mk -x powerpc-ieee1275.mk grub2.old/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c
--- grub2.old/term/ieee1275/ofconsole.c 2007-07-09 17:12:15.000000000 +0200
+++ grub2/term/ieee1275/ofconsole.c 2007-07-10 23:30:34.000000000 +0200
@@ -75,7 +75,45 @@
static void
grub_ofconsole_putchar (grub_uint32_t c)
{
- char chr = c;
+ char chr;
+
+ /* cp437 characters 0xc0 to 0xcb are reserved for the bplan logo. Use
+ this layout to workaround it:
+ ╒═╕
+ │ │
+ ╘═╛
+ */
+ if (c > 0x7F)
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_CP437_DISPLAY))
+ {
+ if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO))
+ switch (c)
+ {
+ case GRUB_TERM_DISP_HLINE:
+ c = 0xcd;
+ break;
+ case GRUB_TERM_DISP_VLINE:
+ c = 0xb3;
+ break;
+ case GRUB_TERM_DISP_UL:
+ c = 0xd5;
+ break;
+ case GRUB_TERM_DISP_UR:
+ c = 0xb8;
+ break;
+ case GRUB_TERM_DISP_LL:
+ c = 0xd4;
+ break;
+ case GRUB_TERM_DISP_LR:
+ c = 0xbe;
+ break;
+ default:
+ c = grub_utf8_to_cp437 (c);
+ }
+ else
+ c = grub_utf8_to_cp437 (c);
+ }
+
if (c == '\n')
{
grub_curr_y++;
@@ -87,6 +125,8 @@
if (grub_curr_x > grub_ofconsole_width)
grub_putcode ('\n');
}
+
+ chr = c;
grub_ieee1275_write (stdout_ihandle, &chr, 1, 0);
}
next prev parent reply other threads:[~2007-10-01 12:31 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-01 10:57 [PATCH] Fixed ieee1275 console Marcin Kurek
2007-10-01 12:31 ` Robert Millan [this message]
2007-10-01 12:33 ` Robert Millan
2007-10-01 18:14 ` Marcin Kurek
2007-10-01 18:39 ` Robert Millan
2007-10-01 19:43 ` Marcin Kurek
2007-10-02 21:39 ` Robert Millan
2007-10-03 23:33 ` Marcin Kurek
2007-10-04 20:50 ` Robert Millan
2007-10-10 15:11 ` Marcin Kurek
2007-10-10 19:19 ` Robert Millan
2007-10-10 21:57 ` Marcin Kurek
2007-10-11 14:01 ` Robert Millan
2007-10-11 15:06 ` Marco Gerards
2007-10-12 16:16 ` Marcin Kurek
2007-11-10 17:05 ` Marco Gerards
2007-11-11 11:02 ` Marcin Kurek
2007-11-18 11:37 ` Marco Gerards
2007-10-15 20:43 ` Marcin Kurek
2007-11-18 13:18 ` Marco Gerards
2007-11-18 12:11 ` Marco Gerards
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071001123102.GA20428@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.