render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone
Glauber Costa 3afbf0
From 34b39c2ba6cc08239a707b52bfb2886df2aa8dec Mon Sep 17 00:00:00 2001
Glauber Costa 3afbf0
From: aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>
Glauber Costa 3afbf0
Date: Sat, 28 Mar 2009 17:28:45 +0000
Glauber Costa 3afbf0
Subject: [PATCH] get roms more room. (Glauber Costa)
Glauber Costa 3afbf0
Glauber Costa 3afbf0
This patch increases by 50 % the size available for option roms.
Glauber Costa 3afbf0
The main motivator is that some roms grew bigger than the 64k we
Glauber Costa 3afbf0
currently allocate for them (Hey, it's 2009!)
Glauber Costa 3afbf0
Glauber Costa 3afbf0
One example is the gpxe project, that produces some roms with 69k,
Glauber Costa 3afbf0
70k, etc. The space proposed by this patch actually makes it as
Glauber Costa 3afbf0
big as 84k. Probably still a fit for some time.
Glauber Costa 3afbf0
Glauber Costa 3afbf0
But there is no free lunch. This space must come from somewhere,
Glauber Costa 3afbf0
and we take it from vga rom space. Currently, our vga roms are
Glauber Costa 3afbf0
around 35k in size. With this patch, option rom space will begin
Glauber Costa 3afbf0
just after vga ends, aligned to the next 2k boundary.
Glauber Costa 3afbf0
Glauber Costa 3afbf0
Technicaly, we could do the same with the uper space (the bios itself),
Glauber Costa 3afbf0
but since bochs bios is already 128 k in size, I don't see an
Glauber Costa 3afbf0
urgent need to do it.
Glauber Costa 3afbf0
Glauber Costa 3afbf0
[ fix case for vgabioses smaller than 30k, by Carl-Daniel Hailfinger ]
Glauber Costa 3afbf0
Glauber Costa 3afbf0
Signed-off-by: Glauber Costa <glommer@redhat.com>
Glauber Costa 3afbf0
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Glauber Costa 3afbf0
Glauber Costa 3afbf0
Glauber Costa 3afbf0
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6896 c046a42c-6fe2-441c-8c8c-71466251a162
Glauber Costa 3afbf0
---
Glauber Costa 3afbf0
 hw/pc.c |   29 +++++++++++++++++++----------
Glauber Costa 3afbf0
 1 files changed, 19 insertions(+), 10 deletions(-)
Glauber Costa 3afbf0
Glauber Costa 3afbf0
Index: qemu-kvm-0.10/qemu/hw/pc.c
Glauber Costa 3afbf0
===================================================================
Glauber Costa 3afbf0
--- qemu-kvm-0.10.orig/qemu/hw/pc.c
Glauber Costa 3afbf0
+++ qemu-kvm-0.10/qemu/hw/pc.c
Glauber Costa 3afbf0
@@ -813,7 +813,7 @@ static void pc_init1(ram_addr_t ram_size
Glauber Costa 3afbf0
 {
Glauber Costa 3afbf0
     char buf[1024];
Glauber Costa 3afbf0
     int ret, linux_boot, i;
Glauber Costa 3afbf0
-    ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset;
Glauber Costa 3afbf0
+    ram_addr_t ram_addr, vga_ram_addr, bios_offset, vga_bios_offset, option_rom_start = 0;
Glauber Costa 3afbf0
     ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
Glauber Costa 3afbf0
     int bios_size, isa_bios_size, vga_bios_size;
Glauber Costa 3afbf0
     int pci_option_rom_offset;
Glauber Costa 3afbf0
@@ -825,6 +825,7 @@ static void pc_init1(ram_addr_t ram_size
Glauber Costa 3afbf0
     int index;
Glauber Costa 3afbf0
     BlockDriverState *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
Glauber Costa 3afbf0
     BlockDriverState *fd[MAX_FD];
Glauber Costa 3afbf0
+    int using_vga = cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled;
Glauber Costa 3afbf0
 
Glauber Costa 3afbf0
     if (ram_size >= 0xe0000000 ) {
Glauber Costa 3afbf0
         above_4g_mem_size = ram_size - 0xe0000000;
Glauber Costa 3afbf0
@@ -900,7 +901,7 @@ static void pc_init1(ram_addr_t ram_size
Glauber Costa 3afbf0
         exit(1);
Glauber Costa 3afbf0
     }
Glauber Costa 3afbf0
 
Glauber Costa 3afbf0
-    if (cirrus_vga_enabled || std_vga_enabled || vmsvga_enabled) {
Glauber Costa 3afbf0
+    if (using_vga) {
Glauber Costa 3afbf0
         /* VGA BIOS load */
Glauber Costa 3afbf0
         if (cirrus_vga_enabled) {
Glauber Costa 3afbf0
             snprintf(buf, sizeof(buf), "%s/%s", bios_dir, VGABIOS_CIRRUS_FILENAME);
Glauber Costa 3afbf0
@@ -918,12 +919,21 @@ vga_bios_error:
Glauber Costa 3afbf0
             fprintf(stderr, "qemu: could not load VGA BIOS '%s'\n", buf);
Glauber Costa 3afbf0
             exit(1);
Glauber Costa 3afbf0
         }
Glauber Costa 3afbf0
+	/* Round up vga bios size to the next 2k boundary */
Glauber Costa 3afbf0
+	vga_bios_size = (vga_bios_size + 2047) & ~2047;
Glauber Costa 3afbf0
+	option_rom_start = 0xc0000 + vga_bios_size;
Glauber Costa 3afbf0
 
Glauber Costa 3afbf0
         /* setup basic memory access */
Glauber Costa 3afbf0
-        cpu_register_physical_memory(0xc0000, 0x10000,
Glauber Costa 3afbf0
+        cpu_register_physical_memory(0xc0000, vga_bios_size,
Glauber Costa 3afbf0
                                      vga_bios_offset | IO_MEM_ROM);
Glauber Costa 3afbf0
     }
Glauber Costa 3afbf0
 
Glauber Costa 3afbf0
+    /* No point in placing option roms before this address, since bochs bios
Glauber Costa 3afbf0
+     * will only start looking for it at 0xc8000 */
Glauber Costa 3afbf0
+    if (option_rom_start < 0xc8000)
Glauber Costa 3afbf0
+	    option_rom_start = 0xc8000;
Glauber Costa 3afbf0
+
Glauber Costa 3afbf0
+
Glauber Costa 3afbf0
     /* map the last 128KB of the BIOS in ISA space */
Glauber Costa 3afbf0
     isa_bios_size = bios_size;
Glauber Costa 3afbf0
     if (isa_bios_size > (128 * 1024))
Glauber Costa 3afbf0
@@ -944,14 +954,14 @@ vga_bios_error:
Glauber Costa 3afbf0
         ram_addr_t option_rom_offset;
Glauber Costa 3afbf0
         int size, offset;
Glauber Costa 3afbf0
 
Glauber Costa 3afbf0
-        offset = 0;
Glauber Costa 3afbf0
+        offset = option_rom_start;
Glauber Costa 3afbf0
         if (linux_boot) {
Glauber Costa 3afbf0
             option_rom_offset = qemu_ram_alloc(TARGET_PAGE_SIZE);
Glauber Costa 3afbf0
             load_linux(phys_ram_base + option_rom_offset,
Glauber Costa 3afbf0
                        kernel_filename, initrd_filename, kernel_cmdline);
Glauber Costa 3afbf0
-            cpu_register_physical_memory(0xd0000, TARGET_PAGE_SIZE,
Glauber Costa 3afbf0
+            cpu_register_physical_memory(option_rom_start, TARGET_PAGE_SIZE,
Glauber Costa 3afbf0
                                          option_rom_offset | IO_MEM_ROM);
Glauber Costa 3afbf0
-            offset = TARGET_PAGE_SIZE;
Glauber Costa 3afbf0
+            offset += TARGET_PAGE_SIZE;
Glauber Costa 3afbf0
         }
Glauber Costa 3afbf0
 
Glauber Costa 3afbf0
         for (i = 0; i < nb_option_roms; i++) {
Glauber Costa 3afbf0
@@ -961,13 +971,13 @@ vga_bios_error:
Glauber Costa 3afbf0
                         option_rom[i]);
Glauber Costa 3afbf0
                 exit(1);
Glauber Costa 3afbf0
             }
Glauber Costa 3afbf0
-            if (size > (0x10000 - offset))
Glauber Costa 3afbf0
+            if (size > (0xe0000 - offset))
Glauber Costa 3afbf0
                 goto option_rom_error;
Glauber Costa 3afbf0
             option_rom_offset = qemu_ram_alloc(size);
Glauber Costa 3afbf0
             ret = load_image(option_rom[i], phys_ram_base + option_rom_offset);
Glauber Costa 3afbf0
             if (ret != size) {
Glauber Costa 3afbf0
             option_rom_error:
Glauber Costa 3afbf0
-                fprintf(stderr, "Too many option ROMS\n");
Glauber Costa 3afbf0
+                fprintf(stderr, "Could not fit %soption roms in available space\n", using_vga ? "VGA bios and " : "");
Glauber Costa 3afbf0
                 exit(1);
Glauber Costa 3afbf0
             }
Glauber Costa 3afbf0
             size = (size + 4095) & ~4095;
Glauber Costa 3afbf0
@@ -975,9 +985,8 @@ vga_bios_error:
Glauber Costa 3afbf0
        initialization, and (optionally) marked readonly by the BIOS
Glauber Costa 3afbf0
        before INT 19h.  See the PNPBIOS specification, appendix B.
Glauber Costa 3afbf0
        DDIM support is mandatory for proper PCI expansion ROM support. */
Glauber Costa 3afbf0
-            cpu_register_physical_memory(0xd0000 + offset,
Glauber Costa 3afbf0
-                                         size, option_rom_offset /* | IO_MEM_ROM */);
Glauber Costa 3afbf0
-            option_rom_setup_reset(0xd0000 + offset, size);
Glauber Costa 3afbf0
+            cpu_register_physical_memory(offset, size, option_rom_offset /* | IO_MEM_ROM */);
Glauber Costa 3afbf0
+            option_rom_setup_reset(offset, size);
Glauber Costa 3afbf0
             offset += size;
Glauber Costa 3afbf0
         }
Glauber Costa 3afbf0
         pci_option_rom_offset = offset;