[Pdbg] [PATCH 06/29] main: Pull cfam functions out of main.c

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


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

diff --git a/Makefile.am b/Makefile.am
index 3c266d2..f148ef9 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/main.c src/cfam.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/cfam.c b/src/cfam.c
new file mode 100644
index 0000000..8120e20
--- /dev/null
+++ b/src/cfam.c
@@ -0,0 +1,43 @@
+/* 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 <stdio.h>
+#include <inttypes.h>
+
+#include <target.h>
+
+int getcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused)
+{
+	uint32_t value;
+
+	if (fsi_read(target, *addr, &value))
+		return 0;
+
+	printf("p%d:0x%x = 0x%08x\n", index, (uint32_t) *addr, value);
+
+	return 1;
+}
+
+int putcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data)
+{
+	if (fsi_write(target, *addr, *data))
+		return 0;
+
+	return 1;
+}
+
+
+
+
diff --git a/src/cfam.h b/src/cfam.h
new file mode 100644
index 0000000..80354e4
--- /dev/null
+++ b/src/cfam.h
@@ -0,0 +1,19 @@
+/* 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>
+
+int getcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused);
+int putcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data);
diff --git a/src/main.c b/src/main.c
index 0967320..913fb6d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,6 +31,7 @@
 #include <libpdbg.h>
 
 #include "bitutils.h"
+#include "cfam.h"
 
 #undef PR_DEBUG
 #define PR_DEBUG(...)
@@ -427,25 +428,6 @@ static int for_each_target(char *class, int (*cb)(struct pdbg_target *, uint32_t
 	return rc;
 }
 
-static int getcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused)
-{
-	uint32_t value;
-
-	if (fsi_read(target, *addr, &value))
-		return 0;
-
-	printf("p%d:0x%x = 0x%08x\n", index, (uint32_t) *addr, value);
-
-	return 1;
-}
-
-static int putcfam(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *data)
-{
-	if (fsi_write(target, *addr, *data))
-		return 0;
-
-	return 1;
-}
 
 static int getscom(struct pdbg_target *target, uint32_t index, uint64_t *addr, uint64_t *unused)
 {
-- 
2.16.1



More information about the Pdbg mailing list