Skip to contentSkip to conversation

Only print "Decompressing Linux" etc when 'debug' is passed.

PATCH NAK Kristian Høgsberg 6 participants 7 messages May 25, 2008 – May 26, 2008 x86

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 Only print "Decompressing Linux" etc when 'debug' is passed.

---

Updated to use the standard 'debug' parameter instead of 'noisy'.

 arch/x86/boot/compressed/misc.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)
arch/x86/boot/compressed/misc.c +27 -3
index 0d03579..017df26 100644
@@ -190,6 +190,7 @@ static void gzip_release(void **);
  */
 static struct boot_params *real_mode;		/* Pointer to real-mode data */
 static struct screen_info *rm_screen_info;	/* Pointer to real-mode data */
+static int debug;
 
 extern unsigned char input_data[];
 extern int input_len;
@@ -391,7 +392,8 @@ static void parse_elf(void *output)
 		return;
 	}
 
-	putstr("Parsing ELF... ");
+	if (debug)
+		putstr("Parsing ELF... ");
 
 	phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
 	if (!phdrs)
@@ -419,11 +421,27 @@ static void parse_elf(void *output)
 	}
 }
 
+static const char *strnstr(const char *string, int len, const char *s)
+{
+	int i, j;
+
+	for (i = 0; i < len; i++) {
+		for (j = 0; i + j < len && s[j]; j++)
+			if (string[i + j] != s[j])
+				break;
+		if (s[j] == '\0')
+			return string + i;
+	}
+
+	return NULL;
+}
 asmlinkage void decompress_kernel(void *rmode, memptr heap,
 				  unsigned char *input_data,
 				  unsigned long input_len,
 				  unsigned char *output)
 {
+	char *cmdline;
+
 	real_mode = rmode;
 
 	if (rm_screen_info->orig_video_mode == 7) {
@@ -437,6 +455,10 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 	lines = rm_screen_info->orig_video_lines;
 	cols = rm_screen_info->orig_video_cols;
 
+	cmdline = (char *) real_mode->hdr.cmd_line_ptr;
+	if (strnstr(cmdline, real_mode->hdr.cmdline_size, "debug"))
+		debug = 1;
+
 	window = output;		/* Output buffer (Normally at 1M) */
 	free_mem_ptr     = heap;	/* Heap */
 	free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
@@ -461,9 +483,11 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 #endif
 
 	makecrc();
-	putstr("\nDecompressing Linux... ");
+	if (debug)
+		putstr("\nDecompressing Linux... ");
 	gunzip();
 	parse_elf(output);
-	putstr("done.\nBooting the kernel.\n");
+	if (debug)
+		putstr("done.\nBooting the kernel.\n");
 	return;
 }
Signature · 1 line
1.5.5.1
#1 lore raw
Quoted 74 lines · Kristian Høgsberg

---

Updated to use the standard 'debug' parameter instead of 'noisy'.

 arch/x86/boot/compressed/misc.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)
arch/x86/boot/compressed/misc.c +23 -2
index 0d03579..017df26 100644
@@ -190,6 +190,7 @@ static void gzip_release(void **);
 */
 static struct boot_params *real_mode;          /* Pointer to real-mode data */
 static struct screen_info *rm_screen_info;     /* Pointer to real-mode data */
+static int debug;
 
 extern unsigned char input_data[];
 extern int input_len;
@@ -391,7 +392,8 @@ static void parse_elf(void *output)
               return;
       }
 
-       putstr("Parsing ELF... ");
+       if (debug)
+               putstr("Parsing ELF... ");
 
       phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum);
       if (!phdrs)
@@ -419,11 +421,27 @@ static void parse_elf(void *output)
       }
 }
 
