[PATCH 1/2 v3] Use structs instead of hardcoded offsets in x86 boot decompressor.

Previous thread: cpufreq pull req by Dave Jones on Thursday, May 29, 2008 - 9:47 am. (1 message)

Next thread: ×@===== 賺人民幣 ===== >&﹦@?? by kong tank on Thursday, May 29, 2008 - 10:30 am. (1 message)
From: Kristian Høgsberg
Date: Thursday, May 29, 2008 - 10:27 am

Just a minor cleanup, making it easier to access the command line in
the following "Honor quiet in decompressor" patch.

Signed-off-by: Kristian Høgsberg <krh@redhat.com>

---

Updated this one to be less intrusive; we just re-#define RM_SCREEN_INFO to
access the boot_params struct instead of using the hard-coded offset.

 arch/x86/boot/compressed/misc.c |   10 +++-------
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 90456ce..102b68e 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -30,6 +30,7 @@
 #include <asm/io.h>
 #include <asm/page.h>
 #include <asm/boot.h>
+#include <asm/bootparam.h>
 
 /* WARNING!!
  * This code is compiled with -fPIC and it is relocated dynamically
@@ -187,13 +188,8 @@ static void gzip_release(void **);
 /*
  * This is set up by the setup-routine at boot-time
  */
-static unsigned char *real_mode; /* Pointer to real-mode data */
-
-#define RM_EXT_MEM_K   (*(unsigned short *)(real_mode + 0x2))
-#ifndef STANDARD_MEMORY_BIOS_CALL
-#define RM_ALT_MEM_K   (*(unsigned long *)(real_mode + 0x1e0))
-#endif
-#define RM_SCREEN_INFO (*(struct screen_info *)(real_mode+0))
+static struct boot_params *real_mode;		/* Pointer to real-mode data */
+#define RM_SCREEN_INFO (real_mode->screen_info)
 
 extern unsigned char input_data[];
 extern int input_len;
-- 
1.5.4.5

--

From: Kristian Høgsberg
Date: Thursday, May 29, 2008 - 10:27 am

This patch lets the early real mode decompressor parse the kernel
command line and look for the 'quiet' option.  When 'quiet' is passed
we suppress the "Decompressing Linux... Parsing ELF... done." messages.

This is in line with how the rest of the kernel suppresses informational
debug spew when quiet is given.

Signed-off-by: Kristian H
From: H. Peter Anvin
Date: Thursday, May 29, 2008 - 11:43 am

You know... we already have a command-line parser in the real-mode part 
of the boot code, and it already extracts the "quiet" option: we should 
be able to do this by passing a bit in "loadflags" (bit 5 suggested.) 
This would have the additional benefit of making it really easy for 
hypervisors that don't support writing to the screen at all to disable 
those messages.

What do you think?

	-hpa
--

From: Kristian
Date: Thursday, May 29, 2008 - 12:55 pm

Hmm, as far as I understand the boot code, the decompressor consists of
just head_32/64.S and misc.c plus the #included inflate.c and the
compressed image in piggy.o.  In this environment there is no command
line parser, it's only available once the image has been decompressed.

Or are you suggesting parsing the "quiet" option in the bootloader and
then setting the loadflags bit from there?  That's certainly doable, and
I can update grub accordingly, but just parsing the command line seems
like a simple, more local fix.  I don't have a strong preference,
though.

cheers,
Kristian


--

From: H. Peter Anvin
Date: Thursday, May 29, 2008 - 1:30 pm

I think you're missing something: the decompressor is the *second stage* 
of the boot code; the first stage is the real-mode code (arch/x86/boot). 
  I'm suggesting passing the flag from the real-mode code to the 
decompressor, not from the boot loader (in the common case.)

	-hpa
--

From: Kristian
Date: Thursday, May 29, 2008 - 3:25 pm

Indeed, I had it the wrong way around.  I like the bootflag approach,
updated patches coming up.

thanks,
Kristian


--

From: H. Peter Anvin
Date: Thursday, May 29, 2008 - 11:48 am

Any reason to leave it in as a macro at all, instead of just 
s/RM_SCREEN_INFO/real_mode->screen_info/g?

We have already gotten rid of most of these macros in the primary kernel.

	-hpa

P.S. Sorry for not giving you feedback sooner.
--

From: Kristian
Date: Thursday, May 29, 2008 - 12:58 pm

Only to keep the patch smaller.  Accessing the struct directly is
definitely nicer, I'll do the sed job when I resubmit with the other
patch.

cheers,
Kristian

--

Previous thread: cpufreq pull req by Dave Jones on Thursday, May 29, 2008 - 9:47 am. (1 message)

Next thread: ×@===== 賺人民幣 ===== >&﹦@?? by kong tank on Thursday, May 29, 2008 - 10:30 am. (1 message)