On Tue Jul 8, 2025 at 8:07 PM CEST, Alejandro Vallejo wrote:
> From: Alejandro Vallejo <agarc...@amd.com>
>
> Part of an unpicking process to extract bootfdt contents independent of 
> bootinfo
> to a separate file for x86 to take.
>
> Move functions required for early FDT parsing from device_tree.h and arm's
> setup.h onto bootfdt.h
>
> Declaration motion only. Not a functional change.
>
> Signed-off-by: Alejandro Vallejo <agarc...@amd.com>
> Reviewed-by: Stefano Stabellini <sstabell...@kernel.org>
> ---
>  xen/arch/riscv/cpufeature.c            |  1 +
>  xen/arch/riscv/smpboot.c               |  1 +
>  xen/common/device-tree/device-tree.c   |  1 +
>  xen/common/device-tree/static-evtchn.c |  1 +
>  xen/common/sched/boot-cpupool.c        |  1 +
>  xen/include/xen/bootfdt.h              | 91 ++++++++++++++++++++++++++
>  xen/include/xen/device_tree.h          | 78 ----------------------
>  7 files changed, 96 insertions(+), 78 deletions(-)
>
> diff --git a/xen/arch/riscv/cpufeature.c b/xen/arch/riscv/cpufeature.c
> index b7d5ec6580..b846a106a3 100644
> --- a/xen/arch/riscv/cpufeature.c
> +++ b/xen/arch/riscv/cpufeature.c
> @@ -8,6 +8,7 @@
>   */
>  
>  #include <xen/bitmap.h>
> +#include <xen/bootfdt.h>
>  #include <xen/ctype.h>
>  #include <xen/device_tree.h>
>  #include <xen/errno.h>
> diff --git a/xen/arch/riscv/smpboot.c b/xen/arch/riscv/smpboot.c
> index 470f6d1311..3b8bf98e20 100644
> --- a/xen/arch/riscv/smpboot.c
> +++ b/xen/arch/riscv/smpboot.c
> @@ -1,3 +1,4 @@
> +#include <xen/bootfdt.h>
>  #include <xen/cpumask.h>
>  #include <xen/device_tree.h>
>  #include <xen/errno.h>
> diff --git a/xen/common/device-tree/device-tree.c 
> b/xen/common/device-tree/device-tree.c
> index 7bede20fa6..4ebdb2e52e 100644
> --- a/xen/common/device-tree/device-tree.c
> +++ b/xen/common/device-tree/device-tree.c
> @@ -8,6 +8,7 @@
>   */
>  
>  #include <xen/bitops.h>
> +#include <xen/bootfdt.h>
>  #include <xen/types.h>
>  #include <xen/init.h>
>  #include <xen/guest_access.h>
> diff --git a/xen/common/device-tree/static-evtchn.c 
> b/xen/common/device-tree/static-evtchn.c
> index 8b82e6b3d8..88342b44a1 100644
> --- a/xen/common/device-tree/static-evtchn.c
> +++ b/xen/common/device-tree/static-evtchn.c
> @@ -1,5 +1,6 @@
>  /* SPDX-License-Identifier: GPL-2.0-only */
>  
> +#include <xen/bootfdt.h>
>  #include <xen/event.h>
>  #include <xen/static-evtchn.h>
>  
> diff --git a/xen/common/sched/boot-cpupool.c b/xen/common/sched/boot-cpupool.c
> index 641f3495cb..03be73efdd 100644
> --- a/xen/common/sched/boot-cpupool.c
> +++ b/xen/common/sched/boot-cpupool.c
> @@ -7,6 +7,7 @@
>   * Copyright (C) 2022 Arm Ltd.
>   */
>  
> +#include <xen/bootfdt.h>
>  #include <xen/acpi.h>
>  #include <xen/sched.h>
>  
> diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h
> index 65ba818e1a..6cf6c1317c 100644
> --- a/xen/include/xen/bootfdt.h
> +++ b/xen/include/xen/bootfdt.h
> @@ -2,8 +2,11 @@
>  #ifndef XEN_BOOTFDT_H
>  #define XEN_BOOTFDT_H
>  
> +#include <xen/byteorder.h>
> +#include <xen/bug.h>
>  #include <xen/types.h>
>  #include <xen/kernel.h>
> +#include <xen/lib.h>
>  #include <xen/macros.h>
>  #include <xen/xmalloc.h>
>  
> @@ -16,8 +19,80 @@
>  #define NR_MEM_BANKS 256
>  #define NR_SHMEM_BANKS 32
>  
> +/* Default #address and #size cells */
> +#define DT_ROOT_NODE_ADDR_CELLS_DEFAULT 2
> +#define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1
> +
>  #define MAX_MODULES 32 /* Current maximum useful modules */
>  
> +#define DEVICE_TREE_MAX_DEPTH 16
> +
> +/* Helper to read a big number; size is in cells (not bytes) */
> +static inline u64 dt_read_number(const __be32 *cell, int size)
> +{
> +    u64 r = 0;
> +
> +    while ( size-- )
> +        r = (r << 32) | be32_to_cpu(*(cell++));
> +    return r;
> +}

Bah, bad rebase. This should've been the new switch. I'll correct it on when I
resend it.

Cheers,
Alejandro

Reply via email to