]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/term/ieee1275/console.c (grub_console_dimensions): Use 80x24
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 26 Apr 2012 18:51:06 +0000 (20:51 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Thu, 26 Apr 2012 18:51:06 +0000 (20:51 +0200)
geometry on serial consoles.

ChangeLog
grub-core/term/ieee1275/console.c

index bf142afdfa60e1cb3d896b51af6ffefb3a7137ef..adbb72430c14556cc0c2709ceae9fba484f4261b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-04-26  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/term/ieee1275/console.c (grub_console_dimensions): Use 80x24
+       geometry on serial consoles.
+
 2012-04-26  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * grub-core/term/terminfo.c (grub_terminfo_readkey): Increase timeout
index 9bb51fa5d18f8e6a8dca3a1602d63ecdd80445fb..9486573fa32be3d98476062f8be8a0f0bd18a5af 100644 (file)
@@ -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);
        }
     }