diff mbox

[v8,API-NEXT,07/12] linux-generic: sysinfo: move PowerPC system info codes to its plarform file

Message ID 1453884974-24724-8-git-send-email-hongbo.zhang@linaro.org
State Accepted
Commit da5cd7c1c3be562aa75a46a82203a3c32e09fa44
Headers show

Commit Message

Hongbo Zhang Jan. 27, 2016, 8:56 a.m. UTC
From: Hongbo Zhang <hongbo.zhang@linaro.org>

This patch moves the PowerPC system info codes into the newly added PowerPC
specific platform file.
This patch also creates syslink to arch/linux/odp_cpu_cycles.c for PowerPC.

Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
---
 configure.ac                                       |  1 +
 platform/linux-generic/Makefile.am                 |  2 +
 platform/linux-generic/arch/powerpc/odp/cpu_arch.h |  1 +
 platform/linux-generic/arch/powerpc/odp_cpu_arch.c |  1 +
 .../linux-generic/arch/powerpc/odp_sysinfo_parse.c | 52 +++++++++++++++++++++
 platform/linux-generic/odp_system_info.c           | 53 ----------------------
 6 files changed, 57 insertions(+), 53 deletions(-)
 create mode 120000 platform/linux-generic/arch/powerpc/odp/cpu_arch.h
 create mode 120000 platform/linux-generic/arch/powerpc/odp_cpu_arch.c
 create mode 100644 platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index fbe7c08..14a025e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,6 +55,7 @@  AX_VALGRIND_CHECK
 AS_CASE([$host],
   [x86*], [ARCH=x86],
   [mips64*], [ARCH=mips64],
+  [powerpc*], [ARCH=powerpc],
   [ARCH=linux]
 )
 AC_SUBST([ARCH])
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index f4bc58e..fded462 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -169,6 +169,8 @@  EXTRA_DIST = \
 	     arch/linux/odp_sysinfo_parse.c \
 	     arch/mips64/odp_cpu_arch.c \
 	     arch/mips64/odp_sysinfo_parse.c \
+	     arch/powerpc/odp_cpu_arch.c \
+	     arch/powerpc/odp_sysinfo_parse.c \
 	     arch/x86/odp_cpu_arch.c \
 	     arch/x86/odp_sysinfo_parse.c
 
diff --git a/platform/linux-generic/arch/powerpc/odp/cpu_arch.h b/platform/linux-generic/arch/powerpc/odp/cpu_arch.h
new file mode 120000
index 0000000..0617d7f
--- /dev/null
+++ b/platform/linux-generic/arch/powerpc/odp/cpu_arch.h
@@ -0,0 +1 @@ 
+../../linux/odp/cpu_arch.h
\ No newline at end of file
diff --git a/platform/linux-generic/arch/powerpc/odp_cpu_arch.c b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c
new file mode 120000
index 0000000..c5fe400
--- /dev/null
+++ b/platform/linux-generic/arch/powerpc/odp_cpu_arch.c
@@ -0,0 +1 @@ 
+../linux/odp_cpu_arch.c
\ No newline at end of file
diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
new file mode 100644
index 0000000..fe13f40
--- /dev/null
+++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
@@ -0,0 +1,52 @@ 
+/* Copyright (c) 2016, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ */
+
+#include <odp_internal.h>
+#include <string.h>
+
+int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
+{
+	char str[1024];
+	char *pos;
+	double mhz = 0.0;
+	int model = 0;
+	int count = 2;
+
+	while (fgets(str, sizeof(str), file) != NULL && count > 0) {
+		if (!mhz) {
+			pos = strstr(str, "clock");
+
+			if (pos)
+				if (sscanf(pos, "clock : %lf", &mhz) == 1)
+					count--;
+		}
+
+		if (!model) {
+			pos = strstr(str, "cpu");
+
+			if (pos) {
+				int len;
+
+				pos = strchr(str, ':');
+				strncpy(sysinfo->model_str[0], pos + 2,
+					sizeof(sysinfo->model_str[0]));
+				len = strlen(sysinfo->model_str[0]);
+				sysinfo->model_str[0][len - 1] = 0;
+				model = 1;
+				count--;
+			}
+		}
+
+		sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0);
+	}
+
+	return 0;
+}
+
+uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
+{
+	return -1;
+}
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index 7d68c2e..210dd1d 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -105,59 +105,6 @@  static int huge_page_size(void)
 }
 
 
-
-/*
- * HW specific /proc/cpuinfo file parsing
- */
-#if defined __powerpc__
-static int odp_cpuinfo_parser(FILE *file, odp_system_info_t *sysinfo)
-{
-	char str[1024];
-	char *pos;
-	double mhz = 0.0;
-	int model = 0;
-	int count = 2;
-
-	while (fgets(str, sizeof(str), file) != NULL && count > 0) {
-		if (!mhz) {
-			pos = strstr(str, "clock");
-
-			if (pos) {
-				sscanf(pos, "clock : %lf", &mhz);
-				count--;
-			}
-		}
-
-		if (!model) {
-			pos = strstr(str, "cpu");
-
-			if (pos) {
-				int len;
-				pos = strchr(str, ':');
-				strncpy(sysinfo->model_str[0], pos + 2,
-					sizeof(sysinfo->model_str[0]));
-				len = strlen(sysinfo->model_str[0]);
-				sysinfo->model_str[0][len - 1] = 0;
-				model = 1;
-				count--;
-			}
-		}
-
-		sysinfo->cpu_hz[0] = (uint64_t)(mhz * 1000000.0);
-	}
-
-
-	return 0;
-}
-
-static uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
-{
-	return -1;
-}
-
-#endif
-
-
 #if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \
 defined __powerpc__