1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
// 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_imp {
const long id;
const char *name;
};
struct sbi_ext {
const u32 id;
const char *name;
};
static struct sbi_imp implementations[] = {
{ 0, "Berkeley Boot Loader (BBL)" },
{ 1, "OpenSBI" },
{ 2, "Xvisor" },
{ 3, "KVM" },
{ 4, "RustSBI" },
{ 5, "Diosix" },
{ 6, "Coffer" },
};
static struct sbi_ext extensions[] = {
{ SBI_EXT_0_1_SET_TIMER, "Set Timer" },
{ SBI_EXT_0_1_CONSOLE_PUTCHAR, "Console Putchar" },
{ SBI_EXT_0_1_CONSOLE_GETCHAR, "Console Getchar" },
{ SBI_EXT_0_1_CLEAR_IPI, "Clear IPI" },
{ SBI_EXT_0_1_SEND_IPI, "Send IPI" },
{ SBI_EXT_0_1_REMOTE_FENCE_I, "Remote FENCE.I" },
{ SBI_EXT_0_1_REMOTE_SFENCE_VMA, "Remote SFENCE.VMA" },
{ SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID, "Remote SFENCE.VMA with ASID" },
{ SBI_EXT_0_1_SHUTDOWN, "System Shutdown" },
{ SBI_EXT_BASE, "SBI Base Functionality" },
{ SBI_EXT_TIME, "Timer Extension" },
{ SBI_EXT_IPI, "IPI Extension" },
{ SBI_EXT_RFENCE, "RFENCE Extension" },
{ SBI_EXT_HSM, "Hart State Management Extension" },
{ SBI_EXT_SRST, "System Reset Extension" },
{ SBI_EXT_PMU, "Performance Monitoring Unit Extension" },
{ SBI_EXT_DBCN, "Debug Console Extension" },
{ SBI_EXT_SUSP, "System Suspend Extension" },
{ SBI_EXT_CPPC, "Collaborative Processor Performance Control Extension" },
};
static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
int i, impl_id;
long ret;
long mvendorid, marchid, mimpid;
ret = sbi_get_spec_version();
if (ret < 0) {
printf("No SBI 0.2+\n");
return CMD_RET_FAILURE;
}
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 (impl_id == implementations[i].id) {
long vers;
printf("\n%s ", implementations[i].name);
ret = sbi_get_impl_version(&vers);
if (ret < 0)
break;
switch (impl_id) {
case 1: /* OpenSBI */
printf("%ld.%ld",
vers >> 16, vers & 0xffff);
break;
case 3: /* KVM */
case 4: /* RustSBI */
printf("%ld.%ld.%ld",
vers >> 16,
(vers >> 8) & 0xff,
vers & 0xff);
break;
default:
printf("0x%lx", vers);
break;
}
break;
}
}
if (i == ARRAY_SIZE(implementations))
printf("Unknown implementation ID %ld", ret);
}
printf("\nMachine:\n");
ret = sbi_get_mvendorid(&mvendorid);
if (!ret)
printf(" Vendor ID %lx\n", mvendorid);
ret = sbi_get_marchid(&marchid);
if (!ret)
printf(" Architecture ID %lx\n", marchid);
ret = sbi_get_mimpid(&mimpid);
if (!ret)
printf(" Implementation ID %lx\n", mimpid);
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
);
|