zimageboot.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 []))simple_strtoul(s0, NULL, 16);
  35. /* empty_zero_page */
  36. if (s1)
  37. param = (unsigned char*)simple_strtoul(s1, NULL, 16);
  38. /* Linux kernel command line */
  39. cmdline = (char *)param + COMMAND_LINE;
  40. bootargs = env_get("bootargs");
  41. /* Clear zero page */
  42. /* cppcheck-suppress nullPointer */
  43. memset(param, 0, 0x1000);
  44. /* Set commandline */
  45. strcpy(cmdline, bootargs);
  46. /* Boot */
  47. zboot_entry(0, NULL);
  48. exit:
  49. return -1;
  50. }
  51. U_BOOT_CMD(
  52. zimageboot, 3, 0, do_sh_zimageboot,
  53. "Boot zImage for Renesas SH",
  54. ""
  55. );