diff --git a/ChangeLog b/ChangeLog index bf142afdf..adbb72430 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-04-26 Vladimir Serbinenko + + * grub-core/term/ieee1275/console.c (grub_console_dimensions): Use 80x24 + geometry on serial consoles. + 2012-04-26 Vladimir Serbinenko * grub-core/term/terminfo.c (grub_terminfo_readkey): Increase timeout diff --git a/grub-core/term/ieee1275/console.c b/grub-core/term/ieee1275/console.c index 9bb51fa5d..9486573fa 100644 --- a/grub-core/term/ieee1275/console.c +++ b/grub-core/term/ieee1275/console.c @@ -77,30 +77,49 @@ static void grub_console_dimensions (void) { grub_ieee1275_ihandle_t options; - grub_ssize_t lval; + grub_ieee1275_phandle_t stdout_phandle; + char val[1024]; + + /* Always assume 80x24 on serial since screen-#rows/screen-#columns is often + garbage for such devices. */ + if (! grub_ieee1275_instance_to_package (stdout_ihandle, + &stdout_phandle) + && ! grub_ieee1275_package_to_path (stdout_phandle, + val, sizeof (val) - 1, 0)) + { + grub_ieee1275_ihandle_t stdout_options; + val[sizeof (val) - 1] = 0; + + if (! grub_ieee1275_finddevice (val, &stdout_options) + && ! grub_ieee1275_get_property (stdout_options, "device_type", + val, sizeof (val) - 1, 0)) + { + val[sizeof (val) - 1] = 0; + if (grub_strcmp (val, "serial") == 0) + { + grub_console_terminfo_output.width = 80; + grub_console_terminfo_output.height = 24; + return; + } + } + } if (! grub_ieee1275_finddevice ("/options", &options) && options != (grub_ieee1275_ihandle_t) -1) { - if (! grub_ieee1275_get_property_length (options, "screen-#columns", - &lval) - && lval >= 0 && lval < 1024) + if (! grub_ieee1275_get_property (options, "screen-#columns", + val, sizeof (val) - 1, 0)) { - char val[lval]; - - if (! grub_ieee1275_get_property (options, "screen-#columns", - val, lval, 0)) - grub_console_terminfo_output.width - = (grub_uint8_t) grub_strtoul (val, 0, 10); + val[sizeof (val) - 1] = 0; + grub_console_terminfo_output.width + = (grub_uint8_t) grub_strtoul (val, 0, 10); } - if (! grub_ieee1275_get_property_length (options, "screen-#rows", &lval) - && lval >= 0 && lval < 1024) + if (! grub_ieee1275_get_property (options, "screen-#rows", + val, sizeof (val) - 1, 0)) { - char val[lval]; - if (! grub_ieee1275_get_property (options, "screen-#rows", - val, lval, 0)) - grub_console_terminfo_output.height - = (grub_uint8_t) grub_strtoul (val, 0, 10); + val[sizeof (val) - 1] = 0; + grub_console_terminfo_output.height + = (grub_uint8_t) grub_strtoul (val, 0, 10); } }