* [PATCH v5 1/1] cmd: provide command sbi
@ 2020-08-20 17:43 Heinrich Schuchardt
2020-08-21 4:39 ` Pragnesh Patel
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA47380A2@ATCPCS16.andestech.com>
0 siblings, 2 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2020-08-20 17:43 UTC (permalink / raw)
To: u-boot
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 <xypron.glpk@gmx.de>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Reviewed-by: Bin Meng <bin.meng@windriver.com>
Tested-by: Bin Meng <bin.meng@windriver.com>
---
v5:
The sbi command takes no arguments. Set maxargs=1.
v4:
only show command name 'sbi' as short description in Kconfig menu
as suggested by Bin
v3:
add dependency on CONFIG_SBI_V02
use lower case for sbi in Kconfig
v2:
provide a non-blank long help text
---
arch/riscv/include/asm/sbi.h | 2 +
arch/riscv/lib/sbi.c | 36 ++++++++++++++++
cmd/Kconfig | 6 +++
cmd/riscv/Makefile | 1 +
cmd/riscv/sbi.c | 82 ++++++++++++++++++++++++++++++++++++
5 files changed, 127 insertions(+)
create mode 100644 cmd/riscv/sbi.c
diff --git a/arch/riscv/include/asm/sbi.h b/arch/riscv/include/asm/sbi.h
index 08e1ac0c0e..53ca316180 100644
--- a/arch/riscv/include/asm/sbi.h
+++ b/arch/riscv/include/asm/sbi.h
@@ -115,6 +115,8 @@ void sbi_remote_sfence_vma_asid(const unsigned long *hart_mask,
unsigned long asid);
#endif
void sbi_set_timer(uint64_t stime_value);
+long sbi_get_spec_version(void);
+int sbi_get_impl_id(void);
int sbi_probe_extension(int ext);
#endif
diff --git a/arch/riscv/lib/sbi.c b/arch/riscv/lib/sbi.c
index 8fbc23839d..920889ed13 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.
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 9ad511aa17..8feeb0ddb0 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -270,6 +270,12 @@ config SPL_CMD_TLV_EEPROM
help
Read system EEPROM data block in ONIE Tlvinfo format from SPL.
+config CMD_SBI
+ bool "sbi"
+ depends on RISCV_SMODE && SBI_V02
+ help
+ Display information about the SBI implementation.
+
endmenu
menu "Boot commands"
diff --git a/cmd/riscv/Makefile b/cmd/riscv/Makefile
index 24df023ece..1e6ac364e3 100644
--- a/cmd/riscv/Makefile
+++ b/cmd/riscv/Makefile
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-2.0+
obj-$(CONFIG_CMD_EXCEPTION) += exception.o
+obj-$(CONFIG_CMD_SBI) += sbi.o
diff --git a/cmd/riscv/sbi.c b/cmd/riscv/sbi.c
new file mode 100644
index 0000000000..7c9151f436
--- /dev/null
+++ b/cmd/riscv/sbi.c
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * The 'sbi' command displays information about the SBI implementation.
+ *
+ * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
+ */
+
+#include <common.h>
+#include <command.h>
+#include <asm/sbi.h>
+
+struct sbi_ext {
+ const u32 id;
+ const char *name;
+};
+
+static struct sbi_ext extensions[] = {
+ { 0x00000000, "sbi_set_timer" },
+ { 0x00000001, "sbi_console_putchar" },
+ { 0x00000002, "sbi_console_getchar" },
+ { 0x00000003, "sbi_clear_ipi" },
+ { 0x00000004, "sbi_send_ipi" },
+ { 0x00000005, "sbi_remote_fence_i" },
+ { 0x00000006, "sbi_remote_sfence_vma" },
+ { 0x00000007, "sbi_remote_sfence_vma_asid" },
+ { 0x00000008, "sbi_shutdown" },
+ { 0x00000010, "SBI Base Functionality" },
+ { 0x54494D45, "Timer Extension" },
+ { 0x00735049, "IPI Extension" },
+ { 0x52464E43, "RFENCE Extension" },
+ { 0x0048534D, "Hart State Management Extension" },
+};
+
+static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ int i;
+ long ret;
+
+ ret = sbi_get_spec_version();
+ if (ret >= 0)
+ printf("SBI %ld.%ld\n", ret >> 24, ret & 0xffffff);
+ ret = sbi_get_impl_id();
+ if (ret >= 0) {
+ switch (ret) {
+ case 0:
+ printf("Berkeley Boot Loader (BBL)\n");
+ break;
+ case 1:
+ printf("OpenSBI\n");
+ break;
+ case 2:
+ printf("Xvisor\n");
+ break;
+ case 3:
+ printf("KVM\n");
+ break;
+ default:
+ printf("Unknown implementation\n");
+ break;
+ }
+ }
+ printf("Extensions:\n");
+ for (i = 0; i < ARRAY_SIZE(extensions); ++i) {
+ ret = sbi_probe_extension(extensions[i].id);
+ if (ret > 0)
+ printf(" %s\n", extensions[i].name);
+ }
+ return 0;
+}
+
+#ifdef CONFIG_SYS_LONGHELP
+static char sbi_help_text[] =
+ "- display SBI spec version, implementation, and available extensions";
+
+#endif
+
+U_BOOT_CMD_COMPLETE(
+ sbi, 1, 0, do_sbi,
+ "display SBI information",
+ sbi_help_text, NULL
+);
--
2.28.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v5 1/1] cmd: provide command sbi
2020-08-20 17:43 [PATCH v5 1/1] cmd: provide command sbi Heinrich Schuchardt
@ 2020-08-21 4:39 ` Pragnesh Patel
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA47380A2@ATCPCS16.andestech.com>
1 sibling, 0 replies; 3+ messages in thread
From: Pragnesh Patel @ 2020-08-21 4:39 UTC (permalink / raw)
To: u-boot
>-----Original Message-----
>From: Heinrich Schuchardt <xypron.glpk@gmx.de>
>Sent: 20 August 2020 23:14
>To: Rick Chen <rick@andestech.com>
>Cc: Bin Meng <bmeng.cn@gmail.com>; Pragnesh Patel
><pragnesh.patel@openfive.com>; Lukas Auer <lukas@auer.io>; Atish Patra
><atish.patra@wdc.com>; u-boot at lists.denx.de; Heinrich Schuchardt
><xypron.glpk@gmx.de>; Bin Meng <bin.meng@windriver.com>
>Subject: [PATCH v5 1/1] cmd: provide command sbi
>
>[External Email] Do not click links or attachments unless you recognize the
>sender and know the content is safe
>
>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 <xypron.glpk@gmx.de>
>Reviewed-by: Atish Patra <atish.patra@wdc.com>
>Reviewed-by: Bin Meng <bin.meng@windriver.com>
>Tested-by: Bin Meng <bin.meng@windriver.com>
>---
>v5:
> The sbi command takes no arguments. Set maxargs=1.
>v4:
> only show command name 'sbi' as short description in Kconfig menu
> as suggested by Bin
>v3:
> add dependency on CONFIG_SBI_V02
> use lower case for sbi in Kconfig
>v2:
> provide a non-blank long help text
>---
> arch/riscv/include/asm/sbi.h | 2 +
> arch/riscv/lib/sbi.c | 36 ++++++++++++++++
> cmd/Kconfig | 6 +++
> cmd/riscv/Makefile | 1 +
> cmd/riscv/sbi.c | 82 ++++++++++++++++++++++++++++++++++++
> 5 files changed, 127 insertions(+)
> create mode 100644 cmd/riscv/sbi.c
Reviewed-by: Pragnesh Patel <pragnesh.patel@openfive.com>
Tested-by: Pragnesh Patel <pragnesh.patel@openfive.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH v5 1/1] cmd: provide command sbi
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA47380A2@ATCPCS16.andestech.com>
@ 2020-08-21 5:39 ` Rick Chen
0 siblings, 0 replies; 3+ messages in thread
From: Rick Chen @ 2020-08-21 5:39 UTC (permalink / raw)
To: u-boot
> From: Heinrich Schuchardt [mailto:xypron.glpk at gmx.de]
> Sent: Friday, August 21, 2020 1:44 AM
> To: Rick Jian-Zhi Chen(???)
> Cc: Bin Meng; Pragnesh Patel; Lukas Auer; Atish Patra; u-boot at lists.denx.de; Heinrich Schuchardt; Bin Meng
> Subject: [PATCH v5 1/1] 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 <xypron.glpk@gmx.de>
> Reviewed-by: Atish Patra <atish.patra@wdc.com>
> Reviewed-by: Bin Meng <bin.meng@windriver.com>
> Tested-by: Bin Meng <bin.meng@windriver.com>
> ---
> v5:
> The sbi command takes no arguments. Set maxargs=1.
> v4:
> only show command name 'sbi' as short description in Kconfig menu
> as suggested by Bin
> v3:
> add dependency on CONFIG_SBI_V02
> use lower case for sbi in Kconfig
> v2:
> provide a non-blank long help text
> ---
> arch/riscv/include/asm/sbi.h | 2 +
> arch/riscv/lib/sbi.c | 36 ++++++++++++++++
> cmd/Kconfig | 6 +++
> cmd/riscv/Makefile | 1 +
> cmd/riscv/sbi.c | 82 ++++++++++++++++++++++++++++++++++++
> 5 files changed, 127 insertions(+)
> create mode 100644 cmd/riscv/sbi.c
Reviewed-by: Rick Chen <rick@andestech.com>
Tested-by: Rick Chen <rick@andestech.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-08-21 5:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-20 17:43 [PATCH v5 1/1] cmd: provide command sbi Heinrich Schuchardt
2020-08-21 4:39 ` Pragnesh Patel
[not found] ` <752D002CFF5D0F4FA35C0100F1D73F3FA47380A2@ATCPCS16.andestech.com>
2020-08-21 5:39 ` Rick Chen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.