bootm.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * (C) Copyright 2011 Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
  3. *
  4. * Based on microblaze implementation by:
  5. * (C) Copyright 2007 Michal Simek
  6. * (C) Copyright 2004 Atmark Techno, Inc.
  7. *
  8. * Michal SIMEK <monstr@monstr.eu>
  9. * Yasushi SHOJI <yashi@atmark-techno.com>
  10. *
  11. * See file CREDITS for list of people who contributed to this
  12. * project.
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. #include <common.h>
  30. #include <command.h>
  31. #include <image.h>
  32. #include <u-boot/zlib.h>
  33. #include <asm/byteorder.h>
  34. DECLARE_GLOBAL_DATA_PTR;
  35. int do_bootm_linux(int flag, int argc, char * const argv[],
  36. bootm_headers_t *images)
  37. {
  38. void (*kernel) (unsigned int);
  39. ulong rd_data_start, rd_data_end;
  40. /*
  41. * allow the PREP bootm subcommand, it is required for bootm to work
  42. */
  43. if (flag & BOOTM_STATE_OS_PREP)
  44. return 0;
  45. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  46. return 1;
  47. int ret;
  48. char *of_flat_tree = NULL;
  49. #if defined(CONFIG_OF_LIBFDT)
  50. /* did generic code already find a device tree? */
  51. if (images->ft_len)
  52. of_flat_tree = images->ft_addr;
  53. #endif
  54. kernel = (void (*)(unsigned int))images->ep;
  55. /* find ramdisk */
  56. ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_OPENRISC,
  57. &rd_data_start, &rd_data_end);
  58. if (ret)
  59. return 1;
  60. show_boot_progress(15);
  61. if (!of_flat_tree && argc > 1)
  62. of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
  63. #ifdef DEBUG
  64. printf("## Transferring control to Linux (at address 0x%08lx) " \
  65. "ramdisk 0x%08lx, FDT 0x%08lx...\n",
  66. (ulong) kernel, rd_data_start, (ulong) of_flat_tree);
  67. #endif
  68. if (dcache_status() || icache_status())
  69. flush_cache((ulong)kernel, max(checkdcache(), checkicache()));
  70. /*
  71. * Linux Kernel Parameters (passing device tree):
  72. * r3: pointer to the fdt, followed by the board info data
  73. */
  74. kernel((unsigned int) of_flat_tree);
  75. /* does not return */
  76. return 1;
  77. }