[API,NEXT,v6,05/14] api: cpu: add new API to get per-CPU model string

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

Commit Message

hongbo.zhang@freescale.com Sept. 17, 2015, 1:10 p.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 | 10 +++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

Patch

diff --git a/include/odp/api/cpu.h b/include/odp/api/cpu.h
index b63a2e9..55f5d23 100644
--- a/include/odp/api/cpu.h
+++ b/include/odp/api/cpu.h
@@ -53,6 +53,17 @@  int odp_cpu_count(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_model_str_id(int id);
+
+/**
  * Current CPU frequency in Hz
  *
  * Returns current frequency of this CPU
diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c
index 8e903b0..ea1f337 100644
--- a/platform/linux-generic/odp_system_info.c
+++ b/platform/linux-generic/odp_system_info.c
@@ -391,7 +391,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_model_str_id(0);
+}
+
+const char *odp_cpu_model_str_id(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)