File grub-verbose.patch of Package grub

Index: grub-0.97/stage2/shared.h
===================================================================
--- grub-0.97.orig/stage2/shared.h
+++ grub-0.97/stage2/shared.h
@@ -679,6 +679,13 @@ extern void (*disk_read_func) (int, int,
 extern int debug;
 #endif /* STAGE1_5 */
 
+/* Verbose mode flag. */
+extern int grub_verbose;
+#define verbose_printf(format...) \
+  do { if (grub_verbose) printf(format); } while (0)
+#define grub_verbose_printf(format...) \
+  do { if (grub_verbose) grub_printf(format); } while (0)
+
 extern unsigned long current_drive;
 extern unsigned long current_partition;
 
Index: grub-0.97/stage2/stage2.c
===================================================================
--- grub-0.97.orig/stage2/stage2.c
+++ grub-0.97/stage2/stage2.c
@@ -260,6 +260,9 @@ restart:
   /* If SHOW_MENU is false, don't display the menu until ESC is pressed.  */
   if (! show_menu)
     {
+      /* Don't show the "Booting in blah seconds message" if the timeout is 0 */
+      int print_message = grub_timeout != 0;
+
       /* Get current time.  */
       while ((time1 = getrtsecs ()) == 0xFF)
 	;
@@ -289,8 +292,9 @@ restart:
 	      grub_timeout--;
 	      
 	      /* Print a message.  */
-	      grub_printf ("\rPress `ESC' to enter the menu... %d   ",
-			   grub_timeout);
+	      if (print_message)
+	        grub_printf ("\rPress `ESC' to enter the menu... %d   ",
+			     grub_timeout);
 	    }
 	}
     }
@@ -720,16 +724,19 @@ restart:
   
  boot_entry:
   
