main.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 <cli.h>
  10. #include <command.h>
  11. #include <console.h>
  12. #include <env.h>
  13. #include <version.h>
  14. /*
  15. * Board-specific Platform code can reimplement show_boot_progress () if needed
  16. */
  17. __weak void show_boot_progress(int val) {}
  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. const char *s;
  35. bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
  36. if (IS_ENABLED(CONFIG_VERSION_VARIABLE))
  37. env_set("ver", version_string); /* set version variable */
  38. cli_init();
  39. if (IS_ENABLED(CONFIG_USE_PREBOOT))
  40. run_preboot_environment_command();
  41. if (IS_ENABLED(CONFIG_UPDATE_TFTP))
  42. update_tftp(0UL, NULL, NULL);
  43. s = bootdelay_process();
  44. if (cli_process_fdt(&s))
  45. cli_secure_boot_cmd(s);
  46. autoboot_command(s);
  47. cli_loop();
  48. panic("No CLI available");
  49. }