main.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. static void run_preboot_environment_command(void)
  18. {
  19. char *p;
  20. p = env_get("preboot");
  21. if (p != NULL) {
  22. int prev = 0;
  23. if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
  24. prev = disable_ctrlc(1); /* disable Ctrl-C checking */
  25. run_command_list(p, -1, 0);
  26. if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
  27. disable_ctrlc(prev); /* restore Ctrl-C checking */
  28. }
  29. }
  30. /* We come here after U-Boot is initialised and ready to process commands */
  31. void main_loop(void)
  32. {
  33. const char *s;
  34. bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
  35. if (IS_ENABLED(CONFIG_VERSION_VARIABLE))
  36. env_set("ver", version_string); /* set version variable */
  37. cli_init();
  38. if (IS_ENABLED(CONFIG_USE_PREBOOT))
  39. run_preboot_environment_command();
  40. if (IS_ENABLED(CONFIG_UPDATE_TFTP))
  41. update_tftp(0UL, NULL, NULL);
  42. s = bootdelay_process();
  43. if (cli_process_fdt(&s))
  44. cli_secure_boot_cmd(s);
  45. autoboot_command(s);
  46. cli_loop();
  47. panic("No CLI available");
  48. }