summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlistair Popple <alistair@popple.id.au>2017-07-13 13:45:27 +1000
committerAlistair Popple <alistair@popple.id.au>2017-07-13 13:45:27 +1000
commit4b55a9664d33a9ea3bab87e9668c71ac3c3f877d (patch)
tree9e83ac5712f42f4030d1c87e19032e2a0dca2f25
parent7970779cfa59b94923e00b3f2898da0badbd4bcf (diff)
downloadpdbg-4b55a9664d33a9ea3bab87e9668c71ac3c3f877d.tar.gz
pdbg-4b55a9664d33a9ea3bab87e9668c71ac3c3f877d.zip
libpdbg: Add a more complete fake backend
The fake backend we had couldn't be used as src/main.c was missing the option to enable it. It was also missing an implementation of a fake pib so add that too. Signed-off-by: Alistair Popple <alistair@popple.id.au>
-rw-r--r--Makefile.am2
-rw-r--r--fake.dts6
-rw-r--r--libpdbg/fake.c66
-rw-r--r--libpdbg/fakepib.c38
-rw-r--r--src/main.c2
5 files changed, 75 insertions, 39 deletions
diff --git a/Makefile.am b/Makefile.am
index 9b1ccd9..c96203d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -33,7 +33,7 @@ libfdt_la_SOURCES = \
libpdbg_la_SOURCES = \
libpdbg/kernel.c \
- libpdbg/fakepib.c \
+ libpdbg/fake.c \
libpdbg/chip.c \
libpdbg/p8chip.c \
libpdbg/p9chip.c \
diff --git a/fake.dts b/fake.dts
index e6dd958..f647491 100644
--- a/fake.dts
+++ b/fake.dts
@@ -12,5 +12,11 @@
index = <0x0>;
status = "hidden";
+
+ pib@0 {
+ compatible = "ibm,fake-pib";
+ reg = <0x0 0x0 0x0>;
+ index = <0x0>;
+ };
};
};
diff --git a/libpdbg/fake.c b/libpdbg/fake.c
new file mode 100644
index 0000000..5e5571c
--- /dev/null
+++ b/libpdbg/fake.c
@@ -0,0 +1,66 @@
+/* copyright 2016 ibm corp.
+ *
+ * licensed under the apache license, version 2.0 (the "license");
+ * you may not use this file except in compliance with the license.
+ * you may obtain a copy of the license at
+ *
+ * http://www.apache.org/licenses/license-2.0
+ *
+ * unless required by applicable law or agreed to in writing, software
+ * distributed under the license is distributed on an "as is" basis,
+ * without warranties or conditions of any kind, either express or
+ * implied.
+ * see the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+#include "operations.h"
+#include <stdio.h>
+#include <inttypes.h>
+
+static int fake_fsi_read(struct fsi *fsi, uint32_t addr, uint32_t *value)
+{
+ *value = 0xfeed0cfa;
+ printf("fake_fsi_read(0x%04" PRIx32 ", 0x%04" PRIx32 ")\n", addr, *value);
+ return 0;
+}
+
+static int fake_fsi_write(struct fsi *fsi, uint32_t addr, uint32_t value)
+{
+ printf("fake_fsi_write(0x%04" PRIx32 ", 0x%04" PRIx32 ")\n", addr, value);
+ return 0;
+}
+
+struct fsi fake_fsi = {
+ .target = {
+ .name = "Fake FSI",
+ .compatible = "ibm,fake-fsi",
+ .class = "fsi",
+ },
+ .read = fake_fsi_read,
+ .write = fake_fsi_write,
+};
+DECLARE_HW_UNIT(fake_fsi);
+
+static int fake_pib_read(struct pib *pib, uint64_t addr, uint64_t *value)
+{
+ *value = 0xdeadbeef;
+ printf("fake_pib_read(0x%08" PRIx64 ", 0x%08" PRIx64 ")\n", addr, *value);
+ return 0;
+}
+
+static int fake_pib_write(struct pib *pib, uint64_t addr, uint64_t value)
+{
+ printf("fake_pib_write(0x%08" PRIx64 ", 0x%08" PRIx64 ")\n", addr, value);
+ return 0;
+}
+
+struct pib fake_pib = {
+ .target = {
+ .name = "Fake PIB",
+ .compatible = "ibm,fake-pib",
+ .class = "pib",
+ },
+ .read = fake_pib_read,
+ .write = fake_pib_write,
+};
+DECLARE_HW_UNIT(fake_pib);
diff --git a/libpdbg/fakepib.c b/libpdbg/fakepib.c
deleted file mode 100644
index 22ea3e7..0000000
--- a/libpdbg/fakepib.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright 2016 IBM Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- * implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-#include "operations.h"
-
-static int fake_read(struct pib *pib, uint64_t addr, uint64_t *value)
-{
- *value = 0xdeadbeef;
- return 0;
-}
-
-static int fake_write(struct pib *pib, uint64_t addr, uint64_t value)
-{
- return 0;
-}
-
-struct pib fake_pib = {
- .target = {
- .name = "Fake PIB",
- .compatible = "ibm,fake-fsi",
- .class = "fsi",
- },
- .read = fake_read,
- .write = fake_write,
-};
-DECLARE_HW_UNIT(fake_pib);
diff --git a/src/main.c b/src/main.c
index 67b4055..7517cf2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -286,6 +286,8 @@ static bool parse_options(int argc, char *argv[])
backend = KERNEL;
/* TODO: use device node to point at a slave
* other than the first? */
+ } else if (strcmp(optarg, "fake") == 0) {
+ backend = FAKE;
} else
opt_error = true;
break;
OpenPOWER on IntegriCloud