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> 13eca86fadSSimon Glass #include <cli_hush.h> 14fbcdf32aSSimon Glass #include <malloc.h> 15fbcdf32aSSimon Glass #include <version.h> 16bdccc4feSwdenk 17*9272a9b4SSimon Glass DECLARE_GLOBAL_DATA_PTR; 18*9272a9b4SSimon Glass 19fad63407SHeiko Schocher /* 20fad63407SHeiko Schocher * Board-specific Platform code can reimplement show_boot_progress () if needed 21fad63407SHeiko Schocher */ 22fad63407SHeiko Schocher void inline __show_boot_progress (int val) {} 235e2c08c3SEmil Medve void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress"))); 24fad63407SHeiko Schocher 25bc2b4c27SSimon Glass void main_loop(void) 26bc2b4c27SSimon Glass { 27bc2b4c27SSimon Glass #ifdef CONFIG_PREBOOT 28bc2b4c27SSimon Glass char *p; 29bc2b4c27SSimon Glass #endif 30bc2b4c27SSimon Glass 31bc2b4c27SSimon Glass bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); 32bc2b4c27SSimon Glass 330f605c15SSimon Glass #ifndef CONFIG_SYS_GENERIC_BOARD 340f605c15SSimon Glass puts("Warning: Your board does not use generic board. Please read\n"); 350f605c15SSimon Glass puts("doc/README.generic-board and take action. Boards not\n"); 360f605c15SSimon Glass puts("upgraded by the late 2014 may break or be removed.\n"); 370f605c15SSimon Glass #endif 380f605c15SSimon Glass 39bc2b4c27SSimon Glass #ifdef CONFIG_MODEM_SUPPORT 40*9272a9b4SSimon Glass debug("DEBUG: main_loop: gd->do_mdm_init=%lu\n", gd->do_mdm_init); 41*9272a9b4SSimon Glass if (gd->do_mdm_init) { 42bc2b4c27SSimon Glass char *str = strdup(getenv("mdm_cmd")); 43bc2b4c27SSimon Glass setenv("preboot", str); /* set or delete definition */ 44bc2b4c27SSimon Glass if (str != NULL) 45bc2b4c27SSimon Glass free(str); 46bc2b4c27SSimon Glass mdm_init(); /* wait for modem connection */ 47bc2b4c27SSimon Glass } 48bc2b4c27SSimon Glass #endif /* CONFIG_MODEM_SUPPORT */ 49bc2b4c27SSimon Glass 50bc2b4c27SSimon Glass #ifdef CONFIG_VERSION_VARIABLE 51bc2b4c27SSimon Glass { 52bc2b4c27SSimon Glass setenv("ver", version_string); /* set version variable */ 53bc2b4c27SSimon Glass } 54bc2b4c27SSimon Glass #endif /* CONFIG_VERSION_VARIABLE */ 55bc2b4c27SSimon Glass 56bc2b4c27SSimon Glass #ifdef CONFIG_SYS_HUSH_PARSER 57bc2b4c27SSimon Glass u_boot_hush_start(); 58bc2b4c27SSimon Glass #endif 59bc2b4c27SSimon Glass 60bc2b4c27SSimon Glass #if defined(CONFIG_HUSH_INIT_VAR) 61bc2b4c27SSimon Glass hush_init_var(); 62bc2b4c27SSimon Glass #endif 63bc2b4c27SSimon Glass 64bc2b4c27SSimon Glass #ifdef CONFIG_PREBOOT 65bc2b4c27SSimon Glass p = getenv("preboot"); 66bc2b4c27SSimon Glass if (p != NULL) { 67bc2b4c27SSimon Glass # ifdef CONFIG_AUTOBOOT_KEYED 68bc2b4c27SSimon Glass int prev = disable_ctrlc(1); /* disable Control C checking */ 69bc2b4c27SSimon Glass # endif 70bc2b4c27SSimon Glass 71bc2b4c27SSimon Glass run_command_list(p, -1, 0); 72bc2b4c27SSimon Glass 73bc2b4c27SSimon Glass # ifdef CONFIG_AUTOBOOT_KEYED 74bc2b4c27SSimon Glass disable_ctrlc(prev); /* restore Control C checking */ 75bc2b4c27SSimon Glass # endif 76bc2b4c27SSimon Glass } 77bc2b4c27SSimon Glass #endif /* CONFIG_PREBOOT */ 78bc2b4c27SSimon Glass 79bc2b4c27SSimon Glass #if defined(CONFIG_UPDATE_TFTP) 80bc2b4c27SSimon Glass update_tftp(0UL); 81bc2b4c27SSimon Glass #endif /* CONFIG_UPDATE_TFTP */ 82bc2b4c27SSimon Glass 8366ded17dSSimon Glass bootdelay_process(); 84c609719bSwdenk /* 85c609719bSwdenk * Main Loop for Monitor Command Processing 86c609719bSwdenk */ 876d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_SYS_HUSH_PARSER 88c609719bSwdenk parse_file_outer(); 89c609719bSwdenk /* This point is never reached */ 90c609719bSwdenk for (;;); 91c609719bSwdenk #else 926493ccc7SSimon Glass cli_loop(); 936d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #endif /*CONFIG_SYS_HUSH_PARSER*/ 94c609719bSwdenk } 95