qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org, seabios@seabios.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 6/8] roms: remove option rom packing logic
Date: Fri, 18 Dec 2009 12:01:12 +0100	[thread overview]
Message-ID: <1261134074-11795-7-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1261134074-11795-1-git-send-email-kraxel@redhat.com>

Now that we load the option roms via fw_cfg, we can stop copying
them to the 0xc000 -> 0xe000.  The patch does just that.

Also the rom loader gets simplified as all remaining users of the
rom loader load the bits at a fixed address so the packing and
aligning logic can go away.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 hw/loader.c |  103 ++++++++++++++++++++++++++---------------------------------
 hw/loader.h |    8 ++--
 2 files changed, 49 insertions(+), 62 deletions(-)

diff --git a/hw/loader.c b/hw/loader.c
index ccc0ccc..49d4839 100644
--- a/hw/loader.c
+++ b/hw/loader.c
@@ -527,13 +527,10 @@ struct Rom {
     char *path;
     size_t romsize;
     uint8_t *data;
-    int align;
     int isrom;
     char *fw_dir;
     char *fw_file;
 
-    target_phys_addr_t min;
-    target_phys_addr_t max;
     target_phys_addr_t addr;
     QTAILQ_ENTRY(Rom) next;
 };
@@ -551,7 +548,7 @@ static void rom_insert(Rom *rom)
 
     /* list is ordered by load address */
     QTAILQ_FOREACH(item, &roms, next) {
-        if (rom->min >= item->min)
+        if (rom->addr >= item->addr)
             continue;
         QTAILQ_INSERT_BEFORE(item, rom, next);
         return;
@@ -560,7 +557,7 @@ static void rom_insert(Rom *rom)
 }
 
 int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
