diff mbox

[2/6] hw/arm/boot: return size of loaded DTB from load_dtb()

Message ID 1409930126-28449-3-git-send-email-ard.biesheuvel@linaro.org
State New
Headers show

Commit Message

Ard Biesheuvel Sept. 5, 2014, 3:15 p.m. UTC
Add a dtb_size output parameter to load_dtb() so that we can find out
what its memory footprint is.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 hw/arm/boot.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Peter Maydell Sept. 9, 2014, 5:57 p.m. UTC | #1
On 5 September 2014 16:15, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> Add a dtb_size output parameter to load_dtb() so that we can find out
> what its memory footprint is.
>
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  hw/arm/boot.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/hw/arm/boot.c b/hw/arm/boot.c
> index e32f2f415885..c103a8fdc941 100644
> --- a/hw/arm/boot.c
> +++ b/hw/arm/boot.c
> @@ -312,7 +312,8 @@ static void set_kernel_args_old(const struct arm_boot_info *info)
>      }
>  }
>
> -static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)
> +static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
> +                    uint32_t *dtb_size)

Given that the return value is just a success/fail
indicator at the moment we could just change it
so we return the size of the dtb, with 0 meaning
"failure".

Either way, the size parameter/return should be
hwaddr, not uint32_t.

thanks
-- PMM
diff mbox

Patch

diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index e32f2f415885..c103a8fdc941 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -312,7 +312,8 @@  static void set_kernel_args_old(const struct arm_boot_info *info)
     }
 }
 
-static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)
+static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
+                    uint32_t *dtb_size)
 {
     void *fdt = NULL;
     int size, rc;
@@ -340,6 +341,9 @@  static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo)
             goto fail;
         }
     }
+    if (dtb_size != NULL) {
+        *dtb_size = size;
+    }
 
     acells = qemu_fdt_getprop_cell(fdt, "/", "#address-cells");
     scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells");
@@ -569,7 +573,7 @@  void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info)
              */
             hwaddr dtb_start = QEMU_ALIGN_UP(info->initrd_start + initrd_size,
                                              4096);
-            if (load_dtb(dtb_start, info)) {
+            if (load_dtb(dtb_start, info, NULL)) {
                 exit(1);
             }
             fixupcontext[FIXUP_ARGPTR] = dtb_start;