From: Bin Meng <bin.meng@windriver.com>
To: qemu-devel@nongnu.org
Cc: Alistair Francis <alistair@alistair23.me>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>,
Peter Maydell <peter.maydell@linaro.org>,
Radoslaw Biernacki <rad@semihalf.com>,
qemu-arm@nongnu.org
Subject: [PATCH 1/3] hw/arm: Refactor struct arm_boot_info::get_dtb()
Date: Mon, 15 Jan 2024 12:34:28 +0800 [thread overview]
Message-ID: <20240115043431.3900922-2-bin.meng@windriver.com> (raw)
In-Reply-To: <20240115043431.3900922-1-bin.meng@windriver.com>
At present we expect struct arm_boot_info::get_dtb() to return the
device tree pointer as well as the device tree size. However, this
is not necessary as we can get the device tree size via the device
tree header directly. Change get_dtb() signature to drop the *size
argument, and get the size by ourselves.
Signed-off-by: Bin Meng <bin.meng@windriver.com>
---
include/hw/arm/boot.h | 8 ++++----
hw/arm/boot.c | 3 ++-
hw/arm/sbsa-ref.c | 3 +--
hw/arm/virt.c | 4 +---
hw/arm/xlnx-versal-virt.c | 4 +---
5 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/include/hw/arm/boot.h b/include/hw/arm/boot.h
index 80c492d742..37fd1b520e 100644
--- a/include/hw/arm/boot.h
+++ b/include/hw/arm/boot.h
@@ -82,11 +82,11 @@ struct arm_boot_info {
const struct arm_boot_info *info);
/* if a board is able to create a dtb without a dtb file then it
* sets get_dtb. This will only be used if no dtb file is provided
- * by the user. On success, sets *size to the length of the created
- * dtb, and returns a pointer to it. (The caller must free this memory
- * with g_free() when it has finished with it.) On failure, returns NULL.
+ * by the user. On success, returns a pointer to it. (The caller must
+ * free this memory with g_free() when it has finished with it.)
+ * On failure, returns NULL.
*/
- void *(*get_dtb)(const struct arm_boot_info *info, int *size);
+ void *(*get_dtb)(const struct arm_boot_info *info);
/* if a board needs to be able to modify a device tree provided by
* the user it should implement this hook.
*/
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 84ea6a807a..ff1173299f 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -538,11 +538,12 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
}
g_free(filename);
} else {
- fdt = binfo->get_dtb(binfo, &size);
+ fdt = binfo->get_dtb(binfo);
if (!fdt) {
fprintf(stderr, "Board was unable to create a dtb blob\n");
goto fail;
}
+ size = fdt_totalsize(fdt);
}
if (addr_limit > addr && size > (addr_limit - addr)) {
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index 477dca0637..c5023871a7 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -681,12 +681,11 @@ static void create_pcie(SBSAMachineState *sms)
create_smmu(sms, pci->bus);
}
-static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size)
+static void *sbsa_ref_dtb(const struct arm_boot_info *binfo)
{
const SBSAMachineState *board = container_of(binfo, SBSAMachineState,
bootinfo);
- *fdt_size = board->fdt_size;
return board->fdt;
}
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 2793121cb4..1996fffa99 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1577,14 +1577,12 @@ static void create_secure_ram(VirtMachineState *vms,
g_free(nodename);
}
-static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size)
+static void *machvirt_dtb(const struct arm_boot_info *binfo)
{
const VirtMachineState *board = container_of(binfo, VirtMachineState,
bootinfo);
MachineState *ms = MACHINE(board);
-
- *fdt_size = board->fdt_size;
return ms->fdt;
}
diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c
index 537118224f..1e043c813e 100644
--- a/hw/arm/xlnx-versal-virt.c
+++ b/hw/arm/xlnx-versal-virt.c
@@ -551,12 +551,10 @@ static void versal_virt_modify_dtb(const struct arm_boot_info *binfo,
fdt_add_memory_nodes(s, fdt, binfo->ram_size);
}
-static void *versal_virt_get_dtb(const struct arm_boot_info *binfo,
- int *fdt_size)
+static void *versal_virt_get_dtb(const struct arm_boot_info *binfo)
{
const VersalVirt *board = container_of(binfo, VersalVirt, binfo);
- *fdt_size = board->fdt_size;
return board->fdt;
}
--
2.34.1
next prev parent reply other threads:[~2024-01-15 4:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-15 4:34 [PATCH 0/3] hw/arm: Pack the QEMU generated device tree Bin Meng
2024-01-15 4:34 ` Bin Meng [this message]
2024-01-15 11:06 ` [PATCH 1/3] hw/arm: Refactor struct arm_boot_info::get_dtb() Philippe Mathieu-Daudé
2024-01-22 3:26 ` Alistair Francis
2024-01-15 4:34 ` [PATCH 2/3] hw/arm: Pack the QEMU generated device tree Bin Meng
2024-01-19 14:17 ` Peter Maydell
2024-01-15 4:34 ` [PATCH 3/3] tests/acpi: Update virt/SSDT.memhp Bin Meng
2024-01-15 11:39 ` Alex Bennée
2024-01-15 14:46 ` Bin Meng
2024-01-15 19:07 ` Laszlo Ersek
2024-01-19 14:29 ` Peter Maydell
2024-01-19 17:19 ` Laszlo Ersek
2024-01-19 17:46 ` Peter Maydell
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=20240115043431.3900922-2-bin.meng@windriver.com \
--to=bin.meng@windriver.com \
--cc=alistair@alistair23.me \
--cc=edgar.iglesias@gmail.com \
--cc=marcin.juszkiewicz@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=quic_llindhol@quicinc.com \
--cc=rad@semihalf.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).