[Pdbg] [PATCH 07/29] main: Pull out scom functions from main.c

Cyril Bur cyrilbur at gmail.com
Fri Feb 9 15:38:35 AEDT 2018


Signed-off-by: Cyril Bur <cyrilbur at gmail.com>
---
 Makefile.am |  2 +-
 src/main.c  | 22 +---------------------
 src/scom.c  | 41 +++++++++++++++++++++++++++++++++++++++++
 src/scom.h  | 21 +++++++++++++++++++++
 4 files changed, 64 insertions(+), 22 deletions(-)
 create mode 100644 src/scom.c
 create mode 100644 src/scom.h

diff --git a/Makefile.am b/Makefile.am
index f148ef9..1e645b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,7 +11,7 @@ ACLOCAL_AMFLAGS = -Im4
 AM_CFLAGS = -I$(top_srcdir)/ccan/array_size -Wall -Werror
 
 pdbg_SOURCES = \
-	src/main.c src/cfam.c
+	src/main.c src/cfam.c src/scom.c
 pdbg_LDADD = fake.dtb.o p8-fsi.dtb.o p8-i2c.dtb.o p9w-fsi.dtb.o	p8-host.dtb.o \
 	p9z-fsi.dtb.o p9r-fsi.dtb.o p9-kernel.dtb.o libpdbg.la libfdt.la \
 	p9-host.dtb.o \
diff --git a/src/main.c b/src/main.c
index 913fb6d..33ebda3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -32,6 +32,7 @@
 
 #include "bitutils.h"
 #include "cfam.h"
+#include "scom.h"
 
 #undef PR_DEBUG
 #define PR_DEBUG(...)
@@ -428,27 +429,6 @@ static int for_each_target(char *class, int (*cb)(struct pdbg_target *, uint32_t
 	return rc;
 }
 
-
-static int getscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused)
-{
-	uint64_t value;
-
-	if (pib_read(target, *addr, &value))
-		return 0;
-
-	printf("p%d:0x%" PRIx64 " = 0x%016" PRIx64 "\n", index, *addr, value);
-
-	return 1;
-}
-
-static int putscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data)
-{
-	if (pib_write(target, *addr, *data))
-		return 0;
-
-	return 1;
-}
-
 static int print_thread_status(struct pdbg_target *target, uint32_t index, uint64_t *status, uint64_t *unused1)
 {
 	*status = SETFIELD(0xf << (index * 4), *status, thread_status(target) & 0xf);
diff --git a/src/scom.c b/src/scom.c
new file mode 100644
index 0000000..f9102cc
--- /dev/null
+++ b/src/scom.c
@@ -0,0 +1,41 @@
+/* Copyright 2017 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 <inttypes.h>
+#include <stdio.h>
+
+#include <target.h>
+
+int getscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused)
+{
+	uint64_t value;
+
+	if (pib_read(target, *addr, &value))
+		return 0;
+
+	printf("p%d:0x%" PRIx64 " = 0x%016" PRIx64 "\n", index, *addr, value);
+
+	return 1;
+}
+
+int putscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data)
+{
+	if (pib_write(target, *addr, *data))
+		return 0;
+
+	return 1;
+}
+
+
diff --git a/src/scom.h b/src/scom.h
new file mode 100644
index 0000000..afda6af
--- /dev/null
+++ b/src/scom.h
@@ -0,0 +1,21 @@
+/* Copyright 2017 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 <inttypes.h>
+
+#include <target.h>
+
+int getscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused);
+int putscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data);
-- 
2.16.1



More information about the Pdbg mailing list