bootm.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * (C) Copyright 2003, Psyent Corporation <www.psyent.com>
  3. * Scott McNutt <smcnutt@psyent.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #define NIOS_MAGIC 0x534f494e /* enable command line and initrd passing */
  9. int do_bootm_linux(int flag, int argc, char * const argv[], bootm_headers_t *images)
  10. {
  11. void (*kernel)(int, int, int, char *) = (void *)images->ep;
  12. char *commandline = getenv("bootargs");
  13. ulong initrd_start = images->rd_start;
  14. ulong initrd_end = images->rd_end;
  15. char *of_flat_tree = NULL;
  16. #if defined(CONFIG_OF_LIBFDT)
  17. /* did generic code already find a device tree? */
  18. if (images->ft_len)
  19. of_flat_tree = images->ft_addr;
  20. #endif
  21. if (!of_flat_tree && argc > 1)
  22. of_flat_tree = (char *)simple_strtoul(argv[1], NULL, 16);
  23. if (of_flat_tree)
  24. initrd_end = (ulong)of_flat_tree;
  25. /*
  26. * allow the PREP bootm subcommand, it is required for bootm to work
  27. */
  28. if (flag & BOOTM_STATE_OS_PREP)
  29. return 0;
  30. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  31. return 1;
  32. /* flushes data and instruction caches before calling the kernel */
  33. disable_interrupts();
  34. flush_dcache_all();
  35. debug("bootargs=%s @ 0x%lx\n", commandline, (ulong)&commandline);
  36. debug("initrd=0x%lx-0x%lx\n", (ulong)initrd_start, (ulong)initrd_end);
  37. /* kernel parameters passing
  38. * r4 : NIOS magic
  39. * r5 : initrd start
  40. * r6 : initrd end or fdt
  41. * r7 : kernel command line
  42. * fdt is passed to kernel via r6, the same as initrd_end. fdt will be
  43. * verified with fdt magic. when both initrd and fdt are used at the
  44. * same time, fdt must follow immediately after initrd.
  45. */
  46. kernel(NIOS_MAGIC, initrd_start, initrd_end, commandline);
  47. /* does not return */
  48. return 1;
  49. }