On Mon, Feb 4, 2013 at 2:27 AM, liguang lig.fnst@cn.fujitsu.com wrote:
it's not necessary to alloc 8K bytes for kernel header, 0.5K is enough.
Signed-off-by: liguang lig.fnst@cn.fujitsu.com
hw/pc.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c index 0ccd775..b6b236f 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -637,6 +637,9 @@ static long get_file_size(FILE *f) return size; }
+#define HEADER_SIZE 0x200 +#define HEADER_SIGNATURE 0x53726448
static void load_linux(void *fw_cfg, const char *kernel_filename, const char *initrd_filename, @@ -646,7 +649,7 @@ static void load_linux(void *fw_cfg, uint16_t protocol; int setup_size, kernel_size, initrd_size = 0, cmdline_size; uint32_t initrd_max;
- uint8_t header[8192], *setup, *kernel, *initrd_data;
- uint8_t header[HEADER_SIZE], *setup, *kernel, *initrd_data; hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0; FILE *f; char *vmode;
@@ -665,8 +668,7 @@ static void load_linux(void *fw_cfg, fprintf(stderr, "can't get size of kernel image file\n"); exit(1); }
- if (fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) !=
MIN(ARRAY_SIZE(header), kernel_size)) {
- if (fread(header, 1, HEADER_SIZE, f) <= 0) { fprintf(stderr, "qemu: could not load kernel '%s': %s\n", kernel_filename, strerror(errno)); exit(1);
@@ -676,7 +678,7 @@ static void load_linux(void *fw_cfg, #if 0 fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202)); #endif
- if (ldl_p(header+0x202) == 0x53726448)
- if (ldl_p(header+0x202) == HEADER_SIGNATURE)
Please add braces while touching the line and add spaces around '+'. Maybe you have not checked the patches with checkpatch.pl?
protocol = lduw_p(header+0x206); else { /* This looks like a multiboot kernel. If it is, let's stop
-- 1.7.2.5