lkml.org 
[lkml]   [2007]   [Oct]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 5/5] lguest: loading bzImage directly
From
Date
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-10-03 11:47    [W:0.100 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site