From bd6ef02d47015706bc7a79cc16b3f19946889a3b Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Sat, 14 Mar 2020 19:39:15 +0530 Subject: [PATCH] include: sbi_platform: Improve sbi_platform_hart_disabled() API The sbi_platform_hart_disabled() should return TRUE for HART id greater than platform hart count. Signed-off-by: Anup Patel Reviewed-by: Bin Meng --- include/sbi/sbi_platform.h | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index bc7991c0..0264732f 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -237,22 +237,6 @@ static inline const char *sbi_platform_name(const struct sbi_platform *plat) return "Unknown"; } -/** - * Check whether the given HART is disabled - * - * @param plat pointer to struct sbi_platform - * @param hartid HART ID - * - * @return TRUE if HART is disabled and FALSE otherwise - */ -static inline bool sbi_platform_hart_disabled(const struct sbi_platform *plat, - u32 hartid) -{ - if (plat && sbi_platform_ops(plat)->hart_disabled) - return sbi_platform_ops(plat)->hart_disabled(hartid); - return FALSE; -} - /** * Get platform specific tlb range flush maximum value. Any request with size * higher than this is upgraded to a full flush. @@ -297,6 +281,26 @@ static inline u32 sbi_platform_hart_stack_size(const struct sbi_platform *plat) return 0; } +/** + * Check whether the given HART is disabled + * + * @param plat pointer to struct sbi_platform + * @param hartid HART ID + * + * @return TRUE if HART is disabled and FALSE otherwise + */ +static inline bool sbi_platform_hart_disabled(const struct sbi_platform *plat, + u32 hartid) +{ + if (plat) { + if (sbi_platform_hart_count(plat) <= hartid) + return TRUE; + if (sbi_platform_ops(plat)->hart_disabled) + return sbi_platform_ops(plat)->hart_disabled(hartid); + } + return FALSE; +} + /** * Bringup a given hart from previous stage. Platform should implement this * operation if they support a custom mechanism to start a hart. Otherwise,