-                 target_phys_addr_t min, target_phys_addr_t max, int align)
+                 target_phys_addr_t addr)
 {
     Rom *rom;
     int rc, fd = -1;
@@ -581,9 +578,7 @@ int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
 
     rom->fw_dir  = fw_dir  ? qemu_strdup(fw_dir)  : NULL;
     rom->fw_file = fw_file ? qemu_strdup(fw_file) : NULL;
-    rom->align   = align;
-    rom->min     = min;
-    rom->max     = max;
+    rom->addr    = addr;
     rom->romsize = lseek(fd, 0, SEEK_END);
     rom->data    = qemu_mallocz(rom->romsize);
     lseek(fd, 0, SEEK_SET);
@@ -608,15 +603,13 @@ err:
 }
 
 int rom_add_blob(const char *name, const void *blob, size_t len,
-                 target_phys_addr_t min, target_phys_addr_t max, int align)
+                 target_phys_addr_t addr)
 {
     Rom *rom;
 
     rom = qemu_mallocz(sizeof(*rom));
     rom->name    = qemu_strdup(name);
-    rom->align   = align;
-    rom->min     = min;
-    rom->max     = max;
+    rom->addr    = addr;
     rom->romsize = len;
     rom->data    = qemu_mallocz(rom->romsize);
     memcpy(rom->data, blob, len);
@@ -628,16 +621,14 @@ int rom_add_vga(const char *file)
 {
     if (!rom_enable_driver_roms)
         return 0;
-    return rom_add_file(file, "vgaroms", file,
-                        PC_ROM_MIN_VGA, PC_ROM_MAX, PC_ROM_ALIGN);
+    return rom_add_file(file, "vgaroms", file, 0);
 }
 
 int rom_add_option(const char *file)
 {
     if (!rom_enable_driver_roms)
         return 0;
-    return rom_add_file(file, "genroms", file,
-                        PC_ROM_MIN_OPTION, PC_ROM_MAX, PC_ROM_ALIGN);
+    return rom_add_file(file, "genroms", file, 0);
 }
 
 static void rom_reset(void *unused)
@@ -645,6 +636,8 @@ static void rom_reset(void *unused)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
+        if (rom->addr == 0)
+            continue;
         if (rom->data == NULL)
             continue;
         cpu_physical_memory_write_rom(rom->addr, rom->data, rom->romsize);
@@ -663,32 +656,16 @@ int rom_load_all(void)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
-        if (addr < rom->min)
-            addr = rom->min;
-        if (rom->max) {
-            /* load address range */
-            if (rom->align) {
-                addr += (rom->align-1);
-                addr &= ~(rom->align-1);
-            }
-            if (addr + rom->romsize > rom->max) {
-                fprintf(stderr, "rom: out of memory (rom %s, "
-                        "addr 0x" TARGET_FMT_plx
-                        ", size 0x%zx, max 0x" TARGET_FMT_plx ")\n",
-                        rom->name, addr, rom->romsize, rom->max);
-                return -1;
-            }
-        } else {
-            /* fixed address requested */
-            if (addr != rom->min) {
-                fprintf(stderr, "rom: requested regions overlap "
-                        "(rom %s. free=0x" TARGET_FMT_plx
-                        ", addr=0x" TARGET_FMT_plx ")\n",
-                        rom->name, addr, rom->min);
-                return -1;
-            }
+        if (rom->addr == 0)
+            continue;
+        if (addr > rom->addr) {
+            fprintf(stderr, "rom: requested regions overlap "
+                    "(rom %s. free=0x" TARGET_FMT_plx
+                    ", addr=0x" TARGET_FMT_plx ")\n",
+                    rom->name, addr, rom->addr);
+            return -1;
         }
-        rom->addr = addr;
+        addr  = rom->addr;
         addr += rom->romsize;
         memtype = cpu_get_physical_page_desc(rom->addr) & (3 << IO_MEM_SHIFT);
         if (memtype == IO_MEM_ROM)
@@ -716,11 +693,11 @@ static Rom *find_rom(target_phys_addr_t addr)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
-        if (rom->max)
+        if (rom->addr == 0)
             continue;
-        if (rom->min > addr)
+        if (rom->addr > addr)
             continue;
-        if (rom->min + rom->romsize < addr)
+        if (rom->addr + rom->romsize < addr)
             continue;
         return rom;
     }
@@ -735,25 +712,25 @@ int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
-        if (rom->max)
+        if (rom->addr == 0)
             continue;
-        if (rom->min > addr)
+        if (rom->addr > addr)
             continue;
-        if (rom->min + rom->romsize < addr)
+        if (rom->addr + rom->romsize < addr)
             continue;
-        if (rom->min > end)
+        if (rom->addr > end)
             break;
         if (!rom->data)
             continue;
 
-        d = dest + (rom->min - addr);
+        d = dest + (rom->addr - addr);
         s = rom->data;
         l = rom->romsize;
 
-        if (rom->min < addr) {
+        if (rom->addr < addr) {
             d = dest;
-            s += (addr - rom->min);
-            l -= (addr - rom->min);
+            s += (addr - rom->addr);
+            l -= (addr - rom->addr);
         }
         if ((d + l) > (dest + size)) {
             l = dest - d;
@@ -772,7 +749,7 @@ void *rom_ptr(target_phys_addr_t addr)
     rom = find_rom(addr);
     if (!rom || !rom->data)
         return NULL;
-    return rom->data + (addr - rom->min);
+    return rom->data + (addr - rom->addr);
 }
 
 void do_info_roms(Monitor *mon)
@@ -780,10 +757,20 @@ void do_info_roms(Monitor *mon)
     Rom *rom;
 
     QTAILQ_FOREACH(rom, &roms, next) {
-        monitor_printf(mon, "addr=" TARGET_FMT_plx
-                       " size=0x%06zx mem=%s name=\"%s\" \n",
-                       rom->addr, rom->romsize,
-                       rom->isrom ? "rom" : "ram",
-                       rom->name);
+        if (rom->addr) {
+            monitor_printf(mon, "addr=" TARGET_FMT_plx
+                           " size=0x%06zx mem=%s name=\"%s\" \n",
+                           rom->addr, rom->romsize,
+                           rom->isrom ? "rom" : "ram",
+                           rom->name);
+        } else {
+            monitor_printf(mon, "fw=%s%s%s"
+                           " size=0x%06zx name=\"%s\" \n",
+                           rom->fw_dir ? rom->fw_dir : "",
+                           rom->fw_dir ? "/" : "",
+                           rom->fw_file,
+                           rom->romsize,
+                           rom->name);
+        }
     }
 }
diff --git a/hw/loader.h b/hw/loader.h
index 634f7d5..77beb0e 100644
--- a/hw/loader.h
+++ b/hw/loader.h
@@ -20,9 +20,9 @@ void pstrcpy_targphys(const char *name,
                       const char *source);
 
 int rom_add_file(const char *file, const char *fw_dir, const char *fw_file,
-                 target_phys_addr_t min, target_phys_addr_t max, int align);
+                 target_phys_addr_t addr);
 int rom_add_blob(const char *name, const void *blob, size_t len,
-                 target_phys_addr_t min, target_phys_addr_t max, int align);
+                 target_phys_addr_t addr);
 int rom_load_all(void);
 int rom_load_fw(void *fw_cfg);
 int rom_copy(uint8_t *dest, target_phys_addr_t addr, size_t size);
