All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: qemu-devel@nongnu.org
Cc: Michael Walle <michael@walle.cc>,
	Laszlo Ersek <lersek@redhat.com>,
	afaerber@suse.de, Anthony Liguori <anthony@codemonkey.ws>
Subject: [Qemu-devel] [PATCH v4 06/23] loader: support for unmapped ROM blobs
Date: Sun, 22 Sep 2013 16:37:20 +0300	[thread overview]
Message-ID: <1379857006-17451-7-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1379857006-17451-1-git-send-email-mst@redhat.com>

Support ROM blobs not mapped into guest memory:
same as ROM files really but use caller's buffer.

Support incoking callback on access and
return memory pointer making it easier
for caller to update memory if necessary.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
---
 hw/lm32/lm32_hwsetup.h |  2 +-
 include/hw/loader.h    |  7 ++++---
 hw/core/loader.c       | 23 ++++++++++++++++++++---
 3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/hw/lm32/lm32_hwsetup.h b/hw/lm32/lm32_hwsetup.h
index 3449bd8..9fd5e69 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, NULL, 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 6145736..e0c576b 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -40,8 +40,9 @@ extern bool rom_file_in_ram;
 
 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);
+void *rom_add_blob(const char *name, const void *blob, size_t len,
+                   hwaddr addr, const char *fw_file_name,
+                   FWCfgReadCallback fw_callback, void *callback_opaque);
 int rom_add_elf_program(const char *name, void *data, size_t datasize,
                         size_t romsize, hwaddr addr);
 int rom_load_all(void);
@@ -53,7 +54,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, NULL, NULL) ? 0 : -1)
 
 #define PC_ROM_MIN_VGA     0xc0000
 #define PC_ROM_MIN_OPTION  0xc8000
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 7b3d3ee..449bd4c 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -700,10 +700,12 @@ err:
     return -1;
 }
 
-int rom_add_blob(const char *name, const void *blob, size_t len,
-                 hwaddr addr)
+void *rom_add_blob(const char *name, const void *blob, size_t len,
+                   hwaddr addr, const char *fw_file_name,
+                   FWCfgReadCallback fw_callback, void *callback_opaque)
 {
     Rom *rom;
+    void *data = NULL;
 
     rom           = g_malloc0(sizeof(*rom));
     rom->name     = g_strdup(name);
@@ -713,7 +715,22 @@ int rom_add_blob(const char *name, const void *blob, size_t len,
     rom->data     = g_malloc0(rom->datasize);
     memcpy(rom->data, blob, len);
     rom_insert(rom);
-    return 0;
+    if (fw_file_name && fw_cfg) {
+        char devpath[100];
+
+        snprintf(devpath, sizeof(devpath), "/rom@%s", fw_file_name);
+
+        if (rom_file_in_ram) {
+            data = rom_set_mr(rom, OBJECT(fw_cfg), devpath);
+        } else {
+            data = rom->data;
+        }
+
+        fw_cfg_add_file_callback(fw_cfg, fw_file_name,
+                                 fw_callback, callback_opaque,
+                                 data, rom->romsize);
+    }
+    return data;
 }
 
 /* This function is specific for elf program because we don't need to allocate
-- 
MST

  parent reply	other threads:[~2013-09-22 13:35 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-22 13:37 [Qemu-devel] [PATCH v4 00/23] qemu: generate acpi tables for the guest Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 01/23] qemu: add Error to typedefs Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 02/23] qom: pull in qemu/typedefs Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 03/23] qom: cleanup struct Error references Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 04/23] qom: add pointer to int property helpers Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 05/23] fw_cfg: interface to trigger callback on read Michael S. Tsirkin
2013-09-22 13:37 ` Michael S. Tsirkin [this message]
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 07/23] pcie_host: expose UNMAPPED macro Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 08/23] pcie_host: expose address format Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 09/23] q35: use macro for MCFG property name Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 10/23] q35: expose mmcfg size as a property Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 11/23] i386: add ACPI table files from seabios Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 12/23] acpi: add rules to compile ASL source Michael S. Tsirkin
2013-09-23 12:36   ` Paolo Bonzini
2013-09-23 13:39     ` Michael S. Tsirkin
2013-09-23 13:44       ` Laszlo Ersek
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 13/23] acpi: pre-compiled ASL files Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 14/23] loader: use file path size from fw_cfg.h Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 15/23] i386: add bios linker/loader Michael S. Tsirkin
2013-09-23 12:48   ` Paolo Bonzini
2013-09-23 13:36     ` Michael S. Tsirkin
2013-09-23 13:39       ` Paolo Bonzini
2013-09-23 13:47         ` Michael S. Tsirkin
2013-09-23 13:52           ` Paolo Bonzini
2013-09-23 19:08             ` Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 16/23] loader: allow adding ROMs in done callbacks Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 17/23] i386: define pc guest info Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 18/23] acpi/piix: add macros for acpi property names Michael S. Tsirkin
2013-09-22 13:37 ` [Qemu-devel] [PATCH v4 19/23] piix: APIs for pc guest info Michael S. Tsirkin
2013-09-23  9:27   ` Igor Mammedov
2013-09-23 10:10     ` Michael S. Tsirkin
2013-09-23 11:14       ` Igor Mammedov
2013-09-23 11:28         ` Michael S. Tsirkin
2013-09-22 13:38 ` [Qemu-devel] [PATCH v4 20/23] ich9: " Michael S. Tsirkin
2013-09-22 13:38 ` [Qemu-devel] [PATCH v4 21/23] pvpanic: add API to access io port Michael S. Tsirkin
2013-09-22 13:38 ` [Qemu-devel] [PATCH v4 22/23] hpet: add API to find it Michael S. Tsirkin
2013-09-22 19:22   ` Paolo Bonzini
2013-09-22 19:58     ` Michael S. Tsirkin
2013-09-22 13:38 ` [Qemu-devel] [PATCH v4 23/23] i386: ACPI table generation code from seabios Michael S. Tsirkin
2013-09-24  9:23 ` [Qemu-devel] [PATCH v4 00/23] qemu: generate acpi tables for the guest Gerd Hoffmann
2013-09-24 21:45   ` 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=1379857006-17451-7-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=afaerber@suse.de \
    --cc=anthony@codemonkey.ws \
    --cc=lersek@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 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.