sb.c 1.3 KB

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