]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
cmd/sbi: format KVM version
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 14 Aug 2022 19:57:14 +0000 (21:57 +0200)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Tue, 6 Sep 2022 05:00:58 +0000 (13:00 +0800)
Format the KVM implementation number in a human readable form.

With the patch output of the sbi command for Linux 5.19.1 looks like:

    => sbi
    SBI 0.3
    KVM 5.19.1
    Machine:
      Vendor ID 0
      Architecture ID 7005c
      Implementation ID 7005c
    Extensions:
      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>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
cmd/riscv/sbi.c

index ee11e0f88e4f78951c9fef5a4c21db86ef55468d..522f502435ba51ccb5ecc4e478ed2b41c7e159fe 100644 (file)
@@ -68,11 +68,21 @@ static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,
                                ret = sbi_get_impl_version(&vers);
                                if (ret < 0)
                                        break;
-                               if (impl_id == 1)
+                               switch (impl_id) {
+                               case 1: /* OpenSBI */
                                        printf("%ld.%ld",
                                               vers >> 16, vers & 0xffff);
-                               else
+                                       break;
+                               case 3: /* KVM */
+                                       printf("%ld.%ld.%ld",
+                                              vers >> 16,
+                                              (vers >> 8) & 0xff,
+                                              vers & 0xff);
+                                       break;
+                               default:
                                        printf("0x%lx", vers);
+                                       break;
+                               }
                                break;
                        }
                }