Re: [PATCH] Fixed ieee1275 console

2007-11-18 Thread Marco Gerards
Marcin Kurek [EMAIL PROTECTED] writes:

Hi,

 Can you provide something that makes use of that?

 Hmm, I should have example code somewhere on disk. I will try to find it.

:-)

 Will do :-)

 I already send e-mail to fsf today as there was no reply to my previous 
 e-mail.

Great!

--
Marco



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Fixed ieee1275 console

2007-11-18 Thread Marco Gerards
Marcin Kurek [EMAIL PROTECTED] writes:

Hi,

 I prefer if it can be detected if this is Efika or for example an
 apple implementation of OF and handle these characters depending on
 that.  IIRC this code does work on the apple, but unfortunately I
 cannot check this anymore.

 Attached current console patchset. The graphical frames workaround is
 used only for SmartFirmware then Apple machines should get cp437
 frames normaly. Sorry still no time to split it :( Anyway I will try
 to explain a bit each of them.

Whoops, I almost missed this patch :-)

 Simple Console: Generaly it seems cp437 frames are used on pc, same
 for simple frames using '-' characters which are used for ncurses
 console and serial console on pc. I think keep same code in many
 places is not so good idea then I moved conversion rutines in to one
 place and introduce two term flags GRUB_TERM_SIMPLE_MENU and
 GRUB_TERM_CP437_MENU.

 In case when term has GRUB_TERM_SIMPLE_MENU set it would automaticly
 use '-' frames and same for GRUB_TERM_CP437_MENU to use cp437 frames.
 If no flags is set there would be no charset translation for frames.

AFAIK it is not certain if it is CP437 that is used.  This is just the
case for PPC.

 Cosmetic: In general I see no reason to use multiple
 grub_ieee1275_write() calls if we can use single one. Nothing
 important, but good to have IMHO.

Right, we can use this and always revert if it causes problems.

 Backspace: As I already wrote my version of OF seems to sent \b 
 del sequence for backspace key. This change cause no side effects on
 Efika (USB keyboard) and Pegasos 1 with PS/2 keyboard. Can anyone
 check it on Apple OF ? In case of any troubles we can still use a
 IEEE1275 flag to use it only for SmartFw.

Right.

 OFConsole: A biggest patch in pack. Generaly the grub console is
 completly broken here (Pegasos 1  2, Efika) The x/y cursor tracking
 not works as expect to and cursor position is random after few written
 lines.

Right.

 Generaly I introduce realy working x/y position tracking and in result
 this give me a working console output in all cases (no random cursor
 position after 'ls' command, no empty screen after more than one
 output, etc)

Great!

 Second change was detection of console type (serial, screen,
 framebuffer) The reason was to draw frames which looks good in all
 three. Default ofconsole uses now simple frames (same for serial
 console) and switch to cp437 frames if detect normal screen console,
 unfortunatly if of uses framebuffer mode (efika, unofficial OF upgrade
 for Pegasos 2) we can not use this frame type as framebuffer font lack
 required characters. The reason why framebuffer mode and serial mode
 are separated is planned vesa support as I already have a basic vesa
 framework we will be able to use it when finished (Then simple frames
 on serial console, cp437 on normal console and graphical frames on
 framebuffer)

The PegasosII has VESA support!?

 This code uses some new flags:

 GRUB_IEEE1275_FLAG_NOFB_ROWS25: For some reason all versions of SF has
 25 rows on normal console, but report only 24 which broke the grub
 console. This flag was added to workaround this problem.

Weird...

 GRUB_IEEE1275_FLAG_NOCLS: Pegasos 1 OF seems to not interpret the cls
 escape then if detected we use \n workaround.

Ok.

 GRUB_IEEE1275_FLAG_BPLAN_LOGO: Arghhh, we can use cp437 frames on
 pegasos, but it seems a parts of characters used by grub are replaced
 by bPlan logo. Use a workaround proposed here in this case and in a
 result have a nice looking grub menu on pegasos/efika too.

Workaround as in using - to draw the menu?

 I hope I explain everything here. In another e-mail I attach rest of
 my patches for grub.

Great!

 -- 
 --- Marcin 'Morgoth' Kurek ---

 diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h
 --- grub2.org/include/grub/term.h 2007-07-22 01:32:22.0 +0200
 +++ grub2/include/grub/term.h 2007-10-15 21:26:48.401210358 +0200
 @@ -51,6 +51,10 @@
  #define GRUB_TERM_NO_EDIT(1  1)
  /* Set when the terminal cannot do fancy things.  */
  #define GRUB_TERM_DUMB   (1  2)
 +/* Set to use ascii menu borders.  */
 +#define GRUB_TERM_SIMPLE_MENU(1  3) 
 +/* Set to use cp437 menu borders.  */
 +#define GRUB_TERM_CP437_MENU (1  4)

Only the GRUB_TERM_SIMPLE_MENU flag should be sufficient, right?

  /* Set when the terminal needs to be initialized.  */
  #define GRUB_TERM_NEED_INIT  (1  16)
  
 diff -urN grub2.org/kern/term.c grub2/kern/term.c
 --- grub2.org/kern/term.c 2007-07-22 01:32:26.0 +0200
 +++ grub2/kern/term.c 2007-10-15 21:26:48.402210358 +0200
 @@ -90,6 +90,94 @@
return grub_cur_term;
  }
  
 +static
 +grub_uint32_t remap_border(grub_uint32_t code)

Please follow the same coding style as we do: the GCS.  Return types
are on a separate line, the ( is prefixed by a space.  Thus:

static grub_uint32_t
remap_border (grub_uint32_t code)

Remap is a somewhat confusing name.  Perhaps something 

Re: [PATCH] Fixed ieee1275 console

2007-11-11 Thread Marcin Kurek
Hell[o]

 Can you provide something that makes use of that?

Hmm, I should have example code somewhere on disk. I will try to find it.

 Will do :-)

I already send e-mail to fsf today as there was no reply to my previous e-mail.

-- 
--- Marcin 'Morgoth' Kurek ---


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Fixed ieee1275 console

2007-11-10 Thread Marco Gerards
Marcin Kurek [EMAIL PROTECTED] writes:

 Hell[o]

 Right, this is because it seems that the MSB is lost when writing a
 character to the screen.  For the borders specific characters are used
 above 127 (non-ASCII).  I wonder if the Pegasos console supports this
 ASCII extension if you change some settings or so...

 The problem is in framebuffer mode OF loads glyphs starting from 32 to
 127 then any characters abowe 127 are displayed as white '?'. The
 solution would be to use set-font to load a proper font to use with
 grub. In non framebuffer mode cp437 is used by console then we can use
 it to draw borders same as for PC.

