main.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2000
  4. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  5. */
  6. /* #define DEBUG */
  7. #include <common.h>
  8. #include <autoboot.h>
  9. #include <bootstage.h>
  10. #include <cli.h>
  11. #include <command.h>
  12. #include <console.h>
  13. #include <env.h>
  14. #include <init.h>
  15. #include <net.h>
  16. #include <version.h>
  17. #include <efi_loader.h>
  18. static void run_preboot_environment_command(void)
  19. {
  20. char *p;
  21. p = env_get("preboot");
  22. if (p != NULL) {
  23. int prev = 0;
  24. if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
  25. prev = disable_ctrlc(1); /* disable Ctrl-C checking */
  26. run_command_list(p, -1, 0);
  27. if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
  28. disable_ctrlc(prev); /* restore Ctrl-C checking */
  29. }
  30. }
  31. /* We come here after U-Boot is initialised and ready to process commands */
  32. void main_loop(void)
  33. {
  34. int ret = 1;
  35. const char *s;
  36. bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
  37. if (IS_ENABLED(CONFIG_VERSION_VARIABLE))
  38. env_set("ver", version_string); /* set version variable */
  39. cli_init();
  40. if (IS_ENABLED(CONFIG_USE_PREBOOT))
  41. run_preboot_environment_command();
  42. if (IS_ENABLED(CONFIG_UPDATE_TFTP))
  43. update_tftp(0UL, NULL, NULL);
  44. if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY))
  45. efi_launch_capsules();
  46. s = bootdelay_process();
  47. if (cli_process_fdt(&s))
  48. cli_secure_boot_cmd(s);
  49. if (IS_ENABLED(CONFIG_AUTO_FASTBOOT_STARFIVE)) {
  50. ret = autofastboot_command();
  51. s = bootdelay_process();
  52. }
  53. if (ret)
  54. autoboot_command(s);
  55. cli_loop();
  56. panic("No CLI available");
  57. }