qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Olivia Yin <hong-hua.yin@freescale.com>
To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org
Cc: Olivia Yin <hong-hua.yin@freescale.com>
Subject: [Qemu-devel] [PATCH 5/5] remove rom related functions in loader
Date: Fri, 26 Oct 2012 16:02:06 +0800	[thread overview]
Message-ID: <1351238526-2551-6-git-send-email-hong-hua.yin@freescale.com> (raw)
In-Reply-To: <1351238526-2551-5-git-send-email-hong-hua.yin@freescale.com>

Signed-off-by: Olivia Yin <hong-hua.yin@freescale.com>
---
 hw/loader.c |  166 -----------------------------------------------------------
 hw/loader.h |   14 -----
 vl.c        |    5 --
 3 files changed, 0 insertions(+), 185 deletions(-)

diff --git a/hw/loader.c b/hw/loader.c
index 5cf776a..5549568 100644
--- a/hw/loader.c
+++ b/hw/loader.c
@@ -54,8 +54,6 @@
 
 #include <zlib.h>
 
-static int roms_loaded;
-
 /* return the size or -1 if error */
 int get_image_size(const char *filename)
 {
@@ -617,172 +615,8 @@ struct Rom {
     QTAILQ_ENTRY(Rom) next;
 };
 
-static FWCfgState *fw_cfg;
 static QTAILQ_HEAD(, Rom) roms = QTAILQ_HEAD_INITIALIZER(roms);
 
-static void rom_insert(Rom *rom)
-{
-    Rom *item;
-
-    if (roms_loaded) {
-        hw_error ("ROM images must be loaded at startup\n");
-    }
-
-    /* list is ordered by load address */
-    QTAILQ_FOREACH(item, &roms, next) {
-        if (rom->addr >= item->addr)
-            continue;
-        QTAILQ_INSERT_BEFORE(item, rom, next);
-        return;
-    }
-    QTAILQ_INSERT_TAIL(&roms, rom, next);
-}
-
-int rom_add_file(const char *file, const char *fw_dir,
-                 target_phys_addr_t addr, int32_t bootindex)
-{
-    Rom *rom;
-    int rc, fd = -1;
-    char devpath[100];
-
-    rom = g_malloc0(sizeof(*rom));
-    rom->name = g_strdup(file);
-    rom->path = qemu_find_file(QEMU_FILE_TYPE_BIOS, rom->name);
-    if (rom->path == NULL) {
-        rom->path = g_strdup(file);
-    }
-
-    fd = open(rom->path, O_RDONLY | O_BINARY);
-    if (fd == -1) {
-        fprintf(stderr, "Could not open option rom '%s': %s\n",
-                rom->path, strerror(errno));
-        goto err;
-    }
-
-    if (fw_dir) {
-        rom->fw_dir  = g_strdup(fw_dir);
-        rom->fw_file = g_strdup(file);
-    }
-    rom->addr    = addr;
-    rom->romsize = lseek(fd, 0, SEEK_END);
-    rom->data    = g_malloc0(rom->romsize);
-    lseek(fd, 0, SEEK_SET);
-    rc = read(fd, rom->data, rom->romsize);
-    if (rc != rom->romsize) {
-        fprintf(stderr, "rom: file %-20s: read error: rc=%d (expected %zd)\n",
-                rom->name, rc, rom->romsize);
-        goto err;
-    }
-    close(fd);
-    rom_insert(rom);
-    if (rom->fw_file && fw_cfg) {
-        const char *basename;
-        char fw_file_name[56];
-
-        basename = strrchr(rom->fw_file, '/');
-        if (basename) {
-            basename++;
-        } else {
-            basename = rom->fw_file;
-        }
-        snprintf(fw_file_name, sizeof(fw_file_name), "%s/%s", rom->fw_dir,
-                 basename);
-        fw_cfg_add_file(fw_cfg, fw_file_name, rom->data, rom->romsize);
-        snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name);
-    } else {
-        snprintf(devpath, sizeof(devpath), "/rom@" TARGET_FMT_plx, addr);
-    }
-
-    add_boot_device_path(bootindex, NULL, devpath);
-    return 0;
-
-err:
-    if (fd != -1)
-        close(fd);
-    g_free(rom->data);
-    g_free(rom->path);
-    g_free(rom->name);
-    g_free(rom);
-    return -1;
-}
-
-int rom_add_blob(const char *name, const void *blob, size_t len,
-                 target_phys_addr_t addr)
-{
-    Rom *rom;
-
-    rom = g_malloc0(sizeof(*rom));
-    rom->name    = g_strdup(name);
-    rom->addr    = addr;
-    rom->romsize = len;
-    rom->data    = g_malloc0(rom->romsize);
-    memcpy(rom->data, blob, len);
-    rom_insert(rom);
-    return 0;
-}
-
-int rom_add_vga(const char *file)
-{
-    return rom_add_file(file, "vgaroms", 0, -1);
-}
-
-int rom_add_option(const char *file, int32_t bootindex)
-{
-    return rom_add_file(file, "genroms", 0, bootindex);
-}
-
-static void rom_reset(void *unused)
-{
-    Rom *rom;
-
-    QTAILQ_FOREACH(rom, &roms, next) {
-        if (rom->fw_file) {
-            continue;
-        }
-        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 */
-            g_free(rom->data);
-            rom->data = NULL;
-        }
-    }
-}
-
-int rom_load_all(void)
-{
-    target_phys_addr_t addr = 0;
-    MemoryRegionSection section;
-    Rom *rom;
-
-    QTAILQ_FOREACH(rom, &roms, next) {
-        if (rom->fw_file) {
-            continue;
-        }
-        if (addr > rom->addr) {
-            fprintf(stderr, "rom: requested regions overlap "
-                    "(rom %s. free=0x" TARGET_FMT_plx
-                    ", addr=0x" TARGET_FMT_plx ")\n",
-                    rom->name, addr, rom->addr);
-            return -1;
-        }
-        addr  = rom->addr;
-        addr += rom->romsize;
-        section = memory_region_find(get_system_memory(), rom->addr, 1);
-        rom->isrom = section.size && memory_region_is_rom(section.mr);
-    }
-    qemu_register_reset(rom_reset, NULL);
-    roms_loaded = 1;
-    return 0;
-}
-
-void rom_set_fw(void *f)
-{
-    fw_cfg = f;
-}
-
 static Rom *find_rom(target_phys_addr_t addr)
 {
     Rom *rom;
diff --git a/hw/loader.h b/hw/loader.h
index e9dc4df..a2b537d 100644
--- a/hw/loader.h
+++ b/hw/loader.h
@@ -21,31 +21,17 @@ 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,
-                 target_phys_addr_t addr, int32_t bootindex);
-int rom_add_blob(const char *name, const void *blob, size_t len,
-                 target_phys_addr_t addr);
-int rom_load_all(void);
 void rom_set_fw(void *f);
 int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size);
 void *rom_ptr(target_phys_addr_t addr);
 void do_info_roms(Monitor *mon);
 
