bootm.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * SPDX-License-Identifier: GPL-2.0+
  12. */
  13. #include <common.h>
  14. #include <command.h>
  15. #include <image.h>
  16. #include <u-boot/zlib.h>
  17. #include <asm/byteorder.h>
  18. DECLARE_GLOBAL_DATA_PTR;
  19. int do_bootm_linux(int flag, int argc, char * const argv[],
  20. bootm_headers_t *images)
  21. {
  22. void (*kernel) (unsigned int);
  23. ulong rd_data_start, rd_data_end;
  24. /*
  25. * allow the PREP bootm subcommand, it is required for bootm to work
  26. */
  27. if (flag & BOOTM_STATE_OS_PREP)
  28. return 0;
  29. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  30. return 1;
  31. int ret;
  32. char *of_flat_tree = NULL;
  33. #if defined(CONFIG_OF_LIBFDT)
  34. /* did generic code already find a device tree? */
  35. if (images->ft_len)
  36. of_flat_tree = images->ft_addr;
  37. #endif
  38. kernel = (void (*)(unsigned int))images->ep;
  39. /* find ramdisk */
  40. ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_OPENRISC,
  41. &rd_data_start, &rd_data_end);
  42. if (ret)
  43. return 1;
  44. show_boot_progress(15);
  45. if (!of_flat_tree && argc > 1)
  46. of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
  47. #ifdef DEBUG
  48. printf("## Transferring control to Linux (at address 0x%08lx) " \
  49. "ramdisk 0x%08lx, FDT 0x%08lx...\n",
  50. (ulong) kernel, rd_data_start, (ulong) of_flat_tree);
  51. #endif
  52. if (dcache_status() || icache_status())
  53. flush_cache((ulong)kernel, max(checkdcache(), checkicache()));
  54. /*
  55. * Linux Kernel Parameters (passing device tree):
  56. * r3: pointer to the fdt, followed by the board info data
  57. */
  58. kernel((unsigned int) of_flat_tree);
  59. /* does not return */
  60. return 1;
  61. }