[API-NEXT,v3,5/8] linux-generic: sysinfo: add new API to get model string for each CPU

Message ID 1436438768-4258-6-git-send-email-hongbo.zhang@freescale.com
State New
Headers show

Commit Message

hongbo.zhang@freescale.com July 9, 2015, 10:46 a.m.
From: Hongbo Zhang <hongbo.zhang@linaro.org>

Previous patch makes varible model_str to array model_str[] to contain data
for each CPU on AMP platforms, and then this patch adds new API to get the
corresponding model string for each CPU indexed by CPU ID.

Signed-off-by: Hongbo Zhang <hongbo.zhang@linaro.org>
---
 include/odp/api/cpu.h                    | 11 +++++++++++
 platform/linux-generic/odp_system_info.c | 11 ++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

Patch

diff --git a/include/odp/api/cpu.h b/include/odp/api/cpu.h
index 56efe14..c2efe31 100644
--- a/include/odp/api/cpu.h
+++ b/include/odp/api/cpu.h
@@ -60,6 +60,17 @@  uint64_t odp_cpu_hz_max(void);
 const char *odp_cpu_model_str(void);
 
 /**
+ * CPU model name of a CPU
+ *
+ * Return CPU model name of the specified CPU.
+ *
+ * @param id    CPU ID
+ *
+ * @return Pointer to CPU model name string
+ */
+const char *odp_cpu_id_model_str(int id);
+
+/**
  * @}
  */
 
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index 225deea..2881695 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -194,6 +194,7 @@  static int cpuinfo_octeon(FILE *file, odp_system_info_t *sysinfo)
 
 	return 0;
 }
+
 #elif defined __powerpc__
 static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo)
 {
@@ -382,7 +383,15 @@  uint64_t odp_sys_page_size(void)
 
 const char *odp_cpu_model_str(void)
 {
-	return odp_global_data.system_info.model_str[0];
+	return odp_cpu_id_model_str(0);
+}
+
+const char *odp_cpu_id_model_str(int id)
+{
+	if (id >= 0 && id < MAX_CPU_NUMBER)
+		return odp_global_data.system_info.model_str[id];
+	else
+		return NULL;
 }
 
 int odp_sys_cache_line_size(void)