[2070] 2009-04-06 Pavel Roskin <[email protected]>

Pavel Roskin <[email protected]>
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2070
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2070
Author:   proski
Date:     2009-04-07 00:48:57 +0000 (Tue, 07 Apr 2009)
Log Message:
-----------
2009-04-06  Pavel Roskin  <[email protected]>

	* include/grub/misc.h (ARRAY_SIZE): New macro.
	* include/grub/i386/linux.h (GRUB_LINUX_VID_MODE_VESA_START):
	New macro.
	* loader/i386/linux.c (allocate_pages): Use free_pages().
	(grub_linux_unload): Don't use free_pages().
	(grub_linux_boot): Prevent accessing linux_vesafb_modes with a
	wrong index.  Treat all other modes as text modes.
	(grub_cmd_linux): Initialize vid_mode unconditionally to
	GRUB_LINUX_VID_MODE_NORMAL.  Recognize and support "vga=ask".

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/include/grub/i386/linux.h
    trunk/grub2/include/grub/misc.h
    trunk/grub2/loader/i386/linux.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-04-06 16:15:36 UTC (rev 2069)
+++ trunk/grub2/ChangeLog	2009-04-07 00:48:57 UTC (rev 2070)
@@ -1,5 +1,15 @@
 2009-04-06  Pavel Roskin  <[email protected]>
 
+	* include/grub/misc.h (ARRAY_SIZE): New macro.
+	* include/grub/i386/linux.h (GRUB_LINUX_VID_MODE_VESA_START):
+	New macro.
+	* loader/i386/linux.c (allocate_pages): Use free_pages().
+	(grub_linux_unload): Don't use free_pages().
+	(grub_linux_boot): Prevent accessing linux_vesafb_modes with a
+	wrong index.  Treat all other modes as text modes.
+	(grub_cmd_linux): Initialize vid_mode unconditionally to
+	GRUB_LINUX_VID_MODE_NORMAL.  Recognize and support "vga=ask".
+
 	* commands/help.c (print_command_help): Use cmd->prio, not
 	cmd->flags to check for GRUB_PRIO_LIST_FLAG_ACTIVE.
 

Modified: trunk/grub2/include/grub/i386/linux.h
===================================================================
--- trunk/grub2/include/grub/i386/linux.h	2009-04-06 16:15:36 UTC (rev 2069)
+++ trunk/grub2/include/grub/i386/linux.h	2009-04-07 00:48:57 UTC (rev 2070)
@@ -38,6 +38,7 @@
 #define GRUB_LINUX_VID_MODE_NORMAL	0xFFFF
 #define GRUB_LINUX_VID_MODE_EXTENDED	0xFFFE
 #define GRUB_LINUX_VID_MODE_ASK		0xFFFD
+#define GRUB_LINUX_VID_MODE_VESA_START	0x0301
 
 #define GRUB_LINUX_SETUP_MOVE_SIZE	0x9100
 #define GRUB_LINUX_CL_MAGIC		0xA33F

Modified: trunk/grub2/include/grub/misc.h
===================================================================
--- trunk/grub2/include/grub/misc.h	2009-04-06 16:15:36 UTC (rev 2069)
+++ trunk/grub2/include/grub/misc.h	2009-04-07 00:48:57 UTC (rev 2070)
@@ -26,6 +26,7 @@
 #include <grub/err.h>
 
 #define ALIGN_UP(addr, align) (((grub_uint64_t)addr + align - 1) & ~(align - 1))
+#define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
 
 #define grub_dprintf(condition, fmt, args...) grub_real_dprintf(__FILE__, __LINE__, condition, fmt, ## args);
 /* XXX: If grub_memmove is too slow, we must implement grub_memcpy.  */

Modified: trunk/grub2/loader/i386/linux.c
===================================================================
--- trunk/grub2/loader/i386/linux.c	2009-04-06 16:15:36 UTC (rev 2069)
+++ trunk/grub2/loader/i386/linux.c	2009-04-07 00:48:57 UTC (rev 2070)
@@ -206,8 +206,7 @@
   prot_mode_pages = (prot_size >> 12);
   
   /* Initialize the memory pointers with NULL for convenience.  */
-  real_mode_mem = 0;
-  prot_mode_mem = 0;
+  free_pages ();
   
   /* FIXME: Should request low memory from the heap when this feature is
      implemented.  */
@@ -332,7 +331,9 @@
   
   params = real_mode_mem;
 
-  if (vid_mode == GRUB_LINUX_VID_MODE_NORMAL || vid_mode == GRUB_LINUX_VID_MODE_EXTENDED)
+  if (vid_mode < GRUB_LINUX_VID_MODE_VESA_START ||
+      vid_mode >= GRUB_LINUX_VID_MODE_VESA_START +
+		  ARRAY_SIZE (linux_vesafb_modes))
     grub_video_restore ();
   else if (vid_mode)
     {
@@ -340,7 +341,7 @@
       int depth, flags;
       
       flags = 0;
-      linux_mode = &linux_vesafb_modes[vid_mode - 0x301];
+      linux_mode = &linux_vesafb_modes[vid_mode - GRUB_LINUX_VID_MODE_VESA_START];
       depth = linux_mode->depth;
       
       /* If we have 8 or less bits, then assume that it is indexed color mode.  */
@@ -443,7 +444,6 @@
 static grub_err_t
 grub_linux_unload (void)
 {
-  free_pages ();
   grub_dl_unref (my_mod);
   loaded = 0;
   return GRUB_ERR_NONE;
@@ -569,7 +569,8 @@
   grub_printf ("   [Linux-bzImage, setup=0x%x, size=0x%x]\n",
 	       (unsigned) real_size, (unsigned) prot_size);
 
-  /* Detect explicitly specified memory size, if any.  */
+  /* Look for memory size and video mode specified on the command line.  */
+  vid_mode = GRUB_LINUX_VID_MODE_NORMAL;
   linux_mem_size = 0;
   for (i = 1; i < argc; i++)
     if (grub_memcmp (argv[i], "vga=", 4) == 0)
@@ -581,6 +582,8 @@
 	  vid_mode = GRUB_LINUX_VID_MODE_NORMAL;
 	else if (grub_strcmp (val, "ext") == 0)
 	  vid_mode = GRUB_LINUX_VID_MODE_EXTENDED;
+	else if (grub_strcmp (val, "ask") == 0)
+	  vid_mode = GRUB_LINUX_VID_MODE_ASK;
 	else
 	  vid_mode = (grub_uint16_t) grub_strtoul (val, 0, 0);
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.