Message ID | 20240115043431.3900922-3-bin.meng@windriver.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | hw/arm: Pack the QEMU generated device tree | expand |
On Mon, 15 Jan 2024 at 04:34, Bin Meng <bin.meng@windriver.com> wrote: > > By default QEMU generates a 1 MiB sized device tree. Let's pack it > to save some room. > > Signed-off-by: Bin Meng <bin.meng@windriver.com> > --- > > hw/arm/boot.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/hw/arm/boot.c b/hw/arm/boot.c > index ff1173299f..511ec10ed0 100644 > --- a/hw/arm/boot.c > +++ b/hw/arm/boot.c > @@ -662,6 +662,17 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, > binfo->modify_dtb(binfo, fdt); > } > > + /* > + * By default QEMU generates a 1 MiB sized device tree. > + * Let's pack it to save some room. > + */ > + if (binfo->get_dtb) { > + rc = fdt_pack(fdt); > + /* Should only fail if we've built a corrupted tree */ > + g_assert(rc == 0); We generally use plain old assert(), not g_assert(). > + size = fdt_totalsize(fdt); > + } > + > qemu_fdt_dumpdtb(fdt, size); Otherwise Reviewed-by: Peter Maydell <peter.maydell@linaro.org> thanks -- PMM
diff --git a/hw/arm/boot.c b/hw/arm/boot.c index ff1173299f..511ec10ed0 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -662,6 +662,17 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, binfo->modify_dtb(binfo, fdt); } + /* + * By default QEMU generates a 1 MiB sized device tree. + * Let's pack it to save some room. + */ + if (binfo->get_dtb) { + rc = fdt_pack(fdt); + /* Should only fail if we've built a corrupted tree */ + g_assert(rc == 0); + size = fdt_totalsize(fdt); + } + qemu_fdt_dumpdtb(fdt, size); /* Put the DTB into the memory map as a ROM image: this will ensure
By default QEMU generates a 1 MiB sized device tree. Let's pack it to save some room. Signed-off-by: Bin Meng <bin.meng@windriver.com> --- hw/arm/boot.c | 11 +++++++++++ 1 file changed, 11 insertions(+)