KVM requires that any ROM memory be registerd through a second interface. This
patch refactors the option ROM loading to simplify adding KVM support (which
will follow in the next patch).
Index: qemu/hw/pc.c
===================================================================
--- qemu.orig/hw/pc.c 2008-01-30 13:47:40.000000000 -0600
+++ qemu/hw/pc.c 2008-01-30 13:47:41.000000000 -0600
@@ -704,6 +704,31 @@
isa_ne2000_init(ne2000_io[nb_ne2k], pic[ne2000_irq[nb_ne2k]], nd);
nb_ne2k++;
}
+
+static int load_option_rom(const char *filename, int offset)
+{
+ ram_addr_t option_rom_offset;
+ int size, ret;
+
+ size = get_image_size(filename);
+ if (size < 0) {
+ fprintf(stderr, "Could not load option rom '%s'\n", filename);
+ exit(1);
+ }
+ if (size > (0x10000 - offset))
+ goto option_rom_error;
+ option_rom_offset = qemu_ram_alloc(size);
+ ret = load_image(filename, phys_ram_base + option_rom_offset);
+ if (ret != size) {
+ option_rom_error:
+ fprintf(stderr, "Too many option ROMS\n");
+ exit(1);
+ }
+ size = (size + 4095) & ~4095;
+ cpu_register_physical_memory(0xd0000 + offset,
+ size, option_rom_offset | IO_MEM_ROM);
+ return size;
+}
/* PC hardware initialisation */
static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
@@ -716,7 +741,7 @@
int ret, linux_boot, i;
ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;
ram_addr_t above_4g_mem_size = 0;
- int bios_size, isa_bios_size, vga_bios_size;
+ int bios_size, isa_bios_size, vga_bios_size, opt_rom_offset;
PCIBus *pci_bus;
int piix3_devfn = -1;
CPUState *env;
@@ -825,33 +850,9 @@
isa_bios_size,
(bios_offset + bios_size - isa_bios_size) |
IO_MEM_ROM);
- {
- ram_addr_t option_rom_offset;
- int size, offset;
-
- offset = 0;
- for (i = 0; i < nb_option_roms; i++) {
- size = get_image_size(option_rom[i]);
- if (size < 0) {
- fprintf(stderr, "Could not load option rom '%s'\n",
- option_rom[i]);
- exit(1);
- }
- if (size > (0x10000 - offset))
- goto option_rom_error;
- option_rom_offset = qemu_ram_alloc(size);
- ret = load_image(option_rom[i], phys_ram_base + option_rom_offset);
- if (ret != size) {
- option_rom_error:
- fprintf(stderr, "Too many option ROMS\n");
- exit(1);
- }
- size = (size + 4095) & ~4095;
- cpu_register_physical_memory(0xd0000 + offset,
- size, option_rom_offset | IO_MEM_ROM);
- offset += size;
- }
- }
+ opt_rom_offset = 0;
+ for (i = 0; i < nb_option_roms; i++)
+ opt_rom_offset += load_option_rom(option_rom[i], opt_rom_offset);
/* map all the bios at the top of memory */
cpu_register_physical_memory((uint32_t)(-bios_size),
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
kvm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/kvm-devel