Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Itk1v-0007ih-0O for mharc-grub-devel@gnu.org; Sun, 18 Nov 2007 08:17:43 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Itk1t-0007iM-FD for grub-devel@gnu.org; Sun, 18 Nov 2007 08:17:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Itk1s-0007ha-Jf for grub-devel@gnu.org; Sun, 18 Nov 2007 08:17:41 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Itk1s-0007hI-AH for grub-devel@gnu.org; Sun, 18 Nov 2007 08:17:40 -0500 Received: from smtp-vbr1.xs4all.nl ([194.109.24.21]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Itk1r-0004ud-EH for grub-devel@gnu.org; Sun, 18 Nov 2007 08:17:40 -0500 Received: from localhost.localdomain (249-174.surfsnel.dsl.internl.net [145.99.174.249]) by smtp-vbr1.xs4all.nl (8.13.8/8.13.8) with ESMTP id lAIDHcoJ079810 for ; Sun, 18 Nov 2007 14:17:38 +0100 (CET) (envelope-from mgerards@xs4all.nl) From: Marco Gerards To: The development of GRUB 2 References: <8a2a06bb0710010357u142f6ba4gb053afde829f0f39@mail.gmail.com> <87zlyp8zcq.fsf@xs4all.nl> <8a2a06bb0710151343h75085506p45c09d08c7466d68@mail.gmail.com> Mail-Copies-To: mgerards@xs4all.nl Date: Sun, 18 Nov 2007 14:18:33 +0100 In-Reply-To: <8a2a06bb0710151343h75085506p45c09d08c7466d68@mail.gmail.com> (Marcin Kurek's message of "Mon, 15 Oct 2007 22:43:59 +0200") Message-ID: <87bq9rpu8m.fsf@xs4all.nl> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: by XS4ALL Virus Scanner X-detected-kernel: by monty-python.gnu.org: FreeBSD 4.6-4.9 Subject: Re: [PATCH] Fixed ieee1275 console X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Nov 2007 13:17:41 -0000 "Marcin Kurek" 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 && > 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! > --=20 > --- 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.000000000 +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)=20 > +/* 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) >=20=20 > diff -urN grub2.org/kern/term.c grub2/kern/term.c > --- grub2.org/kern/term.c 2007-07-22 01:32:26.000000000 +0200 > +++ grub2/kern/term.c 2007-10-15 21:26:48.402210358 +0200 > @@ -90,6 +90,94 @@ > return grub_cur_term; > } >=20=20 > +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 like remap_to_ascii? > diff -urN grub2.org/term/i386/pc/serial.c grub2/term/i386/pc/serial.c > --- grub2.org/term/i386/pc/serial.c 2007-07-22 01:32:30.000000000 +0200 > +++ grub2/term/i386/pc/serial.c 2007-10-15 21:26:48.405210358 +0200 > @@ -324,48 +324,9 @@ > /* Keep track of the cursor. */ > if (keep_track) > { > - /* The serial terminal does not have VGA fonts. */ > + /* The serial terminal does not support Unicode. */ > if (c > 0x7F) > - { > - /* Better than nothing. */ > - switch (c) > - { > - case GRUB_TERM_DISP_LEFT: > - c =3D '<'; > - break; > -=09=20=20=20=20=20=20 > - case GRUB_TERM_DISP_UP: > - c =3D '^'; > - break; > -=09=20=20=20=20=20=20 > - case GRUB_TERM_DISP_RIGHT: > - c =3D '>'; > - break; > -=09=20=20=20=20=20=20 > - case GRUB_TERM_DISP_DOWN: > - c =3D 'v'; > - break; > -=09=20=20=20=20=20=20 > - case GRUB_TERM_DISP_HLINE: > - c =3D '-'; > - break; > -=09=20=20=20=20=20=20 > - case GRUB_TERM_DISP_VLINE: > - c =3D '|'; > - break; > -=09=20=20=20=20=20=20 > - case GRUB_TERM_DISP_UL: > - case GRUB_TERM_DISP_UR: > - case GRUB_TERM_DISP_LL: > - case GRUB_TERM_DISP_LR: > - c =3D '+'; > - break; > -=09=20=20=20=20=20=20 > - default: > - c =3D '?'; > - break; > - } > - } > + c =3D '?'; Sometimes it might be supported, depending on the terminal settings. Can this be detected? =20=20=20=20=20=20=20=20 > switch (c) > { > @@ -498,7 +459,7 @@ > .setcolorstate =3D grub_serial_setcolorstate, > .setcolor =3D grub_serial_setcolor, > .setcursor =3D grub_serial_setcursor, > - .flags =3D 0, > + .flags =3D GRUB_TERM_SIMPLE_MENU, > .next =3D 0 > }; >=20=20 > 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.000000000 +0200 > +++ grub2/term/i386/pc/vesafb.c 2007-10-15 21:26:48.418210358 +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 =3D 0x1b; > - break; > - case 0x2191: /* up arrow */ > - code =3D 0x18; > - break; > - case 0x2192: /* right arrow */ > - code =3D 0x1a; > - break; > - case 0x2193: /* down arrow */ > - code =3D 0x19; > - break; > - case 0x2501: /* horizontal line */ > - code =3D 0xc4; > - break; > - case 0x2503: /* vertical line */ > - code =3D 0xb3; > - break; > - case 0x250F: /* upper-left corner */ > - code =3D 0xda; > - break; > - case 0x2513: /* upper-right corner */ > - code =3D 0xbf; > - break; > - case 0x2517: /* lower-left corner */ > - code =3D 0xc0; > - break; > - case 0x251B: /* lower-right corner */ > - code =3D 0xd9; > - break; > - > - default: > - return grub_font_get_glyph (code, bitmap, width); > - } > - } > + return grub_font_get_glyph (code, bitmap, width); >=20=20 > if (bitmap) > grub_memcpy (bitmap, > @@ -601,7 +563,7 @@ > .setcolorstate =3D grub_virtual_screen_setcolorstate, > .setcolor =3D grub_virtual_screen_setcolor, > .setcursor =3D grub_vesafb_setcursor, > - .flags =3D 0, > + .flags =3D GRUB_TERM_CP437_MENU, > .next =3D 0 > }; >=20=20 > 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.000000000 +0200 > +++ grub2/term/i386/pc/vga.c 2007-10-15 21:26:48.447210358 +0200 > @@ -198,45 +198,7 @@ > get_vga_glyph (grub_uint32_t code, unsigned char bitmap[32], unsigned *w= idth) > { > if (code > 0x7f) > - { > - /* Map some unicode characters to the VGA font, if possible. */ > - switch (code) > - { > - case 0x2190: /* left arrow */ > - code =3D 0x1b; > - break; > - case 0x2191: /* up arrow */ > - code =3D 0x18; > - break; > - case 0x2192: /* right arrow */ > - code =3D 0x1a; > - break; > - case 0x2193: /* down arrow */ > - code =3D 0x19; > - break; > - case 0x2501: /* horizontal line */ > - code =3D 0xc4; > - break; > - case 0x2503: /* vertical line */ > - code =3D 0xb3; > - break; > - case 0x250F: /* upper-left corner */ > - code =3D 0xda; > - break; > - case 0x2513: /* upper-right corner */ > - code =3D 0xbf; > - break; > - case 0x2517: /* lower-left corner */ > - code =3D 0xc0; > - break; > - case 0x251B: /* lower-right corner */ > - code =3D 0xd9; > - break; > - > - default: > - return grub_font_get_glyph (code, bitmap, width); > - } > - } > + return grub_font_get_glyph (code, bitmap, width); >=20=20 > if (bitmap) > grub_memcpy (bitmap, vga_font + code * CHAR_HEIGHT, CHAR_HEIGHT); > @@ -590,7 +552,7 @@ > .setcolorstate =3D grub_vga_setcolorstate, > .setcolor =3D grub_vga_setcolor, > .setcursor =3D grub_vga_setcursor, > - .flags =3D 0, > + .flags =3D GRUB_TERM_CP437_MENU, > .next =3D 0 > }; >=20=20 > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconso= le.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-07-22 11:05:11.000000000 +02= 00 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-15 21:27:17.621210358 +0200 > @@ -366,7 +366,7 @@ > .setcolor =3D grub_ofconsole_setcolor, > .setcursor =3D grub_ofconsole_setcursor, > .refresh =3D grub_ofconsole_refresh, > - .flags =3D 0, > + .flags =3D GRUB_TERM_SIMPLE_MENU, > .next =3D 0 > }; >=20=20 > diff -urN grub2.org/util/console.c grub2/util/console.c > --- grub2.org/util/console.c 2007-07-22 01:32:31.000000000 +0200 > +++ grub2/util/console.c 2007-10-15 21:26:48.456210358 +0200 > @@ -44,47 +44,6 @@ > static void > grub_ncurses_putchar (grub_uint32_t c) > { > - /* Better than nothing. */ > - switch (c) > - { > - case GRUB_TERM_DISP_LEFT: > - c =3D '<'; > - break; > - > - case GRUB_TERM_DISP_UP: > - c =3D '^'; > - break; > - > - case GRUB_TERM_DISP_RIGHT: > - c =3D '>'; > - break; > - > - case GRUB_TERM_DISP_DOWN: > - c =3D 'v'; > - break; > - > - case GRUB_TERM_DISP_HLINE: > - c =3D '-'; > - break; > - > - case GRUB_TERM_DISP_VLINE: > - c =3D '|'; > - break; > - > - case GRUB_TERM_DISP_UL: > - case GRUB_TERM_DISP_UR: > - case GRUB_TERM_DISP_LL: > - case GRUB_TERM_DISP_LR: > - c =3D '+'; > - break; > - > - default: > - /* ncurses does not support Unicode. */ > - if (c > 0x7f) > - c =3D '?'; > - break; > - } > -=20=20 > addch (c | grub_console_attr); > } >=20=20 > @@ -302,7 +261,7 @@ > .setcolor =3D grub_ncurses_setcolor, > .setcursor =3D grub_ncurses_setcursor, > .refresh =3D grub_ncurses_refresh, > - .flags =3D 0, > + .flags =3D GRUB_TERM_SIMPLE_MENU, > .next =3D 0 > }; >=20=20 > > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconso= le.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-10-03 10:55:27.191943734 +02= 00 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-03 10:56:26.399943734 +0200 > @@ -63,12 +63,8 @@ > static void > grub_ofconsole_writeesc (const char *str) > { > - while (*str) > - { > - char chr =3D *(str++); > - grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); > - } > -=20=20 > + int len =3D grub_strlen(str); > + grub_ieee1275_write (stdout_ihandle, str, len, 0); > } Ok. =20=20 > static void > > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconso= le.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-10-15 21:23:24.554210358 +02= 00 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-15 21:24:13.111210358 +0200 > @@ -135,41 +135,54 @@ >=20=20 > grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); What are you doing below? =20=20 > - if (actual > 0 && c =3D=3D '\e') > + if (actual > 0) > { > - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > - if (actual <=3D 0) > - { > - *key =3D '\e'; > - return 1; > - } > + if (c !=3D '\e') > + { > + switch(c) > + { > + case 127: > + /* Backspace */ > + c =3D '\b'; > + break; > + } > + } > + else > + { > + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > + if (actual <=3D 0) > + { > + *key =3D '\e'; > + return 1; > + } >=20=20=20=20=20=20=20=20 > - if (c !=3D 91) > - return 0; > + if (c !=3D 91) > + return 0; >=20=20=20=20=20=20=20=20 > - grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > - if (actual <=3D 0) > - return 0; > + grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); > + if (actual <=3D 0) > + return 0; >=20=20=20=20=20=20=20=20 > - switch (c) > - { > - case 65: > - /* Up: Ctrl-p. */ > - c =3D 16;=20 > - break; > - case 66: > - /* Down: Ctrl-n. */ > - c =3D 14; > - break; > - case 67: > - /* Right: Ctrl-f. */ > - c =3D 6; > - break; > - case 68: > - /* Left: Ctrl-b. */ > - c =3D 2; > - break; > - } > + switch (c) > + { > + case 65: > + /* Up: Ctrl-p. */ > + c =3D 16;=20 > + break; > + case 66: > + /* Down: Ctrl-n. */ > + c =3D 14; > + break; > + case 67: > + /* Right: Ctrl-f. */ > + c =3D 6; > + break; > + case 68: > + /* Left: Ctrl-b. */ > + c =3D 2; > + break; > + } > + } > } >=20=20=20=20 > *key =3D c; > > diff -urN grub2.org/include/grub/ieee1275/ieee1275.h grub2/include/grub/i= eee1275/ieee1275.h > --- grub2.org/include/grub/ieee1275/ieee1275.h 2007-10-04 22:44:12.000000= 000 +0200 > +++ grub2/include/grub/ieee1275/ieee1275.h 2007-10-10 16:41:39.594688149 = +0200 > @@ -82,6 +82,16 @@ >=20=20 > /* 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, > }; >=20=20 > extern int EXPORT_FUNC(grub_ieee1275_test_flag) (enum grub_ieee1275_flag= flag); > diff -urN grub2.org/kern/powerpc/ieee1275/cmain.c grub2/kern/powerpc/ieee= 1275/cmain.c > --- grub2.org/kern/powerpc/ieee1275/cmain.c 2007-10-04 22:44:12.000000000= +0200 > +++ grub2/kern/powerpc/ieee1275/cmain.c 2007-10-10 16:42:30.520688149 +02= 00 > @@ -73,6 +73,8 @@ > { > /* Broken in all versions */ > grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); > + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25); > + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO); I thought this is bplan specific? Or am I missing the context of this check? > /* There are two incompatible ways of checking the version number.= Try > both. */ > @@ -98,6 +100,13 @@ > grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_PARTITION_0); > grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_0_BASED_PARTITIONS); > } > + /* It seems old firmware for Pegaos 1 do not accept cls escape then > + we need to emulate it using \n sequence */ > + if (!grub_strcmp (tmp, "1.0") > + || !grub_strcmp (tmp, "1.1")) > + { > + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOCLS); > + } > } > } > } > diff -urN grub2.org/term/ieee1275/ofconsole.c grub2/term/ieee1275/ofconso= le.c > --- grub2.org/term/ieee1275/ofconsole.c 2007-10-04 22:44:12.000000000 +02= 00 > +++ grub2/term/ieee1275/ofconsole.c 2007-10-10 16:51:56.829688149 +0200 > @@ -24,12 +24,18 @@ > #include > #include >=20=20 > +static void grub_ofconsole_setflags(int flags, int x); setflags (... > + > static grub_ieee1275_ihandle_t stdout_ihandle; > static grub_ieee1275_ihandle_t stdin_ihandle; >=20=20 > static grub_uint8_t grub_ofconsole_width; > static grub_uint8_t grub_ofconsole_height; >=20=20 > +/* We will assume serial console by default */ Please end a sentence with a ".". After every ".", add two spaces before beginning the next sentence or ending the comment. > +static grub_uint8_t grub_ofconsole_fb =3D 0; static grub_uint8_t grub_ofconsole_fb =3D 0; By default this is initialized to 0, no need to do this yourself. > +static grub_uint8_t grub_ofconsole_serial =3D 1; Please just use integers for the two variables you added. > + > static int grub_curr_x; > static int grub_curr_y; >=20=20 > @@ -70,20 +76,76 @@ > static void > grub_ofconsole_putchar (grub_uint32_t c) > { > - char chr =3D c; > -=20=20 > - if (c =3D=3D '\n') > + char chr; > + > + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BPLAN_LOGO)) > { > + /* cp437 characters 0xc0 to 0xcb are reserved for the bplan logo. = Use > + this layout to workaround it: > + =C3=A2=C2=95=C2=92=C3=A2=C2=95=C2=90=C3=A2=C2=95=C2=95 > + =C3=A2=C2=94=C2=82 =C3=A2=C2=94=C2=82 > + =C3=A2=C2=95=C2=98=C3=A2=C2=95=C2=90=C3=A2=C2=95=C2=9B */ Ehm? Please do not put unicode in this C file. > + switch (c) > + { > + case 0xc4: > + /* GRUB_TERM_DISP_HLINE */ > + c =3D 0xcd; > + break; > + case 0xb3: > + /* GRUB_TERM_DISP_VLINE */ > + c =3D 0xb3; > + break; > + case 0xda: > + /* GRUB_TERM_DISP_UL */ > + c =3D 0xd5; > + break; > + case 0xbf: > + /* GRUB_TERM_DISP_UR */ > + c =3D 0xb8; > + break; > + case 0xc0: > + /* GRUB_TERM_DISP_LL */ > + c =3D 0xd4; > + break; > + case 0xd9: > + /* GRUB_TERM_DISP_LR */ > + c =3D 0xbe; > + break; > + } > + } What does this do? You mention macros like GRUB_TERM_DISP_HLINE, but you use constants, why? > + > + switch(c) > + { > + case '\a': > + break;=20=20=20=20=20=20=20=20=20=20=20=20 > + case '\n': > + grub_putcode ('\r'); > grub_curr_y++; > + if(grub_curr_y > (grub_ofconsole_height - 1)) > + /* Is this realy correct for all OF versions around ? */ around? */ > + grub_curr_y =3D grub_ofconsole_fb ? > + grub_curr_y - 4 : grub_ofconsole_height - 1;=20 Please put the "?" on the next line. > + break; > + case '\r': > grub_curr_x =3D 0; > - } > - else > - { > + break; > + case '\b': > + if(grub_curr_x > 0) > + grub_curr_x--; > + break; > + > + default: > + if(c =3D=3D '\t') > + c =3D ' '; > + > + if (grub_curr_x >=3D (grub_ofconsole_width - 1)) > + grub_putcode ('\n'); > + > grub_curr_x++; > - if (grub_curr_x > grub_ofconsole_width) > - grub_putcode ('\n'); > - } > + break; > + }=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 >=20=20 > + chr =3D c; > grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); > } >=20=20 > @@ -228,7 +290,7 @@ > static grub_uint16_t > grub_ofconsole_getxy (void) > { > - return ((grub_curr_x - 1) << 8) | grub_curr_y; > + return (grub_curr_x << 8) | grub_curr_y; > } >=20=20 > static grub_uint16_t > @@ -278,6 +340,10 @@ > if (! grub_ofconsole_height) > grub_ofconsole_height =3D 24; >=20=20 > + if ( grub_ofconsole_fb =3D=3D 0 && grub_ofconsole_serial =3D=3D 0 && g= rub_ofconsole_height =3D=3D 24 &&=20 > + grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25)) > + grub_ofconsole_height =3D 25; > + if (grub_ofconsole_fb =3D=3D 0 && grub_ofconsole_serial =3D=3D 0 && grub_ofconsole_height =3D=3D 24 && grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25)) grub_ofconsole_height =3D 25; > return (grub_ofconsole_width << 8) | grub_ofconsole_height; > } >=20=20 > @@ -295,10 +361,20 @@ > static void > grub_ofconsole_cls (void) > { > - /* Clear the screen. Using serial console, screen(1) only recognizes = the > - * ANSI escape sequence. Using video console, Apple Open Firmware (ve= rsion > - * 3.1.1) only recognizes the literal ^L. So use both. */ > - grub_ofconsole_writeesc (" \e[2J"); > + if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOCLS)) > + { > + /* Clear the screen. Using serial console, screen(1) only recogni= zes the > + * ANSI escape sequence. Using video console, Apple Open Firmware= (version > + * 3.1.1) only recognizes the literal ^L. So use both. */ > + grub_ofconsole_writeesc (" \e[2J"); > + } > + else > + { > + /* It seems no cls escape is available then simulate it using \n f= lood */ ". */" > + int x =3D (grub_ofconsole_height * 2) - grub_curr_y; > + while(x--) > + grub_putcode ('\n'); > + } > grub_gotoxy (0, 0); > } >=20=20 > @@ -317,6 +393,7 @@ > static grub_err_t > grub_ofconsole_init (void) > { > + grub_ieee1275_phandle_t stdout_phandle; > unsigned char data[4]; > grub_ssize_t actual; > int col; > @@ -349,6 +426,48 @@ > /* Set the right fg and bg colors. */ > grub_ofconsole_setcolorstate (GRUB_TERM_COLOR_NORMAL); >=20=20 > + /* Check do we are on serial or normal console */ ". */" > + if(! grub_ieee1275_instance_to_package (stdout_ihandle, &stdout_phandl= e)) > + { > + char type[16]; > + char name[128]; > +=20=20=20=20=20=20 > + if(! grub_ieee1275_get_property (stdout_phandle, "device_type", &t= ype, > + 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 > + */ Please do not use this style of comments. So without the *'s. It's preferred to do: / 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 se= rial console */ . */ Please also fix all the other comments :-) > + if(! grub_strcmp (name, "display")) > + grub_ofconsole_serial =3D 0; > + } > + else > + {=20 > + grub_ofconsole_serial =3D 0; > + > + /* Older versions use name/type set to "bootconsole" */ > + if ( grub_strcmp (name, "bootconsole")) > + grub_ofconsole_fb =3D 1; > + } > + } > + } > +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 > + /* Set term flags */ > + if(!grub_ofconsole_serial && !grub_ofconsole_fb) > + { > + grub_ofconsole_setflags(GRUB_TERM_SIMPLE_MENU, 0); > + grub_ofconsole_setflags(GRUB_TERM_CP437_MENU, 1); > + } > + > return 0; > } >=20=20 > @@ -377,7 +496,7 @@ > .setcolor =3D grub_ofconsole_setcolor, > .setcursor =3D grub_ofconsole_setcursor, > .refresh =3D grub_ofconsole_refresh, > - .flags =3D GRUB_TERM_SIMPLE_MENU, > + .flags =3D GRUB_TERM_SIMPLE_MENU, /* We are set to serial by default= */ > .next =3D 0 > }; >=20=20 > @@ -393,3 +512,12 @@ > { > grub_term_unregister (&grub_ofconsole_term); > } > + > +static void > +grub_ofconsole_setflags(int flags, int x) > +{ > + if(x) > + grub_ofconsole_term.flags |=3D flags; > + else > + grub_ofconsole_term.flags &=3D ~flags; > +} > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/grub-devel