From 9f4e4392cbf72d731a489a3217fe810820b8ba96 Mon Sep 17 00:00:00 2001 From: Joe Millenbach Date: Thu, 19 Jul 2012 18:04:36 -0700 Subject: [PATCH 1/8] x86, boot: Removed quiet flag and switched quiet output to debug flag There are only 3 uses of the quiet flag and they all protect output that is only useful for debugging the stub, therefore we switched to using the debug flag for all extra output. Signed-off-by: Joe Millenbach Link: http://lkml.kernel.org/r/1342746282-28497-2-git-send-email-jmillenbach@gmail.com Signed-off-by: Gokul Caushik Reviewed-by: Josh Triplett Signed-off-by: H. Peter Anvin --- arch/x86/boot/compressed/misc.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index 7116dcba0c9e..8f2355d5858a 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -108,7 +108,6 @@ static void error(char *m); * This is set up by the setup-routine at boot-time */ struct boot_params *real_mode; /* Pointer to real-mode data */ -static int quiet; static int debug; void *memset(void *s, int c, size_t n); @@ -294,7 +293,7 @@ static void parse_elf(void *output) return; } - if (!quiet) + if (debug) putstr("Parsing ELF... "); phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); @@ -332,8 +331,6 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, { real_mode = rmode; - if (cmdline_find_option_bool("quiet")) - quiet = 1; if (cmdline_find_option_bool("debug")) debug = 1; @@ -369,11 +366,11 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, error("Wrong destination address"); #endif - if (!quiet) + if (debug) putstr("\nDecompressing Linux... "); decompress(input_data, input_len, NULL, NULL, output, NULL, error); parse_elf(output); - if (!quiet) + if (debug) putstr("done.\nBooting the kernel.\n"); return; } From e605a425975b073aafebbb2c09d3ae266be2fd3e Mon Sep 17 00:00:00 2001 From: Joe Millenbach Date: Thu, 19 Jul 2012 18:04:37 -0700 Subject: [PATCH 2/8] x86, boot: Wrap debug printing in a new debug_putstr function Change all instances of if (debug) putstr(...) to a new debug_putstr(...). This allows a future change to conditionally stub out debug_putstr to save space. Signed-off-by: Joe Millenbach Link: http://lkml.kernel.org/r/1342746282-28497-3-git-send-email-jmillenbach@gmail.com Signed-off-by: Gokul Caushik Reviewed-by: Josh Triplett Signed-off-by: H. Peter Anvin --- arch/x86/boot/compressed/misc.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index 8f2355d5858a..49c6d5632ef7 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -223,6 +223,12 @@ void __putstr(int error, const char *s) outb(0xff & (pos >> 1), vidport+1); } +static void debug_putstr(const char *s) +{ + if (debug) + putstr(s); +} + void *memset(void *s, int c, size_t n) { int i; @@ -293,8 +299,7 @@ static void parse_elf(void *output) return; } - if (debug) - putstr("Parsing ELF... "); + debug_putstr("Parsing ELF... "); phdrs = malloc(sizeof(*phdrs) * ehdr.e_phnum); if (!phdrs) @@ -346,8 +351,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, cols = real_mode->screen_info.orig_video_cols; console_init(); - if (debug) - putstr("early console in decompress_kernel\n"); + debug_putstr("early console in decompress_kernel\n"); free_mem_ptr = heap; /* Heap */ free_mem_end_ptr = heap + BOOT_HEAP_SIZE; @@ -366,11 +370,9 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, error("Wrong destination address"); #endif - if (debug) - putstr("\nDecompressing Linux... "); + debug_putstr("\nDecompressing Linux... "); decompress(input_data, input_len, NULL, NULL, output, NULL, error); parse_elf(output); - if (debug) - putstr("done.\nBooting the kernel.\n"); + debug_putstr("done.\nBooting the kernel.\n"); return; } From cb454fe10400566214ec690318a0167ff7f5b8ca Mon Sep 17 00:00:00 2001 From: Joe Millenbach Date: Thu, 19 Jul 2012 18:04:38 -0700 Subject: [PATCH 3/8] x86, boot: Changed error putstr path to match new debug_putstr format For consistency we changed the error output path to match the new debug path. Signed-off-by: Joe Millenbach Link: http://lkml.kernel.org/r/1342746282-28497-4-git-send-email-jmillenbach@gmail.com Signed-off-by: Gokul Caushik Reviewed-by: Josh Triplett Signed-off-by: H. Peter Anvin --- arch/x86/boot/compressed/misc.c | 6 +++--- arch/x86/boot/compressed/misc.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index 49c6d5632ef7..de1d54d8bddc 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -270,9 +270,9 @@ void *memcpy(void *dest, const void *src, size_t n) static void error(char *x) { - __putstr(1, "\n\n"); - __putstr(1, x); - __putstr(1, "\n\n -- System halted"); + error_putstr("\n\n"); + error_putstr(x); + error_putstr("\n\n -- System halted"); while (1) asm("hlt"); diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h index 3f19c81a6203..4c1bfb69e0d8 100644 --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -26,6 +26,7 @@ extern struct boot_params *real_mode; /* Pointer to real-mode data */ void __putstr(int error, const char *s); #define putstr(__x) __putstr(0, __x) +#define error_putstr(__x) __putstr(1, __x) #define puts(__x) __putstr(0, __x) /* cmdline.c */ From 7aac3015b533add3e85222f9fd2ab66216b38746 Mon Sep 17 00:00:00 2001 From: Joe Millenbach Date: Thu, 19 Jul 2012 18:04:39 -0700 Subject: [PATCH 4/8] x86, boot: Switch output functions from command-line flags to conditional compilation Changed putstr flagging from parameter to conditional compilation for puts, debug_putstr, and error_putstr. This allows for space savings since most configurations won't use this feature. Signed-off-by: Joe Millenbach Link: http://lkml.kernel.org/r/1342746282-28497-5-git-send-email-jmillenbach@gmail.com Signed-off-by: Gokul Caushik Reviewed-by: Josh Triplett Signed-off-by: H. Peter Anvin --- arch/x86/boot/compressed/misc.c | 12 +----------- arch/x86/boot/compressed/misc.h | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index de1d54d8bddc..8c29f82b15e4 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -169,15 +169,11 @@ static void serial_putchar(int ch) outb(ch, early_serial_base + TXR); } -void __putstr(int error, const char *s) +void __putstr(const char *s) { int x, y, pos; char c; -#ifndef CONFIG_X86_VERBOSE_BOOTUP - if (!error) - return; -#endif if (early_serial_base) { const char *str = s; while (*str) { @@ -223,12 +219,6 @@ void __putstr(int error, const char *s) outb(0xff & (pos >> 1), vidport+1); } -static void debug_putstr(const char *s) -{ - if (debug) - putstr(s); -} - void *memset(void *s, int c, size_t n) { int i; diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h index 4c1bfb69e0d8..618e5c830f15 100644 --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -24,10 +24,19 @@ /* misc.c */ extern struct boot_params *real_mode; /* Pointer to real-mode data */ -void __putstr(int error, const char *s); -#define putstr(__x) __putstr(0, __x) -#define error_putstr(__x) __putstr(1, __x) -#define puts(__x) __putstr(0, __x) +void __putstr(const char *s); +#define error_putstr(__x) __putstr(__x) + +#ifdef CONFIG_X86_VERBOSE_BOOTUP + +#define debug_putstr(__x) __putstr(__x) + +#else + +static inline void debug_putstr(const char *s) +{ } + +#endif /* cmdline.c */ int cmdline_find_option(const char *option, char *buffer, int bufsize); From 641a1cebfe2f05fa1a48503d816fc70cf707d033 Mon Sep 17 00:00:00 2001 From: Joe Millenbach Date: Thu, 19 Jul 2012 18:04:40 -0700 Subject: [PATCH 5/8] x86, boot: Removed unused debug flag and set code As we're no longer using the flag we don't need to extract the value from the command line and store it. This is a step towards removing command line parameter code. Signed-off-by: Joe Millenbach Link: http://lkml.kernel.org/r/1342746282-28497-6-git-send-email-jmillenbach@gmail.com Signed-off-by: Gokul Caushik Reviewed-by: Josh Triplett Signed-off-by: H. Peter Anvin --- arch/x86/boot/compressed/misc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c index 8c29f82b15e4..88f7ff6da404 100644 --- a/arch/x86/boot/compressed/misc.c +++ b/arch/x86/boot/compressed/misc.c @@ -108,7 +108,6 @@ static void error(char *m); * This is set up by the setup-routine at boot-time */ struct boot_params *real_mode; /* Pointer to real-mode data */ -static int debug; void *memset(void *s, int c, size_t n); void *memcpy(void *dest, const void *src, size_t n); @@ -326,9 +325,6 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap, { real_mode = rmode; - if (cmdline_find_option_bool("debug")) - debug = 1; - if (real_mode->screen_info.orig_video_mode == 7) { vidmem = (char *) 0xb0000; vidport = 0x3b4; From cec49df9d331feaa2fea3d24c07147c7659940d1 Mon Sep 17 00:00:00 2001 From: Joe Millenbach Date: Thu, 19 Jul 2012 18:04:41 -0700 Subject: [PATCH 6/8] x86, boot: Exclude early_serial_console.c if can't use it. Removes early_serial_console.c code if we don't have the config option that enables it (EARLY_PRINTK). When disabling this code, make early_serial_base a constant 0 to allow the compiler to optimize away the code that checks for early_serial_base. Signed-off-by: Joe Millenbach Link: http://lkml.kernel.org/r/1342746282-28497-7-git-send-email-jmillenbach@gmail.com Signed-off-by: Gokul Caushik Reviewed-by: Josh Triplett Signed-off-by: H. Peter Anvin --- arch/x86/boot/compressed/early_serial_console.c | 4 ++++ arch/x86/boot/compressed/misc.h | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/arch/x86/boot/compressed/early_serial_console.c b/arch/x86/boot/compressed/early_serial_console.c index 261e81fb9582..d3d003cb5481 100644 --- a/arch/x86/boot/compressed/early_serial_console.c +++ b/arch/x86/boot/compressed/early_serial_console.c @@ -1,5 +1,9 @@ #include "misc.h" +#ifdef CONFIG_EARLY_PRINTK + int early_serial_base; #include "../early_serial_console.c" + +#endif diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h index 618e5c830f15..3ffee6e0c54c 100644 --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -43,7 +43,17 @@ int cmdline_find_option(const char *option, char *buffer, int bufsize); int cmdline_find_option_bool(const char *option); /* early_serial_console.c */ +#ifdef CONFIG_EARLY_PRINTK + extern int early_serial_base; void console_init(void); +#else + +static const int early_serial_base; +static inline void console_init(void) +{ } + +#endif + #endif From bd448d4d0a1bd88dc6fdc41217b2c25383fa8529 Mon Sep 17 00:00:00 2001 From: Gokul Caushik Date: Thu, 19 Jul 2012 18:04:42 -0700 Subject: [PATCH 7/8] x86, boot: Exclude cmdline.c if you can't use it CONFIG_EARLY_PRINTK is the only feature that might use command line parsing in the decompression stage. If it is disabled then we can exclude the related code to save space. This can result in an estimated space savings of 2240 bytes from the compressed kernel image. Signed-off-by: Joe Millenbach Link: http://lkml.kernel.org/r/1342746282-28497-8-git-send-email-jmillenbach@gmail.com Signed-off-by: Gokul Caushik Reviewed-by: Josh Triplett Signed-off-by: H. Peter Anvin --- arch/x86/boot/compressed/cmdline.c | 4 ++++ arch/x86/boot/compressed/misc.h | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/boot/compressed/cmdline.c b/arch/x86/boot/compressed/cmdline.c index cb62f786990d..10f6b1178c68 100644 --- a/arch/x86/boot/compressed/cmdline.c +++ b/arch/x86/boot/compressed/cmdline.c @@ -1,5 +1,7 @@ #include "misc.h" +#ifdef CONFIG_EARLY_PRINTK + static unsigned long fs; static inline void set_fs(unsigned long seg) { @@ -19,3 +21,5 @@ int cmdline_find_option_bool(const char *option) { return __cmdline_find_option_bool(real_mode->hdr.cmd_line_ptr, option); } + +#endif diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h index 3ffee6e0c54c..0e6dc0ee0eea 100644 --- a/arch/x86/boot/compressed/misc.h +++ b/arch/x86/boot/compressed/misc.h @@ -38,18 +38,19 @@ static inline void debug_putstr(const char *s) #endif +#ifdef CONFIG_EARLY_PRINTK + /* cmdline.c */ int cmdline_find_option(const char *option, char *buffer, int bufsize); int cmdline_find_option_bool(const char *option); /* early_serial_console.c */ -#ifdef CONFIG_EARLY_PRINTK - extern int early_serial_base; void console_init(void); #else +/* early_serial_console.c */ static const int early_serial_base; static inline void console_init(void) { } From c5e5c42a68be66cb87573e5c2fcce6f1b5d82bd5 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 23 Jul 2012 16:16:17 -0700 Subject: [PATCH 8/8] x86, doc: Assign a bootloader ID for "Minimal Linux Bootloader" Assign a bootloader ID for Sebastian Plotz' "Minimal Linux Bootloader" (http://sebastian-plotz.blogspot.de). Sebastian has agreed to make this the pilot for the use of extended boot loader IDs, so this is assigned version ID 0x11 (avoid assigning 0x10 for now to catch bugs with people putting E in the primary ID but leaving the extended ID as zero.) Signed-off-by: H. Peter Anvin Cc: Sebastian Plotz Link: http://lkml.kernel.org/n/tip-nq318h0okuaem8x9dpv9854k@git.kernel.org --- Documentation/x86/boot.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Documentation/x86/boot.txt b/Documentation/x86/boot.txt index 7c3a8801b7ce..473b32fd544e 100644 --- a/Documentation/x86/boot.txt +++ b/Documentation/x86/boot.txt @@ -363,7 +363,8 @@ Protocol: 2.00+ ext_loader_type <- 0x05 ext_loader_ver <- 0x23 - Assigned boot loader ids: + Assigned boot loader ids (hexadecimal): + 0 LILO (0x00 reserved for pre-2.00 bootloader) 1 Loadlin 2 bootsect-loader (0x20, all other values reserved) @@ -378,6 +379,8 @@ Protocol: 2.00+ C Arcturus Networks uCbootloader E Extended (see ext_loader_type) F Special (0xFF = undefined) + 10 Reserved + 11 Minimal Linux Bootloader Please contact if you need a bootloader ID value assigned.