Can you provide something that makes use of that?

 I prefer if it can be detected if this is Efika or for example an
 apple implementation of OF and handle these characters depending on
 that.  IIRC this code does work on the apple, but unfortunately I
 cannot check this anymore.

 Ahhh, I see you looked at first version of patch. Please take a look
 at recent version of my patches.

Will do :-)

  Handle 127 keycode as backspace key in grub_ofconsole_readkey() which fix
 [1]

 Can you explain this?

 For some reasons my OF sends \b  127 (Del) sequence for backspace
 key. It seems to be same sa ncurses console.

Ok.

--
Marco



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Fixed ieee1275 console

2007-10-15 Thread Marcin Kurek
Hell[o]

 I prefer if it can be detected if this is Efika or for example an
 apple implementation of OF and handle these characters depending on
 that.  IIRC this code does work on the apple, but unfortunately I
 cannot check this anymore.

Attached current console patchset. The graphical frames workaround is
used only for SmartFirmware then Apple machines should get cp437
frames normaly. Sorry still no time to split it :( Anyway I will try
to explain a bit each of them.



Simple Console: Generaly it seems cp437 frames are used on pc, same
for simple frames using '-' characters which are used for ncurses
console and serial console on pc. I think keep same code in many
places is not so good idea then I moved conversion rutines in to one
place and introduce two term flags GRUB_TERM_SIMPLE_MENU and
GRUB_TERM_CP437_MENU.

In case when term has GRUB_TERM_SIMPLE_MENU set it would automaticly
use '-' frames and same for GRUB_TERM_CP437_MENU to use cp437 frames.
If no flags is set there would be no charset translation for frames.

Cosmetic: In general I see no reason to use multiple
grub_ieee1275_write() calls if we can use single one. Nothing
important, but good to have IMHO.

Backspace: As I already wrote my version of OF seems to sent \b 
del sequence for backspace key. This change cause no side effects on
Efika (USB keyboard) and Pegasos 1 with PS/2 keyboard. Can anyone
check it on Apple OF ? In case of any troubles we can still use a
IEEE1275 flag to use it only for SmartFw.

OFConsole: A biggest patch in pack. Generaly the grub console is
completly broken here (Pegasos 1  2, Efika) The x/y cursor tracking
not works as expect to and cursor position is random after few written
lines.

Generaly I introduce realy working x/y position tracking and in result
this give me a working console output in all cases (no random cursor
position after 'ls' command, no empty screen after more than one
output, etc)

Second change was detection of console type (serial, screen,
framebuffer) The reason was to draw frames which looks good in all
three. Default ofconsole uses now simple frames (same for serial
console) and switch to cp437 frames if detect normal screen console,
unfortunatly if of uses framebuffer mode (efika, unofficial OF upgrade
for Pegasos 2) we can not use this frame type as framebuffer font lack
required characters. The reason why framebuffer mode and serial mode
are separated is planned vesa support as I already have a basic vesa
framework we will be able to use it when finished (Then simple frames
on serial console, cp437 on normal console and graphical frames on
framebuffer)

This code uses some new flags:

GRUB_IEEE1275_FLAG_NOFB_ROWS25: For some reason all versions of SF has
25 rows on normal console, but report only 24 which broke the grub
console. This flag was added to workaround this problem.

GRUB_IEEE1275_FLAG_NOCLS: Pegasos 1 OF seems to not interpret the cls
escape then if detected we use \n workaround.

GRUB_IEEE1275_FLAG_BPLAN_LOGO: Arghhh, we can use cp437 frames on
pegasos, but it seems a parts of characters used by grub are replaced
by bPlan logo. Use a workaround proposed here in this case and in a
result have a nice looking grub menu on pegasos/efika too.

I hope I explain everything here. In another e-mail I attach rest of
my patches for grub.

-- 
--- Marcin 'Morgoth' Kurek ---
diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h
--- grub2.org/include/grub/term.h	2007-07-22 01:32:22.0 +0200
+++ grub2/include/grub/term.h	2007-10-15 21:26:48.401210358 +0200
@@ -51,6 +51,10 @@
 #define GRUB_TERM_NO_EDIT	(1  1)
 /* Set when the terminal cannot do fancy things.  */
 #define GRUB_TERM_DUMB		(1  2)
+/* Set to use ascii menu borders.  */
+#define GRUB_TERM_SIMPLE_MENU	(1  3) 
+/* Set to use cp437 menu borders.  */
+#define GRUB_TERM_CP437_MENU	(1  4)
 /* Set when the terminal needs to be initialized.  */
 #define GRUB_TERM_NEED_INIT	(1  16)
 
diff -urN grub2.org/kern/term.c grub2/kern/term.c
--- grub2.org/kern/term.c	2007-07-22 01:32:26.0 +0200
+++ grub2/kern/term.c	2007-10-15 21:26:48.402210358 +0200
@@ -90,6 +90,94 @@
   return grub_cur_term;
 }
 
