bootz.c 2.7 KB

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