Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 2 | /* |
3 | * (C) Copyright 2000 | ||||
4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | ||||
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 5 | */ |
6 | |||||
wdenk | 9dd2b88 | 2002-12-03 21:28:10 +0000 | [diff] [blame] | 7 | /* #define DEBUG */ |
8 | |||||
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 9 | #include <common.h> |
Simon Glass | 7b6a95a | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 10 | #include <autoboot.h> |
Simon Glass | dec3c01 | 2014-04-10 20:01:25 -0600 | [diff] [blame] | 11 | #include <cli.h> |
Simon Glass | a73bda4 | 2015-11-08 23:47:45 -0700 | [diff] [blame] | 12 | #include <console.h> |
Simon Glass | b2b687f | 2013-05-15 06:23:59 +0000 | [diff] [blame] | 13 | #include <version.h> |
wdenk | 0a65855 | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 14 | |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 15 | /* |
16 | * Board-specific Platform code can reimplement show_boot_progress () if needed | ||||
17 | */ | ||||
Jeroen Hofstee | b735e8c | 2014-06-26 20:18:31 +0200 | [diff] [blame] | 18 | __weak void show_boot_progress(int val) {} |
Heiko Schocher | 8a8ec53 | 2007-07-13 09:54:17 +0200 | [diff] [blame] | 19 | |
Simon Glass | 9f6bb18 | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 20 | static void run_preboot_environment_command(void) |
21 | { | ||||
Simon Glass | de6f0c4 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 22 | #ifdef CONFIG_PREBOOT |
Simon Glass | 9f6bb18 | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 23 | char *p; |
24 | |||||
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 25 | p = env_get("preboot"); |
Simon Glass | de6f0c4 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 26 | if (p != NULL) { |
27 | # ifdef CONFIG_AUTOBOOT_KEYED | ||||
28 | int prev = disable_ctrlc(1); /* disable Control C checking */ | ||||
29 | # endif | ||||
30 | |||||
31 | run_command_list(p, -1, 0); | ||||
32 | |||||
33 | # ifdef CONFIG_AUTOBOOT_KEYED | ||||
34 | disable_ctrlc(prev); /* restore Control C checking */ | ||||
35 | # endif | ||||
36 | } | ||||
37 | #endif /* CONFIG_PREBOOT */ | ||||
Simon Glass | 9f6bb18 | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 38 | } |
39 | |||||
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 40 | /* We come here after U-Boot is initialised and ready to process commands */ |
Simon Glass | 9f6bb18 | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 41 | void main_loop(void) |
42 | { | ||||
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 43 | const char *s; |
44 | |||||
Simon Glass | 9f6bb18 | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 45 | bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); |
46 | |||||
Simon Glass | 9f6bb18 | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 47 | #ifdef CONFIG_VERSION_VARIABLE |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 48 | env_set("ver", version_string); /* set version variable */ |
Simon Glass | 9f6bb18 | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 49 | #endif /* CONFIG_VERSION_VARIABLE */ |
50 | |||||
Simon Glass | 33f7913 | 2014-04-10 20:01:34 -0600 | [diff] [blame] | 51 | cli_init(); |
Simon Glass | 9f6bb18 | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 52 | |
53 | run_preboot_environment_command(); | ||||
Simon Glass | de6f0c4 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 54 | |
55 | #if defined(CONFIG_UPDATE_TFTP) | ||||
Lukasz Majewski | e32125a | 2015-08-24 00:21:47 +0200 | [diff] [blame] | 56 | update_tftp(0UL, NULL, NULL); |
Simon Glass | de6f0c4 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 57 | #endif /* CONFIG_UPDATE_TFTP */ |
58 | |||||
Simon Glass | 5b47e30 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 59 | s = bootdelay_process(); |
60 | if (cli_process_fdt(&s)) | ||||
61 | cli_secure_boot_cmd(s); | ||||
62 | |||||
63 | autoboot_command(s); | ||||
Simon Glass | 33f7913 | 2014-04-10 20:01:34 -0600 | [diff] [blame] | 64 | |
Simon Glass | 66b8c8b | 2014-04-10 20:01:26 -0600 | [diff] [blame] | 65 | cli_loop(); |
Simon Glass | 2833290 | 2016-03-13 19:07:32 -0600 | [diff] [blame] | 66 | panic("No CLI available"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 67 | } |