]> git.ipfire.org Git - thirdparty/u-boot.git/blame - common/main.c
Merge git://git.denx.de/u-boot-socfpga
[thirdparty/u-boot.git] / common / main.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
c609719b
WD
2/*
3 * (C) Copyright 2000
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
c609719b
WD
5 */
6
a6c7ad2f
WD
7/* #define DEBUG */
8
c609719b 9#include <common.h>
66ded17d 10#include <autoboot.h>
18d66533 11#include <cli.h>
24b852a7 12#include <console.h>
fbcdf32a 13#include <version.h>
bdccc4fe 14
fad63407
HS
15/*
16 * Board-specific Platform code can reimplement show_boot_progress () if needed
17 */
3422299d 18__weak void show_boot_progress(int val) {}
fad63407 19
1364a0e4
SG
20static void run_preboot_environment_command(void)
21{
bc2b4c27 22#ifdef CONFIG_PREBOOT
1364a0e4
SG
23 char *p;
24
00caae6d 25 p = env_get("preboot");
bc2b4c27 26 if (p != NULL) {
2cb132ad
SG
27 int prev = 0;
28
29 if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
30 prev = disable_ctrlc(1); /* disable Ctrl-C checking */
bc2b4c27
SG
31
32 run_command_list(p, -1, 0);
33
2cb132ad
SG
34 if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED))
35 disable_ctrlc(prev); /* restore Ctrl-C checking */
bc2b4c27
SG
36 }
37#endif /* CONFIG_PREBOOT */
1364a0e4
SG
38}
39
affb2156 40/* We come here after U-Boot is initialised and ready to process commands */
1364a0e4
SG
41void main_loop(void)
42{
affb2156
SG
43 const char *s;
44
1364a0e4
SG
45 bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop");
46
2cb132ad
SG
47 if (IS_ENABLED(CONFIG_VERSION_VARIABLE))
48 env_set("ver", version_string); /* set version variable */
1364a0e4 49
c1bb2cd0 50 cli_init();
1364a0e4
SG
51
52 run_preboot_environment_command();
bc2b4c27 53
2cb132ad
SG
54 if (IS_ENABLED(CONFIG_UPDATE_TFTP))
55 update_tftp(0UL, NULL, NULL);
bc2b4c27 56
affb2156
SG
57 s = bootdelay_process();
58 if (cli_process_fdt(&s))
59 cli_secure_boot_cmd(s);
60
61 autoboot_command(s);
c1bb2cd0 62
6493ccc7 63 cli_loop();
045e6f0d 64 panic("No CLI available");
c609719b 65}