+static
+grub_uint32_t remap_border(grub_uint32_t code)
+{
+  if (grub_cur_term-flags  GRUB_TERM_SIMPLE_MENU)
+{
+  switch (code)
+{
+case GRUB_TERM_DISP_LEFT:
+  code = '';
+  break;
+
+case GRUB_TERM_DISP_UP:
+  code = '^';
+  break;
+
+case GRUB_TERM_DISP_RIGHT:
+  code = '';
+  break;
+
+case GRUB_TERM_DISP_DOWN:
+  code = 'v';
+  break;
+
+case GRUB_TERM_DISP_HLINE:
+  code = '-';
+  break;
+
+case GRUB_TERM_DISP_VLINE:
+  code = '|';
+  break;
+
+case GRUB_TERM_DISP_UL:
+case GRUB_TERM_DISP_UR:
+case GRUB_TERM_DISP_LL:
+

Re: [PATCH] Fixed ieee1275 console

2007-10-12 Thread Marcin Kurek
Hell[o]

 Right, this is because it seems that the MSB is lost when writing a
 character to the screen.  For the borders specific characters are used
 above 127 (non-ASCII).  I wonder if the Pegasos console supports this
 ASCII extension if you change some settings or so...

The problem is in framebuffer mode OF loads glyphs starting from 32 to
127 then any characters abowe 127 are displayed as white '?'. The
solution would be to use set-font to load a proper font to use with
grub. In non framebuffer mode cp437 is used by console then we can use
it to draw borders same as for PC.


 I prefer if it can be detected if this is Efika or for example an
 apple implementation of OF and handle these characters depending on
 that.  IIRC this code does work on the apple, but unfortunately I
 cannot check this anymore.

Ahhh, I see you looked at first version of patch. Please take a look
at recent version of my patches.

  Handle 127 keycode as backspace key in grub_ofconsole_readkey() which fix
 [1]

 Can you explain this?

For some reasons my OF sends \b  127 (Del) sequence for backspace
key. It seems to be same sa ncurses console.

-- 
--- Marcin 'Morgoth' Kurek ---


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Fixed ieee1275 console

2007-10-11 Thread Robert Millan
On Wed, Oct 10, 2007 at 11:57:44PM +0200, Marcin Kurek wrote:
  In your code there's a condition in which _serial is set to 0 and _fb is
  left unset (as 0).  Is this intended?  Sounds like a bug.
 
 Not this is not a bug. We can heve 3 cases here:
 
 1) True serial console. In this case  recent versions of OF set stdout
 name and type to serial (_serial = 1, _fb = 0) In this case we want
 to use simple frames.
 
 2) On the screen terminal without framebuffer (fb-mode not existing or
 set to 0x0x0) In this case we will get type serial (As it not
 supports pixel operations) and name display as this is not real
 serial console. (_serial = 0, _fb = 0) In this case we can use cp437
 frames.
 
 For old versions of OF this case need to catch bootconsole too.
 
 3) Console with framebuffer (fb-mode != 0x0x0) In this case we will
 get type to display or vga (_serial = 0, _fb = 1) In this case we
 can not use cp437 frames as vga font used by OF maps only first 127
 characters ;( I put this in to separate case as we can still use
 framebuffer interface to draw some frames or try to load a working
 font, etc.
 
 I use 'true serial' as a safe default if detection fails for some reasons.

Ok but do we really need to make that distinction?  Perhaps it would be simpler
to define a structure that only cares about charset capability, and make code
that plays with charsets just check that, without caring if it's a serial
cable or a vga with old firmware, etc.

And possibly this could be integrated with your proposed use of
grub_term.flags ? (I'm not sure if that would make sense, but it would be
nice to simplify if possible)

-- 
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 /.)


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Fixed ieee1275 console

2007-10-11 Thread Marco Gerards
Marcin Kurek [EMAIL PROTECTED] writes:

Hi Marcin,

Sorry for the late reply.  I have been absent for quite a while, but I
intend to go over the emails on this list during the weekend
(including yours).  I noticed this email because I worked on this
problem myself, so that is why I am replying now.

 Finaly I found a few free minutes to look at ofconsole as it never
 correctly work for me. There was 3 problems on my Pegasos:

 1) Backspace key not works with USB keyboard.
 2) menu looks ugly like hell as it contains some random characters in
 place of borders.

Right, this is because it seems that the MSB is lost when writing a
character to the screen.  For the borders specific characters are used
above 127 (non-ASCII).  I wonder if the Pegasos console supports this
ASCII extension if you change some settings or so...

[...]

 Replaced borders characters in grub_ofconsole_putchar() by '-', '|',
 etc. Maybe not perfect, but looks definitly better than before [2].
 Also fixed cursor position tracking (grub_curr_x, grub_curr_y) which
 fix both console problems [3]

I prefer if it can be detected if this is Efika or for example an
apple implementation of OF and handle these characters depending on
that.  IIRC this code does work on the apple, but unfortunately I
cannot check this anymore.

 Handle 127 keycode as backspace key in grub_ofconsole_readkey() which fix [1]

Can you explain this?

--
Marco



___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Fixed ieee1275 console

2007-10-10 Thread Marcin Kurek
Hell[o]

 Avoid the cosmetical changes! (there are more thorough the patch)

Arghh, I was sure I removed it :/ Anyway attached updated console patches.

01-grub2-simple_console.patch: Cleanups only. Should have no more
cosmetical changes inside.

04-grub2-ofconsole_fix.patch: Added detection of console type (serial,
normal or fb) and use GRUB_TERM_CP437_MENU from [01] for normal
console and GRUB_TERM_SIMPLE_MENU for serial (default) and fb (The
font used by fb has no characters required to use cp437 frames. I
think we can use fb interface to draw frames or use set-font commend
to load font with requred characters) Also added workaround of non
working 'cls' escape in old pegasos1 firmware.

To workaround bPlan logo problem I used parts of patch send ealrier to
this list ThX for that.

 Also remember to include a ChangeLog entry.

If the patch would be good enough to commit it I will.

-- 
--- Marcin 'Morgoth' Kurek ---
diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h
--- grub2.org/include/grub/term.h	2007-07-22 01:32:22.0 +0200
+++ grub2/include/grub/term.h	2007-10-10 16:04:18.331688149 +0200
@@ -51,6 +51,10 @@
 #define GRUB_TERM_NO_EDIT	(1  1)
 /* Set when the terminal cannot do fancy things.  */
 #define GRUB_TERM_DUMB		(1  2)
+/* Set to use ascii menu borders.  */
+#define GRUB_TERM_SIMPLE_MENU	(1  3) 
+/* Set to use cp437 menu borders.  */
+#define GRUB_TERM_CP437_MENU	(1  4)
 /* Set when the terminal needs to be initialized.  */
 #define GRUB_TERM_NEED_INIT	(1  16)
 
diff -urN grub2.org/kern/term.c grub2/kern/term.c
--- grub2.org/kern/term.c	2007-07-22 01:32:26.0 +0200
+++ grub2/kern/term.c	2007-10-10 16:05:03.047688149 +0200
@@ -90,6 +90,94 @@
   return grub_cur_term;
 }
 
