bootz.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2000-2009
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. #include <common.h>
  7. #include <bootm.h>
  8. #include <command.h>
  9. #include <image.h>
  10. #include <irq_func.h>
  11. #include <lmb.h>
  12. #include <log.h>
  13. #include <linux/compiler.h>
  14. int __weak bootz_setup(ulong image, ulong *start, ulong *end)
  15. {
  16. /* Please define bootz_setup() for your platform */
  17. puts("Your platform's zImage format isn't supported yet!\n");
  18. return -1;
  19. }
  20. /*
  21. * zImage booting support
  22. */
  23. static int bootz_start(struct cmd_tbl *cmdtp, int flag, int argc,
  24. char *const argv[], bootm_headers_t *images)
  25. {
  26. int ret;
  27. ulong zi_start, zi_end;
  28. ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
  29. images, 1);
  30. /* Setup Linux kernel zImage entry point */
  31. if (!argc) {
  32. images->ep = image_load_addr;
  33. debug("* kernel: default image load address = 0x%08lx\n",
  34. image_load_addr);
  35. } else {
  36. images->ep = hextoul(argv[0], NULL);
  37. debug("* kernel: cmdline image address = 0x%08lx\n",
  38. images->ep);
  39. }
  40. ret = bootz_setup(images->ep, &zi_start, &zi_end);
  41. if (ret != 0)
  42. return 1;
  43. lmb_reserve(&images->lmb, images->ep, zi_end - zi_start);
  44. /*
  45. * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
  46. * have a header that provide this informaiton.
  47. */
  48. if (bootm_find_images(flag, argc, argv, images->ep, zi_end - zi_start))
  49. return 1;
  50. return 0;
  51. }
  52. int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  53. {
  54. int ret;
  55. /* Consume 'bootz' */
  56. argc--; argv++;
  57. if (bootz_start(cmdtp, flag, argc, argv, &images))
  58. return 1;
  59. /*
  60. * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
  61. * disable interrupts ourselves
  62. */
  63. bootm_disable_interrupts();
  64. images.os.os = IH_OS_LINUX;
  65. ret = do_bootm_states(cmdtp, flag, argc, argv,
  66. #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
  67. BOOTM_STATE_RAMDISK |
  68. #endif
  69. BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
  70. BOOTM_STATE_OS_GO,
  71. &images, 1);
  72. return ret;
  73. }
  74. #ifdef CONFIG_SYS_LONGHELP
  75. static char bootz_help_text[] =
  76. "[addr [initrd[:size]] [fdt]]\n"
  77. " - boot Linux zImage stored in memory\n"
  78. "\tThe argument 'initrd' is optional and specifies the address\n"
  79. "\tof the initrd in memory. The optional argument ':size' allows\n"
  80. "\tspecifying the size of RAW initrd.\n"
  81. #if defined(CONFIG_OF_LIBFDT)
  82. "\tWhen booting a Linux kernel which requires a flat device-tree\n"
  83. "\ta third argument is required which is the address of the\n"
  84. "\tdevice-tree blob. To boot that kernel without an initrd image,\n"
  85. "\tuse a '-' for the second argument. If you do not pass a third\n"
  86. "\ta bd_info struct will be passed instead\n"
  87. #endif
  88. "";
  89. #endif
  90. U_BOOT_CMD(
  91. bootz, CONFIG_SYS_MAXARGS, 1, do_bootz,
  92. "boot Linux zImage image from memory", bootz_help_text
  93. );