1 /* 2 * (C) Copyright 2000 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8 /* #define DEBUG */ 9 10 #include <common.h> 11 #include <autoboot.h> 12 #include <cli.h> 13 #include <cli_hush.h> 14 #include <malloc.h> 15 #include <version.h> 16 17 DECLARE_GLOBAL_DATA_PTR; 18 19 /* 20 * Board-specific Platform code can reimplement show_boot_progress () if needed 21 */ 22 void inline __show_boot_progress (int val) {} 23 void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress"))); 24 25 void main_loop(void) 26 { 27 #ifdef CONFIG_PREBOOT 28 char *p; 29 #endif 30 31 bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); 32 33 #ifndef CONFIG_SYS_GENERIC_BOARD 34 puts("Warning: Your board does not use generic board. Please read\n"); 35 puts("doc/README.generic-board and take action. Boards not\n"); 36 puts("upgraded by the late 2014 may break or be removed.\n"); 37 #endif 38 39 #ifdef CONFIG_MODEM_SUPPORT 40 debug("DEBUG: main_loop: gd->do_mdm_init=%lu\n", gd->do_mdm_init); 41 if (gd->do_mdm_init) { 42 char *str = strdup(getenv("mdm_cmd")); 43 setenv("preboot", str); /* set or delete definition */ 44 if (str != NULL) 45 free(str); 46 mdm_init(); /* wait for modem connection */ 47 } 48 #endif /* CONFIG_MODEM_SUPPORT */ 49 50 #ifdef CONFIG_VERSION_VARIABLE 51 { 52 setenv("ver", version_string); /* set version variable */ 53 } 54 #endif /* CONFIG_VERSION_VARIABLE */ 55 56 #ifdef CONFIG_SYS_HUSH_PARSER 57 u_boot_hush_start(); 58 #endif 59 60 #if defined(CONFIG_HUSH_INIT_VAR) 61 hush_init_var(); 62 #endif 63 64 #ifdef CONFIG_PREBOOT 65 p = getenv("preboot"); 66 if (p != NULL) { 67 # ifdef CONFIG_AUTOBOOT_KEYED 68 int prev = disable_ctrlc(1); /* disable Control C checking */ 69 # endif 70 71 run_command_list(p, -1, 0); 72 73 # ifdef CONFIG_AUTOBOOT_KEYED 74 disable_ctrlc(prev); /* restore Control C checking */ 75 # endif 76 } 77 #endif /* CONFIG_PREBOOT */ 78 79 #if defined(CONFIG_UPDATE_TFTP) 80 update_tftp(0UL); 81 #endif /* CONFIG_UPDATE_TFTP */ 82 83 bootdelay_process(); 84 /* 85 * Main Loop for Monitor Command Processing 86 */ 87 #ifdef CONFIG_SYS_HUSH_PARSER 88 parse_file_outer(); 89 /* This point is never reached */ 90 for (;;); 91 #else 92 cli_loop(); 93 #endif /*CONFIG_SYS_HUSH_PARSER*/ 94 } 95