All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kiszka <jan.kiszka@web.de>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: Jordan Justen <jljusten@gmail.com>
Subject: [Qemu-devel] [PATCH] pc_sysfw: Always use alias for ISA BIOS region
Date: Thu, 01 Nov 2012 17:32:06 +0100	[thread overview]
Message-ID: <5092A406.6030402@web.de> (raw)

From: Jan Kiszka <jan.kiszka@siemens.com>

This is no technical reason (anymore) for copying the ISA BIOS from the
original region. Instead, refactor pc_isa_bios_init to serve both pflash
and old-style BIOS setup.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 hw/pc_sysfw.c |   42 +++++++++---------------------------------
 1 files changed, 9 insertions(+), 33 deletions(-)

diff --git a/hw/pc_sysfw.c b/hw/pc_sysfw.c
index 9d7c5f4..07627df 100644
--- a/hw/pc_sysfw.c
+++ b/hw/pc_sysfw.c
@@ -41,36 +41,24 @@ typedef struct PcSysFwDevice {
 } PcSysFwDevice;
 
 static void pc_isa_bios_init(MemoryRegion *rom_memory,
-                             MemoryRegion *flash_mem,
-                             int ram_size)
+                             MemoryRegion *bios)
 {
+    uint64_t bios_size = memory_region_size(bios);
     int isa_bios_size;
     MemoryRegion *isa_bios;
-    uint64_t flash_size;
-    void *flash_ptr, *isa_bios_ptr;
-
-    flash_size = memory_region_size(flash_mem);
 
     /* map the last 128KB of the BIOS in ISA space */
-    isa_bios_size = flash_size;
+    isa_bios_size = bios_size;
     if (isa_bios_size > (128 * 1024)) {
         isa_bios_size = 128 * 1024;
     }
     isa_bios = g_malloc(sizeof(*isa_bios));
-    memory_region_init_ram(isa_bios, "isa-bios", isa_bios_size);
-    vmstate_register_ram_global(isa_bios);
+    memory_region_init_alias(isa_bios, "isa-bios", bios,
+                             bios_size - isa_bios_size, isa_bios_size);
     memory_region_add_subregion_overlap(rom_memory,
                                         0x100000 - isa_bios_size,
                                         isa_bios,
                                         1);
-
-    /* copy ISA rom image from top of flash memory */
-    flash_ptr = memory_region_get_ram_ptr(flash_mem);
-    isa_bios_ptr = memory_region_get_ram_ptr(isa_bios);
-    memcpy(isa_bios_ptr,
-           ((uint8_t*)flash_ptr) + (flash_size - isa_bios_size),
-           isa_bios_size);
-
     memory_region_set_readonly(isa_bios, true);
 }
 
@@ -129,14 +117,14 @@ static void pc_system_flash_init(MemoryRegion *rom_memory,
                                          1, 0x0000, 0x0000, 0x0000, 0x0000, 0);
     flash_mem = pflash_cfi01_get_memory(system_flash);
 
-    pc_isa_bios_init(rom_memory, flash_mem, size);
+    pc_isa_bios_init(rom_memory, flash_mem);
 }
 
 static void old_pc_system_rom_init(MemoryRegion *rom_memory)
 {
     char *filename;
-    MemoryRegion *bios, *isa_bios;
-    int bios_size, isa_bios_size;
+    MemoryRegion *bios;
+    int bios_size;
     int ret;
 
     /* BIOS load */
@@ -167,19 +155,7 @@ static void old_pc_system_rom_init(MemoryRegion *rom_memory)
         g_free(filename);
     }
 
-    /* map the last 128KB of the BIOS in ISA space */
-    isa_bios_size = bios_size;
-    if (isa_bios_size > (128 * 1024)) {
-        isa_bios_size = 128 * 1024;
-    }
-    isa_bios = g_malloc(sizeof(*isa_bios));
-    memory_region_init_alias(isa_bios, "isa-bios", bios,
-                             bios_size - isa_bios_size, isa_bios_size);
-    memory_region_add_subregion_overlap(rom_memory,
-                                        0x100000 - isa_bios_size,
-                                        isa_bios,
-                                        1);
-    memory_region_set_readonly(isa_bios, true);
+    pc_isa_bios_init(rom_memory, bios);
 
     /* map all the bios at the top of memory */
     memory_region_add_subregion(rom_memory,
-- 
1.7.3.4

             reply	other threads:[~2012-11-01 16:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-01 16:32 Jan Kiszka [this message]
2012-11-01 17:15 ` [Qemu-devel] [PATCH] pc_sysfw: Always use alias for ISA BIOS region Jordan Justen
2012-11-01 17:17   ` Jan Kiszka
2012-11-01 17:21     ` Jan Kiszka
2012-11-01 18:03       ` Jordan Justen
2012-11-01 18:23         ` Jan Kiszka
2012-11-02 18:55 ` [Qemu-devel] [PATCH v2] " Jan Kiszka
2012-11-02 21:17   ` Jordan Justen
2012-11-03  7:48     ` Jan Kiszka

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=5092A406.6030402@web.de \
    --to=jan.kiszka@web.de \
    --cc=jljusten@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.