Tom Rini | 83d290c | 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 | a6c7ad2 | 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 | 66ded17 | 2014-04-10 20:01:28 -0600 | [diff] [blame] | 10 | #include <autoboot.h> |
Simon Glass | 52f2423 | 2020-05-10 11:40:00 -0600 | [diff] [blame] | 11 | #include <bootstage.h> |
Simon Glass | 18d6653 | 2014-04-10 20:01:25 -0600 | [diff] [blame] | 12 | #include <cli.h> |
Simon Glass | 288b29e | 2019-11-14 12:57:43 -0700 | [diff] [blame] | 13 | #include <command.h> |
Simon Glass | 24b852a | 2015-11-08 23:47:45 -0700 | [diff] [blame] | 14 | #include <console.h> |
Simon Glass | 9fb625c | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 15 | #include <env.h> |
Ivan Mikhaylov | 4023dc9 | 2023-03-08 01:13:39 +0000 | [diff] [blame] | 16 | #include <fdtdec.h> |
Simon Glass | 6b8d3ce | 2019-12-28 10:44:39 -0700 | [diff] [blame] | 17 | #include <init.h> |
Simon Glass | 90526e9 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 18 | #include <net.h> |
Pali Rohár | bdfb6d7 | 2021-08-02 15:18:31 +0200 | [diff] [blame] | 19 | #include <version_string.h> |
AKASHI Takahiro | c74cd8b | 2020-11-17 09:27:56 +0900 | [diff] [blame] | 20 | #include <efi_loader.h> |
wdenk | bdccc4f | 2003-08-05 17:43:17 +0000 | [diff] [blame] | 21 | |
Simon Glass | 1364a0e | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 22 | static void run_preboot_environment_command(void) |
23 | { | ||||
Simon Glass | 1364a0e | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 24 | char *p; |
25 | |||||
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 26 | p = env_get("preboot"); |
Simon Glass | bc2b4c2 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 27 | if (p != NULL) { |
Simon Glass | 2cb132a | 2018-11-25 20:05:54 -0700 | [diff] [blame] | 28 | int prev = 0; |
29 | |||||
30 | if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED)) | ||||
31 | prev = disable_ctrlc(1); /* disable Ctrl-C checking */ | ||||
Simon Glass | bc2b4c2 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 32 | |
33 | run_command_list(p, -1, 0); | ||||
34 | |||||
Simon Glass | 2cb132a | 2018-11-25 20:05:54 -0700 | [diff] [blame] | 35 | if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED)) |
36 | disable_ctrlc(prev); /* restore Ctrl-C checking */ | ||||
Simon Glass | bc2b4c2 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 37 | } |
Simon Glass | 1364a0e | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 38 | } |
39 | |||||
Simon Glass | affb215 | 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 | 1364a0e | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 41 | void main_loop(void) |
42 | { | ||||
Simon Glass | affb215 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 43 | const char *s; |
44 | |||||
Simon Glass | 1364a0e | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 45 | bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); |
46 | |||||
Simon Glass | 2cb132a | 2018-11-25 20:05:54 -0700 | [diff] [blame] | 47 | if (IS_ENABLED(CONFIG_VERSION_VARIABLE)) |
48 | env_set("ver", version_string); /* set version variable */ | ||||
Simon Glass | 1364a0e | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 49 | |
Simon Glass | c1bb2cd | 2014-04-10 20:01:34 -0600 | [diff] [blame] | 50 | cli_init(); |
Simon Glass | 1364a0e | 2014-04-10 20:01:33 -0600 | [diff] [blame] | 51 | |
Simon Glass | e9f6a37 | 2019-07-20 20:51:11 -0600 | [diff] [blame] | 52 | if (IS_ENABLED(CONFIG_USE_PREBOOT)) |
53 | run_preboot_environment_command(); | ||||
Simon Glass | bc2b4c2 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 54 | |
Simon Glass | 2cb132a | 2018-11-25 20:05:54 -0700 | [diff] [blame] | 55 | if (IS_ENABLED(CONFIG_UPDATE_TFTP)) |
56 | update_tftp(0UL, NULL, NULL); | ||||
Simon Glass | bc2b4c2 | 2013-05-15 06:23:56 +0000 | [diff] [blame] | 57 | |
AKASHI Takahiro | a57ad20 | 2022-04-19 10:05:11 +0900 | [diff] [blame] | 58 | if (IS_ENABLED(CONFIG_EFI_CAPSULE_ON_DISK_EARLY)) { |
59 | /* efi_init_early() already called */ | ||||
60 | if (efi_init_obj_list() == EFI_SUCCESS) | ||||
61 | efi_launch_capsules(); | ||||
62 | } | ||||
AKASHI Takahiro | c74cd8b | 2020-11-17 09:27:56 +0900 | [diff] [blame] | 63 | |
Simon Glass | affb215 | 2014-04-10 20:01:35 -0600 | [diff] [blame] | 64 | s = bootdelay_process(); |
65 | if (cli_process_fdt(&s)) | ||||
66 | cli_secure_boot_cmd(s); | ||||
67 | |||||
68 | autoboot_command(s); | ||||
Simon Glass | c1bb2cd | 2014-04-10 20:01:34 -0600 | [diff] [blame] | 69 | |
Simon Glass | 6493ccc | 2014-04-10 20:01:26 -0600 | [diff] [blame] | 70 | cli_loop(); |
Simon Glass | 045e6f0 | 2016-03-13 19:07:32 -0600 | [diff] [blame] | 71 | panic("No CLI available"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 72 | } |