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 <malloc.h> 14fbcdf32aSSimon Glass #include <version.h> 15bdccc4feSwdenk 169272a9b4SSimon Glass DECLARE_GLOBAL_DATA_PTR; 179272a9b4SSimon Glass 18fad63407SHeiko Schocher /* 19fad63407SHeiko Schocher * Board-specific Platform code can reimplement show_boot_progress () if needed 20fad63407SHeiko Schocher */ 21fad63407SHeiko Schocher void inline __show_boot_progress (int val) {} 225e2c08c3SEmil Medve void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress"))); 23fad63407SHeiko Schocher 241364a0e4SSimon Glass static void modem_init(void) 25bc2b4c27SSimon Glass { 26bc2b4c27SSimon Glass #ifdef CONFIG_MODEM_SUPPORT 279272a9b4SSimon Glass debug("DEBUG: main_loop: gd->do_mdm_init=%lu\n", gd->do_mdm_init); 289272a9b4SSimon Glass if (gd->do_mdm_init) { 29bc2b4c27SSimon Glass char *str = strdup(getenv("mdm_cmd")); 30bc2b4c27SSimon Glass setenv("preboot", str); /* set or delete definition */ 31bc2b4c27SSimon Glass if (str != NULL) 32bc2b4c27SSimon Glass free(str); 33bc2b4c27SSimon Glass mdm_init(); /* wait for modem connection */ 34bc2b4c27SSimon Glass } 35bc2b4c27SSimon Glass #endif /* CONFIG_MODEM_SUPPORT */ 36bc2b4c27SSimon Glass } 37bc2b4c27SSimon Glass 381364a0e4SSimon Glass static void run_preboot_environment_command(void) 391364a0e4SSimon Glass { 40bc2b4c27SSimon Glass #ifdef CONFIG_PREBOOT 411364a0e4SSimon Glass char *p; 421364a0e4SSimon Glass 43bc2b4c27SSimon Glass p = getenv("preboot"); 44bc2b4c27SSimon Glass if (p != NULL) { 45bc2b4c27SSimon Glass # ifdef CONFIG_AUTOBOOT_KEYED 46bc2b4c27SSimon Glass int prev = disable_ctrlc(1); /* disable Control C checking */ 47bc2b4c27SSimon Glass # endif 48bc2b4c27SSimon Glass 49bc2b4c27SSimon Glass run_command_list(p, -1, 0); 50bc2b4c27SSimon Glass 51bc2b4c27SSimon Glass # ifdef CONFIG_AUTOBOOT_KEYED 52bc2b4c27SSimon Glass disable_ctrlc(prev); /* restore Control C checking */ 53bc2b4c27SSimon Glass # endif 54bc2b4c27SSimon Glass } 55bc2b4c27SSimon Glass #endif /* CONFIG_PREBOOT */ 561364a0e4SSimon Glass } 571364a0e4SSimon Glass 58*affb2156SSimon Glass /* We come here after U-Boot is initialised and ready to process commands */ 591364a0e4SSimon Glass void main_loop(void) 601364a0e4SSimon Glass { 61*affb2156SSimon Glass const char *s; 62*affb2156SSimon Glass 631364a0e4SSimon Glass bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); 641364a0e4SSimon Glass 651364a0e4SSimon Glass #ifndef CONFIG_SYS_GENERIC_BOARD 661364a0e4SSimon Glass puts("Warning: Your board does not use generic board. Please read\n"); 671364a0e4SSimon Glass puts("doc/README.generic-board and take action. Boards not\n"); 681364a0e4SSimon Glass puts("upgraded by the late 2014 may break or be removed.\n"); 691364a0e4SSimon Glass #endif 701364a0e4SSimon Glass 711364a0e4SSimon Glass modem_init(); 721364a0e4SSimon Glass #ifdef CONFIG_VERSION_VARIABLE 731364a0e4SSimon Glass setenv("ver", version_string); /* set version variable */ 741364a0e4SSimon Glass #endif /* CONFIG_VERSION_VARIABLE */ 751364a0e4SSimon Glass 76c1bb2cd0SSimon Glass cli_init(); 771364a0e4SSimon Glass 781364a0e4SSimon Glass run_preboot_environment_command(); 79bc2b4c27SSimon Glass 80bc2b4c27SSimon Glass #if defined(CONFIG_UPDATE_TFTP) 81bc2b4c27SSimon Glass update_tftp(0UL); 82bc2b4c27SSimon Glass #endif /* CONFIG_UPDATE_TFTP */ 83bc2b4c27SSimon Glass 84*affb2156SSimon Glass s = bootdelay_process(); 85*affb2156SSimon Glass if (cli_process_fdt(&s)) 86*affb2156SSimon Glass cli_secure_boot_cmd(s); 87*affb2156SSimon Glass 88*affb2156SSimon Glass autoboot_command(s); 89c1bb2cd0SSimon Glass 906493ccc7SSimon Glass cli_loop(); 91c609719bSwdenk } 92