boot.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2000-2003
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. /*
  7. * Misc boot support
  8. */
  9. #include <common.h>
  10. #include <command.h>
  11. #include <net.h>
  12. #ifdef CONFIG_CMD_GO
  13. /* Allow ports to override the default behavior */
  14. __attribute__((weak))
  15. unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc,
  16. char *const argv[])
  17. {
  18. return entry (argc, argv);
  19. }
  20. static int do_go(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  21. {
  22. ulong addr, rc;
  23. int rcode = 0;
  24. if (argc < 2)
  25. return CMD_RET_USAGE;
  26. addr = hextoul(argv[1], NULL);
  27. printf ("## Starting application at 0x%08lX ...\n", addr);
  28. /*
  29. * pass address parameter as argv[0] (aka command name),
  30. * and all remaining args
  31. */
  32. rc = do_go_exec ((void *)addr, argc - 1, argv + 1);
  33. if (rc != 0) rcode = 1;
  34. printf ("## Application terminated, rc = 0x%lX\n", rc);
  35. return rcode;
  36. }
  37. /* -------------------------------------------------------------------- */
  38. U_BOOT_CMD(
  39. go, CONFIG_SYS_MAXARGS, 1, do_go,
  40. "start application at address 'addr'",
  41. "addr [arg ...]\n - start application at address 'addr'\n"
  42. " passing 'arg' as arguments"
  43. );
  44. #endif
  45. U_BOOT_CMD(
  46. reset, 2, 0, do_reset,
  47. "Perform RESET of the CPU",
  48. "- cold boot without level specifier\n"
  49. "reset -w - warm reset if implemented"
  50. );
  51. #ifdef CONFIG_CMD_POWEROFF
  52. U_BOOT_CMD(
  53. poweroff, 1, 0, do_poweroff,
  54. "Perform POWEROFF of the device",
  55. ""
  56. );
  57. #endif