Skip to contentSkip to conversation

more rom loader patches.

PATCH New Gerd Hoffmann 1 participant 5 messages Oct 26, 2009

lore
Share & tools
lore
#0 lore raw

v4 cover more rom loader patches.

Hi,

A collection of rom loader bits, check individual patches for details.

One more change for rom_add_{vga,option}. We are simply using a variable now to enable rom loading, so different TARGET_I386 machine types can have different behavior here. pc98 support needs this.

cheers,
Gerd

#1 lore raw

PATCH v4 1/4 rom loader: use qemu_strdup.

---
 hw/loader.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
hw/loader.c +1 -1
index 7aa1a67..6baafa8 100644
@@ -559,7 +559,7 @@ int rom_add_file(const char *file,
     rom->name = qemu_strdup(file);
     rom->path = qemu_find_file(QEMU_FILE_TYPE_BIOS, rom->name);
     if (rom->path == NULL) {
-        rom->path = strdup(file);
+        rom->path = qemu_strdup(file);
     }
 
     fd = open(rom->path, O_RDONLY | O_BINARY);
Signature · 1 line
1.6.2.5
#2 lore raw

PATCH v4 2/4 rom loader: make vga+rom loading configurable.

In reply to Gerd Hoffmann

The rom_add_vga() and rom_add_option() macros are transformed into functions. They look at the new rom_enable_driver_roms variable and only do something if it is set to non-zero, making vga+option rom loading runtime option. pc_init() sets rom_enable_driver_roms to 1.

With this in place we can move the rom loading calls from pc.c to the individual drivers.

---
 hw/loader.c |   15 +++++++++++++++
 hw/loader.h |    7 +++----
 hw/pc.c     |    1 +
 3 files changed, 19 insertions(+), 4 deletions(-)
hw/loader.c +15 -0
index 6baafa8..a08585b 100644
@@ -534,6 +534,7 @@ struct Rom {
 };
 
 static QTAILQ_HEAD(, Rom) roms = QTAILQ_HEAD_INITIALIZER(roms);
+int rom_enable_driver_roms;
 
 static void rom_insert(Rom *rom)
 {
@@ -612,6 +613,20 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
     return 0;
 }
 
+int rom_add_vga(const char *file)
+{
+    if (!rom_enable_driver_roms)
+        return 0;
+    return rom_add_file(file, PC_ROM_MIN_VGA, PC_ROM_MAX, PC_ROM_ALIGN);
+}
+
+int rom_add_option(const char *file)
+{
+    if (!rom_enable_driver_roms)
+        return 0;
+    return rom_add_file(file, PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN);
+}
+
 static void rom_reset(void *unused)
 {
     Rom *rom;
hw/loader.h +3 -4
index 945c662..67dae57 100644
@@ -38,9 +38,8 @@ void do_info_roms(Monitor *mon);
 #define PC_ROM_ALIGN       0x800
 #define PC_ROM_SIZE        (PC_ROM_MAX - PC_ROM_MIN_VGA)
 
-#define rom_add_vga(_f)                                                 \
-    rom_add_file(_f, PC_ROM_MIN_VGA,    PC_ROM_MAX, PC_ROM_ALIGN)
-#define rom_add_option(_f)                                              \
-    rom_add_file(_f, PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN)
+extern int rom_enable_driver_roms;
+int rom_add_vga(const char *file);
+int rom_add_option(const char *file);
 
 #endif
hw/pc.c +1 -0
index 408d6d6..09d60ed 100644
@@ -1137,6 +1137,7 @@ static void pc_init1(ram_addr_t ram_size,
 
 
 
+    rom_enable_driver_roms = 1;
     option_rom_offset = qemu_ram_alloc(PC_ROM_SIZE);
     cpu_register_physical_memory(PC_ROM_MIN_VGA, PC_ROM_SIZE, option_rom_offset);
 
Signature · 1 line
1.6.2.5
#3 lore raw

PATCH v4 3/4 vga roms: move loading from pc.c to vga drivers.

In reply to Gerd Hoffmann
---
 hw/cirrus_vga.c |    6 +++++-
 hw/pc.c         |   12 ------------
 hw/vga-isa.c    |    3 +++
 hw/vga-pci.c    |    4 ++++
 hw/vga_int.h    |    2 ++
 5 files changed, 14 insertions(+), 13 deletions(-)
hw/cirrus_vga.c +5 -1
index 9dfe76a..f4c9cdf 100644
@@ -32,6 +32,7 @@
 #include "console.h"
 #include "vga_int.h"
 #include "kvm.h"
+#include "loader.h"
 
 /*
  * TODO:
@@ -3162,6 +3163,7 @@ void isa_cirrus_vga_init(void)
                                      s->vga.screen_dump, s->vga.text_update,
                                      &s->vga);
     vmstate_register(0, &vmstate_cirrus_vga, s);
+    rom_add_vga(VGABIOS_CIRRUS_FILENAME);
     /* XXX ISA-LFB support */
 }
 
@@ -3245,7 +3247,9 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
                           PCI_ADDRESS_SPACE_MEM, cirrus_pci_mmio_map);
      }
      vmstate_register(0, &vmstate_pci_cirrus_vga, d);