+static
+grub_uint32_t remap_border(grub_uint32_t code)
+{
+  if (grub_cur_term-flags  GRUB_TERM_SIMPLE_MENU)
+{
+  switch (code)
+{
+case GRUB_TERM_DISP_LEFT:
+  code = '';
+  break;
+
+case GRUB_TERM_DISP_UP:
+  code = '^';
+  break;
+
+case GRUB_TERM_DISP_RIGHT:
+  code = '';
+  break;
+
+case GRUB_TERM_DISP_DOWN:
+  code = 'v';
+  break;
+
+case GRUB_TERM_DISP_HLINE:
+  code = '-';
+  break;
+
+case GRUB_TERM_DISP_VLINE:
+  code = '|';
+  break;
+
+case GRUB_TERM_DISP_UL:
+case GRUB_TERM_DISP_UR:
+case GRUB_TERM_DISP_LL:
+case GRUB_TERM_DISP_LR:
+  code = '+';
+  break;
+}
+}
+  else if(grub_cur_term-flags  GRUB_TERM_CP437_MENU)
+{
+  switch (code)
+{
+case GRUB_TERM_DISP_LEFT:
+  code = 0x1b;
+  break;
+
+case GRUB_TERM_DISP_UP:
+  code = 0x18;
+  break;
+
+case GRUB_TERM_DISP_RIGHT:
+  code = 0x1a;
+  break;
+
+case GRUB_TERM_DISP_DOWN:
+  code = 0x19;
+  break;
+
+case GRUB_TERM_DISP_HLINE:
+  code = 0xc4;
+  break;
+
+case GRUB_TERM_DISP_VLINE:
+  code = 0xb3;
+  break;
+
+case GRUB_TERM_DISP_UL:
+  code = 0xda;
+  break;
+
+case GRUB_TERM_DISP_UR:
+  code = 0xbf;
+  break;
+
+case GRUB_TERM_DISP_LL:
+  code = 0xc0;
+  break;
+
+case GRUB_TERM_DISP_LR:
+  code = 0xd9;
+  break;
+}
+}
+
+  return code;
+}
+
 /* Put a Unicode character.  */
 void
 grub_putcode (grub_uint32_t code)
@@ -107,6 +195,8 @@
   return;
 }
   
+  code = remap_border (code);
+
   (grub_cur_term-putchar) (code);
   
   if (code == '\n')
diff -urN grub2.org/term/i386/pc/console.c grub2/term/i386/pc/console.c
--- grub2.org/term/i386/pc/console.c	2007-07-22 01:32:30.0 +0200
+++ grub2/term/i386/pc/console.c	2007-10-10 16:03:34.131688149 +0200
@@ -25,58 +25,13 @@
 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;
-	  

Re: [PATCH] Fixed ieee1275 console

2007-10-10 Thread Robert Millan
On Wed, Oct 10, 2007 at 05:11:13PM +0200, Marcin Kurek wrote:
 Hell[o]
 
  Avoid the cosmetical changes! (there are more thorough the patch)
 
 Arghh, I was sure I removed it :/ Anyway attached updated console patches.

Great, thank you.

 diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c
 --- grub2.org/term/ieee1275/ofconsole.c   2007-07-22 11:05:11.0 
 +0200
 +++ grub2/term/ieee1275/ofconsole.c   2007-10-10 16:03:34.136688149 +0200
 @@ -75,6 +75,7 @@
  grub_ofconsole_putchar (grub_uint32_t c)
  {
char chr = c;
 +  
if (c == '\n')

Caught you! ;-)

 diff -urN grub2.org/include/grub/ieee1275/ieee1275.h 
 grub2/include/grub/ieee1275/ieee1275.h
 --- grub2.org/include/grub/ieee1275/ieee1275.h2007-10-04 
 22:44:12.0 +0200
 +++ grub2/include/grub/ieee1275/ieee1275.h2007-10-10 16:41:39.594688149 
 +0200
 @@ -82,6 +82,16 @@
  
/* CodeGen firmware does not correctly implement output-device output */
GRUB_IEEE1275_FLAG_BROKEN_OUTPUT,
 +
 +  /* In non fb mode default number of console rows is 24, but in fact it's 
 25 */
 +  GRUB_IEEE1275_FLAG_NOFB_ROWS25,
 +
 +  /* Old Pegaos firmware does not accept cls escape sequence */
 +  GRUB_IEEE1275_FLAG_NOCLS,
 +
 +  /* On CodeGen firmware, cp437 characters 0xc0 to 0xcb are reserved for the
 + bplan logo */
 +  GRUB_IEEE1275_FLAG_BPLAN_LOGO,
  };

I know it seems burdensome, but please can you split this in three patches, one
for each fix?  Then it's easier to review just one and say this is good, and
also easier to figure out why every hunk was done (since one knows what we're
trying to archieve).
 
 +  /* It seems no cls escape is available then simulate it using \n flood 
 */
 +  int x = (grub_ofconsole_height * 2) - grub_curr_y;

Maybe this would be easier to understand as (grub_ofconsole_height -
grub_curr_y) + grub_ofconsole_height.  What do others think? :-)

 +  /* Check do we are on serial or normal console */
 +  if(! grub_ieee1275_instance_to_package (stdout_ihandle, stdout_phandle))
 +{
 +  char type[16];
 +  char name[128];
 +  
 +  if(! grub_ieee1275_get_property (stdout_phandle, device_type, type,
 +   sizeof type, 0) 
 + ! grub_ieee1275_get_property (stdout_phandle, name, name,
 +   sizeof name, 0))
 +{
 +  /*
 +   * In general type serial is used for console without
 +   * framebuffer support in recent firmware versions then
 +   * we need to check the name too to determine is it real or
 +   * serial console
 +   */
 +
 +  if (! grub_strcmp (type, serial))
 +{
 +  /* If name is something else than display we assume serial 
 console */
 +  if(! grub_strcmp (name, display))
 +  grub_ofconsole_serial = 0;
 +}
 +  else
 +{ 
 +  grub_ofconsole_serial = 0;
 +
 +  /* Older versions use name/type set to bootconsole */
 +  if ( grub_strcmp (name, bootconsole))
 +grub_ofconsole_fb = 1;
 +}
 +}
 +}

Nice.  On which firmware variants did you try this?  I can try efika (stock
firmware) if you haven't yet.

In your code there's a condition in which _serial is set to 0 and _fb is
left unset (as 0).  Is this intended?  Sounds like a bug.

This could be avoided if you represent it as a multi-value variable, e.g.

enum
  {
GRUB_OFCONSOLE_SERIAL,
GRUB_OFCONSOLE_FB,
  };

grub_u8_t grub_ofconsole_backend = GRUB_OFCONSOLE_SERIAL;

[...]
if (foo)
  grub_ofconsole_backend = GRUB_OFCONSOLE_FB;

what do you think?

-- 
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 /.)


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Fixed ieee1275 console

2007-10-10 Thread Marcin Kurek
Hell[o]

 Caught you! ;-)

Holy shit. Lesson one take one more look at diff before send it :)

 I know it seems burdensome, but please can you split this in three patches, 
 one
 for each fix?  Then it's easier to review just one and say this is good, and
 also easier to figure out why every hunk was done (since one knows what we're
 trying to archieve).

