diff -urN grub2.org/include/grub/ieee1275/ieee1275.h grub2/include/grub/ieee1275/ieee1275.h --- grub2.org/include/grub/ieee1275/ieee1275.h 2007-10-03 17:52:35.006425889 +0200 +++ grub2/include/grub/ieee1275/ieee1275.h 2007-10-03 16:45:56.000000000 +0200 @@ -82,6 +82,12 @@ /* 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 use workaround */ + GRUB_IEEE1275_FLAG_NOCLS, }; 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/ieee1275/cmain.c --- grub2.org/kern/powerpc/ieee1275/cmain.c 2007-10-03 17:52:35.007425889 +0200 +++ grub2/kern/powerpc/ieee1275/cmain.c 2007-10-03 16:49:21.000000000 +0200 @@ -73,6 +73,7 @@ { /* Broken in all versions */ grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_BROKEN_OUTPUT); + grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25); /* There are two incompatible ways of checking the version number. Try both. */ @@ -98,6 +99,14 @@ 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, "0.") + || !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/ofconsole.c --- grub2.org/term/ieee1275/ofconsole.c 2007-10-03 17:52:35.009425889 +0200 +++ grub2/term/ieee1275/ofconsole.c 2007-10-03 17:40:31.000000000 +0200 @@ -29,6 +29,7 @@ static grub_uint8_t grub_ofconsole_width; static grub_uint8_t grub_ofconsole_height; +static grub_uint8_t grub_ofconsole_fb; static int grub_curr_x; static int grub_curr_y; @@ -70,20 +71,40 @@ static void grub_ofconsole_putchar (grub_uint32_t c) { - char chr = c; - - if (c == '\n') - { + char chr; + + switch(c) + { + case '\a': + break; + 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 ? */ + grub_curr_y = grub_ofconsole_fb ? + grub_curr_y - 4 : grub_ofconsole_height - 1; + break; + case '\r': grub_curr_x = 0; - } - else - { + break; + case '\b': + if(grub_curr_x > 0) + grub_curr_x--; + break; + + default: + if(c == '\t') + c = ' '; + + if (grub_curr_x >= (grub_ofconsole_width - 1)) + grub_putcode ('\n'); + grub_curr_x++; - if (grub_curr_x > grub_ofconsole_width) - grub_putcode ('\n'); - } + break; + } + chr = c; grub_ieee1275_write (stdout_ihandle, &chr, 1, 0); } @@ -228,7 +249,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; } static grub_uint16_t @@ -270,6 +291,21 @@ grub_free (val); } } + if (! grub_ieee1275_get_property_length (options, "fb-mode", + &lval) && lval != -1) + { + val = grub_malloc (lval); + if (val) + { + if (! grub_ieee1275_get_property (options, "fb-mode", + val, lval, 0)) + { + if (grub_strncmp (val, "0x0x0", 5) != 0) + grub_ofconsole_fb = 1; + } + grub_free (val); + } + } } /* Use a small console by default. */ @@ -278,6 +314,9 @@ if (! grub_ofconsole_height) grub_ofconsole_height = 24; + if ( grub_ofconsole_fb == 0 && grub_ofconsole_height == 24 && grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NOFB_ROWS25)) + grub_ofconsole_height = 25; + return (grub_ofconsole_width << 8) | grub_ofconsole_height; } @@ -295,10 +334,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 (version - * 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 recognizes 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 flood */ + int x = (grub_ofconsole_height * 2) - grub_curr_y; + while(x--) + grub_putcode ('\n'); + } grub_gotoxy (0, 0); }