bootz.c 2.7 KB

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