From 31fecad46d1461c3bc6a4ef6d6aa461a19c1d78e Mon Sep 17 00:00:00 2001 From: Atish Patra Date: Tue, 29 Mar 2022 19:25:36 +0530 Subject: lib: sbi: Detect menvcfg CSR at boot time We add the menvcfg CSR as a HART feature and detect it at boot time using traping mechanism. Signed-off-by: Atish Patra Signed-off-by: Anup Patel Reviewed-by: Xiang W --- lib/sbi/sbi_hart.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'lib/sbi') diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c index e028540..31c8f39 100644 --- a/lib/sbi/sbi_hart.c +++ b/lib/sbi/sbi_hart.c @@ -304,6 +304,9 @@ static inline char *sbi_hart_feature_id2string(unsigned long feature) case SBI_HART_HAS_AIA: fstr = "aia"; break; + case SBI_HART_HAS_MENVCFG: + fstr = "menvcfg"; + break; default: break; } @@ -534,6 +537,12 @@ __mhpm_skip: goto __aia_skip; hfeatures->features |= SBI_HART_HAS_AIA; __aia_skip: + + /* Detect if hart has menvcfg CSR */ + csr_read_allowed(CSR_MENVCFG, (unsigned long)&trap); + if (!trap.cause) + hfeatures->features |= SBI_HART_HAS_MENVCFG; + return; } -- cgit v1.2.3