diff mbox series

[API-NEXT,v2,3/8] linux-gen: system: implement system info print

Message ID 20170424104917.24102-4-petri.savolainen@linaro.org
State Superseded
Headers show
Series Use HW time counter | expand

Commit Message

Petri Savolainen April 24, 2017, 10:49 a.m. UTC
Print API, impl name, CPU model/freq, cache line size and
CPU count by default. Print CPU flags in case of x86.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
 .../linux-generic/arch/arm/odp_sysinfo_parse.c     |  4 +++
 .../linux-generic/arch/default/odp_sysinfo_parse.c |  4 +++
 .../linux-generic/arch/mips64/odp_sysinfo_parse.c  |  4 +++
 .../linux-generic/arch/powerpc/odp_sysinfo_parse.c |  4 +++
 .../linux-generic/arch/x86/odp_sysinfo_parse.c     |  6 +++++
 platform/linux-generic/include/odp_internal.h      |  1 +
 platform/linux-generic/odp_system_info.c           | 30 ++++++++++++++++++++++
 7 files changed, 53 insertions(+)

-- 
2.11.0
diff mbox series

Patch

diff --git a/platform/linux-generic/arch/arm/odp_sysinfo_parse.c b/platform/linux-generic/arch/arm/odp_sysinfo_parse.c
index 53e2aaea..8ae2022a 100644
--- a/platform/linux-generic/arch/arm/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/arm/odp_sysinfo_parse.c
@@ -25,3 +25,7 @@  uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
 {
 	return 0;
 }
+
+void sys_info_print_arch(void)
+{
+}
diff --git a/platform/linux-generic/arch/default/odp_sysinfo_parse.c b/platform/linux-generic/arch/default/odp_sysinfo_parse.c
index 53e2aaea..8ae2022a 100644
--- a/platform/linux-generic/arch/default/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/default/odp_sysinfo_parse.c
@@ -25,3 +25,7 @@  uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
 {
 	return 0;
 }
+
+void sys_info_print_arch(void)
+{
+}
diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
index 407264b7..d6f75f28 100644
--- a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c
@@ -62,3 +62,7 @@  uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
 {
 	return 0;
 }
+
+void sys_info_print_arch(void)
+{
+}
diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
index 3b88d55b..bd4b9b42 100644
--- a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c
@@ -61,3 +61,7 @@  uint64_t odp_cpu_hz_current(int id ODP_UNUSED)
 {
 	return 0;
 }
+
+void sys_info_print_arch(void)
+{
+}
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
index 96127ec6..d77165a4 100644
--- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
+++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c
@@ -5,6 +5,7 @@ 
  */
 
 #include <odp_internal.h>
+#include <arch/x86/cpu_flags.h>
 #include <string.h>
 
 int cpuinfo_parser(FILE *file, system_info_t *sysinfo)
@@ -73,3 +74,8 @@  uint64_t odp_cpu_hz_current(int id)
 
 	return 0;
 }
+
+void sys_info_print_arch(void)
+{
+	cpu_flags_print_all();
+}
diff --git a/platform/linux-generic/include/odp_internal.h b/platform/linux-generic/include/odp_internal.h
index acfc3012..90e2a629 100644
--- a/platform/linux-generic/include/odp_internal.h
+++ b/platform/linux-generic/include/odp_internal.h
@@ -133,6 +133,7 @@  int _odp_modules_init_global(void);
 
 int cpuinfo_parser(FILE *file, system_info_t *sysinfo);
 uint64_t odp_cpu_hz_current(int id);
+void sys_info_print_arch(void);
 
 #ifdef __cplusplus
 }
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index 18c61dbe..40ffca07 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -14,6 +14,7 @@ 
 #include <odp_posix_extensions.h>
 
 #include <odp/api/system_info.h>
+#include <odp/api/version.h>
 #include <odp_internal.h>
 #include <odp_debug_internal.h>
 #include <odp/api/align.h>
@@ -405,3 +406,32 @@  int odp_cpu_count(void)
 {
 	return odp_global_data.system_info.cpu_count;
 }
+
+void odp_sys_info_print(void)
+{
+	int len;
+	int max_len = 512;
+	char str[max_len];
+
+	len = snprintf(str, max_len, "\n"
+		       "ODP system info\n"
+		       "---------------\n"
+		       "ODP API version: %s\n"
+		       "ODP impl name:   %s\n"
+		       "CPU model:       %s\n"
+		       "CPU freq (hz):   %" PRIu64 "\n"
+		       "Cache line size: %i\n"
+		       "CPU count:       %i\n"
+		       "\n",
+		       odp_version_api_str(),
+		       odp_version_impl_name(),
+		       odp_cpu_model_str(),
+		       odp_cpu_hz_max(),
+		       odp_sys_cache_line_size(),
+		       odp_cpu_count());
+
+	str[len] = '\0';
+	ODP_PRINT("%s", str);
+
+	sys_info_print_arch();
+}