aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sbi/sbi_hart.h4
-rw-r--r--lib/sbi/sbi_hart.c12
2 files changed, 15 insertions, 1 deletions
diff --git a/include/sbi/sbi_hart.h b/include/sbi/sbi_hart.h
index 0c18ef9..d2db9d6 100644
--- a/include/sbi/sbi_hart.h
+++ b/include/sbi/sbi_hart.h
@@ -20,8 +20,10 @@ enum sbi_hart_features {
SBI_HART_HAS_MCOUNTEREN = (1 << 1),
/** Hart has counter inhibit CSR */
SBI_HART_HAS_MCOUNTINHIBIT = (1 << 2),
+ /** Hart has sscofpmf extension */
+ SBI_HART_HAS_SSCOFPMF = (1 << 3),
/** HART has timer csr implementation in hardware */
- SBI_HART_HAS_TIME = (1 << 3),
+ SBI_HART_HAS_TIME = (1 << 4),
/** Last index of Hart features*/
SBI_HART_HAS_LAST_FEATURE = SBI_HART_HAS_TIME,
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 8eb0c38..7f31bb7 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -281,6 +281,9 @@ static inline char *sbi_hart_feature_id2string(unsigned long feature)
case SBI_HART_HAS_MCOUNTINHIBIT:
fstr = "mcountinhibit";
break;
+ case SBI_HART_HAS_SSCOFPMF:
+ fstr = "sscofpmf";
+ break;
case SBI_HART_HAS_TIME:
fstr = "time";
break;
@@ -490,6 +493,15 @@ __mhpm_skip:
hfeatures->features |= SBI_HART_HAS_MCOUNTINHIBIT;
}
+ /* Counter overflow/filtering is not useful without mcounter/inhibit */
+ if (hfeatures->features & SBI_HART_HAS_MCOUNTINHIBIT &&
+ hfeatures->features & SBI_HART_HAS_MCOUNTEREN) {
+ /* Detect if hart supports sscofpmf */
+ csr_read_allowed(CSR_SCOUNTOVF, (unsigned long)&trap);
+ if (!trap.cause)
+ hfeatures->features |= SBI_HART_HAS_SSCOFPMF;
+ }
+
/* Detect if hart supports time CSR */
csr_read_allowed(CSR_TIME, (unsigned long)&trap);
if (!trap.cause)