zimageboot.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <command.h>
  12. #include <env.h>
  13. #include <irq_func.h>
  14. #include <asm/io.h>
  15. #include <asm/zimage.h>
  16. int do_sh_zimageboot(struct cmd_tbl *cmdtp, int flag, int argc,
  17. char *const argv[])
  18. {
  19. ulong (*zboot_entry)(int, char * const []) = NULL;
  20. char *s0, *s1;
  21. unsigned char *param = NULL;
  22. char *cmdline;
  23. char *bootargs;
  24. disable_interrupts();
  25. if (argc >= 3) {
  26. /* argv[1] holds the address of the zImage */
  27. s0 = argv[1];
  28. /* argv[2] holds the address of zero page */
  29. s1 = argv[2];
  30. } else {
  31. goto exit;
  32. }
  33. if (s0)
  34. zboot_entry = (ulong (*)(int, char * const []))hextoul(s0,
  35. NULL);
  36. /* empty_zero_page */
  37. if (s1)
  38. param = (unsigned char *)hextoul(s1, NULL);
  39. /* Linux kernel command line */
  40. cmdline = (char *)param + COMMAND_LINE;
  41. bootargs = env_get("bootargs");
  42. /* Clear zero page */
  43. /* cppcheck-suppress nullPointer */
  44. memset(param, 0, 0x1000);
  45. /* Set commandline */
  46. strcpy(cmdline, bootargs);
  47. /* Boot */
  48. zboot_entry(0, NULL);
  49. exit:
  50. return -1;
  51. }
  52. U_BOOT_CMD(
  53. zimageboot, 3, 0, do_sh_zimageboot,
  54. "Boot zImage for Renesas SH",
  55. ""
  56. );