[Pdbg] [RFC 04/12] libpdbg: Introduce a backend field
Amitay Isaacs
amitay at ozlabs.org
Tue Aug 20 13:52:49 AEST 2019
As we discussed the new scheme for device trees, we do need a field (of
type struct pdbg_target) to tie the virtual node and the real node.
But we can add that later with the virtual node patches.
On Tue, 2019-08-06 at 11:37 +1000, Alistair Popple wrote:
> It is useful to be able to override a particular targets access
> methods with methods specific to a specific runtime environment. This
> patch introduces a field to every target which can be used for this
> purpose without affecting the current behaviour.
>
> Signed-off-by: Alistair Popple <alistair at popple.id.au>
> ---
> libpdbg/target.c | 12 +++++++++---
> libpdbg/target.h | 1 +
> 2 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/libpdbg/target.c b/libpdbg/target.c
> index 61353bc..e822d70 100644
> --- a/libpdbg/target.c
> +++ b/libpdbg/target.c
> @@ -14,8 +14,8 @@
> struct list_head empty_list = LIST_HEAD_INIT(empty_list);
> struct list_head target_classes = LIST_HEAD_INIT(target_classes);
>
> -/* Work out the address to access based on the current target and
> - * final class name */
> +/* Work out the target and address to call call access methods on
> + * based on the current target and final class name */
> static struct pdbg_target *get_class_target_addr(struct pdbg_target
> *target, const char *name, uint64_t *addr)
> {
> /* Check class */
> @@ -34,7 +34,13 @@ static struct pdbg_target
> *get_class_target_addr(struct pdbg_target *target, con
> assert(target != pdbg_target_root());
> }
>
> - return target;
> + if (target->backend) {
> + /* The backend must implement the same interfaces */
> + assert(!strcmp(target->class, target->backend->class));
> + return target->backend;
> + } else {
> + return target;
> + }
> }
>
> struct pdbg_target *pdbg_address_absolute(struct pdbg_target
> *target, uint64_t *addr)
> diff --git a/libpdbg/target.h b/libpdbg/target.h
> index 9394447..2c76bf9 100644
> --- a/libpdbg/target.h
> +++ b/libpdbg/target.h
> @@ -46,6 +46,7 @@ struct pdbg_target {
> struct list_head properties;
> struct list_head children;
> struct pdbg_target *parent;
> + struct pdbg_target *backend;
> u32 phandle;
> bool probed;
> struct list_node class_link;
> --
> 2.20.1
>
Amitay.
--
Regardless of what company you work for, never forget the most important
product you're selling is yourself.
More information about the Pdbg
mailing list