[PATCH v2 0/2] cmd/sbi: add missing SBI information

The series provides library functions to read
* SBI implementation version * machine vendor ID * machine architecture ID * machine implementation ID
and enhances the sbi command to display this information.
v2: Add constants for hart suspend and resume.
Heinrich Schuchardt (2): riscv: add missing SBI extension definitions cmd/sbi: add missing SBI information
arch/riscv/include/asm/sbi.h | 39 ++++++++++++++++++++++++++++++++++-- cmd/riscv/sbi.c | 19 +++++++++++++++++- 2 files changed, 55 insertions(+), 3 deletions(-)
-- 2.30.2

Add the System Reset Extension and the Hart State Management Extension definitions.
Add missing RFENCE Extension enum values.
The SBI 0.1 extension constants are needed for for the sbi command. Remove an #ifdef.
Cf. https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- v2: Add constants for hart suspend and resume. --- arch/riscv/include/asm/sbi.h | 39 ++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-)
diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h index 53ca316180..34a115afc3 100644 --- a/arch/riscv/include/asm/sbi.h +++ b/arch/riscv/include/asm/sbi.h @@ -12,7 +12,6 @@ #include <linux/types.h>
enum sbi_ext_id { -#ifdef CONFIG_SBI_V01 SBI_EXT_0_1_SET_TIMER = 0x0, SBI_EXT_0_1_CONSOLE_PUTCHAR = 0x1, SBI_EXT_0_1_CONSOLE_GETCHAR = 0x2, @@ -22,11 +21,12 @@ enum sbi_ext_id { SBI_EXT_0_1_REMOTE_SFENCE_VMA = 0x6, SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID = 0x7, SBI_EXT_0_1_SHUTDOWN = 0x8, -#endif SBI_EXT_BASE = 0x10, SBI_EXT_TIME = 0x54494D45, SBI_EXT_IPI = 0x735049, SBI_EXT_RFENCE = 0x52464E43, + SBI_EXT_HSM = 0x48534D, + SBI_EXT_SRST = 0x53525354, };
enum sbi_ext_base_fid { @@ -51,6 +51,41 @@ enum sbi_ext_rfence_fid { SBI_EXT_RFENCE_REMOTE_FENCE_I = 0, SBI_EXT_RFENCE_REMOTE_SFENCE_VMA, SBI_EXT_RFENCE_REMOTE_SFENCE_VMA_ASID, + SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA_VMID, + SBI_EXT_RFENCE_REMOTE_HFENCE_GVMA, + SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA_ASID, + SBI_EXT_RFENCE_REMOTE_HFENCE_VVMA, +}; + +enum sbi_ext_hsm_fid { + SBI_EXT_HSM_HART_START = 0, + SBI_EXT_HSM_HART_STOP, + SBI_EXT_HSM_HART_STATUS, + SBI_EXT_HSM_HART_SUSPEND, +}; + +enum sbi_hsm_hart_status { + SBI_HSM_HART_STATUS_STARTED = 0, + SBI_HSM_HART_STATUS_STOPPED, + SBI_HSM_HART_STATUS_START_PENDING, + SBI_HSM_HART_STATUS_STOP_PENDING, + SBI_HSM_HART_STATUS_SUSPEND_PENDING, + SBI_HSM_HART_STATUS_RESUME_PENDING, +}; + +enum sbi_ext_srst_fid { + SBI_EXT_SRST_RESET = 0, +}; + +enum sbi_srst_reset_type { + SBI_SRST_RESET_TYPE_SHUTDOWN = 0, + SBI_SRST_RESET_TYPE_COLD_REBOOT, + SBI_SRST_RESET_TYPE_WARM_REBOOT, +}; + +enum sbi_srst_reset_reason { + SBI_SRST_RESET_REASON_NONE = 0, + SBI_SRST_RESET_REASON_SYS_FAILURE, };
#ifdef CONFIG_SBI_V01 -- 2.30.2

Let the sbi command display:
* SBI implementation version * machine vendor ID * machine architecture ID * machine implementation ID
With this patch the output for the HiFive Unmatched looks like
=> sbi SBI 0.3 OpenSBI 0.9 Machine: Vendor ID 489 Architecture ID 8000000000000007 Implementation ID 20181004 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 System Reset Extension
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- v2: no change --- cmd/riscv/sbi.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/cmd/riscv/sbi.c b/cmd/riscv/sbi.c index 90c0811e14..c0db763ba7 100644 --- a/cmd/riscv/sbi.c +++ b/cmd/riscv/sbi.c @@ -59,13 +59,30 @@ static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc, if (ret >= 0) { for (i = 0; i < ARRAY_SIZE(implementations); ++i) { if (ret == implementations[i].id) { - printf("%s\n", implementations[i].name); + printf("%s", implementations[i].name); + ret = sbi_get_impl_version(); + if (ret > 0) { + /* OpenSBI specific version encoding */ + printf(" %ld", ret >> 16); + printf(".%ld", ret & 0xffff); + } + printf("\n"); break; } } if (i == ARRAY_SIZE(implementations)) printf("Unknown implementation ID %ld\n", ret); } + printf("Machine:\n"); + ret = sbi_get_mvendorid(); + if (ret != -ENOTSUPP) + printf(" Vendor ID %lx\n", ret); + ret = sbi_get_marchid(); + if (ret != -ENOTSUPP) + printf(" Architecture ID %lx\n", ret); + ret = sbi_get_mimpid(); + if (ret != -ENOTSUPP) + printf(" Implementation ID %lx\n", ret); printf("Extensions:\n"); for (i = 0; i < ARRAY_SIZE(extensions); ++i) { ret = sbi_probe_extension(extensions[i].id); -- 2.30.2

On Mon, Jul 26, 2021 at 08:59:02PM +0800, Heinrich Schuchardt wrote:
The series provides library functions to read
- SBI implementation version
- machine vendor ID
- machine architecture ID
- machine implementation ID
and enhances the sbi command to display this information.
v2: Add constants for hart suspend and resume.
Heinrich Schuchardt (2): riscv: add missing SBI extension definitions cmd/sbi: add missing SBI information
arch/riscv/include/asm/sbi.h | 39 ++++++++++++++++++++++++++++++++++-- cmd/riscv/sbi.c | 19 +++++++++++++++++- 2 files changed, 55 insertions(+), 3 deletions(-)
-- 2.30.2
Hi Heinrich,
I think you mixed these two patchset together ("riscv: enable SBI system reset" and "cmd/sbi: add missing SBI information"). This patchset does not include the implementation of "sbi_get_mvendorid", "sbi_get_marchid", "sbi_get_mimpid", "sbi_get_impl_version".
Could you please re-send the patch again?
Best regards, Leo
participants (2)
-
Heinrich Schuchardt
-
Leo Liang