main.c 1.2 KB

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