summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig6
-rw-r--r--cmd/bootefi.c4
-rw-r--r--cmd/clone.c8
-rw-r--r--cmd/nvedit_efi.c2
-rw-r--r--cmd/riscv/Makefile1
-rw-r--r--cmd/riscv/sbi.c82
6 files changed, 99 insertions, 4 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 9ad511aa17..30c26b5d2b 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/bootefi.c b/cmd/bootefi.c
index fbfed54e85..06563d28ca 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -304,7 +304,11 @@ efi_status_t efi_install_fdt(void *fdt)
/**
* do_bootefi_exec() - execute EFI binary
*
+ * The image indicated by @handle is started. When it returns the allocated
+ * memory for the @load_options is freed.
+ *
* @handle: handle of loaded image
+ * @load_options: load options
* Return: status code
*
* Load the EFI binary into a newly assigned memory unwinding the relocation
diff --git a/cmd/clone.c b/cmd/clone.c
index 97747f8f08..32473a032c 100644
--- a/cmd/clone.c
+++ b/cmd/clone.c
@@ -38,7 +38,7 @@ static int do_clone(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv
srcbz = srcdesc->blksz;
destbz = destdesc->blksz;
- if ((srcbz * (buffersize / srcbz) != buffersize) &&
+ if ((srcbz * (buffersize / srcbz) != buffersize) ||
(destbz * (buffersize / destbz) != buffersize)) {
printf("failed: cannot match device block sizes\n");
return 1;
@@ -55,10 +55,12 @@ static int do_clone(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv
switch (unit[0]) {
case 'g':
case 'G':
- requested *= 1024;
+ requested *= 1024 * 1024 * 1024;
+ break;
case 'm':
case 'M':
- requested *= 1024;
+ requested *= 1024 * 1024;
+ break;
case 'k':
case 'K':
requested *= 1024;
diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c
index 8e31f43e1f..094c0e8098 100644
--- a/cmd/nvedit_efi.c
+++ b/cmd/nvedit_efi.c
@@ -473,7 +473,7 @@ int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc,
argc--;
argv++;
addr = simple_strtoul(argv[0], &ep, 16);
- if (*ep != ',')
+ if (*ep != ':')
return CMD_RET_USAGE;
/* 0 should be allowed for delete */
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..e66fc8e41d
--- /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
+);