Hmmm, I can try, but generaly splitting this fix has only a little
sense as all of these patches depends on each other. Anyway I will
send splited patches tommorow.

  +  /* It seems no cls escape is available then simulate it using \n 
  flood */
  +  int x = (grub_ofconsole_height * 2) - grub_curr_y;

 Maybe this would be easier to understand as (grub_ofconsole_height -
 grub_curr_y) + grub_ofconsole_height.  What do others think? :-)

Hmmm, good point looks better IMHO.

 Nice.  On which firmware variants did you try this?  I can try efika (stock
 firmware) if you haven't yet.

I tired on Pegasos 1 with ancient OF revision, Pegasos 2 with Sven
unofficial one and Efika and it works in all cases.

 In your code there's a condition in which _serial is set to 0 and _fb is
 left unset (as 0).  Is this intended?  Sounds like a bug.

Not this is not a bug. We can heve 3 cases here:

1) True serial console. In this case  recent versions of OF set stdout
name and type to serial (_serial = 1, _fb = 0) In this case we want
to use simple frames.

2) On the screen terminal without framebuffer (fb-mode not existing or
set to 0x0x0) In this case we will get type serial (As it not
supports pixel operations) and name display as this is not real
serial console. (_serial = 0, _fb = 0) In this case we can use cp437
frames.

For old versions of OF this case need to catch bootconsole too.

3) Console with framebuffer (fb-mode != 0x0x0) In this case we will
get type to display or vga (_serial = 0, _fb = 1) In this case we
can not use cp437 frames as vga font used by OF maps only first 127
characters ;( I put this in to separate case as we can still use
framebuffer interface to draw some frames or try to load a working
font, etc.

I use 'true serial' as a safe default if detection fails for some reasons.

-- 
--- Marcin 'Morgoth' Kurek ---


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Fixed ieee1275 console

2007-10-03 Thread Marcin Kurek
Hell[o]

Attached current version of console fix'es patches, generaly synced
with cvs  cleanups for all of them and some changes in
04-grub2-ofconsole_fix.patch.

First it seems pegasos OF uses 24 lines console by default, but it
seems when no framebuffer is used the real number of rows is 25 not
24. Introduced GRUB_IEEE1275_FLAG_NOFB_ROWS25 to handle this
situation.

Second the very old OF version (Pegaos 1 mainly) has problem to
interpret the cls escape and simply ignore it. Introduce
GRUB_IEEE1275_FLAG_NOCLS to simulate cls with sequence of '\n' in that
case.

-- 
--- Marcin 'Morgoth' Kurek ---
diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h
--- grub2.org/include/grub/term.h	2007-07-22 01:32:22.0 +0200
+++ grub2/include/grub/term.h	2007-10-01 19:20:49.734330521 +0200
@@ -51,10 +51,13 @@
 #define GRUB_TERM_NO_EDIT	(1  1)
 /* Set when the terminal cannot do fancy things.  */
 #define GRUB_TERM_DUMB		(1  2)
+/* Set to use ascii menu borders.  */
+#define GRUB_TERM_SIMPLE_MENU	(1  3) 
+/* Set to use cp437 menu borders.  */
+#define GRUB_TERM_CP437_MENU	(1  4)
 /* Set when the terminal needs to be initialized.  */
 #define GRUB_TERM_NEED_INIT	(1  16)
 
-
 /* Unicode characters for fancy graphics.  */
 #define GRUB_TERM_DISP_LEFT	0x2190
 #define GRUB_TERM_DISP_UP	0x2191
diff -urN grub2.org/kern/term.c grub2/kern/term.c
--- grub2.org/kern/term.c	2007-07-22 01:32:26.0 +0200
+++ grub2/kern/term.c	2007-10-01 19:27:23.367330521 +0200
@@ -90,6 +90,94 @@
   return grub_cur_term;
 }
 
+static
+grub_uint32_t remap_border(grub_uint32_t code)
+{
+  if (grub_cur_term-flags  GRUB_TERM_SIMPLE_MENU)
+{
+  switch (code)
+{
+case GRUB_TERM_DISP_LEFT:
+  code = '';
+  break;
+
+case GRUB_TERM_DISP_UP:
+  code = '^';
+  break;
+
+case GRUB_TERM_DISP_RIGHT:
+  code = '';
+  break;
+
+case GRUB_TERM_DISP_DOWN:
+  code = 'v';
+  break;
+
+case GRUB_TERM_DISP_HLINE:
+  code = '-';
+  break;
+
+case GRUB_TERM_DISP_VLINE:
+  code = '|';
+  break;
+
+case GRUB_TERM_DISP_UL:
+case GRUB_TERM_DISP_UR:
+case GRUB_TERM_DISP_LL:
+case GRUB_TERM_DISP_LR:
+  code = '+';
+  break;
+}
+}
+  else if(grub_cur_term-flags  GRUB_TERM_CP437_MENU)
+{
+  switch (code)
+{
+case GRUB_TERM_DISP_LEFT:
+  code = 0x1b;
+  break;
+
+case GRUB_TERM_DISP_UP:
+  code = 0x18;
+  break;
+
+case GRUB_TERM_DISP_RIGHT:
+  code = 0x1a;
+  break;
+
+case GRUB_TERM_DISP_DOWN:
+  code = 0x19;
+  break;
+
+case GRUB_TERM_DISP_HLINE:
+  code = 0xc4;
+  break;
+
+case GRUB_TERM_DISP_VLINE:
+  code = 0xb3;
+  break;
+
+case GRUB_TERM_DISP_UL:
+  code = 0xda;
+  break;
+
+case GRUB_TERM_DISP_UR:
+  code = 0xbf;
+  break;
+
+case GRUB_TERM_DISP_LL:
+  code = 0xc0;
+  break;
+
+case GRUB_TERM_DISP_LR:
+  code = 0xd9;
+  break;
+}
+}
+
+  return code;
+}
+
 /* Put a Unicode character.  */
 void
 grub_putcode (grub_uint32_t code)
@@ -106,7 +194,9 @@
 
   return;
 }
-  
+
+  code = remap_border (code);
+
   (grub_cur_term-putchar) (code);
   
   if (code == '\n')
diff -urN grub2.org/term/i386/pc/console.c grub2/term/i386/pc/console.c
--- grub2.org/term/i386/pc/console.c	2007-07-22 01:32:30.0 +0200
+++ grub2/term/i386/pc/console.c	2007-10-01 19:30:35.966330521 +0200
@@ -25,58 +25,13 @@
 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));
+  /* No Unicode support.  */
+  

Re: [PATCH] Fixed ieee1275 console

