From c92b50a44b95e706b9c0c97544bd7504fe6d36e9 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 20 Aug 2020 19:43:39 +0200 Subject: cmd: provide command sbi Provide a command to display information about the SBI implementation. The output might look like: => sbi SBI 0.2 OpenSBI Extensions: sbi_set_timer sbi_console_putchar sbi_console_getchar sbi_clear_ipi sbi_send_ipi sbi_remote_fence_i sbi_remote_sfence_vma sbi_remote_sfence_vma_asid sbi_shutdown SBI Base Functionality Timer Extension IPI Extension RFENCE Extension Hart State Management Extension The command can be used to construct a unit test checking that the communication with the SEE is working. Signed-off-by: Heinrich Schuchardt Reviewed-by: Atish Patra Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Pragnesh Patel Tested-by: Pragnesh Patel Reviewed-by: Rick Chen Tested-by: Rick Chen --- arch/riscv/lib/sbi.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'arch/riscv/lib/sbi.c') diff --git a/arch/riscv/lib/sbi.c b/arch/riscv/lib/sbi.c index 8fbc23839d..77845a73ca 100644 --- a/arch/riscv/lib/sbi.c +++ b/arch/riscv/lib/sbi.c @@ -53,6 +53,42 @@ void sbi_set_timer(uint64_t stime_value) #endif } +/** + * sbi_get_spec_version() - get current SBI specification version + * + * Return: version id + */ +long sbi_get_spec_version(void) +{ + struct sbiret ret; + + ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_SPEC_VERSION, + 0, 0, 0, 0, 0, 0); + if (!ret.error) + if (ret.value) + return ret.value; + + return -ENOTSUPP; +} + +/** + * sbi_get_impl_id() - get SBI implementation ID + * + * Return: implementation ID + */ +int sbi_get_impl_id(void) +{ + struct sbiret ret; + + ret = sbi_ecall(SBI_EXT_BASE, SBI_EXT_BASE_GET_IMP_ID, + 0, 0, 0, 0, 0, 0); + if (!ret.error) + if (ret.value) + return ret.value; + + return -ENOTSUPP; +} + /** * sbi_probe_extension() - Check if an SBI extension ID is supported or not. * @extid: The extension ID to be probed. -- cgit