main.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 <init.h>
  14. #include <version.h>
  15. /*
  16. * Board-specific Platform code can reimplement show_boot_progress () if needed
  17. */
  18. __weak void show_boot_progress(int val) {}
  19. static void run_preboot_environment_command(void)
  20. {
  21. char *p;
  22. p = env_get("preboot");
  23. if (p != NULL) {
  24. int prev = 0;
  25. if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
  26. prev = disable_ctrlc(1); /* disable Ctrl-C checking */
  27. run_command_list(p, -1, 0);
  28. if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
  29. disable_ctrlc(prev); /* restore Ctrl-C checking */
  30. }
  31. }
  32. /* We come here after U-Boot is initialised and ready to process commands */
  33. void main_loop(void)
  34. {
  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. s = bootdelay_process();
  45. if (cli_process_fdt(&s))
  46. cli_secure_boot_cmd(s);
  47. autoboot_command(s);
  48. cli_loop();
  49. panic("No CLI available");
  50. }