[PATCH 2/2] cmd: sbi: show SBI implementation version

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Mon Oct 25 15:09:35 CEST 2021


Let the sbi command show the SBI implementation version

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
---
 cmd/riscv/sbi.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/cmd/riscv/sbi.c b/cmd/riscv/sbi.c
index 90c0811e14..ed0960c2f2 100644
--- a/cmd/riscv/sbi.c
+++ b/cmd/riscv/sbi.c
@@ -49,24 +49,34 @@ static struct sbi_ext extensions[] = {
 static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,
 		  char *const argv[])
 {
-	int i;
+	int i, impl_id;
 	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) {
+		printf("SBI %ld.%ld", ret >> 24, ret & 0xffffff);
+	impl_id = sbi_get_impl_id();
+	if (impl_id >= 0) {
 		for (i = 0; i < ARRAY_SIZE(implementations); ++i) {
-			if (ret == implementations[i].id) {
-				printf("%s\n", implementations[i].name);
+			if (impl_id == implementations[i].id) {
+				long vers;
+
+				printf("\n%s ", implementations[i].name);
+				ret = sbi_get_impl_version(&vers);
+				if (ret < 0)
+					break;
+				if (impl_id == 1)
+					printf("%ld.%ld",
+					       vers >> 16, vers & 0xffff);
+				else
+					printf("0x%lx", vers);
 				break;
 			}
 		}
 		if (i == ARRAY_SIZE(implementations))
-			printf("Unknown implementation ID %ld\n", ret);
+			printf("Unknown implementation ID %ld", ret);
 	}
-	printf("Extensions:\n");
+	printf("\nExtensions:\n");
 	for (i = 0; i < ARRAY_SIZE(extensions); ++i) {
 		ret = sbi_probe_extension(extensions[i].id);
 		if (ret > 0)
-- 
2.32.0



More information about the U-Boot mailing list