main.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 <version.h>
  12. DECLARE_GLOBAL_DATA_PTR;
  13. /*
  14. * Board-specific Platform code can reimplement show_boot_progress () if needed
  15. */
  16. __weak void show_boot_progress(int val) {}
  17. static void modem_init(void)
  18. {
  19. #ifdef CONFIG_MODEM_SUPPORT
  20. debug("DEBUG: main_loop: gd->do_mdm_init=%lu\n", gd->do_mdm_init);
  21. if (gd->do_mdm_init) {
  22. char *str = getenv("mdm_cmd");
  23. setenv("preboot", str); /* set or delete definition */
  24. mdm_init(); /* wait for modem connection */
  25. }
  26. #endif /* CONFIG_MODEM_SUPPORT */
  27. }
  28. static void run_preboot_environment_command(void)
  29. {
  30. #ifdef CONFIG_PREBOOT
  31. char *p;
  32. p = getenv("preboot");
  33. if (p != NULL) {
  34. # ifdef CONFIG_AUTOBOOT_KEYED
  35. int prev = disable_ctrlc(1); /* disable Control C checking */
  36. # endif
  37. run_command_list(p, -1, 0);
  38. # ifdef CONFIG_AUTOBOOT_KEYED
  39. disable_ctrlc(prev); /* restore Control C checking */
  40. # endif
  41. }
  42. #endif /* CONFIG_PREBOOT */
  43. }
  44. /* We come here after U-Boot is initialised and ready to process commands */
  45. void main_loop(void)
  46. {
  47. const char *s;
  48. bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
  49. #ifndef CONFIG_SYS_GENERIC_BOARD
  50. puts("Warning: Your board does not use generic board. Please read\n");
  51. puts("doc/README.generic-board and take action. Boards not\n");
  52. puts("upgraded by the late 2014 may break or be removed.\n");
  53. #endif
  54. modem_init();
  55. #ifdef CONFIG_VERSION_VARIABLE
  56. setenv("ver", version_string); /* set version variable */
  57. #endif /* CONFIG_VERSION_VARIABLE */
  58. cli_init();
  59. run_preboot_environment_command();
  60. #if defined(CONFIG_UPDATE_TFTP)
  61. update_tftp(0UL, NULL, NULL);
  62. #endif /* CONFIG_UPDATE_TFTP */
  63. s = bootdelay_process();
  64. if (cli_process_fdt(&s))
  65. cli_secure_boot_cmd(s);
  66. autoboot_command(s);
  67. cli_loop();
  68. }