|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 16/19] xen/dt: Extract helper to map nodes to module kinds
This will be required later by x86 code in order to do early identification
of boot modules when booting off a DTB.
Not a functional change.
Signed-off-by: Alejandro Vallejo <agarciav@xxxxxxx>
---
xen/common/device-tree/bootfdt.c | 16 ++++++++++++++++
xen/common/device-tree/bootinfo-fdt.c | 14 +-------------
xen/include/xen/bootfdt.h | 7 +++++++
3 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/xen/common/device-tree/bootfdt.c b/xen/common/device-tree/bootfdt.c
index 5decf17faf..2dda7a9d19 100644
--- a/xen/common/device-tree/bootfdt.c
+++ b/xen/common/device-tree/bootfdt.c
@@ -4,6 +4,22 @@
#include <xen/lib.h>
#include <xen/libfdt/libfdt.h>
+bootmodule_kind __init fdt_node_to_kind(const void *fdt, int node)
+{
+ if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") == 0 ||
+ fdt_node_check_compatible(fdt, node, "multiboot,kernel") == 0 )
+ return BOOTMOD_KERNEL;
+ if ( fdt_node_check_compatible(fdt, node, "xen,linux-initrd") == 0 ||
+ fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") == 0 )
+ return BOOTMOD_RAMDISK;
+ if ( fdt_node_check_compatible(fdt, node, "xen,xsm-policy") == 0 )
+ return BOOTMOD_XSM;
+ if ( fdt_node_check_compatible(fdt, node, "multiboot,device-tree") == 0 )
+ return BOOTMOD_GUEST_DTB;
+
+ return BOOTMOD_UNKNOWN;
+}
+
uint32_t __init device_tree_get_u32(const void *fdt, int node,
const char *prop_name, uint32_t dflt)
{
diff --git a/xen/common/device-tree/bootinfo-fdt.c
b/xen/common/device-tree/bootinfo-fdt.c
index 736f877616..dc399bbf61 100644
--- a/xen/common/device-tree/bootinfo-fdt.c
+++ b/xen/common/device-tree/bootinfo-fdt.c
@@ -239,19 +239,7 @@ static void __init process_multiboot_node(const void *fdt,
int node,
cell = (const __be32 *)prop->data;
device_tree_get_reg(&cell, address_cells, size_cells, &start, &size);
-
- if ( fdt_node_check_compatible(fdt, node, "xen,linux-zimage") == 0 ||
- fdt_node_check_compatible(fdt, node, "multiboot,kernel") == 0 )
- kind = BOOTMOD_KERNEL;
- else if ( fdt_node_check_compatible(fdt, node, "xen,linux-initrd") == 0 ||
- fdt_node_check_compatible(fdt, node, "multiboot,ramdisk") == 0 )
- kind = BOOTMOD_RAMDISK;
- else if ( fdt_node_check_compatible(fdt, node, "xen,xsm-policy") == 0 )
- kind = BOOTMOD_XSM;
- else if ( fdt_node_check_compatible(fdt, node, "multiboot,device-tree") ==
0 )
- kind = BOOTMOD_GUEST_DTB;
- else
- kind = BOOTMOD_UNKNOWN;
+ kind = fdt_node_to_kind(fdt, node);
/**
* Guess the kind of these first two unknowns respectively:
diff --git a/xen/include/xen/bootfdt.h b/xen/include/xen/bootfdt.h
index 766956e102..7bc6209986 100644
--- a/xen/include/xen/bootfdt.h
+++ b/xen/include/xen/bootfdt.h
@@ -102,4 +102,11 @@ uint32_t device_tree_get_u32(const void *fdt, int node,
void device_tree_get_reg(const __be32 **cell, uint32_t address_cells,
uint32_t size_cells, paddr_t *start, paddr_t *size);
+/*
+ * Probe an FDT node thought to be a boot module to identify its kind.
+ *
+ * If correctly identified, returns the detected kind, otherwise
BOOTMOD_UNKNOWN
+ */
+bootmodule_kind fdt_node_to_kind(const void *fdt, int node);
+
#endif /* XEN_BOOTFDT_H */
--
2.43.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |