[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH for-7.2 v4 18/21] device_node.c: enable 'info fdt' to print subno
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH for-7.2 v4 18/21] device_node.c: enable 'info fdt' to print subnodes |
Date: |
Fri, 26 Aug 2022 11:11:47 -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 a770c6c1cc..5e4cb119f2 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 v4 06/21] hw/ppc: set machine->fdt in sam460ex_load_device_tree(), (continued)
- [PATCH for-7.2 v4 06/21] hw/ppc: set machine->fdt in sam460ex_load_device_tree(), Daniel Henrique Barboza, 2022/08/26
- [PATCH for-7.2 v4 05/21] hw/ppc: set machine->fdt in bamboo_load_device_tree(), Daniel Henrique Barboza, 2022/08/26
- [PATCH for-7.2 v4 07/21] hw/ppc: set machine->fdt in xilinx_load_device_tree(), Daniel Henrique Barboza, 2022/08/26
- [PATCH for-7.2 v4 08/21] hw/ppc: set machine->fdt in pegasos2_machine_reset(), Daniel Henrique Barboza, 2022/08/26
- [PATCH for-7.2 v4 09/21] hw/ppc: set machine->fdt in pnv_reset(), Daniel Henrique Barboza, 2022/08/26
- [PATCH for-7.2 v4 11/21] hw/riscv: set machine->fdt in sifive_u_machine_init(), Daniel Henrique Barboza, 2022/08/26
- [PATCH for-7.2 v4 13/21] hw/xtensa: set machine->fdt in xtfpga_init(), Daniel Henrique Barboza, 2022/08/26
- [PATCH for-7.2 v4 12/21] hw/riscv: set machine->fdt in spike_board_init(), Daniel Henrique Barboza, 2022/08/26
- [PATCH for-7.2 v4 18/21] device_node.c: enable 'info fdt' to print subnodes,
Daniel Henrique Barboza <=
- [PATCH for-7.2 v4 16/21] device_tree.c: support string array prop in fdt_format_node(), Daniel Henrique Barboza, 2022/08/26
- [PATCH for-7.2 v4 10/21] hw/ppc: set machine->fdt in spapr machine, Daniel Henrique Barboza, 2022/08/26
- [PATCH for-7.2 v4 15/21] qmp/hmp, device_tree.c: introduce 'info fdt' command, Daniel Henrique Barboza, 2022/08/26
- Re: [PATCH for-7.2 v4 15/21] qmp/hmp, device_tree.c: introduce 'info fdt' command, David Gibson, 2022/08/28
- Re: [PATCH for-7.2 v4 15/21] qmp/hmp, device_tree.c: introduce 'info fdt' command, Daniel Henrique Barboza, 2022/08/29
- Re: [PATCH for-7.2 v4 15/21] qmp/hmp, device_tree.c: introduce 'info fdt' command, David Gibson, 2022/08/29
- Re: [PATCH for-7.2 v4 15/21] qmp/hmp, device_tree.c: introduce 'info fdt' command, Daniel Henrique Barboza, 2022/08/30
- Re: [PATCH for-7.2 v4 15/21] qmp/hmp, device_tree.c: introduce 'info fdt' command, Markus Armbruster, 2022/08/30
- Re: [PATCH for-7.2 v4 15/21] qmp/hmp, device_tree.c: introduce 'info fdt' command, Markus Armbruster, 2022/08/30