bootm.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifdef CFG_DEBUG
  42. static void hexdump (unsigned char *buf, int len)
  43. {
  44. int i;
  45. for (i = 0; i < len; i++) {
  46. if ((i % 16) == 0)
  47. printf ("%s%08x: ", i ? "\n" : "", (unsigned int) &buf[i]);
  48. printf ("%02x ", buf[i]);
  49. }
  50. printf ("\n");
  51. }
  52. #endif
  53. int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
  54. {
  55. char *bootargs = getenv("bootargs");
  56. void (*kernel) (void) = (void (*)(void))images->ep;
  57. /* Setup parameters */
  58. memset(PARAM, 0, 0x1000); /* Clear zero page */
  59. strcpy(COMMAND_LINE, bootargs);
  60. kernel();
  61. /* does not return */
  62. error:
  63. return 1;
  64. }