aboutsummaryrefslogtreecommitdiff
path: root/hw/loader.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2010-01-08 15:25:38 +0100
committerAnthony Liguori <aliguori@us.ibm.com>2010-01-11 13:41:00 -0600
commitbdb5ee3064d5ae786b0bcb6cf6ff4e3554a72990 (patch)
tree929cf6f134782c6cf8370c9fd0a0e1f1da611a77 /hw/loader.c
parent2cae6f5e34d85fe44ec2329a7fbc22dc8cfb079f (diff)
roms: minor fixes and cleanups.
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 <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/loader.c')
-rw-r--r--hw/loader.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/hw/loader.c b/hw/loader.c
index 3aba47c6a7..38ee2daf2a 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);