hw/i386/pc: format load_linux function

Signed-off-by: liguang <lig.fnst@cn.fujitsu.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
liguang 2013-03-26 16:43:19 +08:00 committed by Stefan Hajnoczi
parent 9941afdef4
commit 0f9d76e5a9
1 changed files with 56 additions and 53 deletions

View File

@ -675,14 +675,15 @@ 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) == 0x53726448) {
protocol = lduw_p(header+0x206);
else {
} else {
/* This looks like a multiboot kernel. If it is, let's stop
treating it like a Linux kernel. */
if (load_multiboot(fw_cfg, f, kernel_filename, initrd_filename,
kernel_cmdline, kernel_size, header))
kernel_cmdline, kernel_size, header)) {
return;
}
protocol = 0;
}
@ -714,10 +715,11 @@ static void load_linux(void *fw_cfg,
#endif
/* highest address for loading the initrd */
if (protocol >= 0x203)
if (protocol >= 0x203) {
initrd_max = ldl_p(header+0x22c);
else
} else {
initrd_max = 0x37ffffff;
}
if (initrd_max >= max_ram_size-ACPI_DATA_SIZE)
initrd_max = max_ram_size-ACPI_DATA_SIZE-1;
@ -755,9 +757,9 @@ static void load_linux(void *fw_cfg,
/* High nybble = B reserved for QEMU; low nybble is revision number.
If this code is substantially changed, you may want to consider
incrementing the revision. */
if (protocol >= 0x200)
if (protocol >= 0x200) {
header[0x210] = 0xB0;
}
/* heap */
if (protocol >= 0x201) {
header[0x211] |= 0x80; /* CAN_USE_HEAP */
@ -793,8 +795,9 @@ static void load_linux(void *fw_cfg,
/* load kernel and setup */
setup_size = header[0x1f1];
if (setup_size == 0)
if (setup_size == 0) {
setup_size = 4;
}
setup_size = (setup_size+1)*512;
kernel_size -= setup_size;