-     /* XXX: ROM BIOS */
+
+     /* ROM BIOS */
+     rom_add_vga(VGABIOS_CIRRUS_FILENAME);
      return 0;
 }
 
hw/pc.c +0 -12
index 09d60ed..9e34104 100644
@@ -47,8 +47,6 @@
 //#define DEBUG_MULTIBOOT
 
 #define BIOS_FILENAME "bios.bin"
-#define VGABIOS_FILENAME "vgabios.bin"
-#define VGABIOS_CIRRUS_FILENAME "vgabios-cirrus.bin"
 
 #define PC_MAX_BIOS_SIZE (4 * 1024 * 1024)
 
@@ -1050,7 +1048,6 @@ static void pc_init1(ram_addr_t ram_size,
     IsaIrqState *isa_irq_state;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
     DriveInfo *fd[MAX_FD];
-    int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
     void *fw_cfg;
 
     if (ram_size >= 0xe0000000 ) {
@@ -1141,15 +1138,6 @@ static void pc_init1(ram_addr_t ram_size,
     option_rom_offset = qemu_ram_alloc(PC_ROM_SIZE);
     cpu_register_physical_memory(PC_ROM_MIN_VGA, PC_ROM_SIZE, option_rom_offset);
 
-    if (using_vga) {
-        /* VGA BIOS load */
-        if (cirrus_vga_enabled) {
-            rom_add_vga(VGABIOS_CIRRUS_FILENAME);
-        } else {
-            rom_add_vga(VGABIOS_FILENAME);
-        }
-    }
-
     /* map all the bios at the top of memory */
     cpu_register_physical_memory((uint32_t)(-bios_size),
                                  bios_size, bios_offset | IO_MEM_ROM);
hw/vga-isa.c +3 -0
index 7fa31d3..6b387af 100644
@@ -27,6 +27,7 @@
 #include "vga_int.h"
 #include "pixel_ops.h"
 #include "qemu-timer.h"
+#include "loader.h"
 
 int isa_vga_init(void)
 {
@@ -46,5 +47,7 @@ int isa_vga_init(void)
     cpu_register_physical_memory(VBE_DISPI_LFB_PHYSICAL_ADDRESS,
                                  VGA_RAM_SIZE, s->vram_offset);
 #endif
+    /* ROM BIOS */
+    rom_add_vga(VGABIOS_FILENAME);
     return 0;
 }
hw/vga-pci.c +4 -0
index 5e75938..b5fd666 100644
@@ -28,6 +28,7 @@
 #include "vga_int.h"
 #include "pixel_ops.h"
 #include "qemu-timer.h"
+#include "loader.h"
 
 typedef struct PCIVGAState {
     PCIDevice dev;
@@ -117,6 +118,9 @@ static int pci_vga_initfn(PCIDevice *dev)
         pci_register_bar(&d->dev, PCI_ROM_SLOT, bios_total_size,
                          PCI_ADDRESS_SPACE_MEM_PREFETCH, vga_map);
      }
+
+     /* ROM BIOS */
+     rom_add_vga(VGABIOS_FILENAME);
      return 0;
 }
 
hw/vga_int.h +2 -0
index c162c07..b843e52 100644
@@ -220,6 +220,8 @@ extern const uint8_t sr_mask[8];
 extern const uint8_t gr_mask[16];
 
 #define VGA_RAM_SIZE (8192 * 1024)
+#define VGABIOS_FILENAME "vgabios.bin"
+#define VGABIOS_CIRRUS_FILENAME "vgabios-cirrus.bin"
 
 extern CPUReadMemoryFunc * const vga_mem_read[3];
 extern CPUWriteMemoryFunc * const vga_mem_write[3];
Signature · 1 line
1.6.2.5
#4 lore raw

PATCH v4 4/4 use rom loader for pc bios.

In reply to Gerd Hoffmann

The pc bios shows up in 'info roms' now.

Note that the BIOS is mapped to two places: The complete rom at the top of the memory, and the first 128k at 0xe0000. Only the first place is listed in 'info roms'.

---
 hw/pc.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
hw/pc.c +2 -2
index 9e34104..6b4e008 100644
@@ -1115,8 +1115,8 @@ static void pc_init1(ram_addr_t ram_size,
         goto bios_error;
     }
     bios_offset = qemu_ram_alloc(bios_size);
-    ret = load_image(filename, qemu_get_ram_ptr(bios_offset));
-    if (ret != bios_size) {
+    ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size));
+    if (ret != 0) {
     bios_error:
         fprintf(stderr, "qemu: could not load PC BIOS '%s'\n", bios_name);
         exit(1);
Signature · 1 line
1.6.2.5