diff options
author | Anup Patel <apatel@ventanamicro.com> | 2022-04-28 15:00:02 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2022-05-07 07:19:54 +0300 |
commit | 1a754bb36522247e51fdb95323c5fa3e256db872 (patch) | |
tree | 27f0ad01bf2d5276cc0040a5e82df3cf43ba96ee /include | |
parent | b0c9df514bdb29a0c90c9868f4209f2ac7a6d567 (diff) | |
download | opensbi-1a754bb36522247e51fdb95323c5fa3e256db872.tar.xz |
lib: sbi: Detect and print privileged spec version
It is possible to guess privileged spec versions based on the CSRs
that where introduced in different privileged spec versions. In
future, if we are not able guess privileged spec version then we
can have platform provide it.
We add privileged spec version as per-hart feature and try to guess
it based on presence of mcounteren, mcountinhibit, and menvcfg CSRs.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/sbi/sbi_hart.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h index 1d09374..3c37933 100644 --- a/include/sbi/sbi_hart.h +++ b/include/sbi/sbi_hart.h @@ -12,6 +12,18 @@ #include <sbi/sbi_types.h> +/** Possible privileged specification versions of a hart */ +enum sbi_hart_priv_versions { + /** Unknown privileged specification */ + SBI_HART_PRIV_VER_UNKNOWN = 0, + /** Privileged specification v1.10 */ + SBI_HART_PRIV_VER_1_10 = 1, + /** Privileged specification v1.11 */ + SBI_HART_PRIV_VER_1_11 = 2, + /** Privileged specification v1.12 */ + SBI_HART_PRIV_VER_1_12 = 3, +}; + /** Possible feature flags of a hart */ enum sbi_hart_features { /** Hart has S-mode counter enable */ @@ -56,6 +68,9 @@ unsigned long sbi_hart_pmp_granularity(struct sbi_scratch *scratch); unsigned int sbi_hart_pmp_addrbits(struct sbi_scratch *scratch); unsigned int sbi_hart_mhpm_bits(struct sbi_scratch *scratch); int sbi_hart_pmp_configure(struct sbi_scratch *scratch); +int sbi_hart_priv_version(struct sbi_scratch *scratch); +void sbi_hart_get_priv_version_str(struct sbi_scratch *scratch, + char *version_str, int nvstr); bool sbi_hart_has_feature(struct sbi_scratch *scratch, unsigned long feature); void sbi_hart_get_features_str(struct sbi_scratch *scratch, char *features_str, int nfstr); |