1c609719bSwdenk /* 2c609719bSwdenk * (C) Copyright 2000 3c609719bSwdenk * Wolfgang Denk, DENX Software Engineering, wd@denx.de. 4c609719bSwdenk * 51a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 6c609719bSwdenk */ 7c609719bSwdenk 8a6c7ad2fSwdenk /* #define DEBUG */ 9a6c7ad2fSwdenk 10c609719bSwdenk #include <common.h> 1166ded17dSSimon Glass #include <autoboot.h> 1218d66533SSimon Glass #include <cli.h> 13fbcdf32aSSimon Glass #include <version.h> 14bdccc4feSwdenk 159272a9b4SSimon Glass DECLARE_GLOBAL_DATA_PTR; 169272a9b4SSimon Glass 17fad63407SHeiko Schocher /* 18fad63407SHeiko Schocher * Board-specific Platform code can reimplement show_boot_progress () if needed 19fad63407SHeiko Schocher */ 203422299dSJeroen Hofstee __weak void show_boot_progress(int val) {} 21fad63407SHeiko Schocher 221364a0e4SSimon Glass static void modem_init(void) 23bc2b4c27SSimon Glass { 24bc2b4c27SSimon Glass #ifdef CONFIG_MODEM_SUPPORT 259272a9b4SSimon Glass debug("DEBUG: main_loop: gd->do_mdm_init=%lu\n", gd->do_mdm_init); 269272a9b4SSimon Glass if (gd->do_mdm_init) { 2795856248SSimon Glass char *str = getenv("mdm_cmd"); 2895856248SSimon Glass 29bc2b4c27SSimon Glass setenv("preboot", str); /* set or delete definition */ 30bc2b4c27SSimon Glass mdm_init(); /* wait for modem connection */ 31bc2b4c27SSimon Glass } 32bc2b4c27SSimon Glass #endif /* CONFIG_MODEM_SUPPORT */ 33bc2b4c27SSimon Glass } 34bc2b4c27SSimon Glass 351364a0e4SSimon Glass static void run_preboot_environment_command(void) 361364a0e4SSimon Glass { 37bc2b4c27SSimon Glass #ifdef CONFIG_PREBOOT 381364a0e4SSimon Glass char *p; 391364a0e4SSimon Glass 40bc2b4c27SSimon Glass p = getenv("preboot"); 41bc2b4c27SSimon Glass if (p != NULL) { 42bc2b4c27SSimon Glass # ifdef CONFIG_AUTOBOOT_KEYED 43bc2b4c27SSimon Glass int prev = disable_ctrlc(1); /* disable Control C checking */ 44bc2b4c27SSimon Glass # endif 45bc2b4c27SSimon Glass 46bc2b4c27SSimon Glass run_command_list(p, -1, 0); 47bc2b4c27SSimon Glass 48bc2b4c27SSimon Glass # ifdef CONFIG_AUTOBOOT_KEYED 49bc2b4c27SSimon Glass disable_ctrlc(prev); /* restore Control C checking */ 50bc2b4c27SSimon Glass # endif 51bc2b4c27SSimon Glass } 52bc2b4c27SSimon Glass #endif /* CONFIG_PREBOOT */ 531364a0e4SSimon Glass } 541364a0e4SSimon Glass 55affb2156SSimon Glass /* We come here after U-Boot is initialised and ready to process commands */ 561364a0e4SSimon Glass void main_loop(void) 571364a0e4SSimon Glass { 58affb2156SSimon Glass const char *s; 59affb2156SSimon Glass 601364a0e4SSimon Glass bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); 611364a0e4SSimon Glass 621364a0e4SSimon Glass #ifndef CONFIG_SYS_GENERIC_BOARD 631364a0e4SSimon Glass puts("Warning: Your board does not use generic board. Please read\n"); 641364a0e4SSimon Glass puts("doc/README.generic-board and take action. Boards not\n"); 651364a0e4SSimon Glass puts("upgraded by the late 2014 may break or be removed.\n"); 661364a0e4SSimon Glass #endif 671364a0e4SSimon Glass 681364a0e4SSimon Glass modem_init(); 691364a0e4SSimon Glass #ifdef CONFIG_VERSION_VARIABLE 701364a0e4SSimon Glass setenv("ver", version_string); /* set version variable */ 711364a0e4SSimon Glass #endif /* CONFIG_VERSION_VARIABLE */ 721364a0e4SSimon Glass 73c1bb2cd0SSimon Glass cli_init(); 741364a0e4SSimon Glass 751364a0e4SSimon Glass run_preboot_environment_command(); 76bc2b4c27SSimon Glass 77bc2b4c27SSimon Glass #if defined(CONFIG_UPDATE_TFTP) 78*c7ff5528SLukasz Majewski update_tftp(0UL, NULL, NULL); 79bc2b4c27SSimon Glass #endif /* CONFIG_UPDATE_TFTP */ 80bc2b4c27SSimon Glass 81affb2156SSimon Glass s = bootdelay_process(); 82affb2156SSimon Glass if (cli_process_fdt(&s)) 83affb2156SSimon Glass cli_secure_boot_cmd(s); 84affb2156SSimon Glass 85affb2156SSimon Glass autoboot_command(s); 86c1bb2cd0SSimon Glass 876493ccc7SSimon Glass cli_loop(); 88c609719bSwdenk } 89