sb.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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/state.h>
  11. static int do_sb_handoff(struct cmd_tbl *cmdtp, int flag, int argc,
  12. char *const argv[])
  13. {
  14. #if CONFIG_IS_ENABLED(HANDOFF)
  15. if (gd->spl_handoff)
  16. printf("SPL handoff magic %lx\n", gd->spl_handoff->arch.magic);
  17. else
  18. printf("SPL handoff info not received\n");
  19. return 0;
  20. #else
  21. printf("Command not supported\n");
  22. return CMD_RET_USAGE;
  23. #endif
  24. }
  25. static int do_sb_state(struct cmd_tbl *cmdtp, int flag, int argc,
  26. char *const argv[])
  27. {
  28. struct sandbox_state *state;
  29. state = state_get_current();
  30. state_show(state);
  31. return 0;
  32. }
  33. static struct cmd_tbl cmd_sb_sub[] = {
  34. U_BOOT_CMD_MKENT(handoff, 1, 0, do_sb_handoff, "", ""),
  35. U_BOOT_CMD_MKENT(state, 1, 0, do_sb_state, "", ""),
  36. };
  37. static int do_sb(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  38. {
  39. struct cmd_tbl *c;
  40. /* Skip past 'sb' */
  41. argc--;
  42. argv++;
  43. c = find_cmd_tbl(argv[0], cmd_sb_sub, ARRAY_SIZE(cmd_sb_sub));
  44. if (c)
  45. return c->cmd(cmdtp, flag, argc, argv);
  46. else
  47. return CMD_RET_USAGE;
  48. }
  49. U_BOOT_CMD(
  50. sb, 8, 1, do_sb,
  51. "Sandbox status commands",
  52. "handoff - Show handoff data received from SPL\n"
  53. "sb state - Show sandbox state"
  54. );