@@ -30,9 +30,9 @@ void *rom_ptr(target_phys_addr_t addr);
 void do_info_roms(Monitor *mon);
 
 #define rom_add_file_fixed(_f, _a)              \
-    rom_add_file(_f, NULL, NULL, _a, 0, 0)
+    rom_add_file(_f, NULL, NULL, _a)
 #define rom_add_blob_fixed(_f, _b, _l, _a)      \
-    rom_add_blob(_f, _b, _l, _a, 0, 0)
+    rom_add_blob(_f, _b, _l, _a)
 
 #define PC_ROM_MIN_VGA     0xc0000
 #define PC_ROM_MIN_OPTION  0xc8000
-- 
1.6.5.2

  parent reply	other threads:[~2009-12-18 11:01 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-18 11:01 [Qemu-devel] [PATCH 0/8] option rom loading overhaul Gerd Hoffmann
2009-12-18 11:01 ` [Qemu-devel] [PATCH 1/8] Support PCI based option rom loading Gerd Hoffmann
2009-12-19 10:57   ` Blue Swirl
2009-12-20 15:34     ` Anthony Liguori
2009-12-20 17:02       ` Blue Swirl
2009-12-20 17:18         ` Alexander Graf
2009-12-20 17:55           ` Anthony Liguori
2009-12-20 18:01             ` Alexander Graf
2009-12-20 18:24               ` Andreas Färber
2009-12-20 18:53                 ` Blue Swirl
2009-12-20 21:24                   ` Benjamin Herrenschmidt
2009-12-20 21:23               ` Benjamin Herrenschmidt
2009-12-18 11:01 ` [Qemu-devel] [PATCH 2/8] pci romfiles: add property, add default to PCIDeviceInfo Gerd Hoffmann
2010-01-11 21:18   ` [Qemu-devel] [RFC] New naming rules for GPXE romfiles Stefan Weil
2010-01-11 21:34     ` Anthony Liguori
2010-01-12 10:23     ` Kevin Wolf
2009-12-18 11:01 ` [Qemu-devel] [PATCH 3/8] fw_cfg: make calls typesafe Gerd Hoffmann
2009-12-18 11:01 ` [Qemu-devel] [PATCH 4/8] fw_cfg: add API for file transfer Gerd Hoffmann
2009-12-19 12:06   ` Blue Swirl
2009-12-20  8:42   ` [Qemu-devel] Re: [SeaBIOS] " Gleb Natapov
2009-12-18 11:01 ` [Qemu-devel] [PATCH 5/8] roms: use new fw_cfg file xfer support Gerd Hoffmann
2009-12-20  8:45   ` [Qemu-devel] Re: [SeaBIOS] " Gleb Natapov
2009-12-18 11:01 ` Gerd Hoffmann [this message]
2009-12-18 11:01 ` [Qemu-devel] [PATCH 7/8] updated seabios binary for testing convinience Gerd Hoffmann
2009-12-18 11:01 ` [Qemu-devel] [PATCH 8/8] debug: enable bios messages Gerd Hoffmann
2009-12-18 14:35 ` [Qemu-devel] Re: [SeaBIOS] [PATCH 0/8] option rom loading overhaul Anthony Liguori
2009-12-18 16:34   ` Gerd Hoffmann
2009-12-18 16:42     ` Anthony Liguori
2009-12-18 17:03       ` Gerd Hoffmann
2009-12-18 17:12         ` Anthony Liguori
2009-12-19  1:48           ` Kevin O'Connor
2009-12-19  3:07             ` Anthony Liguori
2009-12-18 17:14         ` Anthony Liguori
2009-12-18 18:04           ` Gerd Hoffmann
2009-12-18 19:41         ` Sebastian Herbszt
2009-12-18 19:53           ` Anthony Liguori
2009-12-18 20:10             ` Sebastian Herbszt
2009-12-20  8:38 ` Gleb Natapov
2009-12-20 14:43   ` Anthony Liguori
2009-12-20 14:52     ` Gleb Natapov
2009-12-20 14:58       ` Anthony Liguori
2009-12-20 15:07         ` Gleb Natapov
2009-12-20 15:11           ` Anthony Liguori
2009-12-20 15:20             ` Avi Kivity
2009-12-20 15:31               ` Anthony Liguori
2009-12-20 15:35                 ` Avi Kivity
2009-12-22 13:04               ` Paul Brook
2009-12-22 13:09                 ` Avi Kivity
2009-12-22 15:11                 ` Anthony Liguori
2009-12-22 15:54                   ` Paul Brook
2009-12-22 16:16                     ` Anthony Liguori
2009-12-20 15:23             ` Gleb Natapov
2009-12-20 15:28               ` Anthony Liguori
2009-12-20 15:33                 ` Gleb Natapov
2009-12-20 15:39                   ` Anthony Liguori
2009-12-20 15:52                     ` Gleb Natapov
2009-12-20 16:08                       ` Blue Swirl
2009-12-20 16:15                         ` Gleb Natapov
2009-12-20 16:23                           ` Blue Swirl
2009-12-20 17:48                       ` Anthony Liguori
2009-12-21  1:59                         ` Kevin O'Connor
2009-12-21  7:32                           ` Gleb Natapov
2009-12-21 16:40                             ` Anthony Liguori
2009-12-21 16:43                               ` Gleb Natapov
2009-12-21 17:26                                 ` Anthony Liguori
2009-12-21 17:43                                   ` Gleb Natapov
2009-12-21 18:24                                     ` [Qemu-devel] Re: Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul Sebastian Herbszt
2009-12-21 18:36                                       ` Gleb Natapov
2009-12-21 19:28                                         ` Sebastian Herbszt
2009-12-21 19:57                                           ` Gleb Natapov
2009-12-21 19:17                                       ` [Qemu-devel] " Anthony Liguori
2009-12-21 19:39                                         ` Sebastian Herbszt
2009-12-21 19:53                                           ` Gleb Natapov
2009-12-21 20:16                                             ` Sebastian Herbszt
2009-12-22  7:58                                               ` Gleb Natapov
2009-12-22 14:57                                                 ` Anthony Liguori
2009-12-21 19:48                                         ` Gleb Natapov
2009-12-21 19:13                                     ` [Qemu-devel] Re: [SeaBIOS] [PATCH 0/8] option rom loading overhaul Anthony Liguori
2009-12-21 19:43                                       ` Gleb Natapov
2009-12-21 23:54                                         ` Anthony Liguori
2009-12-22 20:50                                           ` [Qemu-devel] Re: Re: [SeaBIOS] [PATCH 0/8] option rom loadingoverhaul Sebastian Herbszt
2009-12-21  7:40                         ` [Qemu-devel] Re: [SeaBIOS] [PATCH 0/8] option rom loading overhaul Gleb Natapov
2009-12-21 17:27                           ` Michael S. Tsirkin
2010-01-12  4:48                   ` Jamie Lokier

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=1261134074-11795-7-git-send-email-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=seabios@seabios.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).