[Pdbg] [PATCH 05/23] libpdbg: Backend device tree cannot be overriden
Amitay Isaacs
amitay at ozlabs.org
Tue Apr 14 12:47:32 AEST 2020
With drivers getting registered per backend, backend needs to be
initialised before any device tree can be parsed. PDBG_BACKEND_DTB
allowed to override backend device tree without specifying backend,
which cannot work any more.
To be able to dynamically update backend introduce PDBG_BACKEND and
PDBG_BACKEND_OPTION variables instead of PDBG_BACKEND_DTB.
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
libpdbg/dtb.c | 32 ++++++++++++++++++++++---------
tests/test_p9_fapi_translation.sh | 2 +-
2 files changed, 24 insertions(+), 10 deletions(-)
diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c
index 70b7962..077bc62 100644
--- a/libpdbg/dtb.c
+++ b/libpdbg/dtb.c
@@ -234,7 +234,7 @@ static void bmc_target(struct pdbg_dtb *dtb)
}
/* Opens a dtb at the given path */
-static void mmap_dtb(char *file, bool readonly, struct pdbg_mfile *mfile)
+static void mmap_dtb(const char *file, bool readonly, struct pdbg_mfile *mfile)
{
int fd;
void *dtb;
@@ -308,21 +308,36 @@ const char *pdbg_get_backend_option(void)
struct pdbg_dtb *pdbg_default_dtb(void *system_fdt)
{
struct pdbg_dtb *dtb = &pdbg_dtb;
- char *fdt;
+ const char *fdt, *backend;
dtb->backend.fdt = NULL;
dtb->system.fdt = system_fdt;
- fdt = getenv("PDBG_BACKEND_DTB");
- if (fdt)
- mmap_dtb(fdt, false, &dtb->backend);
-
fdt = getenv("PDBG_DTB");
if (fdt)
mmap_dtb(fdt, false, &dtb->system);
- if (dtb->backend.fdt && dtb->system.fdt)
- goto done;
+ backend = getenv("PDBG_BACKEND");
+ if (backend) {
+ const char *arg;
+
+ arg = getenv("PDBG_BACKEND_OPTION");
+
+ if (!strcmp(backend, "fsi"))
+ pdbg_set_backend(PDBG_BACKEND_FSI, arg);
+ else if (!strcmp(backend, "i2c"))
+ pdbg_set_backend(PDBG_BACKEND_I2C, arg);
+ else if (!strcmp(backend, "kernel"))
+ pdbg_set_backend(PDBG_BACKEND_KERNEL, arg);
+ else if (!strcmp(backend, "fake"))
+ pdbg_set_backend(PDBG_BACKEND_FAKE, arg);
+ else if (!strcmp(backend, "host"))
+ pdbg_set_backend(PDBG_BACKEND_HOST, arg);
+ else if (!strcmp(backend, "cronus"))
+ pdbg_set_backend(PDBG_BACKEND_CRONUS, arg);
+ else
+ pdbg_log(PDBG_ERROR, "Invalid backend '%s', ignoring\n", backend);
+ }
if (!pdbg_backend)
pdbg_backend = default_backend();
@@ -412,7 +427,6 @@ struct pdbg_dtb *pdbg_default_dtb(void *system_fdt)
break;
}
-done:
return dtb;
}
diff --git a/tests/test_p9_fapi_translation.sh b/tests/test_p9_fapi_translation.sh
index a5a09b1..9891d39 100755
--- a/tests/test_p9_fapi_translation.sh
+++ b/tests/test_p9_fapi_translation.sh
@@ -4,7 +4,7 @@
test_group "p9 fapi translation tests"
-export PDBG_BACKEND_DTB=p9-kernel.dtb
+export PDBG_BACKEND=kernel
export PDBG_DTB=p9.dtb
test_result 0 <<EOF
--
2.25.2
More information about the Pdbg
mailing list