bootm.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * (C) Copyright 2003
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. *
  22. */
  23. #include <common.h>
  24. #include <command.h>
  25. #include <asm/byteorder.h>
  26. /* The SH kernel reads arguments from the empty zero page at location
  27. * 0 at the start of SDRAM. The following are copied from
  28. * arch/sh/kernel/setup.c and may require tweaking if the kernel sources
  29. * change.
  30. */
  31. #define PARAM ((unsigned char *)CFG_SDRAM_BASE + 0x1000)
  32. #define MOUNT_ROOT_RDONLY (*(unsigned long *) (PARAM+0x000))
  33. #define RAMDISK_FLAGS (*(unsigned long *) (PARAM+0x004))
  34. #define ORIG_ROOT_DEV (*(unsigned long *) (PARAM+0x008))
  35. #define LOADER_TYPE (*(unsigned long *) (PARAM+0x00c))
  36. #define INITRD_START (*(unsigned long *) (PARAM+0x010))
  37. #define INITRD_SIZE (*(unsigned long *) (PARAM+0x014))
  38. /* ... */
  39. #define COMMAND_LINE ((char *) (PARAM+0x100))
  40. #define RAMDISK_IMAGE_START_MASK 0x07FF
  41. extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]);
  42. #ifdef CFG_DEBUG
  43. static void hexdump (unsigned char *buf, int len)
  44. {
  45. int i;
  46. for (i = 0; i < len; i++) {
  47. if ((i % 16) == 0)
  48. printf ("%s%08x: ", i ? "\n" : "", (unsigned int) &buf[i]);
  49. printf ("%02x ", buf[i]);
  50. }
  51. printf ("\n");
  52. }
  53. #endif
  54. void do_bootm_linux (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
  55. bootm_headers_t *images)
  56. {
  57. ulong ep = 0;
  58. char *bootargs = getenv("bootargs");
  59. /* find kernel entry point */
  60. if (images->legacy_hdr_valid) {
  61. ep = image_get_ep (images->legacy_hdr_os);
  62. #if defined(CONFIG_FIT)
  63. } else if (images->fit_uname_os) {
  64. int ret = fit_image_get_entry (images->fit_hdr_os,
  65. images->fit_noffset_os, &ep);
  66. if (ret) {
  67. puts ("Can't get entry point property!\n");
  68. goto error;
  69. }
  70. #endif
  71. } else {
  72. puts ("Could not find kernel entry point!\n");
  73. goto error;
  74. }
  75. void (*kernel) (void) = (void (*)(void))ep;
  76. if (!images->autostart)
  77. return ;
  78. /* Setup parameters */
  79. memset(PARAM, 0, 0x1000); /* Clear zero page */
  80. strcpy(COMMAND_LINE, bootargs);
  81. kernel();
  82. /* does not return */
  83. return;
  84. error:
  85. if (images->autostart)
  86. do_reset (cmdtp, flag, argc, argv);
  87. return;
  88. }