-#define rom_add_file_fixed(_f, _a, _i)          \
-    rom_add_file(_f, NULL, _a, _i)
-#define rom_add_blob_fixed(_f, _b, _l, _a)      \
-    rom_add_blob(_f, _b, _l, _a)
-
 #define PC_ROM_MIN_VGA     0xc0000
 #define PC_ROM_MIN_OPTION  0xc8000
 #define PC_ROM_MAX         0xe0000
 #define PC_ROM_ALIGN       0x800
 #define PC_ROM_SIZE        (PC_ROM_MAX - PC_ROM_MIN_VGA)
 
-int rom_add_vga(const char *file);
-int rom_add_option(const char *file, int32_t bootindex);
-
 typedef struct ImageFile ImageFile;
 struct ImageFile {
     char *name;
diff --git a/vl.c b/vl.c
index 4bd1623..752162f 100644
--- a/vl.c
+++ b/vl.c
@@ -3761,11 +3761,6 @@ int main(int argc, char **argv, char **envp)
 
     qdev_machine_creation_done();
 
-    if (rom_load_all() != 0) {
-        fprintf(stderr, "rom loading failed\n");
-        exit(1);
-    }
-
     /* TODO: once all bus devices are qdevified, this should be done
      * when bus is created by qdev.c */
     qemu_register_reset(qbus_reset_all_fn, sysbus_get_default());
-- 
1.7.1

  reply	other threads:[~2012-10-26  8:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26  8:02 [Qemu-devel] [PATCH 0/5] register reset handlers to reload image Olivia Yin
2012-10-26  8:02 ` [Qemu-devel] [PATCH 1/5] define image_file_reset and image_blob_reset Olivia Yin
2012-10-26  8:02   ` [Qemu-devel] [PATCH 2/5] use reset handlers to reload kernel and initrd Olivia Yin
2012-10-26  8:02     ` [Qemu-devel] [PATCH 3/5] replace rom_add_file* with image_file_reset Olivia Yin
2012-10-26  8:02       ` [Qemu-devel] [PATCH 4/5] replaece rom_add_blob* with image_blob_reset Olivia Yin
2012-10-26  8:02         ` Olivia Yin [this message]
2012-10-26  9:32     ` [Qemu-devel] [PATCH 2/5] use reset handlers to reload kernel and initrd 陳韋任 (Wei-Ren Chen)
2012-10-29  5:12       ` Yin Olivia-R63875
2012-10-26  9:28   ` [Qemu-devel] [PATCH 1/5] define image_file_reset and image_blob_reset 陳韋任 (Wei-Ren Chen)
2012-10-26  9:17 ` [Qemu-devel] [PATCH 0/5] register reset handlers to reload image 陳韋任 (Wei-Ren Chen)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351238526-2551-6-git-send-email-hong-hua.yin@freescale.com \
    --to=hong-hua.yin@freescale.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).