All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@xilinx.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: alistair.francis@xilinx.com, crosthwaitepeter@gmail.com,
	armbru@redhat.com, cov@codeaurora.org, pbonzini@redhat.com
Subject: [Qemu-devel] [PATCH v11 6/8] loader: Add AddressSpace loading support to targphys
Date: Tue, 20 Sep 2016 07:54:21 -0700	[thread overview]
Message-ID: <87de45de7acf02cbe6bae9d6c4d6fb8f3aba4f61.1474331683.git.alistair.francis@xilinx.com> (raw)
In-Reply-To: <cover.1474331683.git.alistair.francis@xilinx.com>

Add a new function load_image_targphys_as() that allows the caller
to specify an AddressSpace to use when loading a targphys. The
original load_image_targphys() function doesn't have any change in
functionality.

Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
---
V10:
 - Add comment about the function in the header file.

 hw/core/loader.c    | 10 ++++++++--
 include/hw/loader.h | 22 ++++++++++++++++++++++
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/hw/core/loader.c b/hw/core/loader.c
index 86ed784..6e022b5 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -133,10 +133,16 @@ ssize_t read_targphys(const char *name,
     return did;
 }
 
-/* return the size or -1 if error */
 int load_image_targphys(const char *filename,
                         hwaddr addr, uint64_t max_sz)
 {
+    return load_image_targphys_as(filename, addr, max_sz, NULL);
+}
+
+/* return the size or -1 if error */
+int load_image_targphys_as(const char *filename,
+                           hwaddr addr, uint64_t max_sz, AddressSpace *as)
+{
     int size;
 
     size = get_image_size(filename);
@@ -144,7 +150,7 @@ int load_image_targphys(const char *filename,
         return -1;
     }
     if (size > 0) {
-        rom_add_file_fixed(filename, addr, -1);
+        rom_add_file_fixed_as(filename, addr, -1, as);
     }
     return size;
 }
diff --git a/include/hw/loader.h b/include/hw/loader.h
index bce8f43..0381706 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -14,8 +14,28 @@
 int get_image_size(const char *filename);
 int load_image(const char *filename, uint8_t *addr); /* deprecated */
 ssize_t load_image_size(const char *filename, void *addr, size_t size);
+
+/**load_image_targphys_as:
+ * @filename: Path to the image file
+ * @addr: Address to load the image to
+ * @max_sz: The maximum size of the image to load
+ * @as: The AddressSpace to load the ELF to. The value of address_space_memory
+ *      is used if nothing is supplied here.
+ *
+ * Load a fixed image into memory.
+ *
+ * Returns the size of the loaded image on success, -1 otherwise.
+ */
+int load_image_targphys_as(const char *filename,
+                           hwaddr addr, uint64_t max_sz, AddressSpace *as);
+
+/** load_image_targphys:
+ * Same as load_image_targphys_as(), but doesn't allow the caller to specify
+ * an AddressSpace.
+ */
 int load_image_targphys(const char *filename, hwaddr,
                         uint64_t max_sz);
+
 /**
  * load_image_mr: load an image into a memory region
  * @filename: Path to the image file
@@ -179,6 +199,8 @@ void hmp_info_roms(Monitor *mon, const QDict *qdict);
     rom_add_file(_f, NULL, 0, _i, false, _mr, NULL)
 #define rom_add_file_as(_f, _as, _i)            \
     rom_add_file(_f, NULL, 0, _i, false, NULL, _as)
+#define rom_add_file_fixed_as(_f, _a, _i, _as)          \
+    rom_add_file(_f, NULL, _a, _i, false, NULL, _as)
 #define rom_add_blob_fixed_as(_f, _b, _l, _a, _as)      \
     rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, _as)
 
-- 
2.7.4

  parent reply	other threads:[~2016-09-20 15:28 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-20 14:54 [Qemu-devel] [PATCH v11 0/8] Add a generic loader Alistair Francis
2016-09-20 14:54 ` [Qemu-devel] [PATCH v11 1/8] loader: Allow ELF loader to auto-detect the ELF arch Alistair Francis
2016-09-20 14:54 ` [Qemu-devel] [PATCH v11 2/8] loader: Use the specified MemoryRegion Alistair Francis
2016-09-20 14:54 ` [Qemu-devel] [PATCH v11 3/8] loader: Allow a custom AddressSpace when loading ROMs Alistair Francis
2016-09-20 14:54 ` [Qemu-devel] [PATCH v11 4/8] loader: Add AddressSpace loading support to ELFs Alistair Francis
2016-09-20 14:54 ` [Qemu-devel] [PATCH v11 5/8] loader: Add AddressSpace loading support to uImages Alistair Francis
2016-09-20 14:54 ` Alistair Francis [this message]
2016-09-20 14:54 ` [Qemu-devel] [PATCH v11 7/8] generic-loader: Add a generic loader Alistair Francis
2016-09-20 14:54 ` [Qemu-devel] [PATCH v11 8/8] docs: Add a generic loader explanation document Alistair Francis
2016-09-20 17:41 ` [Qemu-devel] [PATCH v11 0/8] Add a generic loader Peter Maydell
2016-09-20 18:22   ` Alistair Francis
2016-09-21  6:05 ` Markus Armbruster
2016-09-21 15:46   ` Alistair Francis
2016-09-21 15:53     ` Paolo Bonzini
2016-09-22  9:19       ` Markus Armbruster
2016-09-22  9:22         ` Paolo Bonzini
2016-09-22 11:50           ` Markus Armbruster
2016-09-22 14:01             ` Peter Maydell
2016-09-23  8:10               ` Markus Armbruster
2016-09-23  8:18                 ` Paolo Bonzini
2016-09-27 13:28                   ` Markus Armbruster
2016-09-27 14:14                     ` Paolo Bonzini
2016-09-27 15:40                       ` Markus Armbruster
2016-09-27 16:24                         ` Alistair Francis
2016-09-28  2:04                           ` Markus Armbruster
2016-09-28 22:48                             ` Alistair Francis
2016-09-27 15:17                     ` Peter Maydell
2016-09-21 15:54   ` Daniel P. Berrange

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=87de45de7acf02cbe6bae9d6c4d6fb8f3aba4f61.1474331683.git.alistair.francis@xilinx.com \
    --to=alistair.francis@xilinx.com \
    --cc=armbru@redhat.com \
    --cc=cov@codeaurora.org \
    --cc=crosthwaitepeter@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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.