From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Michael Walle <michael@walle.cc>
Subject: [Qemu-devel] [PATCH v2 repost 6/9] loader: support for unmapped ROM blobs
Date: Wed, 10 Jul 2013 16:51:49 +0300 [thread overview]
Message-ID: <1373464153-18979-7-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1373464153-18979-1-git-send-email-mst@redhat.com>
Support ROM blobs not mapped into guest memory:
let user pass in MR for memory serving as the backing store.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/core/loader.c | 32 +++++++++++++++++++++++++++++---
hw/lm32/lm32_hwsetup.h | 2 +-
include/hw/loader.h | 4 ++--
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/hw/core/loader.c b/hw/core/loader.c
index d569636..1ead722 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -542,6 +542,7 @@ struct Rom {
size_t datasize;
uint8_t *data;
+ MemoryRegion *mr;
int isrom;
char *fw_dir;
char *fw_file;
@@ -641,7 +642,7 @@ err:
}
int rom_add_blob(const char *name, const void *blob, size_t len,
- hwaddr addr)
+ hwaddr addr, MemoryRegion *mr)
{
Rom *rom;
@@ -651,6 +652,11 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
rom->romsize = len;
rom->datasize = len;
rom->data = g_malloc0(rom->datasize);
+ rom->mr = mr;
+ if (mr) {
+ assert(memory_region_is_ram(mr));
+ rom->isrom = memory_region_is_rom(mr);
+ }
memcpy(rom->data, blob, len);
rom_insert(rom);
return 0;
@@ -697,7 +703,12 @@ static void rom_reset(void *unused)
if (rom->data == NULL) {
continue;
}
- cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize);
+ if (rom->mr) {
+ void *host = memory_region_get_ram_ptr(rom->mr);
+ memcpy(host, rom->data, rom->datasize);
+ } else {
+ cpu_physical_memory_write_rom(rom->addr, rom->data, rom->datasize);
+ }
if (rom->isrom) {
/* rom needs to be written only once */
g_free(rom->data);
@@ -713,6 +724,9 @@ int rom_load_all(void)
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
+ if (rom->mr) {
+ continue;
+ }
if (rom->fw_file) {
continue;
}
@@ -746,6 +760,9 @@ static Rom *find_rom(hwaddr addr)
if (rom->fw_file) {
continue;
}
+ if (rom->mr) {
+ continue;
+ }
if (rom->addr > addr) {
continue;
}
@@ -773,6 +790,9 @@ int rom_copy(uint8_t *dest, hwaddr addr, size_t size)
if (rom->fw_file) {
continue;
}
+ if (rom->mr) {
+ continue;
+ }
if (rom->addr + rom->romsize < addr) {
continue;
}
@@ -832,7 +852,13 @@ void do_info_roms(Monitor *mon, const QDict *qdict)
Rom *rom;
QTAILQ_FOREACH(rom, &roms, next) {
- if (!rom->fw_file) {
+ if (rom->mr) {
+ monitor_printf(mon, "%s"
+ " size=0x%06zx name=\"%s\"\n",
+ rom->mr->name,
+ rom->romsize,
+ rom->name);
+ } else if (!rom->fw_file) {
monitor_printf(mon, "addr=" TARGET_FMT_plx
" size=0x%06zx mem=%s name=\"%s\"\n",
rom->addr, rom->romsize,
diff --git a/hw/lm32/lm32_hwsetup.h b/hw/lm32/lm32_hwsetup.h
index 3449bd8..d6914d6 100644
--- a/hw/lm32/lm32_hwsetup.h
+++ b/hw/lm32/lm32_hwsetup.h
@@ -73,7 +73,7 @@ static inline void hwsetup_free(HWSetup *hw)
static inline void hwsetup_create_rom(HWSetup *hw,
hwaddr base)
{
- rom_add_blob("hwsetup", hw->data, TARGET_PAGE_SIZE, base);
+ rom_add_blob("hwsetup", hw->data, TARGET_PAGE_SIZE, base, NULL);
}
static inline void hwsetup_add_u8(HWSetup *hw, uint8_t u)
diff --git a/include/hw/loader.h b/include/hw/loader.h
index 15d4cc9..b39e7d1 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -27,7 +27,7 @@ void pstrcpy_targphys(const char *name,
int rom_add_file(const char *file, const char *fw_dir,
hwaddr addr, int32_t bootindex);
int rom_add_blob(const char *name, const void *blob, size_t len,
- hwaddr addr);
+ hwaddr addr, MemoryRegion *mr);
int rom_add_elf_program(const char *name, void *data, size_t datasize,
size_t romsize, hwaddr addr);
int rom_load_all(void);
@@ -39,7 +39,7 @@ void do_info_roms(Monitor *mon, const QDict *qdict);
#define rom_add_file_fixed(_f, _a, _i) \
rom_add_file(_f, NULL, _a, _i)
#define rom_add_blob_fixed(_f, _b, _l, _a) \
- rom_add_blob(_f, _b, _l, _a)
+ rom_add_blob(_f, _b, _l, _a, NULL)
#define PC_ROM_MIN_VGA 0xc0000
#define PC_ROM_MIN_OPTION 0xc8000
--
MST
next prev parent reply other threads:[~2013-07-10 13:50 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-10 13:51 [Qemu-devel] [PATCH v2 repost 0/9] qemu: generate acpi tables for the guest Michael S. Tsirkin
2013-07-10 13:51 ` [Qemu-devel] [PATCH v2 repost 1/9] hw/i386/pc.c: move IO_APIC_DEFAULT_ADDRESS to include/hw/i386/apic.h Michael S. Tsirkin
2013-07-11 16:57 ` Laszlo Ersek
2013-07-15 7:11 ` Hu Tao
2013-07-10 13:51 ` [Qemu-devel] [PATCH v2 repost 2/9] i386: add ACPI table files from seabios Michael S. Tsirkin
2013-07-11 16:57 ` Laszlo Ersek
2013-07-15 7:49 ` Hu Tao
2013-07-15 10:14 ` Michael S. Tsirkin
2013-07-10 13:51 ` [Qemu-devel] [PATCH v2 repost 3/9] acpi: add rules to compile ASL source Michael S. Tsirkin
2013-07-11 16:55 ` Laszlo Ersek
2013-07-11 16:58 ` Laszlo Ersek
2013-07-11 17:10 ` Michael S. Tsirkin
2013-07-15 8:00 ` Hu Tao
2013-07-15 8:19 ` Michael S. Tsirkin
2013-07-10 13:51 ` [Qemu-devel] [PATCH v2 repost 4/9] acpi: pre-compiled ASL files Michael S. Tsirkin
2013-07-11 16:59 ` Laszlo Ersek
2013-07-10 13:51 ` [Qemu-devel] [PATCH v2 repost 5/9] i386: add bios linker/loader Michael S. Tsirkin
2013-07-12 14:17 ` Laszlo Ersek
2013-07-14 11:41 ` Michael S. Tsirkin
2013-07-15 7:33 ` Laszlo Ersek
2013-07-15 9:01 ` Michael S. Tsirkin
2013-07-10 13:51 ` Michael S. Tsirkin [this message]
2013-07-15 13:22 ` [Qemu-devel] [PATCH v2 repost 6/9] loader: support for unmapped ROM blobs Laszlo Ersek
2013-07-15 16:03 ` Michael S. Tsirkin
2013-07-15 18:30 ` Laszlo Ersek
2013-07-17 12:20 ` Laszlo Ersek
2013-07-10 13:51 ` [Qemu-devel] [PATCH v2 repost 7/9] loader: allow adding ROMs in done callbacks Michael S. Tsirkin
2013-07-17 12:23 ` Laszlo Ersek
2013-07-10 13:51 ` [Qemu-devel] [PATCH v2 repost 8/9] i386: generate pc guest info Michael S. Tsirkin
2013-07-17 15:07 ` Laszlo Ersek
2013-07-24 15:36 ` Laszlo Ersek
2013-07-24 15:47 ` Michael S. Tsirkin
2013-07-19 3:55 ` Hu Tao
2013-07-10 13:51 ` [Qemu-devel] [PATCH v2 repost 9/9] i386: ACPI table generation code from seabios Michael S. Tsirkin
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=1373464153-18979-7-git-send-email-mst@redhat.com \
--to=mst@redhat.com \
--cc=michael@walle.cc \
--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).