@@ -295,7 +295,7 @@ static int cfam_hmfsi_read(struct fsi *fsi, uint32_t addr, uint32_t *data)
{
struct pdbg_target *parent_fsi = pdbg_target_require_parent("fsi", &fsi->target);
- addr += dt_get_address(&fsi->target, 0, NULL);
+ addr += pdbg_target_address(&fsi->target, NULL);
return fsi_read(parent_fsi, addr, data);
}
@@ -304,7 +304,7 @@ static int cfam_hmfsi_write(struct fsi *fsi, uint32_t addr, uint32_t data)
{
struct pdbg_target *parent_fsi = pdbg_target_require_parent("fsi", &fsi->target);
- addr += dt_get_address(&fsi->target, 0, NULL);
+ addr += pdbg_target_address(&fsi->target, NULL);
return fsi_write(parent_fsi, addr, data);
}
@@ -658,17 +658,16 @@ static u32 dt_n_size_cells(const struct pdbg_target *node)
return dt_prop_get_u32_def(node->parent, "#size-cells", 1);
}
-u64 dt_get_address(const struct pdbg_target *node, unsigned int index,
- u64 *out_size)
+uint64_t pdbg_target_address(struct pdbg_target *target, uint64_t *out_size)
{
const struct dt_property *p;
- u32 na = dt_n_address_cells(node);
- u32 ns = dt_n_size_cells(node);
+ u32 na = dt_n_address_cells(target);
+ u32 ns = dt_n_size_cells(target);
u32 pos, n;
- p = dt_require_property(node, "reg", -1);
+ p = dt_require_property(target, "reg", -1);
n = (na + ns) * sizeof(u32);
- pos = n * index;
+ pos = n;
assert((pos + n) <= p->len);
if (out_size)
*out_size = dt_get_number(p->prop + pos + na * sizeof(u32), ns);
@@ -44,11 +44,4 @@ const void *dt_prop_get(const struct pdbg_target *node, const char *prop);
const void *dt_prop_get_def(const struct pdbg_target *node, const char *prop,
void *def);
-/* Address accessors ("reg" properties parsing). No translation,
- * only support "simple" address forms (1 or 2 cells). Asserts
- * if address doesn't exist
- */
-u64 dt_get_address(const struct pdbg_target *node, unsigned int index,
- u64 *out_size);
-
#endif /* __DEVICE_H */
@@ -131,7 +131,7 @@ int i2c_target_probe(struct pdbg_target *target)
int addr;
bus = dt_prop_get_def(&pib->target, "bus", "/dev/i2c4");
- addr = dt_get_address(&pib->target, 0, NULL);
+ addr = pdbg_target_address(&pib->target, NULL);
assert(addr);
i2c_data = malloc(sizeof(*i2c_data));
@@ -135,11 +135,6 @@ const char *pdbg_target_dn_name(struct pdbg_target *target)
return target->dn_name;
}
-uint64_t pdbg_get_address(struct pdbg_target *target, uint64_t *size)
-{
- return dt_get_address(target, 0, size);
-}
-
int pdbg_target_u32_property(struct pdbg_target *target, const char *name, uint32_t *val)
{
uint32_t *p;
@@ -73,7 +73,7 @@ void pdbg_target_set_property(struct pdbg_target *target, const char *name, cons
/* Get the given property and return the size */
void *pdbg_target_property(struct pdbg_target *target, const char *name, size_t *size);
int pdbg_target_u32_property(struct pdbg_target *target, const char *name, uint32_t *val);
-uint64_t pdbg_get_address(struct pdbg_target *target, uint64_t *size);
+uint64_t pdbg_target_address(struct pdbg_target *target, uint64_t *size);
/* Old deprecated for names for the above. Do not use for new projects
* as these will be removed at some future point. */
@@ -81,6 +81,8 @@ uint64_t pdbg_get_address(struct pdbg_target *target, uint64_t *size);
pdbg_target_set_property(target, name, val, size)
#define pdbg_get_target_property(target, name, size) \
pdbg_target_property(target, name, size)
+#define pdbg_get_address(target, index, size) \
+ (index == 0 ? pdbg_target_address(target, size) : assert(0))
/* Find an chip-id property in this node; if not found, walk up the parent
* nodes. Returns -1 if no chip-id property exists. */
@@ -155,7 +155,7 @@ static int assert_special_wakeup(struct core *chip)
if (i++ > SPECIAL_WKUP_TIMEOUT) {
PR_ERROR("Timeout waiting for special wakeup on %s@0x%08" PRIx64 "\n", chip->target.name,
- dt_get_address(&chip->target, 0, NULL));
+ pdbg_target_address(&chip->target, NULL));
return -1;
}
} while (!(gp0 & SPECIAL_WKUP_DONE));
@@ -479,7 +479,7 @@ static int p8_thread_probe(struct pdbg_target *target)
{
struct thread *thread = target_to_thread(target);
- thread->id = (dt_get_address(target, 0, NULL) >> 4) & 0xf;
+ thread->id = (pdbg_target_address(target, NULL) >> 4) & 0xf;
thread->status = get_thread_status(thread);
return 0;
@@ -527,7 +527,7 @@ static int p9_core_probe(struct pdbg_target *target)
if (i++ > SPECIAL_WKUP_TIMEOUT) {
PR_ERROR("Timeout waiting for special wakeup on %s@0x%08" PRIx64 "\n", target->name,
- dt_get_address(target, 0, NULL));
+ pdbg_target_address(target, NULL));
break;
}
} while (!(value & SPECIAL_WKUP_DONE));
@@ -24,7 +24,7 @@ static struct pdbg_target *get_class_target_addr(struct pdbg_target *target, con
if (target->translate)
*addr = target->translate(target, *addr);
else
- *addr += dt_get_address(target, 0, NULL);
+ *addr += pdbg_target_address(target, NULL);
/* Keep walking the tree translating addresses */
target = target->parent;
Clean up the target addressing functions and rename them to be consistent with other libpdbg function names. Signed-off-by: Alistair Popple <alistair@popple.id.au> --- libpdbg/cfam.c | 4 ++-- libpdbg/device.c | 11 +++++------ libpdbg/device.h | 7 ------- libpdbg/i2c.c | 2 +- libpdbg/libpdbg.c | 5 ----- libpdbg/libpdbg.h | 4 +++- libpdbg/p8chip.c | 4 ++-- libpdbg/p9chip.c | 2 +- libpdbg/target.c | 2 +- 9 files changed, 15 insertions(+), 26 deletions(-)