lib: sbi_platform: Add callback to populate HART extensions

We add platform specific extensions_init() callback which allows
platforms to populate HART extensions for each HART. For example,
the generic platform can populate HART extensions from HART ISA
string described in DeviceTree.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
This commit is contained in:
Anup Patel
2022-04-29 21:02:24 +05:30
committed by Anup Patel
parent 994ace30f7
commit 023f0ad2d9
2 changed files with 32 additions and 4 deletions

View File

@@ -89,6 +89,9 @@ struct sbi_platform_operations {
*/
int (*misa_get_xlen)(void);
/** Initialize (or populate) HART extensions for the platform */
int (*extensions_init)(void);
/** Initialize (or populate) domains for the platform */
int (*domains_init)(void);
@@ -453,6 +456,21 @@ static inline int sbi_platform_misa_xlen(const struct sbi_platform *plat)
return -1;
}
/**
* Initialize (or populate) HART extensions for the platform
*
* @param plat pointer to struct sbi_platform
*
* @return 0 on success and negative error code on failure
*/
static inline int sbi_platform_extensions_init(
const struct sbi_platform *plat)
{
if (plat && sbi_platform_ops(plat)->extensions_init)
return sbi_platform_ops(plat)->extensions_init();
return 0;
}
/**
* Initialize (or populate) domains for the platform
*