+static const char *strnstr(const char *string, int len, const char *s)
+{
+       int i, j;
+
+       for (i = 0; i < len; i++) {
+               for (j = 0; i + j < len && s[j]; j++)
+                       if (string[i + j] != s[j])
+                               break;
+               if (s[j] == '\0')
+                       return string + i;
+       }
+
+       return NULL;
+}
 asmlinkage void decompress_kernel(void *rmode, memptr heap,
                                 unsigned char *input_data,
                                 unsigned long input_len,
                                 unsigned char *output)
 {
+       char *cmdline;
+
       real_mode = rmode;
 
       if (rm_screen_info->orig_video_mode == 7) {
@@ -437,6 +455,10 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
       lines = rm_screen_info->orig_video_lines;
       cols = rm_screen_info->orig_video_cols;
 
+       cmdline = (char *) real_mode->hdr.cmd_line_ptr;
+       if (strnstr(cmdline, real_mode->hdr.cmdline_size, "debug"))
+               debug = 1;
+
       window = output;                /* Output buffer (Normally at 1M) */
       free_mem_ptr     = heap;        /* Heap */
       free_mem_end_ptr = heap + BOOT_HEAP_SIZE;
@@ -461,9 +483,11 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 #endif
 
       makecrc();
-       putstr("\nDecompressing Linux... ");

arch/x86/boot/compressed/misc.c asmlinkage void decompress_kernel(void *rmode, memptr heap,

Quoted 10 lines
arch/x86/boot/compressed/misc.c +4 -2
+       if (debug)
+               putstr("\nDecompressing Linux... ");
       gunzip();
       parse_elf(output);
-       putstr("done.\nBooting the kernel.\n");
+       if (debug)
+               putstr("done.\nBooting the kernel.\n");
       return;
 }
--

does that printout hurt anything?

YH

#2 lore raw
In reply to Kristian Høgsberg
Quoted 4 lines · Kristian Høgsberg
arch/x86/boot/compressed/misc.c +0 -0
@@ -461,9 +483,11 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
 #endif
 
       makecrc();

arch/x86/boot/compressed/misc.c asmlinkage void decompress_kernel(void *rmode, memptr heap, · line 493

Quoted 10 lines
arch/x86/boot/compressed/misc.c +4 -2
-       putstr("\nDecompressing Linux... ");
+       if (debug)
+               putstr("\nDecompressing Linux... ");
       gunzip();
       parse_elf(output);
-       putstr("done.\nBooting the kernel.\n");
+       if (debug)
+               putstr("done.\nBooting the kernel.\n");
       return;
 }

Please add a proper changelog explaining why we want to do this.

#4 lore raw
Quoted 6 lines · Mikael Pettersson
Quoted 5 lines · =?utf-8?q?Kristian=20H=C3=B8gsberg?= writes:

---

Updated to use the standard 'debug' parameter instead of 'noisy'.

Quoted 7 lines
Quoted 2 lines
 arch/x86/boot/compressed/misc.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)

NAK

You still haven't explained why suppressing these
messages is necessary.

In fact, quite the opposite, http://tinyurl.com/68notu , is worthwhile.

#5 lore raw

Hi,

Quoted 10 lines · Jan Engelhardt
Quoted 9 lines · Mikael Pettersson
Quoted 7 lines · =?utf-8?q?Kristian=20H=C3=B8gsberg?= writes:

---

Updated to use the standard 'debug' parameter instead of 'noisy'.

 arch/x86/boot/compressed/misc.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)
Quoted 7 lines
Quoted 4 lines

NAK

You still haven't explained why suppressing these
messages is necessary.

In fact, quite the opposite, http://tinyurl.com/68notu , is worthwhile.

I want dots! My bootloader already prints dots!

Decompressing Linux...................done.
Booting the kernel.

Hannes

#6 lore raw
Quoted 8 lines · Johannes Weiner
Quoted 3 lines

In fact, quite the opposite, http://tinyurl.com/68notu , is worthwhile.

I want dots! My bootloader already prints dots!

Decompressing Linux...................done.
Booting the kernel.

I have deliberately chosen stars instead of dots because the rest of the kernel already uses dots here and there without actually implementing a progress "bar" ("Foobaring your CPU...",wait,"done\n") to stand out a bit, but I do not actually mind what is printed, whether it is stars, dots or ▒s.