main.c 2.0 KB

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