2007-10-02 Thread Robert Millan
On Mon, Oct 01, 2007 at 09:43:27PM +0200, Marcin Kurek wrote:
 Hell[o]
 
  Is this a bitmask?  In this case, looks like you aren't using the right
  numbers.  Now GRUB_TERM_SIMPLE_MENU == GRUB_TERM_DUMB | GRUB_TERM_NO_EDIT
  OTOH if that's what you intended, I think it's better to build one macro
  using the others.
 
 Eeeek, why ? The flags are checked using 'flags  flag' as I can see
 in kern/term.c, then how (1  3) can be evaluated as (1  1) and (1
  2) in this case ?

Oops, sorry.  That was an oversight.  (why does it jump directly from 4 to
16??).

  This part doesn't look right.  vesa/vga is a whole different history.  At 
  the
  least vesa *does* support unicode.
 
 But both remaps border codes to cp437 and my code change only this
 part, the unicode support is still there I does not touch it.

Oh, that's odd.  I thought it would be using utf-8 directly.

  Have you verified that grub-emu still builds / works?
 
 It does not build for ieee1275 on cvs because missing util/hostfs.c in
 powerpc-ieee1275.rmk, but after adding it builds/runs fine.

Fixed, thanks.

-- 
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 /.)


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] Fixed ieee1275 console

2007-10-01 Thread Marcin Kurek
Hell[o]

Finaly I found a few free minutes to look at ofconsole as it never
correctly work for me. There was 3 problems on my Pegasos:

1) Backspace key not works with USB keyboard.
2) menu looks ugly like hell as it contains some random characters in
place of borders.
3) Console works wrong (the cursor position was wrong after some
commands eg. ls and it displays only a black hole when grub prints
more than one screen of text)

I am not sure how correct my fix is for non Efika/ODW machines, but I
tested it on both without any problems.

In grub_ofconsole_writeesc() I think it would be good idea to use
single write command, but this is a cosmetics only I guess. Also in
grub_ofconsole_getxy() the -1 for grub_curr_x seems to be wrong for
me.

Replaced borders characters in grub_ofconsole_putchar() by '-', '|',
etc. Maybe not perfect, but looks definitly better than before [2].
Also fixed cursor position tracking (grub_curr_x, grub_curr_y) which
fix both console problems [3]

Handle 127 keycode as backspace key in grub_ofconsole_readkey() which fix [1]

BTW Also attach my previous patches with [PATCH] in topic this time.

-- 
--- Marcin 'Morgoth' Kurek ---
diff -urN grub2.org/fs/affs.c grub2/fs/affs.c
--- grub2.org/fs/affs.c	2007-08-02 20:40:36.0 +0200
+++ grub2/fs/affs.c	2007-09-15 10:23:35.550133111 +0200
@@ -25,6 +25,7 @@
 #include grub/dl.h
 #include grub/types.h
 #include grub/fshelp.h
+#include grub/partition.h
 
 /* The affs bootblock.  */
 struct grub_affs_bblock
@@ -97,6 +98,9 @@
   struct grub_fshelp_node diropen;
   grub_disk_t disk;
 
+  /* Size in sectors */
+  grub_uint64_t len;
+
   /* Blocksize in sectors.  */
   int blocksize;
 
@@ -170,10 +174,17 @@
   int checksumr = 0;
   int blocksize = 0;
 
+
   data = grub_malloc (sizeof (struct grub_affs_data));
   if (!data)
 return 0;
 
+  /* total_sectors are not valid on ieee1275 */
+  if(disk-partition)
+data-len = grub_partition_get_len (disk-partition);
+  else
+data-len = disk-total_sectors;
+
   /* Read the bootblock.  */
   grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock),
 		  (char *) data-bblock);
@@ -194,12 +205,6 @@
   goto fail;
 }
 
-  /* Read the bootblock.  */
-  grub_disk_read (disk, 0, 0, sizeof (struct grub_affs_bblock),
-		  (char *) data-bblock);
-  if (grub_errno)
-goto fail;
-
   /* No sane person uses more than 8KB for a block.  At least I hope
  for that person because in that case this won't work.  */
   rootblock = grub_malloc (GRUB_DISK_SECTOR_SIZE * 16);
@@ -209,7 +214,7 @@
   rblock = (struct grub_affs_rblock *) rootblock;
 
   /* Read the rootblock.  */
-  grub_disk_read (disk, (disk-total_sectors  1) + blocksize, 0,
+  grub_disk_read (disk, (data-len  1) + blocksize, 0,
 		  GRUB_DISK_SECTOR_SIZE * 16, (char *) rootblock);
   if (grub_errno)
 goto fail;
@@ -241,7 +246,7 @@
   data-disk = disk;
   data-htsize = grub_be_to_cpu32 (rblock-htsize);
   data-diropen.data = data;
-  data-diropen.block = (disk-total_sectors  1);
+  data-diropen.block = (data-len  1);
 
   grub_free (rootblock);
 
@@ -522,7 +527,7 @@
 {
   /* The rootblock maps quite well on a file header block, it's
 	 something we can use here.  */
-  grub_disk_read (data-disk, disk-total_sectors  1,
+  grub_disk_read (data-disk, data-len  1,
 		  data-blocksize * (GRUB_DISK_SECTOR_SIZE
 	 - GRUB_AFFS_FILE_LOCATION),
 		  sizeof (file), (char *) file);
diff -urN grub2.org/conf/powerpc-ieee1275.mk grub2/conf/powerpc-ieee1275.mk
--- grub2.org/conf/powerpc-ieee1275.mk	2007-08-29 19:49:46.0 +0200
+++ grub2/conf/powerpc-ieee1275.mk	2007-09-15 02:40:33.144459267 +0200
@@ -235,14 +235,14 @@
 	normal/menu_entry.c normal/misc.c normal/script.c		\
 	partmap/amiga.c	partmap/apple.c partmap/pc.c partmap/sun.c	\
 	partmap/acorn.c			\
-	util/console.c util/grub-emu.c util/misc.c			\
+	util/console.c util/hostfs.c util/grub-emu.c util/misc.c			\
 	util/biosdisk.c util/getroot.c			\
 	util/powerpc/ieee1275/misc.c grub_script.tab.c grub_emu_init.c
-CLEANFILES += grub-emu grub_emu-commands_boot.o grub_emu-commands_cat.o grub_emu-commands_cmp.o grub_emu-commands_configfile.o grub_emu-commands_help.o grub_emu-commands_search.o grub_emu-commands_terminal.o grub_emu-commands_test.o grub_emu-commands_ls.o grub_emu-commands_blocklist.o grub_emu-commands_ieee1275_halt.o grub_emu-commands_ieee1275_reboot.o grub_emu-disk_loopback.o grub_emu-fs_affs.o grub_emu-fs_ext2.o grub_emu-fs_fat.o grub_emu-fs_fshelp.o grub_emu-fs_hfs.o grub_emu-fs_iso9660.o grub_emu-fs_jfs.o grub_emu-fs_minix.o grub_emu-fs_sfs.o grub_emu-fs_ufs.o grub_emu-fs_xfs.o grub_emu-fs_hfsplus.o grub_emu-fs_ntfs.o grub_emu-io_gzio.o grub_emu-kern_device.o grub_emu-kern_disk.o grub_emu-kern_dl.o grub_emu-kern_elf.o grub_emu-kern_env.o grub_emu-kern_err.o grub_emu-kern_file.o grub_emu-kern_fs.o grub_emu-kern_loader.o grub_emu-kern_main.o grub_emu-kern_misc.o grub_emu-kern_parser.o grub_emu-kern_partition.o grub_emu-kern_rescue.o 

Re: [PATCH] Fixed ieee1275 console

2007-10-01 Thread Robert Millan
On Mon, Oct 01, 2007 at 12:57:35PM +0200, Marcin Kurek wrote:
 Hell[o]
 
 Finaly I found a few free minutes to look at ofconsole as it never
 correctly work for me. There was 3 problems on my Pegasos:
 
 1) Backspace key not works with USB keyboard.
 2) menu looks ugly like hell as it contains some random characters in
 place of borders.
 3) Console works wrong (the cursor position was wrong after some
 commands eg. ls and it displays only a black hole when grub prints
 more than one screen of text)

