diff mbox series

[1/3] loader: Add new load_ramdisk_as()

Message ID 20180215175707.15491-2-peter.maydell@linaro.org
State Superseded
Headers show
Series Arm: honour CPU address space for image loads | expand

Commit Message

Peter Maydell Feb. 15, 2018, 5:57 p.m. UTC
Add a function load_ramdisk_as() which behaves like the existing
load_ramdisk() but allows the caller to specify the AddressSpace
to use. This matches the pattern we have already for various
other loader functions.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 include/hw/loader.h | 12 +++++++++++-
 hw/core/loader.c    |  8 +++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

-- 
2.16.1

Comments

Philippe Mathieu-Daudé Feb. 15, 2018, 6:07 p.m. UTC | #1
On 02/15/2018 02:57 PM, Peter Maydell wrote:
> Add a function load_ramdisk_as() which behaves like the existing

> load_ramdisk() but allows the caller to specify the AddressSpace

> to use. This matches the pattern we have already for various

> other loader functions.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


> ---

>  include/hw/loader.h | 12 +++++++++++-

>  hw/core/loader.c    |  8 +++++++-

>  2 files changed, 18 insertions(+), 2 deletions(-)

> 

> diff --git a/include/hw/loader.h b/include/hw/loader.h

> index 355fe0f5a2..1fd4256782 100644

> --- a/include/hw/loader.h

> +++ b/include/hw/loader.h

> @@ -163,16 +163,26 @@ int load_uimage(const char *filename, hwaddr *ep,

>                  void *translate_opaque);

>  

>  /**

> - * load_ramdisk:

> + * load_ramdisk_as:

>   * @filename: Path to the ramdisk image

>   * @addr: Memory address to load the ramdisk to

>   * @max_sz: Maximum allowed ramdisk size (for non-u-boot ramdisks)

> + * @as: The AddressSpace to load the ELF to. The value of address_space_memory

> + *      is used if nothing is supplied here.

>   *

>   * Load a ramdisk image with U-Boot header to the specified memory

>   * address.

>   *

>   * Returns the size of the loaded image on success, -1 otherwise.

>   */

> +int load_ramdisk_as(const char *filename, hwaddr addr, uint64_t max_sz,

> +                    AddressSpace *as);

> +

> +/**

> + * load_ramdisk:

> + * Same as load_ramdisk_as(), but doesn't allow the caller to specify

> + * an AddressSpace.

> + */

>  int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz);

>  

>  ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen);

> diff --git a/hw/core/loader.c b/hw/core/loader.c

> index 91669d65aa..2b9e7394a1 100644

> --- a/hw/core/loader.c

> +++ b/hw/core/loader.c

> @@ -729,9 +729,15 @@ int load_uimage_as(const char *filename, hwaddr *ep, hwaddr *loadaddr,

>  

>  /* Load a ramdisk.  */

>  int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz)

> +{

> +    return load_ramdisk_as(filename, addr, max_sz, NULL);

> +}

> +

> +int load_ramdisk_as(const char *filename, hwaddr addr, uint64_t max_sz,

> +                    AddressSpace *as)

>  {

>      return load_uboot_image(filename, NULL, &addr, NULL, IH_TYPE_RAMDISK,

> -                            NULL, NULL, NULL);

> +                            NULL, NULL, as);

>  }

>  

>  /* Load a gzip-compressed kernel to a dynamically allocated buffer. */

>
diff mbox series

Patch

diff --git a/include/hw/loader.h b/include/hw/loader.h
index 355fe0f5a2..1fd4256782 100644
--- a/include/hw/loader.h
+++ b/include/hw/loader.h
@@ -163,16 +163,26 @@  int load_uimage(const char *filename, hwaddr *ep,
                 void *translate_opaque);
 
 /**
- * load_ramdisk:
+ * load_ramdisk_as:
  * @filename: Path to the ramdisk image
  * @addr: Memory address to load the ramdisk to
  * @max_sz: Maximum allowed ramdisk size (for non-u-boot ramdisks)
+ * @as: The AddressSpace to load the ELF to. The value of address_space_memory
+ *      is used if nothing is supplied here.
  *
  * Load a ramdisk image with U-Boot header to the specified memory
  * address.
  *
  * Returns the size of the loaded image on success, -1 otherwise.
  */
+int load_ramdisk_as(const char *filename, hwaddr addr, uint64_t max_sz,
+                    AddressSpace *as);
+
+/**
+ * load_ramdisk:
+ * Same as load_ramdisk_as(), but doesn't allow the caller to specify
+ * an AddressSpace.
+ */
 int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz);
 
 ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen);
diff --git a/hw/core/loader.c b/hw/core/loader.c
index 91669d65aa..2b9e7394a1 100644
--- a/hw/core/loader.c
+++ b/hw/core/loader.c
@@ -729,9 +729,15 @@  int load_uimage_as(const char *filename, hwaddr *ep, hwaddr *loadaddr,
 
 /* Load a ramdisk.  */
 int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz)
+{
+    return load_ramdisk_as(filename, addr, max_sz, NULL);
+}
+
+int load_ramdisk_as(const char *filename, hwaddr addr, uint64_t max_sz,
+                    AddressSpace *as)
 {
     return load_uboot_image(filename, NULL, &addr, NULL, IH_TYPE_RAMDISK,
-                            NULL, NULL, NULL);
+                            NULL, NULL, as);
 }
 
 /* Load a gzip-compressed kernel to a dynamically allocated buffer. */