[2179] 2009-05-04 Robert Millan <[email protected]>

Robert Millan <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2179
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2179
Author:   robertmh
Date:     2009-05-04 18:04:09 +0000 (Mon, 04 May 2009)
Log Message:
-----------
2009-05-04  Robert Millan  <[email protected]>

        * loader/i386/linux.c (GRUB_ASSUME_LINUX_HAS_FB_SUPPORT): New macro.
        (grub_linux_boot): Don't check for `linux_vesafb_modes' bounds (this
        is done by grub_cmd_linux() now).
        [! GRUB_ASSUME_LINUX_HAS_FB_SUPPORT]: If "vga=" parameter wasn't set,
        restore video to text mode.
        (grub_cmd_linux): Default `vid_mode' initialization to 0, which
        indicates lack of "vga=" parameter.  "vga=0" is mapped to
        `GRUB_LINUX_VID_MODE_NORMAL'.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/loader/i386/linux.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-05-04 17:57:31 UTC (rev 2178)
+++ trunk/grub2/ChangeLog	2009-05-04 18:04:09 UTC (rev 2179)
@@ -1,3 +1,14 @@
+2009-05-04  Robert Millan  <[email protected]>
+
+	* loader/i386/linux.c (GRUB_ASSUME_LINUX_HAS_FB_SUPPORT): New macro.
+	(grub_linux_boot): Don't check for `linux_vesafb_modes' bounds (this
+	is done by grub_cmd_linux() now).
+	[! GRUB_ASSUME_LINUX_HAS_FB_SUPPORT]: If "vga=" parameter wasn't set,
+	restore video to text mode.
+	(grub_cmd_linux): Default `vid_mode' initialization to 0, which
+	indicates lack of "vga=" parameter.  "vga=0" is mapped to
+	`GRUB_LINUX_VID_MODE_NORMAL'.
+
 2009-05-04  Felix Zielcke  <[email protected]>
 
 	* conf/i386-efi.rmk (grub_emu_SOURCES): Remove `normal/execute.c',

Modified: trunk/grub2/loader/i386/linux.c
===================================================================
--- trunk/grub2/loader/i386/linux.c	2009-05-04 17:57:31 UTC (rev 2178)
+++ trunk/grub2/loader/i386/linux.c	2009-05-04 18:04:09 UTC (rev 2179)
@@ -39,6 +39,14 @@
 #define GRUB_LINUX_CL_OFFSET		0x1000
 #define GRUB_LINUX_CL_END_OFFSET	0x2000
 
+/* This macro is useful for distributors, who can be certain they built FB support
+   into Linux, and therefore can benefit from seamless mode transition between
+   GRUB and Linux (saving boot time and visual glitches).  Official GRUB, OTOH,
+   needs to be conservative.  */
+#ifndef GRUB_ASSUME_LINUX_HAS_FB_SUPPORT
+#define GRUB_ASSUME_LINUX_HAS_FB_SUPPORT 0
+#endif
+
 static grub_dl_t my_mod;
 
 static grub_size_t linux_mem_size;
@@ -332,9 +340,7 @@
   
   params = real_mode_mem;
 
-  if (vid_mode < GRUB_LINUX_VID_MODE_VESA_START ||
-      vid_mode >= GRUB_LINUX_VID_MODE_VESA_START +
-		  ARRAY_SIZE (linux_vesafb_modes))
+  if (vid_mode == GRUB_LINUX_VID_MODE_NORMAL || vid_mode == GRUB_LINUX_VID_MODE_EXTENDED)
     grub_video_restore ();
   else if (vid_mode)
     {
@@ -367,6 +373,12 @@
 	  return grub_errno;
 	}
     }
+#if ! GRUB_ASSUME_LINUX_HAS_FB_SUPPORT
+  else
+    /* If user didn't request a video mode, and we can't assume Linux supports FB,
+       then we go back to text mode.  */
+    grub_video_restore ();
+#endif
 
   if (! grub_linux_setup_video (params))
     params->have_vga = GRUB_VIDEO_TYPE_VLFB;
@@ -593,7 +605,7 @@
 	       (unsigned) real_size, (unsigned) prot_size);
 
   /* Look for memory size and video mode specified on the command line.  */
-  vid_mode = GRUB_LINUX_VID_MODE_NORMAL;
+  vid_mode = 0;
   linux_mem_size = 0;
   for (i = 1; i < argc; i++)
     if (grub_memcmp (argv[i], "vga=", 4) == 0)
@@ -618,6 +630,22 @@
 	else
 	  vid_mode = (grub_uint16_t) grub_strtoul (val, 0, 0);
 
+	switch (vid_mode)
+	  {
+	  case 0:
+	    vid_mode = GRUB_LINUX_VID_MODE_NORMAL;
+	    break;
+	  case 1:
+	    vid_mode = GRUB_LINUX_VID_MODE_EXTENDED;
+	    break;
+	  default:
+	    /* Ignore invalid values.  */
+	    if (vid_mode < GRUB_LINUX_VID_MODE_VESA_START ||
+		vid_mode >= GRUB_LINUX_VID_MODE_VESA_START +
+		ARRAY_SIZE (linux_vesafb_modes))
+	      vid_mode = 0;
+	  }
+
 	if (grub_errno)
 	  goto fail;
       }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.