SBI_HART_HAS_TIME = (1 << 1),
/** HART has AIA local interrupt CSRs */
SBI_HART_HAS_AIA = (1 << 2),
- /** HART has menvcfg CSR */
- SBI_HART_HAS_MENVCFG = (1 << 3),
/** HART has mstateen CSR **/
- SBI_HART_HAS_SMSTATEEN = (1 << 4),
+ SBI_HART_HAS_SMSTATEEN = (1 << 3),
/** HART has SSTC extension implemented in hardware */
- SBI_HART_HAS_SSTC = (1 << 5),
+ SBI_HART_HAS_SSTC = (1 << 4),
/** Last index of Hart features*/
SBI_HART_HAS_LAST_FEATURE = SBI_HART_HAS_SSTC,
mstateen_val |= ((uint64_t)csr_read(CSR_MSTATEEN0H)) << 32;
#endif
mstateen_val |= SMSTATEEN_STATEN;
- if (sbi_hart_has_feature(scratch, SBI_HART_HAS_MENVCFG))
- mstateen_val |= SMSTATEEN0_HSENVCFG;
- else
- mstateen_val &= ~SMSTATEEN0_HSENVCFG;
+ mstateen_val |= SMSTATEEN0_HSENVCFG;
+
if (sbi_hart_has_feature(scratch, SBI_HART_HAS_AIA))
mstateen_val |= (SMSTATEEN0_AIA | SMSTATEEN0_SVSLCT |
SMSTATEEN0_IMSIC);
#endif
}
- if (sbi_hart_has_feature(scratch, SBI_HART_HAS_MENVCFG)) {
+ if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_12) {
menvcfg_val = csr_read(CSR_MENVCFG);
/*
case SBI_HART_HAS_SSTC:
fstr = "sstc";
break;
- case SBI_HART_HAS_MENVCFG:
- fstr = "menvcfg";
- break;
case SBI_HART_HAS_SMSTATEEN:
fstr = "smstateen";
break;
(hfeatures->priv_version >= SBI_HART_PRIV_VER_1_10))
hfeatures->priv_version = SBI_HART_PRIV_VER_1_11;
- /* Detect if hart has menvcfg CSR */
+ /* Detect if hart supports Priv v1.12 */
csr_read_allowed(CSR_MENVCFG, (unsigned long)&trap);
if (!trap.cause &&
- (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_11)) {
+ (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_11))
hfeatures->priv_version = SBI_HART_PRIV_VER_1_12;
- hfeatures->features |= SBI_HART_HAS_MENVCFG;
- }
/* Counter overflow/filtering is not useful without mcounter/inhibit */
if (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_12) {
hfeatures->features |= SBI_HART_HAS_AIA;
__aia_skip:
- /**
- * Detect if hart supports stimecmp CSR(Sstc extension) and menvcfg is
- * implemented.
- */
- if (hfeatures->features & SBI_HART_HAS_MENVCFG) {
+ /* Detect if hart supports stimecmp CSR(Sstc extension) */
+ if (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_12) {
csr_read_allowed(CSR_STIMECMP, (unsigned long)&trap);
if (!trap.cause)
hfeatures->features |= SBI_HART_HAS_SSTC;
}
/* Detect if hart supports mstateen CSRs */
- val = csr_read_allowed(CSR_MSTATEEN0, (unsigned long)&trap);
- if (!trap.cause)
- hfeatures->features |= SBI_HART_HAS_SMSTATEEN;
+ if (hfeatures->priv_version >= SBI_HART_PRIV_VER_1_12) {
+ val = csr_read_allowed(CSR_MSTATEEN0, (unsigned long)&trap);
+ if (!trap.cause)
+ hfeatures->features |= SBI_HART_HAS_SMSTATEEN;
+ }
return;
}