bootm.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2007 Michal Simek
  4. * (C) Copyright 2004 Atmark Techno, Inc.
  5. *
  6. * Michal SIMEK <monstr@monstr.eu>
  7. * Yasushi SHOJI <yashi@atmark-techno.com>
  8. */
  9. #include <common.h>
  10. #include <command.h>
  11. #include <fdt_support.h>
  12. #include <image.h>
  13. #include <u-boot/zlib.h>
  14. #include <asm/byteorder.h>
  15. int do_bootm_linux(int flag, int argc, char * const argv[],
  16. bootm_headers_t *images)
  17. {
  18. /* First parameter is mapped to $r5 for kernel boot args */
  19. void (*thekernel) (char *, ulong, ulong);
  20. char *commandline = env_get("bootargs");
  21. ulong rd_data_start, rd_data_end;
  22. /*
  23. * allow the PREP bootm subcommand, it is required for bootm to work
  24. */
  25. if (flag & BOOTM_STATE_OS_PREP)
  26. return 0;
  27. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  28. return 1;
  29. int ret;
  30. char *of_flat_tree = NULL;
  31. #if defined(CONFIG_OF_LIBFDT)
  32. /* did generic code already find a device tree? */
  33. if (images->ft_len)
  34. of_flat_tree = images->ft_addr;
  35. #endif
  36. thekernel = (void (*)(char *, ulong, ulong))images->ep;
  37. /* find ramdisk */
  38. ret = boot_get_ramdisk(argc, argv, images, IH_ARCH_MICROBLAZE,
  39. &rd_data_start, &rd_data_end);
  40. if (ret)
  41. return 1;
  42. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  43. if (!of_flat_tree && argc > 1)
  44. of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
  45. /* fixup the initrd now that we know where it should be */
  46. if (images->rd_start && images->rd_end && of_flat_tree) {
  47. ret = fdt_initrd(of_flat_tree, images->rd_start,
  48. images->rd_end);
  49. if (ret)
  50. return 1;
  51. }
  52. #ifdef DEBUG
  53. printf("## Transferring control to Linux (at address 0x%08lx) ",
  54. (ulong)thekernel);
  55. printf("ramdisk 0x%08lx, FDT 0x%08lx...\n",
  56. rd_data_start, (ulong) of_flat_tree);
  57. #endif
  58. #ifdef XILINX_USE_DCACHE
  59. flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
  60. #endif
  61. /*
  62. * Linux Kernel Parameters (passing device tree):
  63. * r5: pointer to command line
  64. * r6: pointer to ramdisk
  65. * r7: pointer to the fdt, followed by the board info data
  66. */
  67. thekernel(commandline, rd_data_start, (ulong)of_flat_tree);
  68. /* does not return */
  69. return 1;
  70. }