From patchwork Fri Feb 22 04:15:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liguang X-Patchwork-Id: 222465 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 30D1A2C029D for ; Fri, 22 Feb 2013 15:53:10 +1100 (EST) Received: from localhost ([::1]:41020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8k3T-00088M-5B for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2013 23:16:15 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8k31-0007AR-H2 for qemu-devel@nongnu.org; Thu, 21 Feb 2013 23:15:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8k2y-0005Xh-P1 for qemu-devel@nongnu.org; Thu, 21 Feb 2013 23:15:47 -0500 Received: from [222.73.24.84] (port=33173 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8k2x-0005X8-GA for qemu-devel@nongnu.org; Thu, 21 Feb 2013 23:15:44 -0500 X-IronPort-AV: E=Sophos;i="4.84,713,1355068800"; d="scan'208";a="6747021" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 22 Feb 2013 12:13:22 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r1M4FHP3017362 for ; Fri, 22 Feb 2013 12:15:18 +0800 Received: from liguang.fnst.cn.fujitsu.com ([10.167.225.128]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2013022212143488-334891 ; Fri, 22 Feb 2013 12:14:34 +0800 From: liguang To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2013 12:15:31 +0800 Message-Id: <1361506533-28463-5-git-send-email-lig.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1361506533-28463-1-git-send-email-lig.fnst@cn.fujitsu.com> References: <1361506533-28463-1-git-send-email-lig.fnst@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/02/22 12:14:35, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2013/02/22 12:14:37, Serialize complete at 2013/02/22 12:14:37 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 222.73.24.84 Cc: liguang Subject: [Qemu-devel] [PATCH v2 4/6] pc: format load_linux() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org seems this function was in wrong coding format so try correct it boldly. Signed-off-by: liguang --- hw/pc.c | 90 +++++++++++++++++++++++++++++++------------------------------- 1 files changed, 45 insertions(+), 45 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index f227c12..fd3a68c 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -639,8 +639,8 @@ static long get_file_size(FILE *f) static void load_linux(void *fw_cfg, const char *kernel_filename, - const char *initrd_filename, - const char *kernel_cmdline, + const char *initrd_filename, + const char *kernel_cmdline, hwaddr max_ram_size) { uint16_t protocol; @@ -657,11 +657,11 @@ static void load_linux(void *fw_cfg, /* load the kernel header */ f = fopen(kernel_filename, "rb"); if (!f || !(kernel_size = get_file_size(f)) || - fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) != - MIN(ARRAY_SIZE(header), kernel_size)) { - fprintf(stderr, "qemu: could not load kernel '%s': %s\n", - kernel_filename, strerror(errno)); - exit(1); + fread(header, 1, MIN(ARRAY_SIZE(header), kernel_size), f) != + MIN(ARRAY_SIZE(header), kernel_size)) { + fprintf(stderr, "qemu: could not load kernel '%s': %s\n", + kernel_filename, strerror(errno)); + exit(1); } /* kernel protocol version */ @@ -669,48 +669,48 @@ static void load_linux(void *fw_cfg, fprintf(stderr, "header magic: %#x\n", ldl_p(header+0x202)); #endif if (ldl_p(header+0x202) == 0x53726448) - protocol = lduw_p(header+0x206); + protocol = lduw_p(header+0x206); else { - /* This looks like a multiboot kernel. If it is, let's stop - treating it like a Linux kernel. */ + /* 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)) return; - protocol = 0; + protocol = 0; } if (protocol < 0x200 || !(header[0x211] & 0x01)) { - /* Low kernel */ - real_addr = 0x90000; - cmdline_addr = 0x9a000 - cmdline_size; - prot_addr = 0x10000; + /* Low kernel */ + real_addr = 0x90000; + cmdline_addr = 0x9a000 - cmdline_size; + prot_addr = 0x10000; } else if (protocol < 0x202) { - /* High but ancient kernel */ - real_addr = 0x90000; - cmdline_addr = 0x9a000 - cmdline_size; - prot_addr = 0x100000; + /* High but ancient kernel */ + real_addr = 0x90000; + cmdline_addr = 0x9a000 - cmdline_size; + prot_addr = 0x100000; } else { - /* High and recent kernel */ - real_addr = 0x10000; - cmdline_addr = 0x20000; - prot_addr = 0x100000; + /* High and recent kernel */ + real_addr = 0x10000; + cmdline_addr = 0x20000; + prot_addr = 0x100000; } #if 0 fprintf(stderr, - "qemu: real_addr = 0x" TARGET_FMT_plx "\n" - "qemu: cmdline_addr = 0x" TARGET_FMT_plx "\n" - "qemu: prot_addr = 0x" TARGET_FMT_plx "\n", - real_addr, - cmdline_addr, - prot_addr); + "qemu: real_addr = 0x" TARGET_FMT_plx "\n" + "qemu: cmdline_addr = 0x" TARGET_FMT_plx "\n" + "qemu: prot_addr = 0x" TARGET_FMT_plx "\n", + real_addr, + cmdline_addr, + prot_addr); #endif /* highest address for loading the initrd */ if (protocol >= 0x203) - initrd_max = ldl_p(header+0x22c); + initrd_max = ldl_p(header+0x22c); else - initrd_max = 0x37ffffff; + initrd_max = 0x37ffffff; if (initrd_max >= max_ram_size-ACPI_DATA_SIZE) initrd_max = max_ram_size-ACPI_DATA_SIZE-1; @@ -720,10 +720,10 @@ static void load_linux(void *fw_cfg, fw_cfg_add_string(fw_cfg, FW_CFG_CMDLINE_DATA, kernel_cmdline); if (protocol >= 0x202) { - stl_p(header+0x228, cmdline_addr); + stl_p(header+0x228, cmdline_addr); } else { - stw_p(header+0x20, 0xA33F); - stw_p(header+0x22, cmdline_addr-real_addr); + stw_p(header+0x20, 0xA33F); + stw_p(header+0x22, cmdline_addr-real_addr); } /* handle vga= parameter */ @@ -749,22 +749,22 @@ static void load_linux(void *fw_cfg, If this code is substantially changed, you may want to consider incrementing the revision. */ if (protocol >= 0x200) - header[0x210] = 0xB0; + header[0x210] = 0xB0; /* heap */ if (protocol >= 0x201) { - header[0x211] |= 0x80; /* CAN_USE_HEAP */ - stw_p(header+0x224, cmdline_addr-real_addr-0x200); + header[0x211] |= 0x80; /* CAN_USE_HEAP */ + stw_p(header+0x224, cmdline_addr-real_addr-0x200); } /* load initrd */ if (initrd_filename) { - if (protocol < 0x200) { - fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n"); - exit(1); - } + if (protocol < 0x200) { + fprintf(stderr, "qemu: linux kernel too old to load a ram disk\n"); + exit(1); + } - initrd_size = get_image_size(initrd_filename); + initrd_size = get_image_size(initrd_filename); if (initrd_size < 0) { fprintf(stderr, "qemu: error reading initrd %s\n", initrd_filename); @@ -780,14 +780,14 @@ static void load_linux(void *fw_cfg, fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, initrd_size); fw_cfg_add_bytes(fw_cfg, FW_CFG_INITRD_DATA, initrd_data, initrd_size); - stl_p(header+0x218, initrd_addr); - stl_p(header+0x21c, initrd_size); + stl_p(header+0x218, initrd_addr); + stl_p(header+0x21c, initrd_size); } /* load kernel and setup */ setup_size = header[0x1f1]; if (setup_size == 0) - setup_size = 4; + setup_size = 4; setup_size = (setup_size+1)*512; kernel_size -= setup_size;