Now that I look at it, it seems you attached 3 patches but they're not
addressed at each of the problems you describe.  Could you split up the
console patch in 3 for each of the problems, and start a separate thread
for the others?

Also, please include ChangeLog entries with your patches.

-- 
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 /.)


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH] Fixed ieee1275 console

2007-10-01 Thread Marcin Kurek
Hell[o]

 [...]

OK, split fixes in to separate patches this time as requested.

01-grub2-simple_console.patch
==

This is a idea how to handle asciicp473utf based menus for
diffrent consoles. I added a two term flags GRUB_TERM_SIMPLE_MENU
(ascii menu) and GRUB_TERM_CP437_MENU (cp437 menus) and handle borders
code remap in kern/term.c/grub_putcode() by using new function
remap_border()

For now GRUB_TERM_CP437_MENU is used in i386/pc/console.c, vesafb.c,
vga.c and GRUB_TERM_SIMPLE_MENU is used in i386/pc/serial.c and in
ieee1275/ofconsole.c

I think it would be wise to use ascii border codes for OF as there is
no easy way to check the terminal type (serial, screen) and encoding
(on my ODW normal console seems to use cp437, but framebuffer console
seems to be using something else) Anyway ascii menu looks quite nice
here.

02-grub2-ofconsole_cosmetic.patch
==

Two small things here. First make grub_ofconsole_writeesc() use single
grub_ieee1275_write() call and correct '- 1' in grub_ofconsole_getxy()
... hmmm maybe this should go in to [4]

03-grub2-ofconsole_backspace.patch
===

My OF seems to send 127 for backspace key this patch handle '127' as
backspace. Now I can use it normaly ;)

04-grub2-ofconsole_fix.patch


Fixed cursor x/y position tracking for ofconsole as currect version
definitly doesn't not work as expect to. I am not sure only about
grub_curr_y -= 4; line as my OF scroll the console +4 lines when reach
last line, but is '4' correct for other OF implementations ?

-- 
--- Marcin 'Morgoth' Kurek ---
diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h
--- grub2.org/include/grub/term.h	2007-07-22 01:32:22.0 +0200
+++ grub2/include/grub/term.h	2007-10-01 19:20:49.734330521 +0200
@@ -51,10 +51,13 @@
 #define GRUB_TERM_NO_EDIT	(1  1)
 /* Set when the terminal cannot do fancy things.  */
 #define GRUB_TERM_DUMB		(1  2)
+/* Set to use ascii menu borders.  */
+#define GRUB_TERM_SIMPLE_MENU	(1  3) 
+/* Set to use cp437 menu borders.  */
+#define GRUB_TERM_CP437_MENU	(1  4)
 /* Set when the terminal needs to be initialized.  */
 #define GRUB_TERM_NEED_INIT	(1  16)
 
-
 /* Unicode characters for fancy graphics.  */
 #define GRUB_TERM_DISP_LEFT	0x2190
 #define GRUB_TERM_DISP_UP	0x2191
diff -urN grub2.org/kern/term.c grub2/kern/term.c
--- grub2.org/kern/term.c	2007-07-22 01:32:26.0 +0200
+++ grub2/kern/term.c	2007-10-01 19:27:23.367330521 +0200
@@ -90,6 +90,94 @@
   return grub_cur_term;
 }
 
+static
+grub_uint32_t remap_border(grub_uint32_t code)
+{
+  if (grub_cur_term-flags  GRUB_TERM_SIMPLE_MENU)
+{
+  switch (code)
+{
+case GRUB_TERM_DISP_LEFT:
+  code = '';
+  break;
+
+case GRUB_TERM_DISP_UP:
+  code = '^';
+  break;
+
+case GRUB_TERM_DISP_RIGHT:
+  code = '';
+  break;
+
+case GRUB_TERM_DISP_DOWN:
+  code = 'v';
+  break;
+
+case GRUB_TERM_DISP_HLINE:
+  code = '-';
+  break;
+
+case GRUB_TERM_DISP_VLINE:
+  code = '|';
+  break;
+
+case GRUB_TERM_DISP_UL:
+case GRUB_TERM_DISP_UR:
+case GRUB_TERM_DISP_LL:
+case GRUB_TERM_DISP_LR:
+  code = '+';
+  break;
+}
+}
+  else if(grub_cur_term-flags  GRUB_TERM_CP437_MENU)
+{
+  switch (code)
+{
+case GRUB_TERM_DISP_LEFT:
+  code = 0x1b;
+  break;
+
+case GRUB_TERM_DISP_UP:
+  code = 0x18;
+  break;
+
+case GRUB_TERM_DISP_RIGHT:
+  code = 0x1a;
+  break;
+
+case GRUB_TERM_DISP_DOWN:
+  code = 0x19;
+  break;
+
+case GRUB_TERM_DISP_HLINE:
+  code = 0xc4;
+  break;
+
+case GRUB_TERM_DISP_VLINE:
+  code = 0xb3;
+  break;
+
+case GRUB_TERM_DISP_UL:
+  code = 0xda;
+  break;
+
+case GRUB_TERM_DISP_UR:
+  code = 0xbf;
+  break;
+
+case GRUB_TERM_DISP_LL:
+  code = 0xc0;
+  break;
+
+case GRUB_TERM_DISP_LR:
+  code = 0xd9;
+  break;
+}
+}
+
+  return code;
+}
+
 /* Put a Unicode character.  */
 void
 grub_putcode (grub_uint32_t code)
