wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2000 |
| 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
wdenk | a6c7ad2 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 8 | /* #define DEBUG */ |
| 9 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 10 | #include <common.h> |
Simon Glass | 66ded17 | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 11 | #include <autoboot.h> |
Simon Glass | 18d6653 | 2014-04-10 20:01:25 -0600 | [diff] [blame] | 12 | #include <cli.h> |
Simon Glass | eca86fa | 2014-04-10 20:01:24 -0600 | [diff] [blame] | 13 | #include <cli_hush.h> |
Simon Glass | fbcdf32 | 2013-05-15 06:23:59 +0000 | [diff] [blame] | 14 | #include <malloc.h> |
Simon Glass | fbcdf32 | 2013-05-15 06:23:59 +0000 | [diff] [blame] | 15 | #include <version.h> |
wdenk | bdccc4f | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 16 | |
Simon Glass | 9272a9b | 2014-04-10 20:01:32 -0600 | [diff] [blame^] | 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 19 | /* |
| 20 | * Board-specific Platform code can reimplement show_boot_progress () if needed |
| 21 | */ |
| 22 | void inline __show_boot_progress (int val) {} |
Emil Medve | 5e2c08c | 2009-05-12 13:48:32 -0500 | [diff] [blame] | 23 | void show_boot_progress (int val) __attribute__((weak, alias("__show_boot_progress"))); |
Heiko Schocher | fad6340 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 24 | |
Simon Glass | bc2b4c2 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 25 | void main_loop(void) |
| 26 | { |
Simon Glass | bc2b4c2 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 27 | #ifdef CONFIG_PREBOOT |
| 28 | char *p; |
| 29 | #endif |
| 30 | |
| 31 | bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); |
| 32 | |
Simon Glass | 0f605c1 | 2014-03-22 17:14:51 -0600 | [diff] [blame] | 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 | |
Simon Glass | bc2b4c2 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 39 | #ifdef CONFIG_MODEM_SUPPORT |
Simon Glass | 9272a9b | 2014-04-10 20:01:32 -0600 | [diff] [blame^] | 40 | debug("DEBUG: main_loop: gd->do_mdm_init=%lu\n", gd->do_mdm_init); |
| 41 | if (gd->do_mdm_init) { |
Simon Glass | bc2b4c2 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 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 | |
Simon Glass | 66ded17 | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 83 | bootdelay_process(); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 84 | /* |
| 85 | * Main Loop for Monitor Command Processing |
| 86 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 87 | #ifdef CONFIG_SYS_HUSH_PARSER |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 88 | parse_file_outer(); |
| 89 | /* This point is never reached */ |
| 90 | for (;;); |
| 91 | #else |
Simon Glass | 6493ccc | 2014-04-10 20:01:26 -0600 | [diff] [blame] | 92 | cli_loop(); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 93 | #endif /*CONFIG_SYS_HUSH_PARSER*/ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 94 | } |