1 // SPDX-License-Identifier: GPL-2.0+
3 * The 'sbi' command displays information about the SBI implementation.
5 * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
22 static struct sbi_imp implementations[] = {
23 { 0, "Berkeley Boot Loader (BBL)" },
31 static struct sbi_ext extensions[] = {
32 { SBI_EXT_0_1_SET_TIMER, "sbi_set_timer" },
33 { SBI_EXT_0_1_CONSOLE_PUTCHAR, "sbi_console_putchar" },
34 { SBI_EXT_0_1_CONSOLE_GETCHAR, "sbi_console_getchar" },
35 { SBI_EXT_0_1_CLEAR_IPI, "sbi_clear_ipi" },
36 { SBI_EXT_0_1_SEND_IPI, "sbi_send_ipi" },
37 { SBI_EXT_0_1_REMOTE_FENCE_I, "sbi_remote_fence_i" },
38 { SBI_EXT_0_1_REMOTE_SFENCE_VMA, "sbi_remote_sfence_vma" },
39 { SBI_EXT_0_1_REMOTE_SFENCE_VMA_ASID, "sbi_remote_sfence_vma_asid" },
40 { SBI_EXT_0_1_SHUTDOWN, "sbi_shutdown" },
41 { SBI_EXT_BASE, "SBI Base Functionality" },
42 { SBI_EXT_TIME, "Timer Extension" },
43 { SBI_EXT_IPI, "IPI Extension" },
44 { SBI_EXT_RFENCE, "RFENCE Extension" },
45 { SBI_EXT_HSM, "Hart State Management Extension" },
46 { SBI_EXT_SRST, "System Reset Extension" },
49 static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,
55 ret = sbi_get_spec_version();
57 printf("SBI %ld.%ld", ret >> 24, ret & 0xffffff);
58 impl_id = sbi_get_impl_id();
60 for (i = 0; i < ARRAY_SIZE(implementations); ++i) {
61 if (impl_id == implementations[i].id) {
64 printf("\n%s ", implementations[i].name);
65 ret = sbi_get_impl_version(&vers);
70 vers >> 16, vers & 0xffff);
72 printf("0x%lx", vers);
76 if (i == ARRAY_SIZE(implementations))
77 printf("Unknown implementation ID %ld", ret);
79 printf("\nExtensions:\n");
80 for (i = 0; i < ARRAY_SIZE(extensions); ++i) {
81 ret = sbi_probe_extension(extensions[i].id);
83 printf(" %s\n", extensions[i].name);
88 #ifdef CONFIG_SYS_LONGHELP
89 static char sbi_help_text[] =
90 "- display SBI spec version, implementation, and available extensions";
96 "display SBI information",