diff options
author | Atish Patra <atish.patra@wdc.com> | 2020-05-09 16:47:31 -0700 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2020-05-10 10:24:08 +0530 |
commit | 1f235ec47f85ba90916493c7eb1378b5427a66b5 (patch) | |
tree | d686ed4d551b3e92905a08d1c887542301f9b77f /include | |
parent | ec0d2a7d7d8b78193375651627aa6f65b9219afe (diff) |
lib: Add platform features in boot time print
We have now clear distinction between platform and hart features.
Modify the boot print messages to print platform features in a string
format. In the process, this patch moved relatively larger functions
to its own file from platform.h header file.
Signed-off-by: Atish Patra <atish.patra@wdc.com>
Tested-by: Jonathan Balkind <jbalkind@cs.princeton.edu>
Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/sbi/sbi_platform.h | 67 |
1 files changed, 41 insertions, 26 deletions
diff --git a/include/sbi/sbi_platform.h b/include/sbi/sbi_platform.h index 675d021..dd25aa1 100644 --- a/include/sbi/sbi_platform.h +++ b/include/sbi/sbi_platform.h @@ -56,6 +56,9 @@ enum sbi_platform_features { SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 2), /** Platform has custom secondary hart booting support */ SBI_PLATFORM_HAS_HART_SECONDARY_BOOT = (1 << 3), + + /** Last index of Platform features*/ + SBI_PLATFORM_HAS_LAST_FEATURE = SBI_PLATFORM_HAS_HART_SECONDARY_BOOT, }; /** Default feature set for a platform */ @@ -224,6 +227,29 @@ struct sbi_platform { ((__p)->features & SBI_PLATFORM_HAS_HART_SECONDARY_BOOT) /** + * Get HART index for the given HART + * + * @param plat pointer to struct sbi_platform + * @param hartid HART ID + * + * @return 0 <= value < hart_count for valid HART otherwise -1U + */ +u32 sbi_platform_hart_index(const struct sbi_platform *plat, u32 hartid); + +/** + * Get the platform features in string format + * + * @param plat pointer to struct sbi_platform + * @param features_str pointer to a char array where the features string will be + * updated + * @param nfstr length of the features_str. The feature string will be truncated + * if nfstr is not long enough. + * @return the features value currently set for the given platform + */ +int sbi_platform_get_features_str(const struct sbi_platform *plat, + char *features_str, int nfstr); + +/** * Get name of the platform * * @param plat pointer to struct sbi_platform @@ -238,6 +264,21 @@ static inline const char *sbi_platform_name(const struct sbi_platform *plat) } /** + * Get the platform features + * + * @param plat pointer to struct sbi_platform + * + * @return the features value currently set for the given platform + */ +static inline unsigned long sbi_platform_get_features( + const struct sbi_platform *plat) +{ + if (plat) + return plat->features; + return 0; +} + +/** * Get platform specific tlb range flush maximum value. Any request with size * higher than this is upgraded to a full flush. * @@ -282,32 +323,6 @@ static inline u32 sbi_platform_hart_stack_size(const struct sbi_platform *plat) } /** - * Get HART index for the given HART - * - * @param plat pointer to struct sbi_platform - * @param hartid HART ID - * - * @return 0 <= value < hart_count for valid HART otherwise -1U - */ -static inline u32 sbi_platform_hart_index(const struct sbi_platform *plat, - u32 hartid) -{ - u32 i; - - if (!plat) - return -1U; - if (plat->hart_index2id) { - for (i = 0; i < plat->hart_count; i++) { - if (plat->hart_index2id[i] == hartid) - return i; - } - return -1U; - } - - return hartid; -} - -/** * Check whether given HART is invalid * * @param plat pointer to struct sbi_platform |