diff -rupN powerpc/ieee1275/ofconsole.c sparc64/ieee1275/ofconsole.c --- powerpc/ieee1275/ofconsole.c 2005-06-21 04:33:52.000000000 +0200 +++ sparc64/ieee1275/ofconsole.c 2005-07-13 10:18:46.000000000 +0200 @@ -120,7 +120,7 @@ static int grub_ofconsole_readkey (int *key) { char c; - int actual = 0; + grub_ssize_t actual = 0; grub_ieee1275_read (stdin_ihandle, &c, 1, &actual); @@ -207,6 +207,49 @@ grub_ofconsole_getxy (void) return ((grub_curr_x - 1) << 8) | grub_curr_y; } +static grub_uint16_t +grub_ofconsole_getwh (void) +{ + grub_ieee1275_ihandle_t config; + char *val; + grub_ssize_t lval; + static grub_uint8_t w, h; + + if (w && h) /* Once we have them, don't ask them again. */ + { + if (! grub_ieee1275_open ("/config", &config) && + config != -1) + { + if (! grub_ieee1275_get_property_length (config, "screen-#columns", + &lval) && lval != -1) + { + val = grub_malloc (lval); + if (! grub_ieee1275_get_property (config, "screen-#columns", + val, lval, 0)) + w = (grub_uint8_t) grub_strtoul (val, val + lval, 10); + grub_free (val); + } + if (! grub_ieee1275_get_property_length (config, "screen-#rows", + &lval) && lval != -1) + { + val = grub_malloc (lval); + if (! grub_ieee1275_get_property (config, "screen-#rows", + val, lval, 0)) + h = (grub_uint8_t) grub_strtoul (val, val + lval, 10); + grub_free (val); + } + } + } + + /* XXX: Default values from OpenBoot on my U10. */ + if (! w) + w = 80; + if (! h) + h = 34; + + return (w << 8) | h; +} + static void grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y) { @@ -222,6 +265,8 @@ static void grub_ofconsole_cls (void) { /* Clear the screen. */ + if (grub_env_get ("nocls")) + return; grub_ofconsole_writeesc ("\e[2J"); grub_gotoxy (0, 0); } @@ -241,8 +286,8 @@ grub_ofconsole_refresh (void) static grub_err_t grub_ofconsole_init (void) { - char data[4]; - grub_size_t actual; + unsigned char data[4]; + grub_ssize_t actual; int col; if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdout", data, @@ -287,6 +332,7 @@ static struct grub_term grub_ofconsole_t .checkkey = grub_ofconsole_checkkey, .getkey = grub_ofconsole_getkey, .getxy = grub_ofconsole_getxy, + .getwh = grub_ofconsole_getwh, .gotoxy = grub_ofconsole_gotoxy, .cls = grub_ofconsole_cls, .setcolorstate = grub_ofconsole_setcolorstate,