bootm.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2011 Andes Technology Corporation
  4. * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
  5. * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
  6. * Rick Chen, Andes Technology Corporation <rick@andestech.com>
  7. */
  8. #include <common.h>
  9. #include <command.h>
  10. #include <image.h>
  11. #include <u-boot/zlib.h>
  12. #include <asm/byteorder.h>
  13. #include <asm/bootm.h>
  14. DECLARE_GLOBAL_DATA_PTR;
  15. __weak void board_quiesce_devices(void)
  16. {
  17. }
  18. int arch_fixup_fdt(void *blob)
  19. {
  20. return 0;
  21. }
  22. int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
  23. {
  24. bd_t *bd = gd->bd;
  25. char *s;
  26. int machid = bd->bi_arch_number;
  27. void (*theKernel)(int arch, uint params);
  28. /*
  29. * allow the PREP bootm subcommand, it is required for bootm to work
  30. */
  31. if (flag & BOOTM_STATE_OS_PREP)
  32. return 0;
  33. if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
  34. return 1;
  35. theKernel = (void (*)(int, uint))images->ep;
  36. s = env_get("machid");
  37. if (s) {
  38. machid = simple_strtoul(s, NULL, 16);
  39. printf("Using machid 0x%x from environment\n", machid);
  40. }
  41. bootstage_mark(BOOTSTAGE_ID_RUN_OS);
  42. debug("## Transferring control to Linux (at address %08lx) ...\n",
  43. (ulong)theKernel);
  44. if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
  45. #ifdef CONFIG_OF_LIBFDT
  46. debug("using: FDT\n");
  47. if (image_setup_linux(images)) {
  48. printf("FDT creation failed! hanging...");
  49. hang();
  50. }
  51. #endif
  52. }
  53. /* we assume that the kernel is in place */
  54. printf("\nStarting kernel ...\n\n");
  55. cleanup_before_linux();
  56. if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
  57. theKernel(machid, (unsigned long)images->ft_addr);
  58. /* does not return */
  59. return 1;
  60. }