[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-7.2 v3 18/20] device_node.c: enable 'info fdt' to print subno
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH for-7.2 v3 18/20] device_node.c: enable 'info fdt' to print subnodes |
Date: |
Tue, 16 Aug 2022 14:34:26 -0300 |
Printing subnodes of a given node will allow us to show a whole subtree,
which the additional perk of 'info fdt /' being able to print the whole
FDT.
Since we're now printing more than one subnode, change 'fdt_info' to
print the full path of the first node. This small tweak helps
identifying which node or subnode are being displayed.
To demostrate this capability without printing the whole FDT, the
'/cpus/cpu-map' node from the ARM 'virt' machine has a lot of subnodes:
(qemu) info fdt /cpus/cpu-map
/cpus/cpu-map {
socket0 {
cluster0 {
core0 {
cpu = <0x8001>
}
}
}
}
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
softmmu/device_tree.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c
index 43f96e371b..a6bfbc0617 100644
--- a/softmmu/device_tree.c
+++ b/softmmu/device_tree.c
@@ -766,17 +766,26 @@ static void fdt_prop_format_val(GString *buf, const char
*propname,
g_string_append_printf(buf, "];\n");
}
-static void fdt_format_node(GString *buf, int node, int depth)
+
+static void fdt_format_node(GString *buf, int node, int depth,
+ const char *fullpath)
{
const struct fdt_property *prop = NULL;
+ const char *nodename = NULL;
const char *propname = NULL;
void *fdt = current_machine->fdt;
int padding = depth * 4;
int property = 0;
+ int parent = node;
int prop_size;
- g_string_append_printf(buf, "%*s%s {\n", padding, "",
- fdt_get_name(fdt, node, NULL));
+ if (fullpath != NULL) {
+ nodename = fullpath;
+ } else {
+ nodename = fdt_get_name(fdt, node, NULL);
+ }
+
+ g_string_append_printf(buf, "%*s%s {\n", padding, "", nodename);
padding += 4;
@@ -801,6 +810,10 @@ static void fdt_format_node(GString *buf, int node, int
depth)
}
}
+ fdt_for_each_subnode(node, fdt, parent) {
+ fdt_format_node(buf, node, depth + 1, NULL);
+ }
+
padding -= 4;
g_string_append_printf(buf, "%*s}\n", padding, "");
}
@@ -821,7 +834,7 @@ HumanReadableText *qemu_fdt_qmp_query_fdt(const char
*nodepath, Error **errp)
return NULL;
}
- fdt_format_node(buf, node, 0);
+ fdt_format_node(buf, node, 0, nodepath);
return human_readable_text_from_str(buf);
}
--
2.37.2
- [PATCH for-7.2 v3 12/20] hw/riscv: set machine->fdt in spike_board_init(), (continued)
- [PATCH for-7.2 v3 12/20] hw/riscv: set machine->fdt in spike_board_init(), Daniel Henrique Barboza, 2022/08/16
- [PATCH for-7.2 v3 11/20] hw/riscv: set machine->fdt in sifive_u_machine_init(), Daniel Henrique Barboza, 2022/08/16
- [PATCH for-7.2 v3 16/20] device_tree.c: support string array prop in fdt_format_node(), Daniel Henrique Barboza, 2022/08/16
- [PATCH for-7.2 v3 17/20] device_tree.c: support remaining FDT prop types, Daniel Henrique Barboza, 2022/08/16
- [PATCH for-7.2 v3 15/20] qmp/hmp, device_tree.c: introduce 'info fdt' command, Daniel Henrique Barboza, 2022/08/16
- [PATCH for-7.2 v3 20/20] hmp, device_tree.c: add 'info fdt <property>' support, Daniel Henrique Barboza, 2022/08/16
- [PATCH for-7.2 v3 18/20] device_node.c: enable 'info fdt' to print subnodes,
Daniel Henrique Barboza <=
- [PATCH for-7.2 v3 19/20] device_tree.c: add fdt_format_property() helper, Daniel Henrique Barboza, 2022/08/16