From patchwork Fri Jan 8 14:25:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 42505 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A6771B7C06 for ; Sat, 9 Jan 2010 01:30:01 +1100 (EST) Received: from localhost ([127.0.0.1]:35284 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTFqf-0005MS-S9 for incoming@patchwork.ozlabs.org; Fri, 08 Jan 2010 09:29:57 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NTFmk-0003Gb-1M for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:54 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NTFmf-0003Ce-IZ for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:53 -0500 Received: from [199.232.76.173] (port=43421 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NTFmf-0003C6-19 for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41330) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NTFme-0006JW-Cc for qemu-devel@nongnu.org; Fri, 08 Jan 2010 09:25:48 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o08EPlRw001992 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 8 Jan 2010 09:25:47 -0500 Received: from zweiblum.home.kraxel.org (vpn2-11-198.ams2.redhat.com [10.36.11.198]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o08EPiEH007567; Fri, 8 Jan 2010 09:25:45 -0500 Received: by zweiblum.home.kraxel.org (Postfix, from userid 500) id 666BC70FCF; Fri, 8 Jan 2010 15:25:42 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Fri, 8 Jan 2010 15:25:38 +0100 Message-Id: <1262960742-18267-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1262960742-18267-1-git-send-email-kraxel@redhat.com> References: <1262960742-18267-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Gerd Hoffmann Subject: [Qemu-devel] [PATCH 2/6] roms: minor fixes and cleanups. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Changes: - Drop extra file argument from rom_add_file(). - Drop fw_dir check in do_info_roms, we allways have a dir name. - code style fixes. Signed-off-by: Gerd Hoffmann --- hw/loader.c | 38 +++++++++++++++++++++++--------------- hw/loader.h | 5 +++-- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/hw/loader.c b/hw/loader.c index 3aba47c..38ee2da 100644 --- a/hw/loader.c +++ b/hw/loader.c @@ -556,7 +556,7 @@ static void rom_insert(Rom *rom) QTAILQ_INSERT_TAIL(&roms, rom, next); } -int rom_add_file(const char *file, const char *fw_dir, const char *fw_file, +int rom_add_file(const char *file, const char *fw_dir, target_phys_addr_t addr) { Rom *rom; @@ -576,8 +576,10 @@ int rom_add_file(const char *file, const char *fw_dir, const char *fw_file, goto err; } - rom->fw_dir = fw_dir ? qemu_strdup(fw_dir) : NULL; - rom->fw_file = fw_file ? qemu_strdup(fw_file) : NULL; + if (fw_dir) { + rom->fw_dir = qemu_strdup(fw_dir); + rom->fw_file = qemu_strdup(file); + } rom->addr = addr; rom->romsize = lseek(fd, 0, SEEK_END); rom->data = qemu_mallocz(rom->romsize); @@ -621,14 +623,14 @@ int rom_add_vga(const char *file) { if (!rom_enable_driver_roms) return 0; - return rom_add_file(file, "vgaroms", file, 0); + return rom_add_file(file, "vgaroms", 0); } int rom_add_option(const char *file) { if (!rom_enable_driver_roms) return 0; - return rom_add_file(file, "genroms", file, 0); + return rom_add_file(file, "genroms", 0); } static void rom_reset(void *unused) @@ -639,8 +641,9 @@ static void rom_reset(void *unused) if (rom->fw_file) { continue; } - if (rom->data == NULL) + if (rom->data == NULL) { continue; + } cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize); if (rom->isrom) { /* rom needs to be written only once */ @@ -683,8 +686,9 @@ int rom_load_fw(void *fw_cfg) Rom *rom; QTAILQ_FOREACH(rom, &roms, next) { - if (!rom->fw_file) + if (!rom->fw_file) { continue; + } fw_cfg_add_file(fw_cfg, rom->fw_dir, rom->fw_file, rom->data, rom->romsize); } return 0; @@ -698,10 +702,12 @@ static Rom *find_rom(target_phys_addr_t addr) if (rom->fw_file) { continue; } - if (rom->addr > addr) + if (rom->addr > addr) { continue; - if (rom->addr + rom->romsize < addr) + } + if (rom->addr + rom->romsize < addr) { continue; + } return rom; } return NULL; @@ -723,12 +729,15 @@ int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size) if (rom->fw_file) { continue; } - if (rom->addr + rom->romsize < addr) + if (rom->addr + rom->romsize < addr) { continue; - if (rom->addr > end) + } + if (rom->addr > end) { break; - if (!rom->data) + } + if (!rom->data) { continue; + } d = dest + (rom->addr - addr); s = rom->data; @@ -771,10 +780,9 @@ void do_info_roms(Monitor *mon) rom->isrom ? "rom" : "ram", rom->name); } else { - monitor_printf(mon, "fw=%s%s%s" + monitor_printf(mon, "fw=%s/%s" " size=0x%06zx name=\"%s\" \n", - rom->fw_dir ? rom->fw_dir : "", - rom->fw_dir ? "/" : "", + rom->fw_dir, rom->fw_file, rom->romsize, rom->name); diff --git a/hw/loader.h b/hw/loader.h index 77beb0e..698160b 100644 --- a/hw/loader.h +++ b/hw/loader.h @@ -19,7 +19,8 @@ void pstrcpy_targphys(const char *name, target_phys_addr_t dest, int buf_size, const char *source); -int rom_add_file(const char *file, const char *fw_dir, const char *fw_file, + +int rom_add_file(const char *file, const char *fw_dir, target_phys_addr_t addr); int rom_add_blob(const char *name, const void *blob, size_t len, target_phys_addr_t addr); @@ -30,7 +31,7 @@ void *rom_ptr(target_phys_addr_t addr); void do_info_roms(Monitor *mon); #define rom_add_file_fixed(_f, _a) \ - rom_add_file(_f, NULL, NULL, _a) + rom_add_file(_f, NULL, _a) #define rom_add_blob_fixed(_f, _b, _l, _a) \ rom_add_blob(_f, _b, _l, _a)