@@ -268,6 +268,16 @@ _Static_assert(
*/
u32 sbi_platform_hart_index(const struct sbi_platform *plat, u32 hartid);
+/**
+ * Get HART id for the given index
+ *
+ * @param plat porinter to struct sbi_platform
+ * @param index HART index
+ *
+ * @return -1U is invalid value
+*/
+u32 sbi_platform_hart_index2id(const struct sbi_platform *plat, u32 index);
+
/**
* Get the platform features in string format
*
@@ -88,3 +88,12 @@ u32 sbi_platform_hart_index(const struct sbi_platform *plat, u32 hartid)
return hartid;
}
+
+u32 sbi_platform_hart_index2id(const struct sbi_platform *plat, u32 index)
+{
+ if (!plat || index >= plat->hart_count)
+ return -1U;
+ if (plat->hart_index2id)
+ return plat->hart_index2id[index];
+ return index;
+}
Add sbi_platform_hart_index2id to find hart index by hartid. Signed-off-by: Xiang W <wxjstz@126.com> --- include/sbi/sbi_platform.h | 10 ++++++++++ lib/sbi/sbi_platform.c | 9 +++++++++ 2 files changed, 19 insertions(+)