sbi.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * The 'sbi' command displays information about the SBI implementation.
  4. *
  5. * Copyright (c) 2020, Heinrich Schuchardt <xypron.glpk@gmx.de>
  6. */
  7. #include <common.h>
  8. #include <command.h>
  9. #include <asm/sbi.h>
  10. struct sbi_ext {
  11. const u32 id;
  12. const char *name;
  13. };
  14. static struct sbi_ext extensions[] = {
  15. { 0x00000000, "sbi_set_timer" },
  16. { 0x00000001, "sbi_console_putchar" },
  17. { 0x00000002, "sbi_console_getchar" },
  18. { 0x00000003, "sbi_clear_ipi" },
  19. { 0x00000004, "sbi_send_ipi" },
  20. { 0x00000005, "sbi_remote_fence_i" },
  21. { 0x00000006, "sbi_remote_sfence_vma" },
  22. { 0x00000007, "sbi_remote_sfence_vma_asid" },
  23. { 0x00000008, "sbi_shutdown" },
  24. { 0x00000010, "SBI Base Functionality" },
  25. { 0x54494D45, "Timer Extension" },
  26. { 0x00735049, "IPI Extension" },
  27. { 0x52464E43, "RFENCE Extension" },
  28. { 0x0048534D, "Hart State Management Extension" },
  29. };
  30. static int do_sbi(struct cmd_tbl *cmdtp, int flag, int argc,
  31. char *const argv[])
  32. {
  33. int i;
  34. long ret;
  35. ret = sbi_get_spec_version();
  36. if (ret >= 0)
  37. printf("SBI %ld.%ld\n", ret >> 24, ret & 0xffffff);
  38. ret = sbi_get_impl_id();
  39. if (ret >= 0) {
  40. switch (ret) {
  41. case 0:
  42. printf("Berkeley Boot Loader (BBL)\n");
  43. break;
  44. case 1:
  45. printf("OpenSBI\n");
  46. break;
  47. case 2:
  48. printf("Xvisor\n");
  49. break;
  50. case 3:
  51. printf("KVM\n");
  52. break;
  53. default:
  54. printf("Unknown implementation\n");
  55. break;
  56. }
  57. }
  58. printf("Extensions:\n");
  59. for (i = 0; i < ARRAY_SIZE(extensions); ++i) {
  60. ret = sbi_probe_extension(extensions[i].id);
  61. if (ret > 0)
  62. printf(" %s\n", extensions[i].name);
  63. }
  64. return 0;
  65. }
  66. #ifdef CONFIG_SYS_LONGHELP
  67. static char sbi_help_text[] =
  68. "- display SBI spec version, implementation, and available extensions";
  69. #endif
  70. U_BOOT_CMD_COMPLETE(
  71. sbi, 1, 0, do_sbi,
  72. "display SBI information",
  73. sbi_help_text, NULL
  74. );