zimageboot.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * (C) Copyright 2010
  3. * Renesas Solutions Corp.
  4. * Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
  5. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. /*
  25. * Linux SuperH zImage loading and boot
  26. */
  27. #include <common.h>
  28. #include <asm/io.h>
  29. #include <asm/zimage.h>
  30. int do_sh_zimageboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  31. {
  32. ulong (*zboot_entry)(int, char * const []) = NULL;
  33. char *s0, *s1;
  34. unsigned char *param = NULL;
  35. char *cmdline;
  36. char *bootargs;
  37. disable_interrupts();
  38. if (argc >= 3) {
  39. /* argv[1] holds the address of the zImage */
  40. s0 = argv[1];
  41. /* argv[2] holds the address of zero page */
  42. s1 = argv[2];
  43. } else {
  44. goto exit;
  45. }
  46. if (s0)
  47. zboot_entry = (ulong (*)(int, char * const []))simple_strtoul(s0, NULL, 16);
  48. /* empty_zero_page */
  49. if (s1)
  50. param = (unsigned char*)simple_strtoul(s1, NULL, 16);
  51. /* Linux kernel command line */
  52. cmdline = (char *)param + COMMAND_LINE;
  53. bootargs = getenv("bootargs");
  54. /* Clear zero page */
  55. memset(param, 0, 0x1000);
  56. /* Set commandline */
  57. strcpy(cmdline, bootargs);
  58. /* Boot */
  59. zboot_entry(0, NULL);
  60. exit:
  61. return -1;
  62. }
  63. U_BOOT_CMD(
  64. zimageboot, 3, 0, do_sh_zimageboot,
  65. "Boot zImage for Renesas SH",
  66. ""
  67. );