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 <console.h>
  11. #include <version.h>
  12. /*
  13. * Board-specific Platform code can reimplement show_boot_progress () if needed
  14. */
  15. __weak void show_boot_progress(int val) {}
  16. static void run_preboot_environment_command(void)
  17. {
  18. #ifdef CONFIG_PREBOOT
  19. char *p;
  20. p = env_get("preboot");
  21. if (p != NULL) {
  22. # ifdef CONFIG_AUTOBOOT_KEYED
  23. int prev = disable_ctrlc(1); /* disable Control C checking */
  24. # endif
  25. run_command_list(p, -1, 0);
  26. # ifdef CONFIG_AUTOBOOT_KEYED
  27. disable_ctrlc(prev); /* restore Control C checking */
  28. # endif
  29. }
  30. #endif /* CONFIG_PREBOOT */
  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. #ifdef CONFIG_VERSION_VARIABLE
  38. env_set("ver", version_string); /* set version variable */
  39. #endif /* CONFIG_VERSION_VARIABLE */
  40. cli_init();
  41. run_preboot_environment_command();
  42. #if defined(CONFIG_UPDATE_TFTP)
  43. update_tftp(0UL, NULL, NULL);
  44. #endif /* CONFIG_UPDATE_TFTP */
  45. s = bootdelay_process();
  46. if (cli_process_fdt(&s))
  47. cli_secure_boot_cmd(s);
  48. autoboot_command(s);
  49. cli_loop();
  50. panic("No CLI available");
  51. }