-  cls ();
-  setcursor (1);
+  if (grub_verbose || show_menu)
+    {
+      cls ();
+      setcursor (1);
+    }
   
   while (1)
     {
       if (config_entries)
-	printf ("  Booting \'%s\'\n\n",
+	verbose_printf ("  Booting \'%s\'\n\n",
 		get_entry (menu_entries, first_entry + entryno, 0));
       else
-	printf ("  Booting command-list\n\n");
+	verbose_printf ("  Booting command-list\n\n");
 
       if (! cur_entry)
 	cur_entry = get_entry (config_entries, first_entry + entryno, 1);
@@ -1556,6 +1563,7 @@ cmain (void)
 	  /* If no acceptable config file, goto command-line, starting
 	     heap from where the config entries would have been stored
 	     if there were any.  */
+	  grub_verbose = 1;
 	  enter_cmdline (config_entries, 1);
 	}
       else
Index: grub-0.97/stage2/boot.c
===================================================================
--- grub-0.97.orig/stage2/boot.c
+++ grub-0.97/stage2/boot.c
@@ -280,9 +280,9 @@ load_image (char *kernel, char *arg, ker
 	errnum = ERR_WONT_FIT;
       else
 	{
-	  grub_printf ("   [Linux-%s, setup=0x%x, size=0x%x]\n",
-		       (big_linux ? "bzImage" : "zImage"), data_len, text_len);
-
+          grub_verbose_printf ("   [Linux-%s, setup=0x%x, size=0x%x]\n",
+                               (big_linux ? "bzImage" : "zImage"),
+                               data_len, text_len);
 	  /* Video mode selection support. What a mess!  */
 	  /* NOTE: Even the word "mess" is not still enough to
 	     represent how wrong and bad the Linux video support is,
@@ -505,7 +505,7 @@ load_image (char *kernel, char *arg, ker
       if (flags & MULTIBOOT_AOUT_KLUDGE)
 	str = "-and-data";
 
-      printf (", loadaddr=0x%x, text%s=0x%x", cur_addr, str, text_len);
+      verbose_printf (", loadaddr=0x%x, text%s=0x%x", cur_addr, str, text_len);
 
       /* read text, then read data */
       if (grub_read ((char *) RAW_ADDR (cur_addr), text_len) == text_len)
@@ -518,9 +518,9 @@ load_image (char *kernel, char *arg, ker
 	      if (align_4k)
 		cur_addr = (cur_addr + 0xFFF) & 0xFFFFF000;
 	      else
-		printf (", C");
+		verbose_printf (", C");
 
-	      printf (", data=0x%x", data_len);
+	      verbose_printf (", data=0x%x", data_len);
 
 	      if ((grub_read ((char *) RAW_ADDR (cur_addr), data_len)
 		   != data_len)
@@ -534,7 +534,7 @@ load_image (char *kernel, char *arg, ker
 	      memset ((char *) RAW_ADDR (cur_addr), 0, bss_len);
 	      cur_addr += bss_len;
 
-	      printf (", bss=0x%x", bss_len);
+	      verbose_printf (", bss=0x%x", bss_len);
 	    }
 	}
       else if (!errnum)
@@ -554,7 +554,7 @@ load_image (char *kernel, char *arg, ker
 	  *((int *) RAW_ADDR (cur_addr)) = pu.aout->a_syms;
 	  cur_addr += sizeof (int);
 	  
-	  printf (", symtab=0x%x", pu.aout->a_syms);
+	  verbose_printf (", symtab=0x%x", pu.aout->a_syms);
 
 	  if (grub_read ((char *) RAW_ADDR (cur_addr), pu.aout->a_syms)
 	      == pu.aout->a_syms)
@@ -571,7 +571,7 @@ load_image (char *kernel, char *arg, ker
 
 		  i -= sizeof (int);
 
-		  printf (", strtab=0x%x", i);
+		  verbose_printf (", strtab=0x%x", i);
 
 		  symtab_err = (grub_read ((char *) RAW_ADDR (cur_addr), i)
 				!= i);
@@ -585,7 +585,7 @@ load_image (char *kernel, char *arg, ker
 
 	  if (symtab_err)
 	    {
-	      printf ("(bad)");
+	      verbose_printf ("(bad)");
 	      cur_addr = orig_addr;
 	      mbi.syms.a.tabsize = 0;
 	      mbi.syms.a.strsize = 0;
@@ -639,7 +639,7 @@ load_image (char *kernel, char *arg, ker
 	      /* mark memory as used */
 	      if (cur_addr < memaddr + memsiz)
 		cur_addr = memaddr + memsiz;
-	      printf (", <0x%x:0x%x:0x%x>", memaddr, filesiz,
+	      verbose_printf (", <0x%x:0x%x:0x%x>", memaddr, filesiz,
 		      memsiz - filesiz);
 	      /* increment number of segments */
 	      loaded++;
@@ -685,7 +685,7 @@ load_image (char *kernel, char *arg, ker
 		  shdr = (Elf32_Shdr *) mbi.syms.e.addr;
 		  cur_addr += tab_size;
 		  
-		  printf (", shtab=0x%x", cur_addr);
+		  verbose_printf (", shtab=0x%x", cur_addr);
   		  
 		  for (i = 0; i < mbi.syms.e.num; i++)
 		    {
@@ -727,7 +727,7 @@ load_image (char *kernel, char *arg, ker
 	      
 	      if (symtab_err) 
 		{
-		  printf ("(bad)");
+		  verbose_printf ("(bad)");
 		  mbi.syms.e.num = 0;
 		  mbi.syms.e.size = 0;
 		  mbi.syms.e.addr = 0;
@@ -742,7 +742,7 @@ load_image (char *kernel, char *arg, ker
 
   if (! errnum)
     {
-      grub_printf (", entry=0x%x]\n", (unsigned) entry_addr);
+      grub_verbose_printf (", entry=0x%x]\n", (unsigned) entry_addr);
       
       /* If the entry address is physically different from that of the ELF
 	 header, correct it here.  */
@@ -785,7 +785,7 @@ load_module (char *module, char *arg)
       return 0;
     }
 
-  printf ("   [Multiboot-module @ 0x%x, 0x%x bytes]\n", cur_addr, len);
+  verbose_printf ("   [Multiboot-module @ 0x%x, 0x%x bytes]\n", cur_addr, len);
 
   /* these two simply need to be set if any modules are loaded at all */
   mbi.flags |= MB_INFO_MODS;
@@ -848,7 +848,7 @@ load_initrd (char *initrd)
   moveto -= 0x10000;
   memmove ((void *) RAW_ADDR (moveto), (void *) cur_addr, len);
 
-  printf ("   [Linux-initrd @ 0x%x, 0x%x bytes]\n", moveto, len);
+  verbose_printf ("   [Linux-initrd @ 0x%x, 0x%x bytes]\n", moveto, len);
 
   /* FIXME: Should check if the kernel supports INITRD.  */
   lh->ramdisk_image = RAW_ADDR (moveto);
Index: grub-0.97/stage2/builtins.c
===================================================================
--- grub-0.97.orig/stage2/builtins.c
+++ grub-0.97/stage2/builtins.c
@@ -56,6 +56,8 @@ static int bootdev;
 /* True when the debug mode is turned on, and false
    when it is turned off.  */
 int debug = 0;
+/* Print what we're booting */
+int grub_verbose = 0;
 /* The default entry.  */
 int default_entry = 0;
 /* The fallback entry.  */
@@ -767,6 +769,33 @@ static struct builtin builtin_debug =
 };
 
 
+/* verbose */
+static int
+verbose_func (char *arg, int flags)
+{
+  if (grub_verbose)
+    {
+      grub_verbose = 0;
+      grub_printf (" Verbose mode is turned off\n");
+    }
+  else
+    {
+      grub_verbose = 1;
+      grub_printf (" Verbose mode is turned on\n");
+    }
+
+  return 0;
+}
+
+static struct builtin builtin_verbose =
+{
+  "verbose",
+  verbose_func,
+  BUILTIN_CMDLINE | BUILTIN_MENU,
+  "verbose",
+  "Turn on/off verbose output."
+};
+
 /* default */
 static int
 default_func (char *arg, int flags)
@@ -3235,7 +3264,8 @@ real_root_func (char *arg, int attempt_m
 	return 1;
       
       /* Print the type of the filesystem.  */
-      print_fsys_type ();
+      if (grub_verbose)
+       print_fsys_type ();
     }
   
   return 0;
@@ -4964,5 +4994,6 @@ struct builtin *builtin_table[] =
   &builtin_unhide,
   &builtin_uppermem,
   &builtin_vbeprobe,
+  &builtin_verbose,
   0
 };
Index: grub-0.97/stage2/cmdline.c
===================================================================
--- grub-0.97.orig/stage2/cmdline.c
+++ grub-0.97/stage2/cmdline.c
@@ -232,12 +232,12 @@ run_script (char *script, char *heap)
       builtin = find_command (heap);
       if (! builtin)
 	{
-	  grub_printf ("%s\n", old_entry);
+	  grub_verbose_printf ("%s\n", old_entry);
 	  continue;
 	}
 
       if (! (builtin->flags & BUILTIN_NO_ECHO))
-	grub_printf ("%s\n", old_entry);
+	grub_verbose_printf ("%s\n", old_entry);
 
       /* If BUILTIN cannot be run in the command-line, skip it.  */
       if (! (builtin->flags & BUILTIN_CMDLINE))
Index: grub-0.97/stage2/stage1_5.c
===================================================================
--- grub-0.97.orig/stage2/stage1_5.c
+++ grub-0.97/stage2/stage1_5.c
@@ -30,7 +30,8 @@ disk_read_savesect_func (int sector, int
 void
 cmain (void)
 {
-  grub_printf ("\n\nGRUB loading, please wait...\n");
+  if (0)
+    grub_printf ("\n\nGRUB loading, please wait...\n");
 
   /*
    *  Here load the true second-stage boot-loader.
Index: grub-0.97/stage1/stage1.S
===================================================================
--- grub-0.97.orig/stage1/stage1.S
+++ grub-0.97/stage1/stage1.S
@@ -31,6 +31,8 @@
 
 	/* Print message string */
 #define MSG(x)	movw $ABS(x), %si; call message
+        /* Print verbose message string */
+#define VMSG(x)
 
 	/* XXX:	binutils-2.9.1.0.x doesn't produce a short opcode for this. */
 #define	MOV_MEM_TO_AL(x)	.byte 0xa0;  .word x
@@ -151,7 +153,7 @@ real_start:
 	pushw	%dx
 
 	/* print a notification message on the screen */
-	MSG(notification_string)
+	VMSG(notification_string)
 
 	/* do not probe LBA if the drive is a floppy */
 	testb	$STAGE1_BIOS_HD_FLAG, %dl
Index: grub-0.97/stage2/start.S
===================================================================
--- grub-0.97.orig/stage2/start.S
+++ grub-0.97/stage2/start.S
@@ -40,6 +40,9 @@
 	/* Print message string */
 #define MSG(x)	movw $ABS(x), %si; call message
 
+       /* Print verbose message string */
+#define VMSG(x)
+
 	.file	"start.S"
 
 	.text
@@ -67,7 +70,7 @@ _start:
 
 	/* print a notification message on the screen */
 	pushw	%si
-	MSG(notification_string)
+	VMSG(notification_string)
 	popw	%si
 	
 	/* this sets up for the first run through "bootloop" */
@@ -291,9 +294,9 @@ copy_buffer:
 	movsb		/* this runs the actual copy */
 
 	/* restore addressing regs and print a dot with correct DS 
-	   (MSG modifies SI, which is saved, and unused AX and BX) */
+	   (VMSG modifies SI, which is saved, and unused AX and BX) */
 	popw	%ds
-	MSG(notification_step)
+	VMSG(notification_step)
 	popa
 
 	/* check if finished with this dataset */
@@ -310,7 +313,7 @@ copy_buffer:
 
 bootit:
 	/* print a newline */
-	MSG(notification_done)
+	VMSG(notification_done)
 	popw	%dx	/* this makes sure %dl is our "boot" drive */
 #ifdef STAGE1_5
 	ljmp	$0, $0x2200
openSUSE Build Service is sponsored by