@@ -106,7 +194,9 @@
 
   return;
 }
-  
+
+  code = remap_border (code);
+
   (grub_cur_term-putchar) (code);
   
   if (code == '\n')
diff -urN grub2.org/term/i386/pc/console.c grub2/term/i386/pc/console.c
--- grub2.org/term/i386/pc/console.c	2007-07-22 01:32:30.0 +0200
+++ grub2/term/i386/pc/console.c	2007-10-01 19:30:35.966330521 +0200
@@ -25,58 +25,13 @@
 static grub_uint8_t grub_console_normal_color = 0x7;
 

Re: [PATCH] Fixed ieee1275 console

2007-10-01 Thread Robert Millan
On Mon, Oct 01, 2007 at 08:14:16PM +0200, Marcin Kurek wrote:
 diff -urN grub2.org/include/grub/term.h grub2/include/grub/term.h
 --- grub2.org/include/grub/term.h 2007-07-22 01:32:22.0 +0200
 +++ grub2/include/grub/term.h 2007-10-01 19:20:49.734330521 +0200
 @@ -51,10 +51,13 @@
  #define GRUB_TERM_NO_EDIT(1  1)
  /* Set when the terminal cannot do fancy things.  */
  #define GRUB_TERM_DUMB   (1  2)
 +/* Set to use ascii menu borders.  */
 +#define GRUB_TERM_SIMPLE_MENU(1  3) 
 +/* Set to use cp437 menu borders.  */
 +#define GRUB_TERM_CP437_MENU (1  4)
  /* Set when the terminal needs to be initialized.  */
  #define GRUB_TERM_NEED_INIT  (1  16)

Is this a bitmask?  In this case, looks like you aren't using the right
numbers.  Now GRUB_TERM_SIMPLE_MENU == GRUB_TERM_DUMB | GRUB_TERM_NO_EDIT
OTOH if that's what you intended, I think it's better to build one macro
using the others.

 diff -urN grub2.org/term/i386/pc/vesafb.c grub2/term/i386/pc/vesafb.c
 --- grub2.org/term/i386/pc/vesafb.c   2007-07-22 01:32:31.0 +0200
 +++ grub2/term/i386/pc/vesafb.c   2007-10-01 19:37:38.160330521 +0200
 @@ -214,45 +214,7 @@
  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);
 - }
 -}
 +return grub_font_get_glyph (code, bitmap, width);
  
if (bitmap)
  grub_memcpy (bitmap,
 @@ -601,7 +563,7 @@
  .setcolorstate = grub_virtual_screen_setcolorstate,
  .setcolor = grub_virtual_screen_setcolor,
  .setcursor = grub_vesafb_setcursor,
 -.flags = 0,
 +.flags = GRUB_TERM_CP437_MENU,
  .next = 0
};
  
 diff -urN grub2.org/term/i386/pc/vga.c grub2/term/i386/pc/vga.c
 --- grub2.org/term/i386/pc/vga.c  2007-07-22 01:32:31.0 +0200
 +++ grub2/term/i386/pc/vga.c  2007-10-01 19:38:10.883330521 +0200
 @@ -198,45 +198,7 @@
  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);
 - }
 -}
 +return grub_font_get_glyph (code, bitmap, width);

This part doesn't look right.  vesa/vga is a whole different history.  At the
least vesa *does* support unicode.

 diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconsole.c
 --- grub2.org/term/ieee1275/ofconsole.c   2007-07-22 11:05:11.0 
 +0200
 +++ grub2/term/ieee1275/ofconsole.c   2007-10-01 19:01:49.820330521 +0200
 @@ -75,6 +75,7 @@
  grub_ofconsole_putchar (grub_uint32_t c)
  {
char chr = c;
 +  
if (c == '\n')
  {
grub_curr_y++;
 @@ -86,6 +87,7 @@
if (grub_curr_x  grub_ofconsole_width)
   grub_putcode ('\n');
  }
 +
grub_ieee1275_write (stdout_ihandle, chr, 1, 0);
  }

Please try to avoid cosmetical changes.

 diff -urN grub2.org/util/console.c grub2/util/console.c
 --- grub2.org/util/console.c  2007-07-22 01:32:31.0 +0200
 +++ grub2/util/console.c  2007-10-01 19:01:49.821330521 +0200
 @@ -44,47 +44,6 @@
  static void
  grub_ncurses_putchar (grub_uint32_t c)
  

Re: [PATCH] Fixed ieee1275 console

2007-10-01 Thread Marcin Kurek
Hell[o]

 Is this a bitmask?  In this case, looks like you aren't using the right
 numbers.  Now GRUB_TERM_SIMPLE_MENU == GRUB_TERM_DUMB | GRUB_TERM_NO_EDIT
 OTOH if that's what you intended, I think it's better to build one macro
 using the others.

Eeeek, why ? The flags are checked using 'flags  flag' as I can see
in kern/term.c, then how (1  3) can be evaluated as (1  1) and (1
 2) in this case ?

 This part doesn't look right.  vesa/vga is a whole different history.  At the
 least vesa *does* support unicode.

But both remaps border codes to cp437 and my code change only this
part, the unicode support is still there I does not touch it.

 Please try to avoid cosmetical changes.

Hmmm, I can not see this change in patch in files I have on my hd :/

 Have you verified that grub-emu still builds / works?

It does not build for ieee1275 on cvs because missing util/hostfs.c in
powerpc-ieee1275.rmk, but after adding it builds/runs fine.

 What is 127 normally?  For firmware bugs, we have a flag mechanism so that it
 only affects the buggy firmware.  Check my latest commit to
 kern/powerpc/ieee1275/cmain.c.

It's DEL key. I placed it here as I saw similar thing in
util/console.c and of coz I verified first that both keys (del 
backspace) are working correctly on ODW  Efika.

-- 
--- Marcin 'Morgoth' Kurek ---


___
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel