[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1191404221.17247.15.camel@feisty>
Date: Wed, 03 Oct 2007 10:37:01 +0100
From: Chris Malley <mail@...ismalley.co.uk>
To: Rusty Russell <rusty@...tcorp.com.au>
Cc: lkml - Kernel Mailing List <linux-kernel@...r.kernel.org>,
Jeremy Fitzhardinge <jeremy@...p.org>,
lguest <lguest@...abs.org>,
James Bottomley <James.Bottomley@...senPartnership.com>,
Vivek Goyal <vgoyal@...ibm.com>,
"Eric W. Biederman" <ebiederm@...ssion.com>,
"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH 5/5] lguest: loading bzImage directly
Hi guys
Would it not be clearer to #include <asm/bootparam.h> and use
the relevant named members of struct setup_header / struct boot_params
rather than the hard-coded values 0x202, 0x1F1, 0x214 ?
--
Chris
On Wed, 2007-10-03 at 09:40 +1000, Rusty Russell wrote:
[snip]
> + u8 hdr[1024];
> + int r;
> + /* Modern bzImages get loaded at 1M. */
> + void *p = from_guest_phys(0x100000);
> +
> + /* Go back to the start of the file and read the header. It should be
> + * a Linux boot header (see Documentation/i386/boot.txt) */
> + lseek(fd, 0, SEEK_SET);
> + read(fd, hdr, sizeof(hdr));
> +
> + /* At offset 0x202, we expect the magic "HdrS" */
> + if (memcmp(hdr + 0x202, "HdrS", 4) != 0)
> + errx(1, "This doesn't look like a bzImage to me");
> +
> + /* The byte at 0x1F1 tells us how many extra sectors of
> + * header: skip over them all. */
> + lseek(fd, (unsigned long)(hdr[0x1F1]+1) * 512, SEEK_SET);
> +
> + /* Now read everything into memory. in nice big chunks. */
> + while ((r = read(fd, p, 65536)) > 0)
> + p += r;
> +
> + /* Finally, 0x214 tells us where to start the kernel. */
> + return *(unsigned long *)&hdr[0x214];
> }
>
> /*L:140 Loading the kernel is easy when it's a "vmlinux", but most kernels
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists