qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: kvm-devel@lists.sourceforge.net, Paul Brook <paul@codesourcery.com>
Subject: [Qemu-devel] [PATCH 5/6] Refactor option ROM loading
Date: Thu, 31 Jan 2008 16:36:19 -0600	[thread overview]
Message-ID: <1201818980-27534-6-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1201818980-27534-1-git-send-email-aliguori@us.ibm.com>

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),

  parent reply	other threads:[~2008-01-31 22:37 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-31 22:36 [Qemu-devel] [PATCH 0/6] Support for the Kernel Virtual Machine interface Anthony Liguori
2008-01-31 22:36 ` [Qemu-devel] [PATCH 1/6] Use correct types to enable > 2G support Anthony Liguori
2008-01-31 23:54   ` [Qemu-devel] " Paul Brook
2008-02-01  0:25     ` Anthony Liguori
2008-02-01  0:37       ` Paul Brook
2008-02-01  0:40         ` Anthony Liguori
2008-02-01 10:26   ` Fabrice Bellard
2008-02-01 14:35     ` Anthony Liguori
2008-02-01 15:13       ` Avi Kivity
2008-02-01 11:56         ` Robert William Fuller
2008-02-01 16:09           ` M. Warner Losh
2008-02-01 16:47             ` Philip Boulain
2008-02-01 17:35           ` Jamie Lokier
2008-02-01 15:33         ` [Qemu-devel] Re: [kvm-devel] " Anthony Liguori
2008-02-01 15:40           ` Ian Jackson
2008-02-01 17:53             ` [kvm-devel] [Qemu-devel] " Anthony Liguori
2008-02-01 17:57               ` Daniel P. Berrange
2008-02-01 20:31                 ` Anthony Liguori
2008-02-01 21:33                   ` Paul Brook
2008-02-01 16:00       ` Paul Brook
2008-02-01 16:21         ` Fabrice Bellard
2008-02-05 11:34           ` Ian Jackson
2008-02-01 17:49         ` [Qemu-devel] Re: [kvm-devel] " Anthony Liguori
2008-02-03  8:58   ` Izik Eidus
2008-01-31 22:36 ` [Qemu-devel] [PATCH 2/6] SCI fixes Anthony Liguori
2008-01-31 22:36 ` [Qemu-devel] [PATCH 3/6] Fix daemonize options Anthony Liguori
2008-01-31 22:36 ` [Qemu-devel] [PATCH 4/6] Tell BIOS about the number of CPUs Anthony Liguori
2008-02-01  0:14   ` [Qemu-devel] " Paul Brook
2008-02-01  0:28     ` Anthony Liguori
2008-02-01  0:40       ` Paul Brook
2008-01-31 22:36 ` Anthony Liguori [this message]
2008-01-31 22:36 ` [Qemu-devel] [PATCH 6/6] QEMU support for the Kernel Virtual Machine interface Anthony Liguori
2008-02-01  9:49   ` [Qemu-devel] " Fabrice Bellard
2008-02-01 14:18     ` Anthony Liguori
2008-01-31 22:53 ` [qemu-devel] [PATCH 0/6] Support " Anthony Liguori

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=1201818980-27534-6-git-send-email-aliguori@us.ibm.com \
    --to=aliguori@us.ibm.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@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).