bootz.c 2.7 KB

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