[Pdbg] [PATCH 10/11] dts: Split fake backend and system trees
Amitay Isaacs
amitay at ozlabs.org
Thu Apr 30 13:05:43 AEST 2020
Signed-off-by: Amitay Isaacs <amitay at ozlabs.org>
---
Makefile.am | 4 ++--
fake-backend.dts.m4 | 52 +++++++++++++++++++++++++++++++++++++++++++++
fake.dts.m4 | 31 +--------------------------
libpdbg/dtb.c | 3 +++
tests/test_prop.sh | 4 ++++
5 files changed, 62 insertions(+), 32 deletions(-)
create mode 100644 fake-backend.dts.m4
diff --git a/Makefile.am b/Makefile.am
index babb82c..e0b0954 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,7 +35,7 @@ PDBG_TESTS = \
TESTS = $(libpdbg_tests) optcmd_test $(PDBG_TESTS)
tests/test_tree2.sh: fake2.dtb
-tests/test_prop.sh: fake.dtb
+tests/test_prop.sh: fake.dtb fake-backend.dtb
tests/test_p9_fapi_translation.sh: p9.dtb bmc-kernel.dtb
test: $(libpdbg_tests)
@@ -77,7 +77,7 @@ if TARGET_PPC
ARCH_FLAGS="-DTARGET_PPC=1"
endif
-DT = fake.dts fake2.dts p8-cronus.dts bmc-cronus.dts \
+DT = fake.dts fake-backend.dts fake2.dts p8-cronus.dts bmc-cronus.dts \
p8-fsi.dts p8-i2c.dts p8-kernel.dts \
p9w-fsi.dts p9r-fsi.dts p9z-fsi.dts bmc-kernel.dts \
bmc-sbefifo.dts \
diff --git a/fake-backend.dts.m4 b/fake-backend.dts.m4
new file mode 100644
index 0000000..2686c4e
--- /dev/null
+++ b/fake-backend.dts.m4
@@ -0,0 +1,52 @@
+define(`CONCAT', `$1$2')dnl
+
+dnl
+dnl forloop([var], [start], [end], [iterator])
+dnl
+divert(`-1')
+define(`forloop', `pushdef(`$1', `$2')_forloop($@)popdef(`$1')')
+define(`_forloop',
+ `$4`'ifelse($1, `$3', `', `define(`$1', incr($1))$0($@)')')
+
+dnl
+dnl dump_backend([index], [addr])
+dnl
+define(`dump_backend',dnl
+`define(`pib_addr', eval(`$2+100'))dnl
+
+ fsi@$2 {
+ #address-cells = <0x1>;
+ #size-cells = <0x1>;
+ compatible = "ibm,fake-fsi";
+ system-path = "/proc$1/fsi";
+ reg = <0x0 0x0>;
+ index = <0x$1>;
+
+ CONCAT(pib@,pib_addr) {
+ #address-cells = <0x1>;
+ #size-cells = <0x1>;
+ compatible = "ibm,fake-pib";
+ system-path = "/proc$1/pib";
+ reg = <CONCAT(0x,pib_addr) 0x0>;
+ index = <0x$1>;
+ ATTR1 = <0xc0ffee>;
+ };
+ };
+
+')dnl
+
+dnl
+dnl dump_system([num_processors], [num_cores], [num_threads])
+dnl
+define(`dump_system',
+`forloop(`i', `0', eval(`$1-1'), `dump_backend(i, eval(20000+i*1000))')
+')
+divert`'dnl
+
+/dts-v1/;
+
+/ {
+ #address-cells = <0x1>;
+ #size-cells = <0x1>;
+dump_system(8, 4, 2)
+};
diff --git a/fake.dts.m4 b/fake.dts.m4
index 3824738..190597a 100644
--- a/fake.dts.m4
+++ b/fake.dts.m4
@@ -71,40 +71,11 @@ define(`dump_processor',dnl
forloop(`i', `0', eval(`$2-1'), `dump_core(i, eval(10000+(i+1)*10), $3)')
dump_processor_post()')
-dnl
-dnl dump_backend([index], [addr])
-dnl
-define(`dump_backend',dnl
-`define(`pib_addr', eval(`$2+100'))dnl
-
- fsi@$2 {
- #address-cells = <0x1>;
- #size-cells = <0x1>;
- compatible = "ibm,fake-fsi";
- system-path = "/proc$1/fsi";
- reg = <0x0 0x0>;
- index = <0x$1>;
-
- CONCAT(pib@,pib_addr) {
- #address-cells = <0x1>;
- #size-cells = <0x1>;
- compatible = "ibm,fake-pib";
- system-path = "/proc$1/pib";
- reg = <CONCAT(0x,pib_addr) 0x0>;
- index = <0x$1>;
- ATTR1 = <0xc0ffee>;
- };
- };
-
-')dnl
-
-
dnl
dnl dump_system([num_processors], [num_cores], [num_threads])
dnl
define(`dump_system',
-`forloop(`i', `0', eval(`$1-1'), `dump_backend(i, eval(20000+i*1000))')
-forloop(`i', `0', eval(`$1-1'),dnl
+`forloop(`i', `0', eval(`$1-1'),dnl
`
CONCAT(proc,i) {
index = < CONCAT(0x,i) >;
diff --git a/libpdbg/dtb.c b/libpdbg/dtb.c
index 5013d96..09f039f 100644
--- a/libpdbg/dtb.c
+++ b/libpdbg/dtb.c
@@ -31,6 +31,7 @@
#include "target.h"
#include "fake.dt.h"
+#include "fake-backend.dt.h"
#include "p8-i2c.dt.h"
#include "p8-fsi.dt.h"
@@ -447,6 +448,8 @@ struct pdbg_dtb *pdbg_default_dtb(void *system_fdt)
case PDBG_BACKEND_FAKE:
if (!dtb->system.fdt)
dtb->system.fdt = &_binary_fake_dtb_o_start;
+ if (!dtb->backend.fdt)
+ dtb->backend.fdt = &_binary_fake_backend_dtb_o_start;
break;
}
diff --git a/tests/test_prop.sh b/tests/test_prop.sh
index 5511a75..ba7eaac 100755
--- a/tests/test_prop.sh
+++ b/tests/test_prop.sh
@@ -39,7 +39,11 @@ test_run libpdbg_prop_test /proc0/pib write ATTR2 char PROCESSOR0
cp fake.dtb fake-prop.dtb
test_cleanup rm -f fake-prop.dtb
+cp fake-backend.dtb fake-backend-prop.dtb
+test_cleanup rm -f fake-backend-prop.dtb
+
export PDBG_DTB=fake-prop.dtb
+export PDBG_BACKEND_DTB=fake-backend-prop.dtb
test_result 0 --
test_run libpdbg_prop_test /proc1/pib write ATTR1 int 0xdeadbeef
--
2.25.4
More information about the Pdbg
mailing list