zimageboot.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2010
  4. * Renesas Solutions Corp.
  5. * Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
  6. */
  7. /*
  8. * Linux SuperH zImage loading and boot
  9. */
  10. #include <common.h>
  11. #include <asm/io.h>
  12. #include <asm/zimage.h>
  13. int do_sh_zimageboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  14. {
  15. ulong (*zboot_entry)(int, char * const []) = NULL;
  16. char *s0, *s1;
  17. unsigned char *param = NULL;
  18. char *cmdline;
  19. char *bootargs;
  20. disable_interrupts();
  21. if (argc >= 3) {
  22. /* argv[1] holds the address of the zImage */
  23. s0 = argv[1];
  24. /* argv[2] holds the address of zero page */
  25. s1 = argv[2];
  26. } else {
  27. goto exit;
  28. }
  29. if (s0)
  30. zboot_entry = (ulong (*)(int, char * const []))simple_strtoul(s0, NULL, 16);
  31. /* empty_zero_page */
  32. if (s1)
  33. param = (unsigned char*)simple_strtoul(s1, NULL, 16);
  34. /* Linux kernel command line */
  35. cmdline = (char *)param + COMMAND_LINE;
  36. bootargs = env_get("bootargs");
  37. /* Clear zero page */
  38. /* cppcheck-suppress nullPointer */
  39. memset(param, 0, 0x1000);
  40. /* Set commandline */
  41. strcpy(cmdline, bootargs);
  42. /* Boot */
  43. zboot_entry(0, NULL);
  44. exit:
  45. return -1;
  46. }
  47. U_BOOT_CMD(
  48. zimageboot, 3, 0, do_sh_zimageboot,
  49. "Boot zImage for Renesas SH",
  50. ""
  51. );