lib: sbi: Add Zicntr as a HART ISA extension

Recently ratified Zicntr ISA extension covers cycle, time and
instret CSRs so we replace the "time" ISA extension with "zicntr"
ISA extension in OpenSBI.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Xiang W <wxjstz@126.com>
This commit is contained in:
Anup Patel
2023-07-05 11:57:17 +05:30
committed by Anup Patel
parent c6a35733b7
commit 1a398d9faa
3 changed files with 6 additions and 6 deletions

View File

@@ -28,8 +28,8 @@ enum sbi_hart_priv_versions {
enum sbi_hart_extensions { enum sbi_hart_extensions {
/** Hart has Sscofpmt extension */ /** Hart has Sscofpmt extension */
SBI_HART_EXT_SSCOFPMF = 0, SBI_HART_EXT_SSCOFPMF = 0,
/** HART has HW time CSR (extension name not available) */ /** HART has Zicntr extension (i.e. HW cycle, time & instret CSRs) */
SBI_HART_EXT_TIME, SBI_HART_EXT_ZICNTR,
/** HART has AIA M-mode CSRs */ /** HART has AIA M-mode CSRs */
SBI_HART_EXT_SMAIA, SBI_HART_EXT_SMAIA,
/** HART has Smstateen CSR **/ /** HART has Smstateen CSR **/

View File

@@ -441,8 +441,8 @@ static inline char *sbi_hart_extension_id2string(int ext)
case SBI_HART_EXT_SSCOFPMF: case SBI_HART_EXT_SSCOFPMF:
estr = "sscofpmf"; estr = "sscofpmf";
break; break;
case SBI_HART_EXT_TIME: case SBI_HART_EXT_ZICNTR:
estr = "time"; estr = "zicntr";
break; break;
case SBI_HART_EXT_SMAIA: case SBI_HART_EXT_SMAIA:
estr = "smaia"; estr = "smaia";
@@ -676,7 +676,7 @@ __mhpm_skip:
csr_read_allowed(CSR_TIME, (unsigned long)&trap); csr_read_allowed(CSR_TIME, (unsigned long)&trap);
if (!trap.cause) if (!trap.cause)
__sbi_hart_update_extension(hfeatures, __sbi_hart_update_extension(hfeatures,
SBI_HART_EXT_TIME, true); SBI_HART_EXT_ZICNTR, true);
/* Detect if hart has AIA local interrupt CSRs */ /* Detect if hart has AIA local interrupt CSRs */
csr_read_allowed(CSR_MTOPI, (unsigned long)&trap); csr_read_allowed(CSR_MTOPI, (unsigned long)&trap);

View File

@@ -188,7 +188,7 @@ int sbi_timer_init(struct sbi_scratch *scratch, bool cold_boot)
if (!time_delta_off) if (!time_delta_off)
return SBI_ENOMEM; return SBI_ENOMEM;
if (sbi_hart_has_extension(scratch, SBI_HART_EXT_TIME)) if (sbi_hart_has_extension(scratch, SBI_HART_EXT_ZICNTR))
get_time_val = get_ticks; get_time_val = get_ticks;
} else { } else {
if (!time_delta_off) if (!time_delta_off)