main.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * (C) Copyright 2000
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. /* #define DEBUG */
  8. #include <common.h>
  9. #include <autoboot.h>
  10. #include <cli.h>
  11. #include <console.h>
  12. #include <version.h>
  13. DECLARE_GLOBAL_DATA_PTR;
  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. #ifdef CONFIG_PREBOOT
  21. char *p;
  22. p = getenv("preboot");
  23. if (p != NULL) {
  24. # ifdef CONFIG_AUTOBOOT_KEYED
  25. int prev = disable_ctrlc(1); /* disable Control C checking */
  26. # endif
  27. run_command_list(p, -1, 0);
  28. # ifdef CONFIG_AUTOBOOT_KEYED
  29. disable_ctrlc(prev); /* restore Control C checking */
  30. # endif
  31. }
  32. #endif /* CONFIG_PREBOOT */
  33. }
  34. /* We come here after U-Boot is initialised and ready to process commands */
  35. void main_loop(void)
  36. {
  37. const char *s;
  38. bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
  39. #ifdef CONFIG_VERSION_VARIABLE
  40. setenv("ver", version_string); /* set version variable */
  41. #endif /* CONFIG_VERSION_VARIABLE */
  42. cli_init();
  43. run_preboot_environment_command();
  44. #if defined(CONFIG_UPDATE_TFTP)
  45. update_tftp(0UL, NULL, NULL);
  46. #endif /* CONFIG_UPDATE_TFTP */
  47. s = bootdelay_process();
  48. if (cli_process_fdt(&s))
  49. cli_secure_boot_cmd(s);
  50. autoboot_command(s);
  51. cli_loop();
  52. panic("No CLI available");
  53. }