From: Alejandro Vallejo <agarciav@amd.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: <xen-devel@lists.xenproject.org>, Julien Grall <julien@xen.org>,
"Bertrand Marquis" <bertrand.marquis@arm.com>,
Michal Orzel <michal.orzel@amd.com>,
"Daniel P. Smith" <dpsmith@apertussolutions.com>
Subject: Re: [PATCH v3 08/14] xen/dt: Move bootfdt functions to xen/bootfdt.h
Date: Mon, 16 Jun 2025 15:57:21 +0200 [thread overview]
Message-ID: <DAO0DMLBGSY7.25MPPJVB6G2KZ@amd.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2506131815200.8480@ubuntu-linux-20-04-desktop>
On Sat Jun 14, 2025 at 3:16 AM CEST, Stefano Stabellini wrote:
> On Fri, 13 Jun 2025, Alejandro Vallejo wrote:
>> 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 <agarciav@amd.com>
>> ---
>> v3:
>> * Avoid mutations during code motion
>> ---
>> xen/include/xen/bootfdt.h | 62 +++++++++++++++++++++++++++++++++++
>> xen/include/xen/device_tree.h | 40 +---------------------
>> 2 files changed, 63 insertions(+), 39 deletions(-)
>>
>> diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h
>> index 8ea52290b7..b6ae7d6aa6 100644
>> --- a/xen/include/xen/bootfdt.h
>> +++ b/xen/include/xen/bootfdt.h
>> @@ -2,6 +2,7 @@
>> #ifndef XEN_BOOTFDT_H
>> #define XEN_BOOTFDT_H
>>
>> +#include <xen/byteorder.h>
>> #include <xen/types.h>
>> #include <xen/kernel.h>
>> #include <xen/macros.h>
>> @@ -16,8 +17,53 @@
>> #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;
>> +}
>> +
>> +static inline u64 dt_next_cell(int s, const __be32 **cellp)
>> +{
>> + const __be32 *p = *cellp;
>> +
>> + *cellp = p + s;
>> + return dt_read_number(p, s);
>> +}
>> +
>> +typedef int (*device_tree_node_func)(const void *fdt,
>> + int node, const char *name, int depth,
>> + u32 address_cells, u32 size_cells,
>> + void *data);
>> +
>> +/**
>> + * device_tree_for_each_node - iterate over all device tree sub-nodes
>> + * @fdt: flat device tree.
>> + * @node: parent node to start the search from
>> + * @func: function to call for each sub-node.
>> + * @data: data to pass to @func.
>> + *
>> + * Any nodes nested at DEVICE_TREE_MAX_DEPTH or deeper are ignored.
>> + *
>> + * Returns 0 if all nodes were iterated over successfully. If @func
>> + * returns a value different from 0, that value is returned immediately.
>> + */
>> +int device_tree_for_each_node(const void *fdt, int node,
>> + device_tree_node_func func,
>> + void *data);
>> +
>> typedef enum {
>> BOOTMOD_XEN,
>> BOOTMOD_FDT,
>> @@ -260,4 +306,20 @@ static inline struct membanks *membanks_xzalloc(unsigned int nr,
>> return banks;
>> }
>>
>> +/*
>> + * Interpret the property `prop_name` of `node` as a u32.
>> + *
>> + * Returns the property value on success; otherwise returns `dflt`.
>> + */
>> +u32 device_tree_get_u32(const void *fdt, int node,
>> + const char *prop_name, u32 dflt);
>> +
>> +/*
>> + * Interpret the property `prop_name` of `node` as a "reg".
>> + *
>> + * Returns outputs in `start` and `size`.
>> + */
>> +void device_tree_get_reg(const __be32 **cell, uint32_t address_cells,
>> + uint32_t size_cells, paddr_t *start, paddr_t *size);
>> +
>> #endif /* XEN_BOOTFDT_H */
>> diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
>> index 75017e4266..0a22b1ba1d 100644
>> --- a/xen/include/xen/device_tree.h
>> +++ b/xen/include/xen/device_tree.h
>> @@ -10,6 +10,7 @@
>> #ifndef __XEN_DEVICE_TREE_H__
>> #define __XEN_DEVICE_TREE_H__
>>
>> +#include <xen/bootfdt.h>
>> #include <xen/byteorder.h>
>
> This should not be needed?
I wanted to avoid having to touch include sites. Let me check how many affected
places there are and fix up accordingly if any needs adjusting.
Cheers,
Alejandro
next prev parent reply other threads:[~2025-06-16 13:57 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-13 15:13 [PATCH v3 00/15] Allow x86 to unflatten DTs Alejandro Vallejo
2025-06-13 15:13 ` [PATCH v3 01/14] arm/gnttab: Remove xen/grant_table.h cyclic include Alejandro Vallejo
2025-06-14 0:30 ` Stefano Stabellini
2025-06-13 15:13 ` [PATCH v3 02/14] x86: Preinitialise all modules to be of kind BOOTMOD_UNKNOWN Alejandro Vallejo
2025-06-16 6:46 ` Jan Beulich
2025-06-13 15:13 ` [PATCH v3 03/14] CODING_STYLE: Custom type names must be snake-cased by word Alejandro Vallejo
2025-06-14 0:32 ` Stefano Stabellini
2025-06-16 11:08 ` Alejandro Vallejo
2025-06-16 6:48 ` Jan Beulich
2025-06-16 11:07 ` Alejandro Vallejo
2025-06-13 15:13 ` [PATCH v3 04/14] xen: Rename bootmodule{,s} to boot_module{,s} Alejandro Vallejo
2025-06-14 0:41 ` Stefano Stabellini
2025-06-17 1:12 ` Daniel P. Smith
2025-06-13 15:13 ` [PATCH v3 05/14] x86: Replace arch-specific boot_module with common one Alejandro Vallejo
2025-06-14 0:54 ` Stefano Stabellini
2025-06-16 11:35 ` Alejandro Vallejo
2025-06-17 11:36 ` Alejandro Vallejo
2025-06-13 15:13 ` [PATCH v3 06/14] xen: Refactor kernel_info to have a header like boot_domain Alejandro Vallejo
2025-06-14 0:58 ` Stefano Stabellini
2025-06-17 1:22 ` Daniel P. Smith
2025-06-17 10:05 ` Alejandro Vallejo
2025-06-13 15:13 ` [PATCH v3 07/14] x86: Replace arch-specific boot_domain common one bootdomain Alejandro Vallejo
2025-06-14 1:08 ` Stefano Stabellini
2025-06-13 15:13 ` [PATCH v3 08/14] xen/dt: Move bootfdt functions to xen/bootfdt.h Alejandro Vallejo
2025-06-14 1:16 ` Stefano Stabellini
2025-06-16 13:57 ` Alejandro Vallejo [this message]
2025-06-19 14:24 ` Alejandro Vallejo
2025-06-19 19:50 ` Stefano Stabellini
2025-06-13 15:13 ` [PATCH v3 09/14] xen/dt: Move bootinfo functions to a new bootinfo.h Alejandro Vallejo
2025-06-14 1:22 ` Stefano Stabellini
2025-06-13 15:13 ` [PATCH v3 10/14] xen/dt: Rename bootfdt.c -> bootinfo-fdt.c Alejandro Vallejo
2025-06-13 15:13 ` [PATCH v3 11/14] xen/dt: Extract helper to map nodes to module kinds Alejandro Vallejo
2025-06-13 15:13 ` [PATCH v3 12/14] xen/dt: ifdef out DEV_DT-related bits from device_tree.{c,h} Alejandro Vallejo
2025-06-14 1:24 ` Stefano Stabellini
2025-06-16 7:01 ` Jan Beulich
2025-06-16 7:57 ` Julien Grall
2025-06-13 15:13 ` [PATCH v3 13/14] xen/dt: Allow CONFIG_DOM0LESS_BOOT to include device-tree/ Alejandro Vallejo
2025-06-14 1:25 ` Stefano Stabellini
2025-06-16 6:55 ` Jan Beulich
2025-06-16 14:08 ` Alejandro Vallejo
2025-06-16 23:41 ` Stefano Stabellini
2025-06-13 15:13 ` [PATCH v3 14/14] kconfig: Allow x86 to pick CONFIG_DOM0LESS_BOOT Alejandro Vallejo
2025-06-14 1:26 ` Stefano Stabellini
2025-06-16 6:59 ` Jan Beulich
2025-06-16 14:12 ` Alejandro Vallejo
2025-06-16 14:19 ` Jan Beulich
2025-06-16 8:00 ` Julien Grall
2025-06-16 14:39 ` Alejandro Vallejo
2025-06-16 23:39 ` Stefano Stabellini
2025-06-17 1:01 ` dmkhn
2025-06-17 6:17 ` Jan Beulich
2025-06-13 15:28 ` [PATCH v3 00/15] Allow x86 to unflatten DTs Alejandro Vallejo
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=DAO0DMLBGSY7.25MPPJVB6G2KZ@amd.com \
--to=agarciav@amd.com \
--cc=bertrand.marquis@arm.com \
--cc=dpsmith@apertussolutions.com \
--cc=julien@xen.org \
--cc=michal.orzel@amd.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.