[Pdbg] [PATCH 01/13] libpdbg: Cache device tree pointer and offset for each node
Amitay Isaacs
amitay at ozlabs.org
Wed Jan 15 16:18:49 AEDT 2020
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
libpdbg/device.c | 9 ++++++---
libpdbg/target.h | 2 ++
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/libpdbg/device.c b/libpdbg/device.c
index ad498dc..ac2351d 100644
--- a/libpdbg/device.c
+++ b/libpdbg/device.c
@@ -115,7 +115,7 @@ static struct pdbg_target *dt_pdbg_target_new(const void *fdt, int node_offset)
return target;
}
-static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int node_offset)
+static struct pdbg_target *dt_new_node(const char *name, void *fdt, int node_offset)
{
struct pdbg_target *node = NULL;
size_t size = sizeof(*node);
@@ -131,6 +131,9 @@ static struct pdbg_target *dt_new_node(const char *name, const void *fdt, int no
abort();
}
+ node->fdt = fdt;
+ node->fdt_offset = fdt ? node_offset : -1;
+
node->dn_name = take_name(name);
node->parent = NULL;
list_head_init(&node->properties);
@@ -547,7 +550,7 @@ static enum pdbg_target_status str_to_status(const char *status)
assert(0);
}
-static int dt_expand_node(struct pdbg_target *node, const void *fdt, int fdt_node)
+static int dt_expand_node(struct pdbg_target *node, void *fdt, int fdt_node)
{
const struct fdt_property *prop;
int offset, nextoffset, err;
@@ -604,7 +607,7 @@ static int dt_expand_node(struct pdbg_target *node, const void *fdt, int fdt_nod
return nextoffset;
}
-static void dt_expand(struct pdbg_target *root, const void *fdt)
+static void dt_expand(struct pdbg_target *root, void *fdt)
{
PR_DEBUG("FDT: Parsing fdt @%p\n", fdt);
diff --git a/libpdbg/target.h b/libpdbg/target.h
index a8f777d..9e25a43 100644
--- a/libpdbg/target.h
+++ b/libpdbg/target.h
@@ -39,6 +39,8 @@ struct pdbg_target {
int (*probe)(struct pdbg_target *target);
void (*release)(struct pdbg_target *target);
uint64_t (*translate)(struct pdbg_target *target, uint64_t addr);
+ void *fdt;
+ int fdt_offset;
int index;
enum pdbg_target_status status;
const char *dn_name;
--
2.21.1
More information about the Pdbg
mailing list