sb.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2018, Google Inc.
  4. * Written by Simon Glass <sjg@chromium.org>
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <dm.h>
  9. #include <spl.h>
  10. #include <asm/global_data.h>
  11. #include <asm/state.h>
  12. static int do_sb_handoff(struct cmd_tbl *cmdtp, int flag, int argc,
  13. char *const argv[])
  14. {
  15. #if CONFIG_IS_ENABLED(HANDOFF)
  16. if (gd->spl_handoff)
  17. printf("SPL handoff magic %lx\n", gd->spl_handoff->arch.magic);
  18. else
  19. printf("SPL handoff info not received\n");
  20. return 0;
  21. #else
  22. printf("Command not supported\n");
  23. return CMD_RET_USAGE;
  24. #endif
  25. }
  26. static int do_sb_state(struct cmd_tbl *cmdtp, int flag, int argc,
  27. char *const argv[])
  28. {
  29. struct sandbox_state *state;
  30. state = state_get_current();
  31. state_show(state);
  32. return 0;
  33. }
  34. static struct cmd_tbl cmd_sb_sub[] = {
  35. U_BOOT_CMD_MKENT(handoff, 1, 0, do_sb_handoff, "", ""),
  36. U_BOOT_CMD_MKENT(state, 1, 0, do_sb_state, "", ""),
  37. };
  38. static int do_sb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  39. {
  40. struct cmd_tbl *c;
  41. /* Skip past 'sb' */
  42. argc--;
  43. argv++;
  44. c = find_cmd_tbl(argv[0], cmd_sb_sub, ARRAY_SIZE(cmd_sb_sub));
  45. if (c)
  46. return c->cmd(cmdtp, flag, argc, argv);
  47. else
  48. return CMD_RET_USAGE;
  49. }
  50. U_BOOT_CMD(
  51. sb, 8, 1, do_sb,
  52. "Sandbox status commands",
  53. "handoff - Show handoff data received from SPL\n"
  54. "sb state - Show sandbox state"
  55. );