diff options
author | Anup Patel <apatel@ventanamicro.com> | 2023-02-13 07:50:30 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2023-02-27 08:56:35 +0300 |
commit | 81adc62f45c0baf13112358164a327197e70a7af (patch) | |
tree | 37afd08b27918809a2e3ee7090ba3108b45adc54 /lib | |
parent | 30ea8069f4c704e67017215f90f74b8588ee9bdf (diff) | |
download | opensbi-81adc62f45c0baf13112358164a327197e70a7af.tar.xz |
lib: sbi: Align SBI vendor extension id with mvendorid CSR
As-per the SBI specification, the lower 24bits of the SBI vendor
extension id is same as lower 24bits of the mvendorid CSR.
We update the SBI vendor extension id checking based on above.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sbi/sbi_ecall_vendor.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/sbi/sbi_ecall_vendor.c b/lib/sbi/sbi_ecall_vendor.c index 9252829..9ea5156 100644 --- a/lib/sbi/sbi_ecall_vendor.c +++ b/lib/sbi/sbi_ecall_vendor.c @@ -13,12 +13,23 @@ #include <sbi/sbi_error.h> #include <sbi/sbi_platform.h> #include <sbi/sbi_trap.h> +#include <sbi/riscv_asm.h> + +static inline unsigned long sbi_ecall_vendor_id(void) +{ + return SBI_EXT_VENDOR_START + + (csr_read(CSR_MVENDORID) & + (SBI_EXT_VENDOR_END - SBI_EXT_VENDOR_START)); +} static int sbi_ecall_vendor_probe(unsigned long extid, unsigned long *out_val) { - *out_val = sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr(), - extid); + if (!sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr()) || + extid != sbi_ecall_vendor_id()) + *out_val = 0; + else + *out_val = 1; return 0; } @@ -27,6 +38,10 @@ static int sbi_ecall_vendor_handler(unsigned long extid, unsigned long funcid, unsigned long *out_val, struct sbi_trap_info *out_trap) { + if (!sbi_platform_vendor_ext_check(sbi_platform_thishart_ptr()) || + extid != sbi_ecall_vendor_id()) + return SBI_ERR_NOT_SUPPORTED; + return sbi_platform_vendor_ext_provider(sbi_platform_thishart_ptr(), extid, funcid, regs, out_val, out_trap); |