Re: [PATCH v3 05/15] tests: treegen: Introduce emit_fdt_header_vers()
From: David Gibson
Date: Wed Sep 09 2026 - 02:38:49 EST
On Wed, Aug 26, 2026 at 10:31:36AM +0200, Herve Codina wrote:
11;rgb:1c1c/1c1c/1f1f> treegen is used to generate custom dtbs. It uses emit_fdt_header()
> to generate the header part.
>
> The current definition of this function doesn't allow to set custom
> settings related to version fields.
>
> In order to easily generate some dtb with custom version values,
> introduce emit_fdt_header_vers().
>
> The modification doesn't introduce any functional changes.
>
> Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>
Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
> ---
> tests/treegen.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/tests/treegen.c b/tests/treegen.c
> index 6891bfd6..28943d43 100644
> --- a/tests/treegen.c
> +++ b/tests/treegen.c
> @@ -105,7 +105,8 @@ static void fill_prop_name(struct buf *b, size_t strs, size_t prop, size_t strof
>
> /* FDT structure helpers */
>
> -static size_t emit_fdt_header(struct buf *b)
> +static size_t emit_fdt_header_vers(struct buf *b, uint32_t version,
> + uint32_t last_comp_version)
> {
> size_t off = emit_u32(b, FDT_MAGIC);
>
> @@ -113,14 +114,19 @@ static size_t emit_fdt_header(struct buf *b)
> emit_u32(b, 0); /* off_dt_struct */
> emit_u32(b, 0); /* off_dt_strings */
> emit_u32(b, 0); /* off_mem_rsvmap */
> - emit_u32(b, 0x11); /* version */
> - emit_u32(b, 0x10); /* last_comp_version */
> + emit_u32(b, version); /* version */
> + emit_u32(b, last_comp_version); /* last_comp_version */
> emit_u32(b, 0); /* boot_cpuid_phys */
> emit_u32(b, 0); /* size_dt_strings */
> emit_u32(b, 0); /* size_dt_struct */
> return off;
> }
>
> +static size_t emit_fdt_header(struct buf *b)
> +{
> + return emit_fdt_header_vers(b, 0x11, 0x10);
> +}
> +
> static void finish_rsvmap(struct buf *b, size_t hdr, size_t rsvmap)
> {
> struct fdt_header *fh = (struct fdt_header *)(b->data + hdr);
> --
> 2.55.0
>
>
--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson
Attachment:
signature.asc
Description: PGP signature