[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 30/36] loader: Add AddressSpace loading support to uI
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PULL 30/36] loader: Add AddressSpace loading support to uImages |
Date: |
Thu, 22 Sep 2016 18:22:09 +0100 |
From: Alistair Francis <address@hidden>
Add a new function load_uimage_as() that allows the caller to
specify an AddressSpace to use when loading the uImage. The
original load_uimage() function doesn't have any change in
functionality.
Signed-off-by: Alistair Francis <address@hidden>
Reviewed-by: Peter Maydell <address@hidden>
Message-id: address@hidden
Signed-off-by: Peter Maydell <address@hidden>
---
hw/core/loader.c | 17 +++++++++++++----
include/hw/loader.h | 26 ++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 4 deletions(-)
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 31cbeac..86ed784 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -581,7 +581,7 @@ static ssize_t gunzip(void *dst, size_t dstlen, uint8_t
*src,
static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr,
int *is_linux, uint8_t image_type,
uint64_t (*translate_fn)(void *, uint64_t),
- void *translate_opaque)
+ void *translate_opaque, AddressSpace *as)
{
int fd;
int size;
@@ -682,7 +682,7 @@ static int load_uboot_image(const char *filename, hwaddr
*ep, hwaddr *loadaddr,
hdr->ih_size = bytes;
}
- rom_add_blob_fixed(filename, data, hdr->ih_size, address);
+ rom_add_blob_fixed_as(filename, data, hdr->ih_size, address, as);
ret = hdr->ih_size;
@@ -698,14 +698,23 @@ int load_uimage(const char *filename, hwaddr *ep, hwaddr
*loadaddr,
void *translate_opaque)
{
return load_uboot_image(filename, ep, loadaddr, is_linux, IH_TYPE_KERNEL,
- translate_fn, translate_opaque);
+ translate_fn, translate_opaque, NULL);
+}
+
+int load_uimage_as(const char *filename, hwaddr *ep, hwaddr *loadaddr,
+ int *is_linux,
+ uint64_t (*translate_fn)(void *, uint64_t),
+ void *translate_opaque, AddressSpace *as)
+{
+ return load_uboot_image(filename, ep, loadaddr, is_linux, IH_TYPE_KERNEL,
+ translate_fn, translate_opaque, as);
}
/* Load a ramdisk. */
int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz)
{
return load_uboot_image(filename, NULL, &addr, NULL, IH_TYPE_RAMDISK,
- NULL, NULL);
+ NULL, NULL, NULL);
}
/* Load a gzip-compressed kernel to a dynamically allocated buffer. */
diff --git a/include/hw/loader.h b/include/hw/loader.h
index fdf0a51..bce8f43 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -102,6 +102,30 @@ void load_elf_hdr(const char *filename, void *hdr, bool
*is64, Error **errp);
int load_aout(const char *filename, hwaddr addr, int max_sz,
int bswap_needed, hwaddr target_page_size);
+
+/** load_uimage_as:
+ * @filename: Path of uimage file
+ * @ep: Populated with program entry point. Ignored if NULL.
+ * @loadaddr: Populated with the load address. Ignored if NULL.
+ * @is_linux: Is set to true if the image loaded is Linux. Ignored if NULL.
+ * @translate_fn: optional function to translate load addresses
+ * @translate_opaque: opaque data passed to @translate_fn
+ * @as: The AddressSpace to load the ELF to. The value of address_space_memory
+ * is used if nothing is supplied here.
+ *
+ * Loads a u-boot image into memory.
+ *
+ * Returns the size of the loaded image on success, -1 otherwise.
+ */
+int load_uimage_as(const char *filename, hwaddr *ep,
+ hwaddr *loadaddr, int *is_linux,
+ uint64_t (*translate_fn)(void *, uint64_t),
+ void *translate_opaque, AddressSpace *as);
+
+/** load_uimage:
+ * Same as load_uimage_as(), but doesn't allow the caller to specify an
+ * AddressSpace.
+ */
int load_uimage(const char *filename, hwaddr *ep,
hwaddr *loadaddr, int *is_linux,
uint64_t (*translate_fn)(void *, uint64_t),
@@ -155,6 +179,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_blob_fixed_as(_f, _b, _l, _a, _as) \
+ rom_add_blob(_f, _b, _l, _l, _a, NULL, NULL, _as)
#define PC_ROM_MIN_VGA 0xc0000
#define PC_ROM_MIN_OPTION 0xc8000
--
2.7.4
- [Qemu-devel] [PULL 09/36] aspeed: add a ast2500 SoC and support to the SCU and SDMC controllers, (continued)
- [Qemu-devel] [PULL 09/36] aspeed: add a ast2500 SoC and support to the SCU and SDMC controllers, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 22/36] cadence_gem: Add support for screening, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 25/36] xlnx-zynqmp: Set the number of priority queues, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 11/36] palmetto-bmc: remove extra no_sdcard assignement, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 14/36] aspeed: add a ram_size property to the memory controller, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 21/36] cadence_gem: Add the num-priority-queues property, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 27/36] loader: Use the specified MemoryRegion, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 02/36] ast2400: rename the Aspeed SoC files to aspeed_soc, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 20/36] cadence_gem: QOMify Cadence GEM, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 29/36] loader: Add AddressSpace loading support to ELFs, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 30/36] loader: Add AddressSpace loading support to uImages,
Peter Maydell <=
- [Qemu-devel] [PULL 01/36] arm: add Cortex A7 CPU parameters, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 04/36] aspeed-soc: provide a framework to add new SoCs, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 31/36] loader: Add AddressSpace loading support to targphys, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 32/36] dma: xlnx-zynq-devcfg: Fix up XLNX_ZYNQ_DEVCFG_R_MAX, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 34/36] vmstateify ssi-sd, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 36/36] imx: Use 'const char', not 'char const', Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 06/36] palmetto-bmc: replace palmetto_bmc with aspeed, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 17/36] hw/ptimer: Introduce timer policy feature, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 19/36] tests: Add ptimer tests, Peter Maydell, 2016/09/22
- [Qemu-devel] [PULL 24/36] cadence_gem: Correct indentation, Peter Maydell, 2016/09/22